diff --git a/cli/adapter/PndAdapter.go b/cli/adapter/PndAdapter.go index 99379d0a91f799ca651d7caa449ecd51b4a0d5f7..5797e250f13acd9555a5f6ab683f50846e2d0054 100644 --- a/cli/adapter/PndAdapter.go +++ b/cli/adapter/PndAdapter.go @@ -47,8 +47,8 @@ func (p *PndAdapter) RemoveSbi(uuid.UUID) error { // AddNetworkElement adds a new device to the controller. The device name is optional. // If no name is provided a name will be generated upon device creation. -func (p *PndAdapter) AddNetworkElement(ctx context.Context, name string, opts *tpb.TransportOption, pluginId uuid.UUID, gNMISubscribePaths []string) (*mnepb.AddListResponse, error) { - return api.AddNetworkElement(ctx, p.endpoint, name, opts, pluginId, p.ID(), gNMISubscribePaths) +func (p *PndAdapter) AddNetworkElement(ctx context.Context, name, mneUUID string, opts *tpb.TransportOption, pluginId uuid.UUID, gNMISubscribePaths []string) (*mnepb.AddListResponse, error) { + return api.AddNetworkElement(ctx, p.endpoint, name, mneUUID, opts, pluginId, p.ID(), gNMISubscribePaths) } // GetPluginSchemaTree requests a plugin schema tree. diff --git a/cli/adapter/PndAdapter_test.go b/cli/adapter/PndAdapter_test.go index 25686416fb2349e37e63118ae487c8c008e214f2..45fbf7145e181ba80708e9f27b6a5ed1f3d729dc 100644 --- a/cli/adapter/PndAdapter_test.go +++ b/cli/adapter/PndAdapter_test.go @@ -75,9 +75,10 @@ func TestPndAdapter_AddNetworkElement(t *testing.T) { endpoint string } type args struct { - name string - opts *tpb.TransportOption - sid uuid.UUID + name string + opts *tpb.TransportOption + sid uuid.UUID + mneUUID string } tests := []struct { name string @@ -93,7 +94,7 @@ func TestPndAdapter_AddNetworkElement(t *testing.T) { id: tt.fields.id, endpoint: tt.fields.endpoint, } - if _, err := p.AddNetworkElement(context.TODO(), tt.args.name, tt.args.opts, tt.args.sid, []string{}); (err != nil) != tt.wantErr { + if _, err := p.AddNetworkElement(context.TODO(), tt.args.name, tt.args.mneUUID, tt.args.opts, tt.args.sid, []string{}); (err != nil) != tt.wantErr { t.Errorf("PndAdapter.AddNetworkElement() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/cli/cmd/networkElementCreate.go b/cli/cmd/networkElementCreate.go index 6811e0397c2276049947bce9d0f1cc4ed38abc10..4d0b4e5553a28aefb0606d193cd1dae8af203251 100644 --- a/cli/cmd/networkElementCreate.go +++ b/cli/cmd/networkElementCreate.go @@ -71,7 +71,7 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`, return } - resp, err := pndAdapter.AddNetworkElement(createContextWithAuthorization(), mneName, opt, pluginUUID, []string{"system/config/hostname", "system/config/domain-name"}) + resp, err := pndAdapter.AddNetworkElement(createContextWithAuthorization(), mneName, mneUUID, opt, pluginUUID, []string{"system/config/hostname", "system/config/domain-name"}) if err != nil { spinner.Fail(err) return @@ -85,12 +85,13 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`, // Necessary for prompt mode. The flag variables have to be resetted, // since in prompt mode the program keeps running. - mneName, pluginID, address, username, password = "", "", "", "", "" + mneName, mneUUID, pluginID, address, username, password = "", "", "", "", "", "" tls = false }, } var mneName string +var mneUUID string var pluginID string var tls bool @@ -103,4 +104,5 @@ func init() { networkElementCreateCmd.Flags().StringVarP(&username, "username", "u", "", "username for a gnmi resource") networkElementCreateCmd.Flags().StringVarP(&password, "password", "p", "", "password for a gnmi resource") networkElementCreateCmd.Flags().BoolVarP(&tls, "tls", "t", false, "use flag to enable the controller to send requests to network elements using tls") + networkElementCreateCmd.Flags().StringVar(&mneUUID, "uuid", "", "add a network element UUID (optional)") } diff --git a/controller/api/managedNetworkElement.go b/controller/api/managedNetworkElement.go index 71d6dd0629cb010d5360360ccb030f91fd1ee2e7..b07ad58e0d8156ff079401f0a57813926b061d92 100644 --- a/controller/api/managedNetworkElement.go +++ b/controller/api/managedNetworkElement.go @@ -20,7 +20,7 @@ import ( // AddNetworkElement adds a new network element to the controller. The network element name is optional. // If no name is provided a name will be generated upon network element creation. -func AddNetworkElement(ctx context.Context, addr, mneName string, opt *tpb.TransportOption, pluginID, pid uuid.UUID, gNMISubscribePaths []string) (*mnepb.AddListResponse, error) { +func AddNetworkElement(ctx context.Context, addr, mneName, mneUUID string, opt *tpb.TransportOption, pluginID, pid uuid.UUID, gNMISubscribePaths []string) (*mnepb.AddListResponse, error) { client, err := nbi.NetworkElementClient(addr, dialOptions...) if err != nil { return nil, err @@ -36,6 +36,7 @@ func AddNetworkElement(ctx context.Context, addr, mneName string, opt *tpb.Trans Pid: pid.String(), TransportOption: opt, GnmiSubscribePaths: gNMISubscribePaths, + MneId: mneUUID, }, }, Pid: pid.String(),