Skip to content

Commit 22c6b47

Browse files
committed
Merge pull request #1585 from nlivens/CLOUDSTACK-9399
CLOUDSTACK-9399 : NPE during deletion of host when clusterId is nullIn most network plugins, there's a Resource class which will handle the communication with the actual device / underlaying client / ... They're configured as a host, so ACS is able to send commands towards it. When they're configured as a host, the clusterId is not filled in since it's not relevant. Hence, the NPE while deleting this host because of ```long clusterId = host.getClusterId();``` * pr/1585: Nuage VSP : Enhancing Marvin test coverage CLOUDSTACK-9399 : Marvin test coverage for Nuage VSP device CRUD operations CLOUDSTACK-9399 : NPE during deletion of host when clusterId is null Signed-off-by: Will Stevens <williamstevens@gmail.com>
2 parents 76d5350 + 7531f24 commit 22c6b47

7 files changed

Lines changed: 799 additions & 645 deletions

File tree

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ protected boolean doDeleteHost(final long hostId, final boolean isForced, final
847847
return true;
848848
}
849849

850-
long clusterId = host.getClusterId();
850+
Long clusterId = host.getClusterId();
851851

852852
_agentMgr.notifyMonitorsOfHostAboutToBeRemoved(host.getId());
853853

@@ -927,7 +927,9 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
927927
}
928928
});
929929

930-
_agentMgr.notifyMonitorsOfRemovedHost(host.getId(), clusterId);
930+
if (clusterId != null) {
931+
_agentMgr.notifyMonitorsOfRemovedHost(host.getId(), clusterId);
932+
}
931933

932934
return true;
933935
}

test/integration/plugins/nuagevsp/nuageTestCase.py

Lines changed: 305 additions & 225 deletions
Large diffs are not rendered by default.

test/integration/plugins/nuagevsp/test_nuage_password_reset.py

Lines changed: 156 additions & 165 deletions
Large diffs are not rendered by default.

test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py

Lines changed: 233 additions & 238 deletions
Large diffs are not rendered by default.

test/integration/plugins/nuagevsp/test_nuage_vpc_network.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_nuage_vpc_network(self):
5757
# 6. Deploy a VM in the created VPC network, check if the VM is successfully deployed and is in the "Running"
5858
# state.
5959
# 7. Verify that the created ACL item is successfully implemented in Nuage VSP.
60+
# 8. Delete all the created objects (cleanup).
6061

6162
# Creating a VPC offering
6263
self.debug("Creating Nuage VSP VPC offering...")
@@ -91,12 +92,12 @@ def test_nuage_vpc_network(self):
9192
self.check_VM_state(vm, state="Running")
9293

9394
# VSD verification
94-
self.verify_vsp_network(self.domain.id, vpc_network, vpc)
95-
self.verify_vsp_router(vr)
96-
self.verify_vsp_vm(vm)
95+
self.verify_vsd_network(self.domain.id, vpc_network, vpc)
96+
self.verify_vsd_router(vr)
97+
self.verify_vsd_vm(vm)
9798

9899
# VSD verification for ACL item
99-
self.verify_vsp_firewall_rule(acl_item)
100+
self.verify_vsd_firewall_rule(acl_item)
100101

101102
@attr(tags=["advanced", "nuagevsp", "multizone"], required_hardware="false")
102103
def test_nuage_vpc_network_multizone(self):

test/integration/plugins/nuagevsp/test_nuage_vsp.py

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"""
2020
# Import Local Modules
2121
from nuageTestCase import nuageTestCase
22-
from marvin.lib.base import Account
22+
from marvin.lib.base import Account, Nuage
23+
from marvin.cloudstackAPI import deleteNuageVspDevice
2324
# Import System Modules
2425
from nose.plugins.attrib import attr
26+
import copy
2527

2628

2729
class TestNuageVsp(nuageTestCase):
@@ -43,6 +45,91 @@ def setUp(self):
4345
self.cleanup = [self.account]
4446
return
4547

48+
# validate_NuageVspDevice - Validates the addition of Nuage VSP device in the Nuage VSP Physical Network
49+
def validate_NuageVspDevice(self):
50+
"""Validates the addition of Nuage VSP device in the Nuage VSP Physical Network"""
51+
self.debug("Validating the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" %
52+
self.vsp_physical_network.id)
53+
nuage_vsp_device = Nuage.list(self.api_client,
54+
physicalnetworkid=self.vsp_physical_network.id
55+
)
56+
self.assertEqual(isinstance(nuage_vsp_device, list), True,
57+
"List Nuage VSP device should return a valid list"
58+
)
59+
self.debug("Successfully validated the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" %
60+
self.vsp_physical_network.id)
61+
62+
# delete_NuageVspDevice - Deletes the Nuage VSP device in the Nuage VSP Physical Network
63+
def delete_NuageVspDevice(self):
64+
"""Deletes the Nuage VSP device in the Nuage VSP Physical Network"""
65+
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network - %s" %
66+
self.vsp_physical_network.id)
67+
nuage_vsp_device = Nuage.list(self.api_client,
68+
physicalnetworkid=self.vsp_physical_network.id
69+
)[0]
70+
cmd = deleteNuageVspDevice.deleteNuageVspDeviceCmd()
71+
cmd.vspdeviceid = nuage_vsp_device.vspdeviceid
72+
self.api_client.deleteNuageVspDevice(cmd)
73+
self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network - %s" %
74+
self.vsp_physical_network.id)
75+
76+
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
77+
def test_nuage_vsp_device(self):
78+
""" Test Nuage VSP device in the Nuage VSP Physical Network
79+
"""
80+
81+
# 1. Verify that the Nuage VSP network service provider is successfully created and enabled in the Nuage VSP
82+
# Physical Network.
83+
# 2. Verify that the Nuage VSP device is successfully created in the Nuage VSP Physical Network.
84+
# 3. Delete the Nuage VSP device in the Nuage VSP Physical Network, verify that the Nuage VSP device is
85+
# successfully deleted in the Nuage VSP Physical Network.
86+
# 4. Add the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials, verify that the
87+
# Nuage VSP device failed to add in the Nuage VSP Physical Network.
88+
# 5. Add the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials, verify that the
89+
# Nuage VSP device is successfully added in the Nuage VSP Physical Network.
90+
91+
# Nuage VSP network service provider validation
92+
self.debug("Validating the Nuage VSP network service provider in the Nuage VSP Physical Network...")
93+
self.validate_NetworkServiceProvider("NuageVsp", state="Enabled")
94+
95+
# Nuage VSP device validation
96+
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
97+
self.validate_NuageVspDevice()
98+
99+
# Nuage VSP device deletion
100+
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network...")
101+
self.delete_NuageVspDevice()
102+
103+
# Nuage VSP device validation
104+
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
105+
with self.assertRaises(Exception):
106+
self.validate_NuageVspDevice()
107+
self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network")
108+
109+
# Adding the Nuage VSP device with invalid VSD credentials
110+
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials...")
111+
vsd_info = self.nuage_vsp_device.__dict__
112+
invalid_vsd_info = copy.deepcopy(vsd_info)
113+
invalid_vsd_info["password"] = ""
114+
with self.assertRaises(Exception):
115+
Nuage.add(self.api_client, invalid_vsd_info, self.vsp_physical_network.id)
116+
self.debug("Failed to add the Nuage VSP device in the Nuage VSP Physical Network due to invalid VSD "
117+
"credentials")
118+
119+
# Nuage VSP device validation
120+
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
121+
with self.assertRaises(Exception):
122+
self.validate_NuageVspDevice()
123+
self.debug("The Nuage VSP device is not added in the Nuage VSP Physical Network")
124+
125+
# Adding the Nuage VSP device with valid VSD credentials
126+
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials...")
127+
Nuage.add(self.api_client, vsd_info, self.vsp_physical_network.id)
128+
129+
# Nuage VSP device validation
130+
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
131+
self.validate_NuageVspDevice()
132+
46133
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
47134
def test_nuage_vsp(self):
48135
""" Test Nuage VSP SDN plugin with basic Isolated Network functionality
@@ -58,9 +145,7 @@ def test_nuage_vsp(self):
58145
# "Running" state.
59146
# 6. Delete the created Isolated Network after destroying its VMs, check if the Isolated network is successfully
60147
# deleted.
61-
62-
self.debug("Validating the Nuage VSP network service provider...")
63-
self.validate_NetworkServiceProvider("NuageVsp", state="Enabled")
148+
# 7. Delete all the created objects (cleanup).
64149

65150
# Creating a network offering
66151
self.debug("Creating and enabling Nuage VSP Isolated Network offering...")
@@ -81,16 +166,16 @@ def test_nuage_vsp(self):
81166
self.check_VM_state(vm_1, state="Running")
82167

83168
# VSD verification
84-
self.verify_vsp_network(self.domain.id, network)
85-
self.verify_vsp_router(vr)
86-
self.verify_vsp_vm(vm_1)
169+
self.verify_vsd_network(self.domain.id, network)
170+
self.verify_vsd_router(vr)
171+
self.verify_vsd_vm(vm_1)
87172

88173
# Deploying one more VM in the network
89174
vm_2 = self.create_VM(network)
90175
self.check_VM_state(vm_2, state="Running")
91176

92177
# VSD verification
93-
self.verify_vsp_vm(vm_2)
178+
self.verify_vsd_vm(vm_2)
94179

95180
# Deleting the network
96181
self.debug("Deleting the Isolated Network with Nuage VSP Isolated Network offering...")
@@ -103,5 +188,5 @@ def test_nuage_vsp(self):
103188

104189
# VSD verification
105190
with self.assertRaises(Exception):
106-
self.verify_vsp_network(self.domain.id, network)
191+
self.verify_vsd_network(self.domain.id, network)
107192
self.debug("Isolated Network successfully deleted in VSD")

ui/scripts/system.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13256,7 +13256,7 @@
1325613256
dataType: "json",
1325713257
async: false,
1325813258
success: function(json) {
13259-
var items = json.listnuagevspdeviceresponse.nuagevspdevice;
13259+
var items = json.listnuagevspdevicesresponse.nuagevspdevice;
1326013260
args.response.success({
1326113261
data: items
1326213262
});
@@ -13325,7 +13325,7 @@
1332513325
dataType: "json",
1332613326
async: true,
1332713327
success: function(json) {
13328-
var item = json.listnuagevspdeviceresponse.nuagevspdevice[0];
13328+
var item = json.listnuagevspdevicesresponse.nuagevspdevice[0];
1332913329
args.response.success({
1333013330
data: item
1333113331
});

0 commit comments

Comments
 (0)