Skip to content
Snippets Groups Projects
Commit d34c744a authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark
Browse files

add linux support

parent c12d43c4
No related branches found
No related tags found
3 merge requests!406Draft: Add backup script,!404Enable export and import of SDN configuration,!377Add Linux support to venv-manager
Pipeline #116044 failed
This commit is part of merge request !404. Comments created here will be created in the context of that merge request.
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"strings"
venvmanager "code.fbi.h-da.de/danet/gosdn/applications/venv-manager/venv-manager" venvmanager "code.fbi.h-da.de/danet/gosdn/applications/venv-manager/venv-manager"
"google.golang.org/grpc" "google.golang.org/grpc"
...@@ -30,6 +31,8 @@ func main() { ...@@ -30,6 +31,8 @@ func main() {
} }
flag.Parse() flag.Parse()
customContainerRegistryURL = ensureLastCharIsSlash(customContainerRegistryURL)
fmt.Println("I will try to connect to goSDN located at", dialConnectionURL) fmt.Println("I will try to connect to goSDN located at", dialConnectionURL)
venvManager := venvmanager.NewVenvManager(dialConnectionURL, dialOption, yamlFilepath, customContainerRegistryURL) venvManager := venvmanager.NewVenvManager(dialConnectionURL, dialOption, yamlFilepath, customContainerRegistryURL)
...@@ -50,3 +53,15 @@ func main() { ...@@ -50,3 +53,15 @@ func main() {
} }
os.Exit(0) os.Exit(0)
} }
func ensureLastCharIsSlash(inputString string) string {
if len(inputString) == 0 {
return inputString
}
if strings.HasSuffix(inputString, "/") {
return inputString
}
return inputString + "/"
}
...@@ -23,14 +23,19 @@ func (n Node) GetID() string { ...@@ -23,14 +23,19 @@ func (n Node) GetID() string {
// FillAllFields fills all remaining fields of object with data from YangData. // FillAllFields fills all remaining fields of object with data from YangData.
func (n *Node) FillAllFields(containerRegistryURL string) { func (n *Node) FillAllFields(containerRegistryURL string) {
// make switch case here to differentialte between linux, arista, etc // Works if linux and our gnmi target is used.
softwareVersion := n.YangData.System.State.SoftwareVersion
// err = *&n.YangData.System.State. if softwareVersion != nil {
n.Kind = "linux"
n.Image = containerRegistryURL + *softwareVersion
return
}
// specific to arista // specific to arista
regex := regexp.MustCompile(`[0-9]+\.[0-9]+\.[0-9][A-Z]`) regex := regexp.MustCompile(`[0-9]+\.[0-9]+\.[0-9][A-Z]`)
dockerTag := string(regex.FindAll([]byte(*n.YangData.Lldp.Config.SystemDescription), 1)[0]) dockerTag := string(regex.FindAll([]byte(*n.YangData.Lldp.Config.SystemDescription), 1)[0])
// If it's not linux with our gnmi target and not arista, we don't support it.
if len(dockerTag) == 0 { if len(dockerTag) == 0 {
n.Kind = "couldn't detect kind" n.Kind = "couldn't detect kind"
n.Image = "couldn't detect image" n.Image = "couldn't detect image"
...@@ -39,5 +44,4 @@ func (n *Node) FillAllFields(containerRegistryURL string) { ...@@ -39,5 +44,4 @@ func (n *Node) FillAllFields(containerRegistryURL string) {
n.Kind = "ceos" n.Kind = "ceos"
n.Image = containerRegistryURL + n.Kind + ":" + dockerTag n.Image = containerRegistryURL + n.Kind + ":" + dockerTag
} }
...@@ -215,7 +215,7 @@ func (v *VenvManager) getAndAddMoreData(topologyData *topology.GoSdnTopology) (* ...@@ -215,7 +215,7 @@ func (v *VenvManager) getAndAddMoreData(topologyData *topology.GoSdnTopology) (*
// Create 'root' path to be able to load the whole model from the store. // Create 'root' path to be able to load the whole model from the store.
path, err := ygot.StringToPath("/", ygot.StructuredPath) path, err := ygot.StringToPath("/", ygot.StructuredPath)
if err != nil { if err != nil {
panic(err) return nil, err
} }
// just to load model data into goSDN to have newest data available for get request // just to load model data into goSDN to have newest data available for get request
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment