Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove resetter interface from arista as this api doesn't #449

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cloudbuild/vendors_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pushd "$HOME/kne/cloudbuild"
go test -v vendors/vendors_test.go \
-testbed testbed.textproto \
-topology topology.textproto \
-skip_reset \
-vendor_creds ARISTA/admin/admin \
-vendor_creds JUNIPER/root/Google123 \
-vendor_creds CISCO/cisco/cisco123 \
Expand Down
28 changes: 0 additions & 28 deletions topo/node/arista/arista.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"path/filepath"
"regexp"
"strings"
"time"

cpb "github.com/openconfig/kne/proto/ceos"
tpb "github.com/openconfig/kne/proto/topo"
Expand Down Expand Up @@ -65,7 +64,6 @@ type Node struct {
var (
_ node.Certer = (*Node)(nil)
_ node.ConfigPusher = (*Node)(nil)
_ node.Resetter = (*Node)(nil)

ethIntfRe = regexp.MustCompile(`^Ethernet\d+(?:/\d+)?(?:/\d+)?$`)
mgmtIntfRe = regexp.MustCompile(`^Management\d+(?:/\d+)?$`)
Expand Down Expand Up @@ -303,32 +301,6 @@ func (n *Node) ConfigPush(ctx context.Context, r io.Reader) error {
return resp.Failed
}

func (n *Node) ResetCfg(ctx context.Context) error {
log.Infof("%s resetting config", n.Name())

err := n.SpawnCLIConn()
if err != nil {
return err
}

defer n.cliConn.Close()

// this takes a long time sometimes, so we crank timeouts up
resp, err := n.cliConn.SendCommand(
"configure replace clean-config",
scrapliopts.WithTimeoutOps(300*time.Second),
)
if err != nil {
return err
}

if resp.Failed == nil {
log.Infof("%s - finshed resetting config", n.Name())
}

return resp.Failed
}

func defaults(pb *tpb.Node) *tpb.Node {
if pb == nil {
pb = &tpb.Node{
Expand Down
86 changes: 0 additions & 86 deletions topo/node/arista/arista_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"fmt"
"testing"
"time"

ceos "github.com/aristanetworks/arista-ceoslab-operator/v2/api/v1alpha1"
ceosclient "github.com/aristanetworks/arista-ceoslab-operator/v2/api/v1alpha1/dynamic"
Expand All @@ -27,9 +26,6 @@ import (
ceospb "github.com/openconfig/kne/proto/ceos"
topopb "github.com/openconfig/kne/proto/topo"
"github.com/openconfig/kne/topo/node"
scrapliopts "github.com/scrapli/scrapligo/driver/options"
scraplitransport "github.com/scrapli/scrapligo/transport"
scrapliutil "github.com/scrapli/scrapligo/util"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
Expand Down Expand Up @@ -438,85 +434,3 @@ func TestCRD(t *testing.T) {
})
}
}

func TestResetCfg(t *testing.T) {
ki := fake.NewSimpleClientset(&corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod1",
},
})

reaction := func(action ktest.Action) (handled bool, ret watch.Interface, err error) {
f := &fakeWatch{
e: []watch.Event{{
Object: &corev1.Pod{
Status: corev1.PodStatus{
Phase: corev1.PodRunning,
},
},
}},
}
return true, f, nil
}
ki.PrependWatchReactor("*", reaction)

ni := &node.Impl{
KubeClient: ki,
Namespace: "test",
Proto: &topopb.Node{
Name: "pod1",
Vendor: topopb.Vendor_ARISTA,
Config: &topopb.Config{},
},
}

tests := []struct {
desc string
wantErr bool
ni *node.Impl
testFile string
}{
{
// successfully configure certificate
desc: "success",
wantErr: false,
ni: ni,
testFile: "testdata/reset_config_success",
},
{
// device returns "% Invalid input" -- we expect to fail
desc: "failure",
wantErr: true,
ni: ni,
testFile: "testdata/reset_config_failure",
},
}

for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
nImpl, err := New(tt.ni)

if err != nil {
t.Fatalf("failed creating kne arista node")
}

n, _ := nImpl.(*Node)

n.testOpts = []scrapliutil.Option{
scrapliopts.WithTransportType(scraplitransport.FileTransport),
scrapliopts.WithFileTransportFile(tt.testFile),
scrapliopts.WithTimeoutOps(2 * time.Second),
scrapliopts.WithTransportReadSize(1),
scrapliopts.WithReadDelay(0),
scrapliopts.WithDefaultLogger(),
}

ctx := context.Background()

err = n.ResetCfg(ctx)
if err != nil && !tt.wantErr {
t.Fatalf("resetting config failed, error: %+v\n", err)
}
})
}
}
Loading