Best Python code snippet using tempest_python
test_volume_migrate_attached.py
Source:test_volume_migrate_attached.py
...51 return self.create_server(image_id='',52 key_name=key_name,53 security_groups=security_groups,54 block_device_mapping=block_device_mapping)55 def _create_volume_types(self):56 backend_names = CONF.volume.backend_names57 backend_source = backend_names[0]58 backend_dest = backend_names[1]59 source_body = self.create_volume_type(backend_name=backend_source)60 dest_body = self.create_volume_type(backend_name=backend_dest)61 LOG.info("Created Volume types: %(src)s -> %(src_backend)s, %(dst)s "62 "-> %(dst_backend)s", {'src': source_body['name'],63 'src_backend': backend_source,64 'dst': dest_body['name'],65 'dst_backend': backend_dest})66 return source_body['name'], dest_body['name']67 def _volume_retype_with_migration(self, volume_id, new_volume_type):68 migration_policy = 'on-demand'69 self.volumes_client.retype_volume(70 volume_id, new_type=new_volume_type,71 migration_policy=migration_policy)72 waiters.wait_for_volume_retype(self.volumes_client,73 volume_id, new_volume_type)74 @decorators.idempotent_id('deadd2c2-beef-4dce-98be-f86765ff311b')75 @test.services('compute', 'volume')76 def test_volume_migrate_attached(self):77 LOG.info("Creating keypair and security group")78 keypair = self.create_keypair()79 security_group = self._create_security_group()80 # create volume types81 LOG.info("Creating Volume types")82 source_type, dest_type = self._create_volume_types()83 # create an instance from volume84 LOG.info("Booting instance from volume")85 volume_origin = self.create_volume(imageRef=CONF.compute.image_ref,86 volume_type=source_type)87 instance = self._boot_instance_from_volume(volume_origin['id'],88 keypair, security_group)89 # write content to volume on instance90 LOG.info("Setting timestamp in instance %s", instance['id'])91 ip_instance = self.get_server_ip(instance)92 timestamp = self.create_timestamp(ip_instance,93 private_key=keypair['private_key'])94 # retype volume with migration from backend #1 to backend #295 LOG.info("Retyping Volume %s to new type %s", volume_origin['id'],96 dest_type)...
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!!