How to use describe_image_attribute method in localstack

Best Python code snippet using localstack_python

test_images.py

Source:test_images.py Github

copy

Full Screen

...176 def test_check_simple_image_attributes(self):177 name = data_utils.rand_name('image')178 desc = data_utils.rand_name('desc for image')179 image_id, image_clean = self._create_image(name, desc)180 data = self.client.describe_image_attribute(181 ImageId=image_id, Attribute='kernel')182 self.assertNotIn('KernelId', data)183 data = self.client.describe_image_attribute(184 ImageId=image_id, Attribute='ramdisk')185 self.assertNotIn('RamdiskId', data)186 # description187 data = self.client.describe_image_attribute(188 ImageId=image_id, Attribute='description')189 self.assertIn('Description', data)190 self.assertIn('Value', data['Description'])191 self.assertEqual(desc, data['Description']['Value'])192 def _modify_description(**kwargs):193 self.client.modify_image_attribute(ImageId=image_id, **kwargs)194 data = self.client.describe_image_attribute(195 ImageId=image_id, Attribute='description')196 self.assertEqual(new_desc, data['Description']['Value'])197 new_desc = data_utils.rand_name('new desc')198 _modify_description(Attribute='description', Value=new_desc)199 _modify_description(Description={'Value': new_desc})200 data = self.client.deregister_image(ImageId=image_id)201 self.cancelResourceCleanUp(image_clean)202 @decorators.idempotent_id('680963cf-84f2-488d-bcdb-fc6f9b39f78c')203 @testtools.skipUnless(CONF.aws.ebs_image_id, "EBS image id is not defined")204 def test_check_bdm_in_image(self):205 image_id = CONF.aws.ebs_image_id206 data = self.client.describe_images(ImageIds=[image_id])207 root_device_name = data['Images'][0]['RootDeviceName']208 device_name_prefix = base.get_device_name_prefix(root_device_name)209 device_name = device_name_prefix + 'h'210 name = data_utils.rand_name('image')211 desc = data_utils.rand_name('description')212 image_id, image_clean = self._create_image(213 name, desc,214 extra_run_instance_args={215 'BlockDeviceMappings': [{'DeviceName': device_name,216 'Ebs': {'VolumeSize': 1}}]})217 data = self.client.describe_images(ImageIds=[image_id])218 image = data['Images'][0]219 for bdm in image['BlockDeviceMappings']:220 self.assertTrue('DeviceName', bdm)221 data = self.client.deregister_image(ImageId=image_id)222 self.cancelResourceCleanUp(image_clean)223 @decorators.idempotent_id('1c244c9a-af3e-47f0-bc85-034e24b051e4')224 @testtools.skipUnless(CONF.aws.run_incompatible_tests,225 'By default glance is configured as "publicize_image": "role:admin"')226 @testtools.skipUnless(CONF.aws.run_incompatible_tests,227 'skip due to bug #1439819')228 @testtools.skipUnless(CONF.aws.ebs_image_id, "EBS image id is not defined")229 def test_check_launch_permission_attribute(self):230 name = data_utils.rand_name('image')231 desc = data_utils.rand_name('desc for image')232 image_id, image_clean = self._create_image(name, desc)233 # launch permission234 data = self.client.describe_image_attribute(235 ImageId=image_id, Attribute='launchPermission')236 self.assertIn('LaunchPermissions', data)237 self.assertEmpty(data['LaunchPermissions'])238 def _modify_launch_permission(**kwargs):239 self.client.modify_image_attribute(ImageId=image_id, **kwargs)240 data = self.client.describe_image_attribute(241 ImageId=image_id, Attribute='launchPermission')242 self.assertIn('LaunchPermissions', data)243 self.assertNotEmpty(data['LaunchPermissions'])244 self.assertIn('Group', data['LaunchPermissions'][0])245 self.assertEqual('all', data['LaunchPermissions'][0]['Group'])246 data = self.client.describe_images(ImageIds=[image_id])247 self.assertTrue(data['Images'][0]['Public'])248 self.client.reset_image_attribute(249 ImageId=image_id, Attribute='launchPermission')250 data = self.client.describe_image_attribute(251 ImageId=image_id, Attribute='launchPermission')252 self.assertEmpty(data['LaunchPermissions'])253 data = self.client.describe_images(ImageIds=[image_id])254 self.assertFalse(data['Images'][0]['Public'])255 _modify_launch_permission(Attribute='launchPermission',256 OperationType='add', UserGroups=['all'])257 _modify_launch_permission(LaunchPermission={'Add': [{'Group': 'all'}]})258 data = self.client.deregister_image(ImageId=image_id)259 self.cancelResourceCleanUp(image_clean)260class ImageRegisterTest(base.EC2TestCase):261 valid_image_state = set(('available', 'pending', 'failed'))262 @classmethod263 @base.safe_setup264 def setUpClass(cls):...

Full Screen

Full Screen

ami.py

Source:ami.py Github

copy

Full Screen

...62 ami_imagetype.append(ami['ImageType'])63 ami_virtualization.append(ami['VirtualizationType'])64 ami_usageoperation.append(ami['UsageOperation'])65for id in ami_id:66 response = ec2.describe_image_attribute(Attribute='kernel',ImageId=id)67 if len(response['KernelId']) > 0:68 try:69 ami_kernelid.append(response['KernelId'][0]['Value'])70 except:71 ami_kernelid.append('-')72 else:73 ami_kernelid.append('-')74 response = ec2.describe_image_attribute(Attribute='ramdisk',ImageId=id)75 if len(response['RamdiskId']) > 0:76 try:77 ami_ramdiskid.append(response['RamdiskId'][0]['Value'])78 except:79 ami_ramdiskid.append('-')80 else:81 ami_ramdiskid.append('-')82 response = ec2.describe_image_attribute(Attribute='productCodes',ImageId=id)83 if len(response['ProductCodes']) > 0:84 try:85 ami_product.append(response['ProductCodeId'][0]['Value'])86 except:87 ami_product.append('-')88 else:89 ami_product.append('-')90 91print(len(ami_name))92print(len(ami_id))93print(len(ami_origem))94print(ami_visibilidade)95print(len(ami_owner))96print(len(ami_state))...

Full Screen

Full Screen

image.py

Source:image.py Github

copy

Full Screen

...5registry = FlagRegistry()6FLAGS = Flags('BASE', 'KERNEL', 'RAMDISK', 'LAUNCHPERMISSION', 'PRODUCTCODES')7@registry.register(flag=FLAGS.KERNEL)8def get_kernel(image, **conn):9 attribute = describe_image_attribute(10 Attribute='kernel', ImageId=image['ImageId'], **conn)11 return dict(KernelId=attribute['KernelId'])12@registry.register(flag=FLAGS.RAMDISK)13def get_ramdisk(image, **conn):14 attribute = describe_image_attribute(15 Attribute='ramdisk', ImageId=image['ImageId'], **conn)16 return dict(RamdiskId=attribute['RamdiskId'])17@registry.register(flag=FLAGS.LAUNCHPERMISSION)18def get_launch_permission(image, **conn):19 attribute = describe_image_attribute(20 Attribute='launchPermission', ImageId=image['ImageId'], **conn)21 return dict(LaunchPermissions=attribute['LaunchPermissions'])22@registry.register(flag=FLAGS.PRODUCTCODES)23def get_product_codes(image, **conn):24 attribute = describe_image_attribute(25 Attribute='productCodes', ImageId=image['ImageId'], **conn)26 return dict(ProductCodes=attribute['ProductCodes'])27@registry.register(flag=FLAGS.BASE)28def get_base(image, **conn):29 image = describe_images(ImageIds=[image['ImageId']], **conn)30 image = image[0]31 arn = 'arn:aws:ec2:{region}::image/{imageid}'.format(32 region=conn['region'],33 imageid=image['ImageId'])34 image.update({'Arn': arn, 'Region': conn['region'], '_version': 1})35 return image36@modify_output37def get_image(image_id, flags=FLAGS.ALL, **conn):38 """...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful