Best Python code snippet using tempest_python
snapshot.py
Source:snapshot.py
...60 default_retry_delay=15,61 soft_time_limit=15,62 max_retries=3,63 ignore_results=True)64def create_volume_from_image(identity_uuid, image_id, size_id, name,65 description, metadata):66 """67 Create a new volume from an image68 """69 try:70 identity = Identity.objects.get(uuid=identity_uuid)71 user = identity.created_by72 driver = get_cached_driver(identity=identity)73 image = driver._connection.ex_get_image(image_id)74 size = driver._connection.ex_get_size(size_id)75 if not image:76 raise Exception("No image found for id=%s." % image_id)77 if not size:78 raise Exception("No size found for id=%s." % size_id)...
driver.py
Source:driver.py
...16class NoopManager(object):17 def __init__(self):18 super(NoopManager, self).__init__()19 self.volumeconfig = {}20 def create_volume_from_image(self, image_id):21 LOG.debug("Volume %s no-op, image id %s",22 self.__class__.__name__, image_id)23 self.volumeconfig[image_id] = (image_id, 'create_volume_from_image')24 volume_id = uuidutils.generate_uuid()25 return volume_id26 def delete_volume(self, volume_id):27 LOG.debug("Volume %s no-op, volume id %s",28 self.__class__.__name__, volume_id)29 self.volumeconfig[volume_id] = (volume_id, 'delete')30 def get_image_from_volume(self, volume_id):31 LOG.debug("Volume %s no-op, volume id %s",32 self.__class__.__name__, volume_id)33 self.volumeconfig[volume_id] = (volume_id, 'get_image_from_volume')34 image_id = uuidutils.generate_uuid()35 return image_id36class NoopVolumeDriver(driver_base.VolumeBase):37 def __init__(self):38 super(NoopVolumeDriver, self).__init__()39 self.driver = NoopManager()40 def create_volume_from_image(self, image_id):41 volume_id = self.driver.create_volume_from_image(image_id)42 return volume_id43 def delete_volume(self, volume_id):44 self.driver.delete_volume(volume_id)45 def get_image_from_volume(self, volume_id):46 image_id = self.driver.get_image_from_volume(volume_id)...
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!!