diff --git a/README.md b/README.md index aecc71b49a1faf1c2fffd9b6a76317c2f33c5e15..8bdcfddc7cccca7204540b89d7093bfb65ae2f25 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,80 @@ -# GoSDN +# goSDN [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) -### CI Status Master -[](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) -[](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) +`goSDN` is a prototypical approach to build a model driven multi-vendor SDN controller. -### CI Status Develop +# Table of Contents -[](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/develop) -[](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/develop) +- [Overview](#overview) +- [Concepts](#concepts) +- [Installing](#installing) +- [Getting Started](#getting-started) + * [k8s](#k8s) + * [Using the goSDN CLI](#using-the-cli) + * [Example](#example) +- [Contributing](CONTRIBUTING.md) +- [License](LICENSE) +- [CI Status](#ci-status) -The GIT repo for the GoSDN design and implementation. GoSDN is intended to be controller for Software Defined Networks (SDN) that follows a modern software architecture design and a well-documented implementation in the go language. +# Overview -## Generate Code Stubs +`goSDN` is also an application that will allow you to manage your multi-vendor network using one unified controller. -YANG code stubs are located in the `yang-processor` directory. They are generated by calling `go generate` from their respective sub directories. +`goSDN` provides: +* Model driven device representation +* Native multi vendor support +* Multi controller environments + +# Concepts + +The `goSDN` core - also called `nucleus` - is a lightweight library that manages principal network domains and provides southbound interface operations for orchestrated networking devices. + +## Principal Networking Domain (PND) + +The PND is the single source of truth within a network. Its state is held and maintained by the controller. Any configuration of an OND has to be applied by the PND. + +## Orchestrated Networking Device (OND) + +Any device directly configured by `goSDN` + +# Installing +You can install the latest release of `goSDN` locally using the `go get` command. Since the repository and some dependencies are not publicly available you have to modify your git config first: +```sh +> git config --global url."git@code.fbi.h-da.de:".insteadOf "https://code.fbi.h-da.de" +> go get code.fbi.h-da.de/cocsn/gosdn/cmd/gosdn ``` -gosdn -+-- yang-processor - +-- ciena //Ciena code stubs - +-- tapi //TAPI code stubs -+-- yang //All YANG modules + +To install the development version you need to clone the repo and use `go install` to build and install the binary: +```sh +# If you haven't cloned the repo yet +> git config --global url."git@code.fbi.h-da.de:".insteadOf "https://code.fbi.h-da.de" +> cd $GOPATH/src +> git clone git@code.fbi.h-da.de:cocsn/gosdn.git + +# checkout the develop branch (or any other branch) +> cd $GOPATH/src/code.fbi.h-da.de/cocsn/gosdn +> git checkout develop +> go install ./cmd/gosdn ``` -## Documentation +Now you can start `goSDN` locally using the `gosdn` command or [use the CLI](#using-the-cli) to interact with a running `goSDN` instance. + +# Getting Started +## k8s + +We have an instance of `goSDN` for each the latest master and current develop branch running on the department's k8s cluster. These endpoints can be accessed using the `gosdn cli` command. If anything breaks please file an [issue](https://code.fbi.h-da.de/cocsn/gosdn/-/issues/new). + +## Using the CLI + +The `gosdn cli` command allows you to interact with a running `goSDN` controller. Use `gosdn help cli` to print the available commands and flags. + +## Example + +[](https://asciinema.org/a/dfrDlFQt5DPlG9HDyetdmeEW8) + +# CI Status -The latest documentatiion generated on the master branch can be downloaded [here](https://code.fbi.h-da.de/cocsn/gosdn/-/jobs). +| Master | Develop | +| ------ | ------ | +| [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) | [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/develop) | +| [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/master) | [](https://code.fbi.h-da.de/cocsn/gosdn/-/commits/develop) | diff --git a/cli/http.go b/cli/http.go index 9707fc9abd31d19a6a6e397cc6c55a2e1a7c76f7..746c4a45146a882d827ef4b58526a5e06e4ef9a3 100644 --- a/cli/http.go +++ b/cli/http.go @@ -43,7 +43,9 @@ func HTTPGet(apiEndpoint, f string, args ...string) error { viper.Set("CLI_PND", pnd) viper.Set("CLI_SBI", sbi) err := viper.WriteConfig() - log.Error(err) + if err != nil { + log.Error(err) + } default: fmt.Println(string(bytes)) } diff --git a/cmd/addDevice.go b/cmd/addDevice.go index 3b98c03b9ba3af1a506672c5d5f3227e83535823..95180504c5828c06dce7cbb713a204e3acd9275b 100644 --- a/cmd/addDevice.go +++ b/cmd/addDevice.go @@ -40,7 +40,10 @@ import ( var addDeviceCmd = &cobra.Command{ Use: "add-device", Short: "adds a device to the controller", - Long: ``, + Long: `Adds a device to the controller. + +Device address and user credentials need to be provided +if they diverge from the default credentials.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet( apiEndpoint, diff --git a/cmd/capabilities.go b/cmd/capabilities.go index fe687884a67b8e7360cac82a7720ae7de3d1cec4..437f6f25f83b62616fd72c918bd78ee45ad82fbb 100644 --- a/cmd/capabilities.go +++ b/cmd/capabilities.go @@ -41,7 +41,7 @@ var capabilitiesCmd = &cobra.Command{ Use: "capabilities", Short: "capabilities request", Long: `Sends a gNMI Capabilities request to the specified target -// and prints the supported models to stdout.`, +and prints the supported models to stdout.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Capabilities(username, password, address) }, diff --git a/cmd/cli.go b/cmd/cli.go index e8810e5344e8f024c7d1debbf2a4eb581a3b7482..320c17ca84c17bafde8a2fa350e9d67e98465fb2 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -42,8 +42,9 @@ var apiEndpoint string // cliCmd represents the cli command var cliCmd = &cobra.Command{ Use: "cli", - Short: "", - Long: ``, + Short: "initialises the cli", + Long: `Initialises the CLI. The first PND UUID and SBI UUID +are written to the config file for subsequent requests.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet(apiEndpoint, "init") }, @@ -52,7 +53,6 @@ var cliCmd = &cobra.Command{ func init() { rootCmd.AddCommand(cliCmd) - cliCmd.PersistentFlags().StringVar(&uuid, "uuid", "", "uuid of the requested device") - cliCmd.PersistentFlags().StringVar(&apiEndpoint, "api-endpoint", "http://gosdn-develop.apps.ocp.fbi.h-da.de/api", "address of the target") + cliCmd.PersistentFlags().StringVar(&apiEndpoint, "controller", "http://gosdn-develop.apps.ocp.fbi.h-da.de/api", "address of the controller") } diff --git a/cmd/cliSet.go b/cmd/cliSet.go index 525125472c77281ca56d7e2b773c6a98831017e4..9a79c630bed30d80c0d8438224edc42f084ff14d 100644 --- a/cmd/cliSet.go +++ b/cmd/cliSet.go @@ -39,8 +39,10 @@ import ( // cliSetCmd represents the cliSet command var cliSetCmd = &cobra.Command{ Use: "set", + Args: cobra.ExactArgs(2), Short: "set a value on a device", - Long: ``, + Long: `Set a path value for a given device. Only one path and +only one value supported for now`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet( apiEndpoint, @@ -57,4 +59,6 @@ var cliSetCmd = &cobra.Command{ func init() { cliCmd.AddCommand(cliSetCmd) + + cliSetCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device") } diff --git a/cmd/get.go b/cmd/get.go index e2d42d80cd7697fef0d59c24615cc696d8e9f266..d200f3a08d4d8116e4168886dbde25427f99fa36 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -40,7 +40,8 @@ import ( var getCmd = &cobra.Command{ Use: "gosdn get", Short: "get request", - Long: `Sends a gNMI Get request to the specified target and prints the response to stdout`, + Long: `Sends a gNMI Get request to the specified target and +prints the response to stdout`, RunE: func(cmd *cobra.Command, args []string) error { _, err := cli.Get(address, username, password, args...) return err diff --git a/cmd/getDevice.go b/cmd/getDevice.go index b9d3408c15d9681c78ac447c152b563119211ed2..2daf934073e6f69dc0f8b55971aa747c9eccec13 100644 --- a/cmd/getDevice.go +++ b/cmd/getDevice.go @@ -39,13 +39,16 @@ import ( // getDeviceCmd represents the getDevice command var getDeviceCmd = &cobra.Command{ Use: "get-device", + Args: cobra.ExactArgs(1), Short: "gets device information from the controller", - Long: ``, + Long: `Gets device information from the controller. + +Device UUID needs to be specified as positional argument.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet( apiEndpoint, "getDevice", - "uuid="+uuid, + "uuid="+args[0], "sbi="+cliSbi, "pnd="+cliPnd, ) diff --git a/cmd/getIds.go b/cmd/getIds.go index b4f0685be494c085b98226cb5c64f9877e4d1781..ec858fd9cc857369ea9ead8887ec36c2025e0a29 100644 --- a/cmd/getIds.go +++ b/cmd/getIds.go @@ -40,7 +40,7 @@ import ( var getIdsCmd = &cobra.Command{ Use: "get-ids", Short: "gets device IDs from the controller", - Long: ``, + Long: `Gets device IDs from the controller and lists them.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet(apiEndpoint, "getIDs") }, diff --git a/cmd/init.go b/cmd/init.go index 9a140f3c26fa1cd8c35a67987db1bf48326ca324..6a4b3e9bab78477c71efc80a075b3855b1a3265d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -40,7 +40,9 @@ import ( var initCmd = &cobra.Command{ Use: "init", Short: "initialise SBI and PND", - Long: ``, + Long: `Initialise SBI and PND and saves values to config file. + +Same as invoking "gosdn cli" without any arguments`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet(apiEndpoint, "init") }, diff --git a/cmd/legacy.go b/cmd/legacy.go deleted file mode 100644 index 2d90ae0936190e5522171eb91be8b244b1b8224f..0000000000000000000000000000000000000000 --- a/cmd/legacy.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright © 2021 da/net research group <danet.fbi.h-da.de> -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -package cmd - -import ( - "errors" - "github.com/spf13/cobra" -) - -// legacyCmd represents the legacy command -var legacyCmd = &cobra.Command{ - Use: "legacy", - Short: "multiple ygot utils - not yet implemented", - Long: ``, - RunE: func(cmd *cobra.Command, args []string) error { - return errors.New("not implemented") - }, -} - -func init() { - pathCmd.AddCommand(legacyCmd) -} diff --git a/cmd/path.go b/cmd/path.go deleted file mode 100644 index abb49047ea79da513743c1cda48b774003725aea..0000000000000000000000000000000000000000 --- a/cmd/path.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright © 2021 da/net research group <danet.fbi.h-da.de> -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -*/ - -package cmd - -import ( - "errors" - "github.com/spf13/cobra" -) - -// pathCmd represents the path command -var pathCmd = &cobra.Command{ - Use: "path", - Short: "multiple ygot utils - not yet implemented", - Long: ``, - RunE: func(cmd *cobra.Command, args []string) error { - return errors.New("not implemented") - }, -} - -func init() { - rootCmd.AddCommand(pathCmd) -} diff --git a/cmd/request.go b/cmd/request.go index 7e887b79097f805e76d6bd8d78cdefd97c879b41..54dd12becaad214a2d19f36d9da6a0a2cf7ac174 100644 --- a/cmd/request.go +++ b/cmd/request.go @@ -39,8 +39,11 @@ import ( // requestCmd represents the request command var requestCmd = &cobra.Command{ Use: "request", + Args: cobra.ExactArgs(1), Short: "requests a path from a specified device on the controller", - Long: ``, + Long: `Requests a path from a specified device on the controller. + +The request path is passed as positional argument.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet( apiEndpoint, @@ -55,4 +58,6 @@ var requestCmd = &cobra.Command{ func init() { cliCmd.AddCommand(requestCmd) + + requestCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device") } diff --git a/cmd/requestAll.go b/cmd/requestAll.go index 183d89d4a2b72a0e3b1acd02c7e31bf7d8cb4985..11234826ed412ed507e9711b7b4af84b379c856e 100644 --- a/cmd/requestAll.go +++ b/cmd/requestAll.go @@ -39,8 +39,12 @@ import ( // requestAllCmd represents the requestAll command var requestAllCmd = &cobra.Command{ Use: "request-all", + Args: cobra.ExactArgs(1), Short: "requests specified path from all devices on the controller", - Long: ``, + Long: `Requests a path from all devices on the controller known by +the controller. + +The request path is passed as positional argument.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.HTTPGet( apiEndpoint, diff --git a/cmd/root.go b/cmd/root.go index ca92d95ce6b98af7d52ac3e7520b7f144ca1459f..61b1e153fba0a4294eb7a18ff2538186739d5143 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -32,11 +32,12 @@ POSSIBILITY OF SUCH DAMAGE. package cmd import ( - "code.fbi.h-da.de/cocsn/gosdn/nucleus" "context" + "os" + + "code.fbi.h-da.de/cocsn/gosdn/nucleus" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "os" "github.com/spf13/viper" ) @@ -54,7 +55,8 @@ var cliSbi string var rootCmd = &cobra.Command{ Use: "gosdn", Short: "starts the gosdn controller", - Long: `Set GOSDN_DEBUG environment variable to enable debug logging.`, + Long: `Starts the gosdn controller and listens on port 8080 +for REST API calls.`, RunE: func(cmd *cobra.Command, args []string) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -74,14 +76,10 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./configs/gosdn.toml)") rootCmd.PersistentFlags().StringVarP(&username, "username", "u", "admin", "username for a gnmi resource") rootCmd.PersistentFlags().StringVarP(&password, "password", "p", "arista", "password for a gnmi resource") - rootCmd.PersistentFlags().StringVarP(&address, "address", "a", "ceos-cocsn.apps.ocp.fbi.h-da.de:6030", "address to a gnmi resource") + rootCmd.PersistentFlags().StringVarP(&address, "address", "a", "ceos-cocsn.apps.ocp.fbi.h-da.de:6030", "address of a gnmi target") rootCmd.PersistentFlags().StringVarP(&loglevel, "log-level", "l", "", "log level 'debug' or 'trace'") rootCmd.Flags().StringVar(&grpcPort, "grpc-port", "55055", "port for gRPC NBI") @@ -110,7 +108,10 @@ func initConfig() { cliPnd = viper.GetString("CLI_PND") cliSbi = viper.GetString("CLI_SBI") - loglevel = viper.GetString("GOSDN_LOG") + ll := viper.GetString("GOSDN_LOG") + if ll != "" { + loglevel = ll + } log.SetReportCaller(true) switch loglevel { case "trace": diff --git a/cmd/set.go b/cmd/set.go index 0f2b758cd13d23c428a83b6c24cccbe33b56b244..486d9f594a7942d25aa690d5e4b970eb96816624 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -43,7 +43,7 @@ var setCmd = &cobra.Command{ Use: "set", Short: "set request", Long: `Sends a gNMI Set request to the specified target. Only one - request per invocation supported.`, +request per invocation supported.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Set(address, username, password, typ, args...) }, diff --git a/cmd/subscribe.go b/cmd/subscribe.go index eac7b4518f6e4409759a4f01a037a7b78b893025..a641b7fb4f4abffebd4e6848ae5cf6343644d276 100644 --- a/cmd/subscribe.go +++ b/cmd/subscribe.go @@ -45,7 +45,7 @@ var subscribeCmd = &cobra.Command{ Short: "subscribe to target", Long: `Starts a gNMI subscriber requesting the specified paths on the target and logs the response to stdout. - Only 'stream' mode with 'sample' operation supported.`, +Only 'stream' mode with 'sample' operation supported.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Subscribe(address, username, password, sampleInterval, heartbeatInterval, args...) }, diff --git a/go.mod b/go.mod index 0ff00d4c822ef6682a5da308969cd95a71eb9751..9822234c73e01a5119746554b44198af1da233b9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802 github.com/openconfig/goyang v0.2.3 github.com/openconfig/ygot v0.10.0 - github.com/sirupsen/logrus v1.4.2 + github.com/sirupsen/logrus v1.7.0 github.com/spf13/cobra v1.1.1 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.6.1 diff --git a/go.sum b/go.sum index 1a42253423ce3a13303668e00677ea278d69350d..df1bca3a02416ecdb2b8129aa30f24d7ceea3832 100644 --- a/go.sum +++ b/go.sum @@ -260,7 +260,6 @@ github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo github.com/klauspost/pgzip v1.2.4/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/reedsolomon v1.9.3/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -379,8 +378,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= @@ -545,6 +545,7 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/nucleus/http.go b/nucleus/http.go index c4419fb7906b1b0d094725cc122db3c47ee12c68..56ad4cb0af707662e72656e1a7b6a4fa0a88f046 100644 --- a/nucleus/http.go +++ b/nucleus/http.go @@ -61,19 +61,26 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { return } + id, err := uuid.Parse(query.Get("uuid")) if err != nil { - log.Error(err) + if err.Error() != "invalid UUID length: 0" { + log.Error(err) + } } pid, err := uuid.Parse(query.Get("pnd")) if err != nil { - log.Error(err) + if err.Error() != "invalid UUID length: 0" { + log.Error(err) + } } sid, err := uuid.Parse(query.Get("sbi")) if err != nil { - log.Error(err) + if err.Error() != "invalid UUID length: 0" { + log.Error(err) + } } var pnd PrincipalNetworkDomain @@ -166,10 +173,17 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { fmt.Fprintf(writer, "%v: %v\n", i+1, id) } } - writeIDs("PNDs", c.pndc.UUIDs()) + pnds := c.pndc.UUIDs() + writeIDs("PNDs", pnds) writeIDs("SBIs", c.sbic.UUIDs()) - if pnd != nil { - writeIDs("Devices", pnd.(*pndImplementation).devices.UUIDs()) + for _,id := range pnds{ + p, err := c.pndc.get(id) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + log.Error(err) + return + } + writeIDs("Devices", p.(*pndImplementation).devices.UUIDs()) } case "init": writeIDs := func(typ string, ids []uuid.UUID) {