Skip to content

Commit 5a90a78

Browse files
authored
Merge pull request #24 from schadalawada/main
NFV-25313: updated ZNPD logic to support new changes
2 parents f863c89 + 3f59012 commit 5a90a78

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

rest_device.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ const (
2424
//DeviceLicenseModeBYOL indicates device software license mode where
2525
//customer provides his own, externally procured device license
2626
DeviceLicenseModeBYOL = "BYOL"
27-
//Connectivity type ZNPD indicates device with no internet
28-
ConnectivityZnpd = "ZNPD"
29-
//ZNPD indicates device with no internet
30-
Znpd = "PRIVATE"
31-
//DeviceManagementTypeSelfZnpd indicates device management mode where customer
32-
//fully manages the device and device is created with no internet access
33-
DeviceManagementTypeSelfZnpd = "SELF-CONFIGURED-ZNPD"
3427
)
3528

3629
type restDeviceUpdateRequest struct {
@@ -246,14 +239,12 @@ func mapDeviceAPIToDomain(apiDevice api.Device) *Device {
246239
}
247240
if apiDevice.DeviceManagementType != nil {
248241
if *apiDevice.DeviceManagementType == DeviceManagementTypeSelf {
249-
if apiDevice.Connectivity != nil && strings.EqualFold(*apiDevice.Connectivity, ConnectivityZnpd) {
250-
device.Connectivity = String(Znpd)
251-
}
252242
device.IsSelfManaged = Bool(true)
253243
} else {
254244
device.IsSelfManaged = Bool(false)
255245
}
256246
}
247+
device.Connectivity = apiDevice.Connectivity
257248
device.Interfaces = mapDeviceInterfacesAPIToDomain(apiDevice.Interfaces)
258249
device.VendorConfiguration = apiDevice.VendorConfig
259250
device.UserPublicKey = mapDeviceUserPublicKeyAPIToDomain(apiDevice.UserPublicKey)
@@ -386,15 +377,12 @@ func createDeviceRequest(device Device) api.DeviceRequest {
386377
req.InterfaceCount = device.InterfaceCount
387378
if device.IsSelfManaged != nil {
388379
if *device.IsSelfManaged {
389-
if device.Connectivity != nil && strings.EqualFold(*device.Connectivity, Znpd) {
390-
req.DeviceManagementType = String(DeviceManagementTypeSelfZnpd)
391-
} else {
392-
req.DeviceManagementType = String(DeviceManagementTypeSelf)
393-
}
380+
req.DeviceManagementType = String(DeviceManagementTypeSelf)
394381
} else {
395382
req.DeviceManagementType = String(DeviceManagementTypeEquinix)
396383
}
397384
}
385+
req.Connectivity = device.Connectivity
398386
req.Core = device.CoreCount
399387
req.AdditionalBandwidth = device.AdditionalBandwidth
400388
req.SshInterfaceId = device.WanInterfaceId

rest_device_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ func TestCreateDevice(t *testing.T) {
7575
//then
7676
assert.Nil(t, err, "Error is not returned")
7777
assert.Equal(t, uuid, resp.UUID, "UUID matches")
78-
verifyDeviceRequest(t, device, req, false)
78+
verifyDeviceRequest(t, device, req)
7979
}
8080

81-
func TestCreateZnpdDevice(t *testing.T) {
81+
func TestCreateDeviceWithConnectivityTypeAsPrivate(t *testing.T) {
8282
//given
8383
resp := api.DeviceRequestResponse{}
8484
if err := readJSONData("./test-fixtures/ne_device_create_resp.json", &resp); err != nil {
@@ -138,7 +138,7 @@ func TestCreateZnpdDevice(t *testing.T) {
138138
//then
139139
assert.Nil(t, err, "Error is not returned")
140140
assert.Equal(t, uuid, resp.UUID, "UUID matches")
141-
verifyDeviceRequest(t, device, req, true)
141+
verifyDeviceRequest(t, device, req)
142142
}
143143

144144
func TestCreateRedundantDevice(t *testing.T) {
@@ -494,7 +494,7 @@ func verifyDeviceInterface(t *testing.T, inf DeviceInterface, apiInf api.DeviceI
494494
assert.Equal(t, apiInf.Type, inf.Type, "Type matches")
495495
}
496496

497-
func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest, isZnpd bool) {
497+
func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest) {
498498
assert.Equal(t, device.Throughput, req.Throughput, "Throughput matches")
499499
assert.Equal(t, device.ThroughputUnit, req.ThroughputUnit, "ThroughputUnit matches")
500500
assert.Equal(t, device.MetroCode, req.MetroCode, "MetroCode matches")
@@ -519,11 +519,8 @@ func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest, isZ
519519
assert.Equal(t, device.Version, req.Version, "Version matches")
520520
assert.Equal(t, device.InterfaceCount, req.InterfaceCount, "InterfaceCount matches")
521521
if *device.IsSelfManaged {
522-
if isZnpd {
523-
assert.Equal(t, DeviceManagementTypeSelfZnpd, StringValue(req.DeviceManagementType), "DeviceManagementType matches")
524-
} else {
525-
assert.Equal(t, DeviceManagementTypeSelf, StringValue(req.DeviceManagementType), "DeviceManagementType matches")
526-
}
522+
523+
assert.Equal(t, DeviceManagementTypeSelf, StringValue(req.DeviceManagementType), "DeviceManagementType matches")
527524
} else {
528525
assert.Equal(t, DeviceManagementTypeEquinix, StringValue(req.DeviceManagementType), "DeviceManagementType matches")
529526
}
@@ -536,7 +533,7 @@ func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest, isZ
536533
}
537534

538535
func verifyRedundantDeviceRequest(t *testing.T, primary, secondary Device, req api.DeviceRequest) {
539-
verifyDeviceRequest(t, primary, req, false)
536+
verifyDeviceRequest(t, primary, req)
540537
assert.Equal(t, secondary.MetroCode, req.Secondary.MetroCode, "Secondary MetroCode matches")
541538
assert.Equal(t, secondary.LicenseToken, req.Secondary.LicenseToken, "LicenseFileID matches")
542539
assert.Equal(t, secondary.LicenseFileID, req.Secondary.LicenseFileID, "LicenseFileID matches")

0 commit comments

Comments
 (0)