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

demo fudanet kolloquium

parent d8db3e1d
No related branches found
No related tags found
No related merge requests found
File added
...@@ -46,7 +46,14 @@ Cobra is a CLI library for Go that empowers applications. ...@@ -46,7 +46,14 @@ Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return gnmidemo.Get(args[0]) flags := cmd.Flags()
u, err := flags.GetString("username")
p, err := flags.GetString("password")
a, err := flags.GetString("address")
if err != nil {
return err
}
return gnmidemo.Get(args[0], a, u, p)
}, },
} }
......
...@@ -69,7 +69,7 @@ func init() { ...@@ -69,7 +69,7 @@ func init() {
cobra.OnInitialize(initConfig) cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gnmi-demo.yaml)") rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gnmi-demo.yaml)")
rootCmd.PersistentFlags().StringP("address", "a", "arista.kieweg.dev", "address of the endpiont") rootCmd.PersistentFlags().StringP("address", "a", "arista.kieweg.dev:6030", "address of the endpiont")
rootCmd.PersistentFlags().StringP("username", "u", "admin", "username for the user") rootCmd.PersistentFlags().StringP("username", "u", "admin", "username for the user")
rootCmd.PersistentFlags().StringP("password", "p", "arista", "password of the user") rootCmd.PersistentFlags().StringP("password", "p", "arista", "password of the user")
} }
......
...@@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
package cmd package cmd
import ( import (
"fmt" gnmidemo "code.fbi.h-da.de/danet/gnmi-demo"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
...@@ -46,8 +45,15 @@ and usage of using your command. For example: ...@@ -46,8 +45,15 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("set called") flags := cmd.Flags()
u, err := flags.GetString("username")
p, err := flags.GetString("password")
a, err := flags.GetString("address")
if err != nil {
return err
}
return gnmidemo.Set(args[0], a, u, p)
}, },
} }
......
...@@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
package cmd package cmd
import ( import (
"fmt" gnmidemo "code.fbi.h-da.de/danet/gnmi-demo"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
...@@ -46,8 +45,15 @@ and usage of using your command. For example: ...@@ -46,8 +45,15 @@ and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("subscribe called") flags := cmd.Flags()
u, err := flags.GetString("username")
p, err := flags.GetString("password")
a, err := flags.GetString("address")
if err != nil {
return err
}
return gnmidemo.Subscribe(args[0], a, u, p)
}, },
} }
......
...@@ -66,11 +66,20 @@ func Get(params ...string) error { ...@@ -66,11 +66,20 @@ func Get(params ...string) error {
if err := util.Write(resp.(proto.Message), "device"); err != nil { if err := util.Write(resp.(proto.Message), "device"); err != nil {
return err return err
} }
log.Info("wrote root resource to file")
default: default:
device := &openconfig.Device{} device := &openconfig.Device{}
blank := &gpb.GetResponse{}
if err := util.Read("device", blank); err != nil {
return err
}
if err := transport.ProcessResponse(blank, device, southbound.Schema()); err != nil {
return err
}
if err := transport.ProcessResponse(resp, device, southbound.Schema()); err != nil { if err := transport.ProcessResponse(resp, device, southbound.Schema()); err != nil {
return err return err
} }
log.Infof("response: %v", resp)
} }
return nil return nil
} }
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment