def test_02_nicira_controller_redirect(self): """ Nicira clusters will redirect clients (in this case ACS) to the master node. This test assumes that a Nicira cluster is present and configured properly, and that it has at least two controller nodes. The test will check that ASC follows redirects by: - adding a Nicira Nvp device that points to one of the cluster's slave controllers, - create a VM in a Nicira backed network If all is well, no matter what controller is specified (slaves or master), the vm (and respective router VM) should be created without issues. """ nicira_slave = self.determine_slave_conroller(self.nicira_hosts, self.nicira_master_controller) self.debug("Nicira slave controller is: %s " % nicira_slave) nicira_device = NiciraNvp.add( self.api_client, None, self.physical_network_id, hostname=nicira_slave, username=self.nicira_credentials['username'], password=self.nicira_credentials['password'], transportzoneuuid=self.transport_zone_uuid) self.test_cleanup.append(nicira_device) network_services = { 'name' : 'nicira_enabled_network', 'displaytext' : 'nicira_enabled_network', 'zoneid' : self.zone.id, 'networkoffering' : self.network_offering.id } network = Network.create( self.api_client, network_services, accountid='admin', domainid=self.domain.id, ) self.test_cleanup.append(network) virtual_machine = VirtualMachine.create( self.api_client, self.vm_services['small'], accountid='admin', domainid=self.domain.id, serviceofferingid=self.service_offering.id, networkids=[network.id], mode=self.vm_services['mode'] ) self.test_cleanup.append(virtual_machine) list_vm_response = VirtualMachine.list(self.api_client, id=virtual_machine.id) self.debug("Verify listVirtualMachines response for virtual machine: %s" % virtual_machine.id) self.assertEqual(isinstance(list_vm_response, list), True, 'Response did not return a valid list') self.assertNotEqual(len(list_vm_response), 0, 'List of VMs is empty') vm_response = list_vm_response[0] self.assertEqual(vm_response.id, virtual_machine.id, 'Virtual machine in response does not match request') self.assertEqual(vm_response.state, 'Running', 'VM is not in Running state')
def add_nicira_device(self, hostname): nicira_device = NiciraNvp.add( self.api_client, None, self.physical_network_id, hostname=hostname, username=self.nicira_credentials['username'], password=self.nicira_credentials['password'], transportzoneuuid=self.transport_zone_uuid) self.test_cleanup.append(nicira_device)
def test_01_nicira_controller(self): nicira_device = NiciraNvp.add( self.api_client, None, self.physical_network_id, hostname=self.nicira_master_controller, username=self.nicira_credentials['username'], password=self.nicira_credentials['password'], transportzoneuuid=self.transport_zone_uuid) self.test_cleanup.append(nicira_device) network_services = { 'name' : 'nicira_enabled_network', 'displaytext' : 'nicira_enabled_network', 'zoneid' : self.zone.id, 'networkoffering' : self.network_offering.id } network = Network.create( self.api_client, network_services, accountid='admin', domainid=self.domain.id, ) self.test_cleanup.append(network) virtual_machine = VirtualMachine.create( self.api_client, self.vm_services['small'], accountid='admin', domainid=self.domain.id, serviceofferingid=self.service_offering.id, networkids=[network.id], mode=self.vm_services['mode'] ) self.test_cleanup.append(virtual_machine) list_vm_response = VirtualMachine.list(self.api_client, id=virtual_machine.id) self.debug("Verify listVirtualMachines response for virtual machine: %s" % virtual_machine.id) self.assertEqual(isinstance(list_vm_response, list), True, 'Response did not return a valid list') self.assertNotEqual(len(list_vm_response), 0, 'List of VMs is empty') vm_response = list_vm_response[0] self.assertEqual(vm_response.id, virtual_machine.id, 'Virtual machine in response does not match request') self.assertEqual(vm_response.state, 'Running', 'VM is not in Running state')