Fixed configuration issue 69/247569/1
authorMukunth A <a.mukunth@samsung.com>
Thu, 22 Oct 2020 10:17:59 +0000 (15:47 +0530)
committerMukunth A <a.mukunth@samsung.com>
Thu, 12 Nov 2020 06:15:27 +0000 (06:15 +0000)
Change-Id: Iee32d8f09d8794f2997b0817d836fe4a79bea305
Signed-off-by: Mukunth A <a.mukunth@samsung.com>
(cherry picked from commit e4cd0628d62d8e010240c88cb265cf46ee0aa740)

CMain/lib/liborchestration.a
build.sh
patches/commands.patch [new file with mode: 0644]
patches/commandvalidator.patch [new file with mode: 0644]
patches/configuremgr.patch
patches/native.patch [new file with mode: 0644]
patches/orchestration.patch

index 5df45c50a2d7b1ee3030a8f901a9a1d463f52dbb..2a190dfe715bbccbffb10da9ebc30b06f9b94dcd 100644 (file)
Binary files a/CMain/lib/liborchestration.a and b/CMain/lib/liborchestration.a differ
index 7dc3c737ea7a711b8b060bb4311f8e3401ed0174..3ce0225fcc3096b8a72debcccef4085751813894 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -76,6 +76,9 @@ function submodule_apply_patch() {
     git apply ../patches/capabilitydetails.patch
     git apply ../patches/capability.patch
     git apply ../patches/capability_test.patch
+    git apply ../patches/commands.patch
+    git apply ../patches/commandvalidator.patch
+    git apply ../patches/native.patch
     git apply ../patches/configuremgr.patch
     git apply ../patches/configuremgr_test.patch
     git apply ../patches/devicedetails.patch
diff --git a/patches/commands.patch b/patches/commands.patch
new file mode 100644 (file)
index 0000000..5dc3b0c
--- /dev/null
@@ -0,0 +1,23 @@
+diff --git a/src/common/commandvalidator/commands/commands.go b/src/common/commandvalidator/commands/commands.go
+index 4b6f1d6..ed35d20 100644
+--- a/src/common/commandvalidator/commands/commands.go
++++ b/src/common/commandvalidator/commands/commands.go
+@@ -25,6 +25,7 @@ import (
+ type CommandStore interface {
+       GetServiceFileName(serviceName string) (string, error)
+       StoreServiceInfo(serviceName, command string)
++      DeleteServiceInfo(serviceName string)
+ }
+ type commands struct {
+@@ -63,3 +64,10 @@ func (c *commands) StoreServiceInfo(serviceName, command string) {
+       c.serviceInfos[serviceName] = command
+ }
++
++func (c *commands) DeleteServiceInfo(serviceName string) {
++      c.mutex.Lock()
++      defer c.mutex.Unlock()
++
++      delete(c.serviceInfos, serviceName)
++}
diff --git a/patches/commandvalidator.patch b/patches/commandvalidator.patch
new file mode 100644 (file)
index 0000000..5e6e375
--- /dev/null
@@ -0,0 +1,24 @@
+diff --git a/src/common/commandvalidator/commandvalidator.go b/src/common/commandvalidator/commandvalidator.go
+index 9486c56..8284a52 100644
+--- a/src/common/commandvalidator/commandvalidator.go
++++ b/src/common/commandvalidator/commandvalidator.go
+@@ -37,6 +37,7 @@ const (
+ type ICommandValidator interface {
+       AddWhiteCommand(configuremgrtypes.ServiceInfo) error
++      DeleteCommand(serviceName string) error
+       GetCommand(serviceName string) (string, error)
+       CheckCommand(command []string) error
+ }
+@@ -66,6 +67,11 @@ func (CommandValidator) AddWhiteCommand(serviceInfo configuremgrtypes.ServiceInf
+       return nil
+ }
++func (CommandValidator) DeleteCommand(serviceName string) error {
++      commands.GetInstance().DeleteServiceInfo(serviceName)
++      return nil
++}
++
+ func (CommandValidator) CheckCommand(serviceName string, command []string) error {
+       fullCommand := strings.Join(command, " ")
+       if injectionchecker.HasInjectionOperator(fullCommand) {
index 7888388b50ac2081b168ae7d77c63de316ebd07d..7a47c3b662091dcf1e247191d9c7748a269ffe91 100644 (file)
@@ -1,8 +1,25 @@
 diff --git a/src/controller/configuremgr/configuremgr.go b/src/controller/configuremgr/configuremgr.go
-index a70ce04..9094442 100644
+index a70ce04..10ae665 100644
 --- a/src/controller/configuremgr/configuremgr.go
 +++ b/src/controller/configuremgr/configuremgr.go
-@@ -29,3 +29,9 @@ type Notifier interface {
+@@ -15,17 +15,24 @@
+  *
+  *******************************************************************************/
+-// Package configuremgr provides interfaces between ochrestrationapi and configuremgr
++// Package configuremgr provides interfaces between orchestrationapi and configuremgr
+ package configuremgr
+ import "common/types/configuremgrtypes"
+-// Notifier is the interface to get scoring infomation for each service application
++// Notifier is the interface to get scoring information for each service application
+ type Notifier interface {
+       Notify(serviceinfo configuremgrtypes.ServiceInfo)
++      NotifyRemove(serviceName string)
+ }
+ // Watcher is the interface to check if service application is installed/updated/deleted
  type Watcher interface {
        Watch(notifier Notifier)
  }
diff --git a/patches/native.patch b/patches/native.patch
new file mode 100644 (file)
index 0000000..7dc6e75
--- /dev/null
@@ -0,0 +1,22 @@
+diff --git a/src/controller/configuremgr/native/native.go b/src/controller/configuremgr/native/native.go
+index 831da33..2787d39 100644
+--- a/src/controller/configuremgr/native/native.go
++++ b/src/controller/configuremgr/native/native.go
+@@ -108,13 +108,15 @@ func (cfgMgr ConfigureMgr) Watch(notifier configuremgr.Notifier) {
+                                       }
+                                       notifier.Notify(getServiceInfo(event.Name))
+                               case fsnotify.Remove:
+-                                      // TODO remove scoring
++                                      s := strings.Split(event.Name, "/")
++                                      log.Println(s[len(s)-1])
++                                      notifier.NotifyRemove(s[len(s)-1])
+                               }
+                       case err := <-watcher.Errors:
+                               if err != nil {
+                                       log.Println("error:", err)
+                               }
+-                      } //selecte end
++                      } //select end
+               } //for end
+       }()
index 40bb296fe1197b4c4bf9df02f310f731ea1e576b..16d42a178bb934ec1541e10ba469775008a54920 100644 (file)
@@ -1,5 +1,5 @@
 diff --git a/src/orchestrationapi/orchestration.go b/src/orchestrationapi/orchestration.go
-index 60673bc..8af5a20 100644
+index 60673bc..5518be7 100644
 --- a/src/orchestrationapi/orchestration.go
 +++ b/src/orchestrationapi/orchestration.go
 @@ -39,7 +39,7 @@ import (
@@ -60,3 +60,23 @@ index 60673bc..8af5a20 100644
        resourceMonitorImpl = resourceutil.GetMonitoringInstance()
  
        orcheIns.notificationIns = notification.GetInstance()
+@@ -189,6 +201,19 @@ func (o orcheImpl) Notify(serviceInfo configuremgrtypes.ServiceInfo) {
+       }
+ }
++func (o orcheImpl) NotifyRemove(serviceName string) {
++      validator := commandvalidator.CommandValidator{}
++      if err := validator.DeleteCommand(serviceName); err != nil {
++              log.Println(logtag, "[Error]", err.Error())
++              return
++      }
++
++      if err := o.discoverIns.RemoveServiceName(serviceName); err != nil {
++              log.Println(logtag, "[Error]", err.Error())
++              return
++      }
++}
++
+ // ExecuteAppOnLocal executes a service application on local device
+ func (o orcheImpl) ExecuteAppOnLocal(appInfo map[string]interface{}) {
+       o.serviceIns.ExecuteAppOnLocal(appInfo)