diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp.py b/test/integration/plugins/nuagevsp/test_nuage_vsp.py index ca2a28e2769..0227ce5c8e8 100644 --- a/test/integration/plugins/nuagevsp/test_nuage_vsp.py +++ b/test/integration/plugins/nuagevsp/test_nuage_vsp.py @@ -19,9 +19,11 @@ """ # Import Local Modules from nuageTestCase import nuageTestCase -from marvin.lib.base import Account +from marvin.lib.base import Account, Nuage +from marvin.cloudstackAPI import deleteNuageVspDevice # Import System Modules from nose.plugins.attrib import attr +import copy class TestNuageVsp(nuageTestCase): @@ -43,6 +45,91 @@ class TestNuageVsp(nuageTestCase): self.cleanup = [self.account] return + # validate_NuageVspDevice - Validates the addition of Nuage VSP device in the Nuage VSP Physical Network + def validate_NuageVspDevice(self): + """Validates the addition of Nuage VSP device in the Nuage VSP Physical Network""" + self.debug("Validating the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" % + self.vsp_physical_network.id) + nuage_vsp_device = Nuage.list(self.api_client, + physicalnetworkid=self.vsp_physical_network.id + ) + self.assertEqual(isinstance(nuage_vsp_device, list), True, + "List Nuage VSP device should return a valid list" + ) + self.debug("Successfully validated the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" % + self.vsp_physical_network.id) + + # delete_NuageVspDevice - Deletes the Nuage VSP device in the Nuage VSP Physical Network + def delete_NuageVspDevice(self): + """Deletes the Nuage VSP device in the Nuage VSP Physical Network""" + self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network - %s" % + self.vsp_physical_network.id) + nuage_vsp_device = Nuage.list(self.api_client, + physicalnetworkid=self.vsp_physical_network.id + )[0] + cmd = deleteNuageVspDevice.deleteNuageVspDeviceCmd() + cmd.vspdeviceid = nuage_vsp_device.vspdeviceid + self.api_client.deleteNuageVspDevice(cmd) + self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network - %s" % + self.vsp_physical_network.id) + + @attr(tags=["advanced", "nuagevsp"], required_hardware="false") + def test_nuage_vsp_device(self): + """ Test Nuage VSP device in the Nuage VSP Physical Network + """ + + # 1. Verify that the Nuage VSP network service provider is successfully created and enabled in the Nuage VSP + # Physical Network. + # 2. Verify that the Nuage VSP device is successfully created in the Nuage VSP Physical Network. + # 3. Delete the Nuage VSP device in the Nuage VSP Physical Network, verify that the Nuage VSP device is + # successfully deleted in the Nuage VSP Physical Network. + # 4. Add the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials, verify that the + # Nuage VSP device failed to add in the Nuage VSP Physical Network. + # 5. Add the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials, verify that the + # Nuage VSP device is successfully added in the Nuage VSP Physical Network. + + # Nuage VSP network service provider validation + self.debug("Validating the Nuage VSP network service provider in the Nuage VSP Physical Network...") + self.validate_NetworkServiceProvider("NuageVsp", state="Enabled") + + # Nuage VSP device validation + self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...") + self.validate_NuageVspDevice() + + # Nuage VSP device deletion + self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network...") + self.delete_NuageVspDevice() + + # Nuage VSP device validation + self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...") + with self.assertRaises(Exception): + self.validate_NuageVspDevice() + self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network") + + # Adding the Nuage VSP device with invalid VSD credentials + self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials...") + vsd_info = self.nuage_vsp_device.__dict__ + invalid_vsd_info = copy.deepcopy(vsd_info) + invalid_vsd_info["password"] = "" + with self.assertRaises(Exception): + Nuage.add(self.api_client, invalid_vsd_info, self.vsp_physical_network.id) + self.debug("Failed to add the Nuage VSP device in the Nuage VSP Physical Network due to invalid VSD " + "credentials") + + # Nuage VSP device validation + self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...") + with self.assertRaises(Exception): + self.validate_NuageVspDevice() + self.debug("The Nuage VSP device is not added in the Nuage VSP Physical Network") + + # Adding the Nuage VSP device with valid VSD credentials + self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials...") + Nuage.add(self.api_client, vsd_info, self.vsp_physical_network.id) + + # Nuage VSP device validation + self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...") + self.validate_NuageVspDevice() + @attr(tags=["advanced", "nuagevsp"], required_hardware="false") def test_nuage_vsp(self): """ Test Nuage VSP SDN plugin with basic Isolated Network functionality @@ -58,9 +145,7 @@ class TestNuageVsp(nuageTestCase): # "Running" state. # 6. Delete the created Isolated Network after destroying its VMs, check if the Isolated network is successfully # deleted. - - self.debug("Validating the Nuage VSP network service provider...") - self.validate_NetworkServiceProvider("NuageVsp", state="Enabled") + # 7. Delete all the created objects (cleanup). # Creating a network offering self.debug("Creating and enabling Nuage VSP Isolated Network offering...")