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

Merge branch '99-commit-confirm-mechanic-for-ond-changes' into 'develop'

Commit-Confirm Mechanic for PND

See merge request cocsn/gosdn!147
parents 5e53f43f 78e57d25
Branches
Tags
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!147Commit-Confirm Mechanic for PND,!138Develop
Pipeline #69009 passed
This commit is part of merge request !138. Comments created here will be created in the context of that merge request.
......@@ -27,22 +27,23 @@ integration-test:
allow_failure: true
variables:
GOSDN_LOG: "nolog"
GOSDN_CHANGE_TIMEOUT: "100ms"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
- if: $CI_NIGHTLY
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
allow_failure: true
after_script:
- go tool cover -func=coverage.out
unit-test:
script:
- go test -short -race $(go list ./... | grep -v /forks/ | grep -v /api/ | grep -v /mocks ) -v -coverprofile=coverage.out
after_script:
- go tool cover -func=coverage.out
<<: *test
http-api-test:
controller-test:
script:
- cd ./nucleus
- go test -race -v -run Test_httpApi -coverprofile=coverage.out
- go test -race -v -run TestRun
<<: *test
\ No newline at end of file
......@@ -3,11 +3,12 @@ package cli
import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"io/ioutil"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
const apiRoot = "?"
......@@ -26,6 +27,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
resp, err := http.Get(apiEndpoint + apiRoot + "q=" + f + builder.String())
if err != nil {
log.Info(fmt.Sprintf("Err: %s", err))
return err
}
builder.Reset()
......@@ -38,8 +40,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
switch f {
case "init":
pnd := string(bytes[:36])
sbi := string(bytes[36:])
pnd := string(bytes[9:45])
sbi := string(bytes[55:91])
viper.Set("CLI_PND", pnd)
viper.Set("CLI_SBI", sbi)
err := viper.WriteConfig()
......@@ -49,6 +51,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
default:
fmt.Println(string(bytes))
}
case http.StatusCreated:
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
......@@ -58,6 +61,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
uuid := string(bytes[19:55])
viper.Set("LAST_DEVICE_UUID", uuid)
fmt.Println(string(bytes))
case http.StatusAccepted:
default:
log.WithFields(log.Fields{
"status code": resp.StatusCode,
......
......@@ -3,10 +3,7 @@ package cli
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
"context"
pb "google.golang.org/protobuf/proto"
"os"
)
// Set sends a gNMI Set request to the specified target. Only one
......@@ -23,28 +20,5 @@ func Set(a, u, p, typ string, args ...string) error {
if err != nil {
return err
}
path := gnmi.SplitPath(args[0])
req := []interface{}{
&gnmi.Operation{
Type: typ,
Origin: "",
Target: "",
Path: path,
Val: args[1],
},
}
resp, err := t.Set(context.Background(), req...)
if err != nil {
return err
}
_, tap := os.LookupEnv("GOSDN_TAP")
if tap {
if err := proto.Write(resp.(pb.Message), "resp-set-system-config-hostname"); err != nil {
return err
}
}
return nil
return t.Set(context.Background(), args)
}
/*
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 (
"github.com/spf13/cobra"
)
// changeCmd represents the change command
var changeCmd = &cobra.Command{
Use: "change",
Short: "manage changes of the specified pnd",
Long: `use "change list" or "change list-pending" to list changes
use "change commit" or "change confirm" respectively`,
}
func init() {
cliCmd.AddCommand(changeCmd)
}
......@@ -41,12 +41,14 @@ var cliSetCmd = &cobra.Command{
Use: "set",
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`,
Long: `Update a path value for a given device. Only one path and
only one value supported for now.
Use "set replace" or "set delete" respectively`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"set",
"update",
"uuid="+uuid,
"cliSbi="+cliSbi,
"cliPnd="+cliPnd,
......@@ -60,5 +62,5 @@ only one value supported for now`,
func init() {
cliCmd.AddCommand(cliSetCmd)
cliSetCmd.Flags().StringVar(&uuid, "uuid", "", "uuid of the requested device")
cliSetCmd.PersistentFlags().StringVar(&uuid, "uuid", "", "uuid of the target device")
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// commitCmd represents the commit command
var commitCmd = &cobra.Command{
Use: "commit",
Args: cobra.ExactArgs(1),
Short: "Commit the given change for the active PND",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"change-commit",
"pnd="+cliPnd,
"cuid="+args[0],
)
},
}
func init() {
changeCmd.AddCommand(commitCmd)
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// confirmCmd represents the confirm command
var confirmCmd = &cobra.Command{
Use: "confirm",
Args: cobra.ExactArgs(1),
Short: "Confirms the given change for the active PND",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"change-confirm",
"pnd="+cliPnd,
"cuid="+args[0],
)
},
}
func init() {
changeCmd.AddCommand(confirmCmd)
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
Use: "delete",
Args: cobra.ExactArgs(1),
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`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"delete",
"uuid="+uuid,
"cliSbi="+cliSbi,
"cliPnd="+cliPnd,
"path="+args[0],
"address="+address,
)
},
}
func init() {
cliSetCmd.AddCommand(deleteCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// deleteCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// deleteCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// listCmd represents the list command
var listCmd = &cobra.Command{
Use: "list",
Short: "Lists all committed changes",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"change-list",
"pnd="+cliPnd,
)
},
}
func init() {
changeCmd.AddCommand(listCmd)
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// listPendingCmd represents the listPending command
var listPendingCmd = &cobra.Command{
Use: "listPending",
Short: "Lists all committed changes",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"change-list-pending",
"pnd="+cliPnd,
)
},
}
func init() {
changeCmd.AddCommand(listPendingCmd)
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// replaceCmd represents the replace command
var replaceCmd = &cobra.Command{
Use: "replace",
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`,
RunE: func(cmd *cobra.Command, args []string) error {
return cli.HTTPGet(
apiEndpoint,
"replace",
"uuid="+uuid,
"cliSbi="+cliSbi,
"cliPnd="+cliPnd,
"path="+args[0],
"address="+address,
"value="+args[1],
)
},
}
func init() {
cliSetCmd.AddCommand(replaceCmd)
}
/*
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 (
"code.fbi.h-da.de/cocsn/gosdn/cli"
"github.com/spf13/cobra"
)
// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Args: cobra.ExactArgs(2),
Short: "update a value on a device",
Long: `Update 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,
"update",
"uuid="+uuid,
"cliSbi="+cliSbi,
"cliPnd="+cliPnd,
"path="+args[0],
"address="+address,
"value="+args[1],
)
},
}
func init() {
cliSetCmd.AddCommand(updateCmd)
}
......@@ -118,7 +118,7 @@ func DialContext(ctx context.Context, cfg *Config) (pb.GNMIClient, error) {
if cfg.TLS || cfg.CAFile != "" || cfg.CertFile != "" || cfg.Token != "" {
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
MinVersion: tls.VersionTLS12,
}
if cfg.CAFile != "" {
b, err := ioutil.ReadFile(cfg.CAFile)
......
......@@ -9,17 +9,17 @@ require (
github.com/google/gnxi v0.0.0-20201221102247-c26672548161
github.com/google/uuid v1.1.2
github.com/neo4j/neo4j-go-driver v1.8.3
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.7.0
github.com/spf13/cobra v1.1.1
github.com/openconfig/gnmi v0.0.0-20210428141518-ae4d850000ab
github.com/openconfig/goyang v0.2.4
github.com/openconfig/ygot v0.10.5
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20201216054612-986b41b23924
google.golang.org/grpc v1.34.0
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
k8s.io/api v0.20.5
k8s.io/apimachinery v0.20.5
k8s.io/client-go v0.20.5
k8s.io/api v0.21.0
k8s.io/apimachinery v0.21.0
k8s.io/client-go v0.21.0
)
This diff is collapsed.
// Code generated by mockery v2.6.0. DO NOT EDIT.
// Code generated by mockery 2.7.4. DO NOT EDIT.
package mocks
......@@ -6,6 +6,8 @@ import (
mock "github.com/stretchr/testify/mock"
uuid "github.com/google/uuid"
ygot "github.com/openconfig/ygot/ygot"
)
// PrincipalNetworkDomain is an autogenerated mock type for the PrincipalNetworkDomain type
......@@ -41,6 +43,71 @@ func (_m *PrincipalNetworkDomain) AddSbi(_a0 interface{}) error {
return r0
}
// ChangeOND provides a mock function with given fields: _a0, operation, path, value
func (_m *PrincipalNetworkDomain) ChangeOND(_a0 uuid.UUID, operation interface{}, path string, value ...string) error {
_va := make([]interface{}, len(value))
for _i := range value {
_va[_i] = value[_i]
}
var _ca []interface{}
_ca = append(_ca, _a0, operation, path)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
var r0 error
if rf, ok := ret.Get(0).(func(uuid.UUID, interface{}, string, ...string) error); ok {
r0 = rf(_a0, operation, path, value...)
} else {
r0 = ret.Error(0)
}
return r0
}
// Commit provides a mock function with given fields: _a0
func (_m *PrincipalNetworkDomain) Commit(_a0 uuid.UUID) error {
ret := _m.Called(_a0)
var r0 error
if rf, ok := ret.Get(0).(func(uuid.UUID) error); ok {
r0 = rf(_a0)
} else {
r0 = ret.Error(0)
}
return r0
}
// Committed provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) Committed() []uuid.UUID {
ret := _m.Called()
var r0 []uuid.UUID
if rf, ok := ret.Get(0).(func() []uuid.UUID); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]uuid.UUID)
}
}
return r0
}
// Confirm provides a mock function with given fields: _a0
func (_m *PrincipalNetworkDomain) Confirm(_a0 uuid.UUID) error {
ret := _m.Called(_a0)
var r0 error
if rf, ok := ret.Get(0).(func(uuid.UUID) error); ok {
r0 = rf(_a0)
} else {
r0 = ret.Error(0)
}
return r0
}
// ContainsDevice provides a mock function with given fields: _a0
func (_m *PrincipalNetworkDomain) ContainsDevice(_a0 uuid.UUID) bool {
ret := _m.Called(_a0)
......@@ -69,6 +136,22 @@ func (_m *PrincipalNetworkDomain) Destroy() error {
return r0
}
// Devices provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) Devices() []uuid.UUID {
ret := _m.Called()
var r0 []uuid.UUID
if rf, ok := ret.Get(0).(func() []uuid.UUID); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]uuid.UUID)
}
}
return r0
}
// GetDescription provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) GetDescription() string {
ret := _m.Called()
......@@ -83,6 +166,29 @@ func (_m *PrincipalNetworkDomain) GetDescription() string {
return r0
}
// GetDevice provides a mock function with given fields: _a0
func (_m *PrincipalNetworkDomain) GetDevice(_a0 uuid.UUID) (ygot.GoStruct, error) {
ret := _m.Called(_a0)
var r0 ygot.GoStruct
if rf, ok := ret.Get(0).(func(uuid.UUID) ygot.GoStruct); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(ygot.GoStruct)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(uuid.UUID) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetName provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) GetName() string {
ret := _m.Called()
......@@ -113,7 +219,7 @@ func (_m *PrincipalNetworkDomain) GetSBIs() interface{} {
return r0
}
// Id provides a mock function with given fields:
// ID provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) ID() uuid.UUID {
ret := _m.Called()
......@@ -150,6 +256,22 @@ func (_m *PrincipalNetworkDomain) MarshalDevice(_a0 uuid.UUID) (string, error) {
return r0, r1
}
// Pending provides a mock function with given fields:
func (_m *PrincipalNetworkDomain) Pending() []uuid.UUID {
ret := _m.Called()
var r0 []uuid.UUID
if rf, ok := ret.Get(0).(func() []uuid.UUID); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]uuid.UUID)
}
}
return r0
}
// RemoveDevice provides a mock function with given fields: _a0
func (_m *PrincipalNetworkDomain) RemoveDevice(_a0 uuid.UUID) error {
ret := _m.Called(_a0)
......
// Code generated by mockery v2.6.0. DO NOT EDIT.
// Code generated by mockery 2.7.4. DO NOT EDIT.
package mocks
......@@ -18,7 +18,7 @@ type SouthboundInterface struct {
mock.Mock
}
// Id provides a mock function with given fields:
// ID provides a mock function with given fields:
func (_m *SouthboundInterface) ID() uuid.UUID {
ret := _m.Called()
......
// Code generated by mockery v2.6.0. DO NOT EDIT.
// Code generated by mockery 2.7.4. DO NOT EDIT.
package mocks
......@@ -13,7 +13,7 @@ type Storable struct {
mock.Mock
}
// Id provides a mock function with given fields:
// ID provides a mock function with given fields:
func (_m *Storable) ID() uuid.UUID {
ret := _m.Called()
......
// Code generated by mockery v2.6.0. DO NOT EDIT.
// Code generated by mockery 2.7.4. DO NOT EDIT.
package mocks
......@@ -76,29 +76,20 @@ func (_m *Transport) ProcessResponse(resp interface{}, root interface{}, models
}
// Set provides a mock function with given fields: ctx, params
func (_m *Transport) Set(ctx context.Context, params ...interface{}) (interface{}, error) {
func (_m *Transport) Set(ctx context.Context, params ...interface{}) error {
var _ca []interface{}
_ca = append(_ca, ctx)
_ca = append(_ca, params...)
ret := _m.Called(_ca...)
var r0 interface{}
if rf, ok := ret.Get(0).(func(context.Context, ...interface{}) interface{}); ok {
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, ...interface{}) error); ok {
r0 = rf(ctx, params...)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(interface{})
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, ...interface{}) error); ok {
r1 = rf(ctx, params...)
} else {
r1 = ret.Error(1)
r0 = ret.Error(0)
}
return r0, r1
return r0
}
// Subscribe provides a mock function with given fields: ctx, params
......
// Code generated by mockery v2.6.0. DO NOT EDIT.
// Code generated by mockery 2.7.4. DO NOT EDIT.
package mocks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment