diff --git a/cli/adapter/PndAdapter.go b/cli/adapter/PndAdapter.go index 238df3c664b8dd06cee2b86d85061a07e0a51f9a..3f4908a24c06538d6aa87fa662c237150b4d2215 100644 --- a/cli/adapter/PndAdapter.go +++ b/cli/adapter/PndAdapter.go @@ -11,7 +11,6 @@ import ( "code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors" "github.com/google/uuid" "github.com/openconfig/goyang/pkg/yang" - log "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" "google.golang.org/protobuf/proto" ) @@ -106,17 +105,16 @@ func (p *PndAdapter) RemovePnd(pid uuid.UUID) (*core.DeletePndResponse, error) { // ChangeOND sends an API call to the controller requesting the creation of // a change from the provided Operation, path and value. The Change is marked // as Pending and times out after the specified timeout period -func (p *PndAdapter) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path string, value ...string) (uuid.UUID, error) { +func (p *PndAdapter) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path string, value ...string) (*ppb.SetPathListResponse, error) { var v string if len(value) != 0 { v = value[0] } resp, err := api.ChangeRequest(p.endpoint, duid.String(), p.id.String(), path, v, operation) if err != nil { - return uuid.Nil, err + return nil, err } - log.Info(resp) - return uuid.Nil, err + return resp, err } // Request sends an API call to the controller requesting the specified path @@ -221,23 +219,21 @@ func (p *PndAdapter) GetChange(uuid.UUID) (change.Change, error) { } // Commit sends an API call to the controller committing the specified change -func (p *PndAdapter) Commit(cuid uuid.UUID) error { +func (p *PndAdapter) Commit(cuid uuid.UUID) (*ppb.SetChangeListResponse, error) { resp, err := api.Commit(p.endpoint, p.id.String(), cuid.String()) if err != nil { - return err + return nil, err } - log.Info(resp) - return nil + return resp, nil } // Confirm sends an API call to the controller confirming the specified change -func (p *PndAdapter) Confirm(cuid uuid.UUID) error { +func (p *PndAdapter) Confirm(cuid uuid.UUID) (*ppb.SetChangeListResponse, error) { resp, err := api.Confirm(p.endpoint, p.id.String(), cuid.String()) if err != nil { - return err + return nil, err } - log.Info(resp) - return nil + return resp, nil } func filterChanges(state ppb.ChangeState, resp *ppb.GetChangeListResponse) []uuid.UUID { diff --git a/cli/adapter/PndAdapter_test.go b/cli/adapter/PndAdapter_test.go index 1feb4519a07938a16582897b91324a4fbe340a67..41cffaa69505fd76f6d5952eea6d164d72f36d99 100644 --- a/cli/adapter/PndAdapter_test.go +++ b/cli/adapter/PndAdapter_test.go @@ -473,7 +473,7 @@ func TestPndAdapter_Commit(t *testing.T) { id: tt.fields.id, endpoint: tt.fields.endpoint, } - if err := p.Commit(tt.args.cuid); (err != nil) != tt.wantErr { + if _, err := p.Commit(tt.args.cuid); (err != nil) != tt.wantErr { t.Errorf("PndAdapter.Commit() error = %v, wantErr %v", err, tt.wantErr) } }) @@ -502,7 +502,7 @@ func TestPndAdapter_Confirm(t *testing.T) { id: tt.fields.id, endpoint: tt.fields.endpoint, } - if err := p.Confirm(tt.args.cuid); (err != nil) != tt.wantErr { + if _, err := p.Confirm(tt.args.cuid); (err != nil) != tt.wantErr { t.Errorf("PndAdapter.Confirm() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/cli/cmd/changeCommit.go b/cli/cmd/changeCommit.go index 5e969b258fb5db1855fc2abee87cd78cfd9dcf36..db5038b511fe3194a452ce8d7cde8220de287932 100644 --- a/cli/cmd/changeCommit.go +++ b/cli/cmd/changeCommit.go @@ -50,9 +50,13 @@ Change UUID must be specified as positional argument.`, if err != nil { pterm.Error.Println(err) } - if err := pndAdapter.Commit(cuid); err != nil { + resp, err := pndAdapter.Commit(cuid) + if err != nil { pterm.Error.Println(err) } + for _, r := range resp.GetResponses() { + pterm.Info.Println(r.String()) + } }, } diff --git a/cli/cmd/changeConfirm.go b/cli/cmd/changeConfirm.go index 21ff472a13439cbc74bde26b33334157c1757c76..1283c7d36329e1e3b885a2a80598667eba74deaa 100644 --- a/cli/cmd/changeConfirm.go +++ b/cli/cmd/changeConfirm.go @@ -50,9 +50,14 @@ Change UUID must be specified as positional argument`, if err != nil { pterm.Error.Println(err) } - if err := pndAdapter.Confirm(cuid); err != nil { + + resp, err := pndAdapter.Confirm(cuid) + if err != nil { pterm.Error.Println(err) } + for _, r := range resp.GetResponses() { + pterm.Info.Println(r.String()) + } }, } diff --git a/cli/cmd/pndRemove.go b/cli/cmd/pndRemove.go index 0fb318679c754cf36fa797f276401cb1a4acdde2..948d9c008bcf632f34473b13452cb21b212aa9cd 100644 --- a/cli/cmd/pndRemove.go +++ b/cli/cmd/pndRemove.go @@ -47,7 +47,7 @@ var pndRemoveCmd = &cobra.Command{ Long: "Removes the PND with the provided ID", RunE: func(cmd *cobra.Command, args []string) error { - spinner, _ := pterm.DefaultSpinner.Start("Fetching changes for type: ", cType.String()) + spinner, _ := pterm.DefaultSpinner.Start("Removing PND with ID: ", args[0]) pid, err := uuid.Parse(args[0]) if err != nil { spinner.Fail(err)