From 94046887fe2e16821e7abbe00cef65f4c1eaa838 Mon Sep 17 00:00:00 2001 From: schadalawada Date: Mon, 8 Jan 2024 21:09:05 -0800 Subject: [PATCH] NFV-27102: Changes to support cluster name update --- client.go | 1 + internal/api/device.go | 1 + rest_device.go | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/client.go b/client.go index 87878f6..e3d13a7 100644 --- a/client.go +++ b/client.go @@ -151,6 +151,7 @@ type DeviceUpdateRequest interface { WithAdditionalBandwidth(additionalBandwidth int) DeviceUpdateRequest WithACLTemplate(templateID string) DeviceUpdateRequest WithMgmtAclTemplate(mgmtAclTemplateUuid string) DeviceUpdateRequest + WithClusterName(clusterName string) DeviceUpdateRequest Execute() error } diff --git a/internal/api/device.go b/internal/api/device.go index fa330ab..5cebe1f 100644 --- a/internal/api/device.go +++ b/internal/api/device.go @@ -144,6 +144,7 @@ type DeviceUpdateRequest struct { TermLength *int `json:"termLength,omitempty"` VirtualDeviceName *string `json:"virtualDeviceName,omitempty"` Core *int `json:"core,omitempty"` + ClusterName *string `json:"clusterName,omitempty"` } // DeviceAdditionalBandwidthUpdateRequest describes network device additional bandwidth update request diff --git a/rest_device.go b/rest_device.go index 65edb4f..772c8b9 100644 --- a/rest_device.go +++ b/rest_device.go @@ -151,6 +151,12 @@ func (req *restDeviceUpdateRequest) WithCore(core int) DeviceUpdateRequest { return req } +// WithClusterName sets new cluster name in a composite device update request +func (req *restDeviceUpdateRequest) WithClusterName(clusterName string) DeviceUpdateRequest { + req.deviceFields["clusterName"] = clusterName + return req +} + // WithAdditionalBandwidth sets new additional bandwidth in a composite device update request func (req *restDeviceUpdateRequest) WithAdditionalBandwidth(additionalBandwidth int) DeviceUpdateRequest { req.additionalBandwidth = &additionalBandwidth @@ -466,6 +472,10 @@ func (c RestClient) replaceDeviceFields(uuid string, fields map[string]interface reqBody.Core = Int(v.(int)) okToSend = true } + if v, ok := fields["clusterName"]; ok { + reqBody.ClusterName = String(v.(string)) + okToSend = true + } if okToSend { path := "/ne/v1/devices/" + uuid req := c.R().SetBody(&reqBody)