How to use shelve_server method in tempest

Best Python code snippet using tempest_python

test_attach_volume.py

Source:test_attach_volume.py Github

copy

Full Screen

...80 self.admin_pass,81 self.validation_resources['keypair']['private_key'])82 linux_client.validate_authentication()83 # If validation went ok, shelve the server84 compute.shelve_server(self.servers_client, self.server['id'])85 # Attach the volume to the server86 self.attachment = self.servers_client.attach_volume(87 self.server['id'],88 volumeId=self.volume['id'],89 device='/dev/%s' % self.device)['volumeAttachment']90 waiters.wait_for_volume_status(self.volumes_client,91 self.volume['id'], 'in-use')92 self.addCleanup(self._detach, self.server['id'], self.volume['id'])93 @test.idempotent_id('52e9045a-e90d-4c0d-9087-79d657faffff')94 @testtools.skipUnless(CONF.validation.run_validation,95 'SSH required for this test')96 def test_attach_detach_volume(self):97 # Stop and Start a server with an attached volume, ensuring that98 # the volume remains attached.99 self._create_and_attach()100 self.servers_client.stop_server(self.server['id'])101 waiters.wait_for_server_status(self.servers_client, self.server['id'],102 'SHUTOFF')103 self.servers_client.start_server(self.server['id'])104 waiters.wait_for_server_status(self.servers_client, self.server['id'],105 'ACTIVE')106 linux_client = remote_client.RemoteClient(107 self.get_server_ip(self.server),108 self.image_ssh_user,109 self.admin_pass,110 self.validation_resources['keypair']['private_key'],111 server=self.server,112 servers_client=self.servers_client)113 partitions = linux_client.get_partitions()114 self.assertIn(self.device, partitions)115 self._detach(self.server['id'], self.volume['id'])116 self.attachment = None117 self.servers_client.stop_server(self.server['id'])118 waiters.wait_for_server_status(self.servers_client, self.server['id'],119 'SHUTOFF')120 self.servers_client.start_server(self.server['id'])121 waiters.wait_for_server_status(self.servers_client, self.server['id'],122 'ACTIVE')123 linux_client = remote_client.RemoteClient(124 self.get_server_ip(self.server),125 self.image_ssh_user,126 self.admin_pass,127 self.validation_resources['keypair']['private_key'],128 server=self.server,129 servers_client=self.servers_client)130 partitions = linux_client.get_partitions()131 self.assertNotIn(self.device, partitions)132 @test.idempotent_id('7fa563fe-f0f7-43eb-9e22-a1ece036b513')133 def test_list_get_volume_attachments(self):134 # Create Server, Volume and attach that Volume to Server135 self._create_and_attach()136 # List Volume attachment of the server137 body = self.servers_client.list_volume_attachments(138 self.server['id'])['volumeAttachments']139 self.assertEqual(1, len(body))140 self.assertIn(self.attachment, body)141 # Get Volume attachment of the server142 body = self.servers_client.show_volume_attachment(143 self.server['id'],144 self.attachment['id'])['volumeAttachment']145 self.assertEqual(self.server['id'], body['serverId'])146 self.assertEqual(self.volume['id'], body['volumeId'])147 self.assertEqual(self.attachment['id'], body['id'])148class AttachVolumeShelveTestJSON(AttachVolumeTestJSON):149 """Testing volume with shelved instance.150 This test checks the attaching and detaching volumes from151 a shelved or shelved ofload instance.152 """153 min_microversion = '2.20'154 max_microversion = 'latest'155 def _unshelve_server_and_check_volumes(self, number_of_partition):156 # Unshelve the instance and check that there are expected volumes157 self.servers_client.unshelve_server(self.server['id'])158 waiters.wait_for_server_status(self.servers_client,159 self.server['id'],160 'ACTIVE')161 linux_client = remote_client.RemoteClient(162 self.get_server_ip(self.server['id']),163 self.image_ssh_user,164 self.admin_pass,165 self.validation_resources['keypair']['private_key'],166 server=self.server,167 servers_client=self.servers_client)168 command = 'grep vd /proc/partitions | wc -l'169 nb_partitions = linux_client.exec_command(command).strip()170 self.assertEqual(number_of_partition, nb_partitions)171 @test.idempotent_id('13a940b6-3474-4c3c-b03f-29b89112bfee')...

Full Screen

Full Screen

vm_operation.py

Source:vm_operation.py Github

copy

Full Screen

...41 {42 'operation':'SHELVE',43 'targetStatus':'SHELVED_OFFLOADED',44 'requiredStatus':['ACTIVE', 'SHUTOFF', 'SUSPENDED', 'STOPPED'],45 'anonymousFunction':lambda compute, server: compute.shelve_server(server)46 }...

Full Screen

Full Screen

shelve-action-runners.py

Source:shelve-action-runners.py Github

copy

Full Screen

...18 )19 if server.status == 'SHUTOFF' and server.task_state is None:20 print(f'... shelving {server.name}.')21 try:22 connection.compute.shelve_server(server)23 except Exception as e:24 print(f'::warning:: Failed to shelve server {server.name}:',25 str(e))26 sys.stdout.flush()27if __name__ == '__main__':28 # catch errors and return success so that this script doesn't stop the whole29 # actions job30 try:31 connection = openstack.connect()32 except Exception as e:33 print('::warning:: Failed to connect to cloud:', str(e))34 sys.exit(0)...

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 tempest 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