Best Python code snippet using tempest_python
test_live_migration.py
Source:test_live_migration.py
...176 self._live_migrate(server_id, target_host, 'ACTIVE')177 server = self.admin_servers_client.show_server(server_id)['server']178 volume_id2 = server["os-extended-volumes:volumes_attached"][0]["id"]179 self.assertEqual(volume_id1, volume_id2)180 def _create_net_subnet(self, name, cidr):181 net_name = data_utils.rand_name(name=name)182 net = self.networks_client.create_network(name=net_name)['network']183 self.addClassResourceCleanup(184 self.networks_client.delete_network, net['id'])185 subnet = self.subnets_client.create_subnet(186 network_id=net['id'],187 cidr=cidr,188 ip_version=4)189 self.addClassResourceCleanup(self.subnets_client.delete_subnet,190 subnet['subnet']['id'])191 return net192 def _create_port(self, network_id, name):193 name = data_utils.rand_name(name=name)194 port = self.ports_client.create_port(name=name,195 network_id=network_id)['port']196 self.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,197 self.ports_client.delete_port,198 port_id=port['id'])199 return port200 def _create_trunk_with_subport(self):201 tenant_network = self.get_tenant_network()202 parent = self._create_port(network_id=tenant_network['id'],203 name='parent')204 net = self._create_net_subnet(name='subport_net', cidr='19.80.0.0/24')205 subport = self._create_port(network_id=net['id'], name='subport')206 trunk = self.trunks_client.create_trunk(207 name=data_utils.rand_name('trunk'),208 port_id=parent['id'],209 sub_ports=[{"segmentation_id": 42, "port_id": subport['id'],210 "segmentation_type": "vlan"}]211 )['trunk']212 self.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,213 self.trunks_client.delete_trunk,214 trunk['id'])215 return trunk, parent, subport216 def _is_port_status_active(self, port_id):217 port = self.ports_client.show_port(port_id)['port']218 return port['status'] == 'ACTIVE'...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!