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
--- /dev/null
+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)
++}
--- /dev/null
+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) {
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)
}
--- /dev/null
+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
+ }()
+
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 (
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)