Skip to content
Snippets Groups Projects
Commit 04c55e4f authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

.

parent 4ffc66f4
No related branches found
No related tags found
2 merge requests!221Thesis mk,!173Process response overhaul
Pipeline #74375 passed with warnings
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound" spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport" tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
nbi "code.fbi.h-da.de/cocsn/gosdn/northbound/client" nbi "code.fbi.h-da.de/cocsn/gosdn/northbound/client"
"github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
...@@ -41,7 +42,7 @@ func Init(addr string) error { ...@@ -41,7 +42,7 @@ func Init(addr string) error {
log.Infof("SBI: %v", sbi) log.Infof("SBI: %v", sbi)
} }
} }
return nil return viper.WriteConfig()
} }
// GetIds requests all UUID information from the controller // GetIds requests all UUID information from the controller
...@@ -184,7 +185,7 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str ...@@ -184,7 +185,7 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str
}, },
DeviceName: deviceName, DeviceName: deviceName,
TransportOption: &tpb.TransportOption{ TransportOption: &tpb.TransportOption{
Address: addr, Address: deviceAddress,
Username: username, Username: username,
Password: password, Password: password,
TransportOption: &tpb.TransportOption_GnmiTransportOption{ TransportOption: &tpb.TransportOption_GnmiTransportOption{
...@@ -196,7 +197,8 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str ...@@ -196,7 +197,8 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str
Pid: pnd, Pid: pnd,
} }
if sbi == "csbi" { if sbi == "csbi" {
req.Ond[0].Sbi = nil req.Ond[0].Sbi.Id = uuid.Nil.String()
req.Ond[0].Sbi.Type = spb.Type_CONTAINERISED
req.Ond[0].TransportOption.Csbi = true req.Ond[0].TransportOption.Csbi = true
} }
ctx := context.Background() ctx := context.Background()
......
...@@ -47,6 +47,9 @@ var addDeviceCmd = &cobra.Command{ ...@@ -47,6 +47,9 @@ var addDeviceCmd = &cobra.Command{
Device address and user credentials need to be provided Device address and user credentials need to be provided
if they diverge from the default credentials.`, if they diverge from the default credentials.`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if csbi {
cliSbi = "csbi"
}
resp, err := cli.AddDevice( resp, err := cli.AddDevice(
apiEndpoint, apiEndpoint,
username, username,
...@@ -65,9 +68,11 @@ if they diverge from the default credentials.`, ...@@ -65,9 +68,11 @@ if they diverge from the default credentials.`,
} }
var deviceName string var deviceName string
var csbi bool
func init() { func init() {
cliCmd.AddCommand(addDeviceCmd) cliCmd.AddCommand(addDeviceCmd)
addDeviceCmd.Flags().StringVar(&deviceName, "name", "", "add a device name (optional)") addDeviceCmd.Flags().StringVar(&deviceName, "name", "", "add a device name (optional)")
addDeviceCmd.Flags().BoolVar(&csbi, "csbi", false, "add a csbi device")
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment