Add STMsocket to dryad/conf 80/181880/1
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 23 Jan 2018 15:05:44 +0000 (16:05 +0100)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 18 Jun 2018 12:16:19 +0000 (14:16 +0200)
Due to change in git.tizen.org/tools/muxpi/sw/nanopi/stm communication
medium has changed. Preferably, dryad should connect to the running
process of stm via unix socket exposing Go RPC interface.

It is possible to use it in the old way by assigning "" to stm_socket
configuration entry.

Change-Id: If6f4b41c9dbf467e3d40772eb52b55cbbc79d749
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
cmd/dryad/dryad.go
dryad/conf/conf.go
dryad/conf/conf_test.go

index 1e79d87..b7d637f 100644 (file)
@@ -28,6 +28,7 @@ import (
        "git.tizen.org/tools/boruta/dryad/conf"
        dryad_rpc "git.tizen.org/tools/boruta/rpc/dryad"
        superviser_rpc "git.tizen.org/tools/boruta/rpc/superviser"
+       "git.tizen.org/tools/muxpi/sw/nanopi/stm"
 )
 
 var (
@@ -75,7 +76,20 @@ func main() {
        }
        readConfFile()
 
-       rusalka := dryad.NewRusalka(configuration.User.Name, configuration.User.Groups)
+       var dev stm.InterfaceCloser
+       if configuration.STMsocket != "" {
+               cl, err := rpc.Dial("unix", configuration.STMsocket)
+               exitOnErr("failed to connect to RPC service:", err)
+
+               dev = stm.NewInterfaceClient(cl)
+       } else {
+               var err error
+               dev, err = stm.GetDefaultSTM()
+               exitOnErr("failed to connect to STM:", err)
+       }
+       defer dev.Close()
+
+       rusalka := dryad.NewRusalka(dev, configuration.User.Name, configuration.User.Groups)
 
        l, err := net.Listen("tcp", configuration.Address)
        exitOnErr("can't listen on port:", err)
index 42675ba..049fb7b 100644 (file)
@@ -40,7 +40,8 @@ func NewConf() *General {
                        Name:   "boruta-user",
                        Groups: []string{},
                },
-               SDcard: "/dev/sdX",
+               SDcard:    "/dev/sdX",
+               STMsocket: "/run/stm.socket",
        }
 }
 
@@ -68,6 +69,8 @@ type General struct {
        User *User `toml:"user"`
        // SDcard is a base path to block device of sdcard.
        SDcard string `toml:"sdcard"`
+       // STMsocket is a path to the socket on which Go RPC service of stm.Interface is available.
+       STMsocket string `toml:"stm_path"`
 }
 
 // Marshal writes TOML representation of g to w.
index f1f7177..f8f9997 100644 (file)
@@ -31,6 +31,7 @@ var _ = Describe("Conf", func() {
        marshaled := `listen_address = ":7175"
 boruta_address = ""
 sdcard = "/dev/sdX"
+stm_path = "/run/stm.socket"
 
 [caps]
 
@@ -45,7 +46,8 @@ sdcard = "/dev/sdX"
                        Name:   "boruta-user",
                        Groups: []string{},
                },
-               SDcard: "/dev/sdX",
+               SDcard:    "/dev/sdX",
+               STMsocket: "/run/stm.socket",
        }
        var g *General