Commit 9ed2e793 authored by Manuel Kieweg's avatar Manuel Kieweg 🤷
Browse files

rewrite readme. asciinema missing

parent 24779b58
......@@ -38,12 +38,26 @@ The PND is the single source of truth within a network. Its state is held and ma
Any device directly configured by `goSDN`
# Installing
You can install `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:
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
```
Now you can start `goSDN` locally using the `gosdn` command or [use the CLI](#using-the-cli) to interact with a running `goSDN` instance.
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
```
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
......
......@@ -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))
}
......
......@@ -42,8 +42,8 @@ var addDeviceCmd = &cobra.Command{
Short: "adds a device to the controller",
Long: `Adds a device to the controller.
Device address and user credentials need to be provided
if they diverge from the default credentials.`,
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,
......
......@@ -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)
},
......
......@@ -44,7 +44,7 @@ var cliCmd = &cobra.Command{
Use: "cli",
Short: "initialises the cli",
Long: `Initialises the CLI. The first PND UUID and SBI UUID
are written to the config file for subsequent requests.`,
are written to the config file for subsequent requests.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(apiEndpoint, "init")
},
......@@ -53,6 +53,6 @@ var cliCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(cliCmd)
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")
}
......@@ -42,7 +42,7 @@ var cliSetCmd = &cobra.Command{
Args: cobra.ExactArgs(2),
Short: "set a value on a device",
Long: `Set a path value for a given device. Only one path and
only one value supported for now`,
only one value supported for now`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
......@@ -60,5 +60,5 @@ var cliSetCmd = &cobra.Command{
func init() {
cliCmd.AddCommand(cliSetCmd)
cliCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device")
cliSetCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device")
}
......@@ -41,7 +41,7 @@ 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`,
prints the response to stdout`,
RunE: func(cmd *cobra.Command, args []string) error {
_, err := cli.Get(address, username, password, args...)
return err
......
......@@ -43,7 +43,7 @@ var getDeviceCmd = &cobra.Command{
Short: "gets device information from the controller",
Long: `Gets device information from the controller.
Device UUID needs to be specified as positional argument.`,
Device UUID needs to be specified as positional argument.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
......
......@@ -42,7 +42,7 @@ var initCmd = &cobra.Command{
Short: "initialise SBI and PND",
Long: `Initialise SBI and PND and saves values to config file.
Same as invoking "gosdn cli" without any arguments`,
Same as invoking "gosdn cli" without any arguments`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(apiEndpoint, "init")
},
......
......@@ -43,7 +43,7 @@ var requestCmd = &cobra.Command{
Short: "requests a path from a specified device on the controller",
Long: `Requests a path from a specified device on the controller.
The request path is passed as positional argument.`,
The request path is passed as positional argument.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
......@@ -59,5 +59,5 @@ var requestCmd = &cobra.Command{
func init() {
cliCmd.AddCommand(requestCmd)
cliCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device")
requestCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device")
}
......@@ -42,9 +42,9 @@ var requestAllCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Short: "requests specified path from all devices on the controller",
Long: `Requests a path from all devices on the controller known by
the controller.
the controller.
The request path is passed as positional argument.`,
The request path is passed as positional argument.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
......
......@@ -56,7 +56,7 @@ var rootCmd = &cobra.Command{
Use: "gosdn",
Short: "starts the gosdn controller",
Long: `Starts the gosdn controller and listens on port 8080
for REST API calls.`,
for REST API calls.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
......@@ -79,7 +79,7 @@ func init() {
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")
......@@ -108,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":
......
......@@ -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...)
},
......
......@@ -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...)
},
......
......@@ -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=
......
......@@ -61,24 +61,37 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) {
return
}
var hasPnd bool
var hasSbi bool
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)
}
} else {
hasPnd = true
}
sid, err := uuid.Parse(query.Get("sbi"))
if err != nil {
log.Error(err)
if err.Error() != "invalid UUID length: 0" {
log.Error(err)
}
} else {
hasSbi = true
}
var pnd PrincipalNetworkDomain
var sbi SouthboundInterface
if query.Get("q") != "init" && query.Get("q") != "getIDs" {
if hasSbi && hasPnd {
pnd, err = c.pndc.get(pid)
if err != nil {
log.Error(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment