How to use unlock_server method in tempest

Best Python code snippet using tempest_python

test_server_misc_policy_actions_rbac.py

Source:test_server_misc_policy_actions_rbac.py Github

copy

Full Screen

...118 @rbac_rule_validation.action(119 service="nova",120 rule="os_compute_api:os-lock-server:unlock")121 @decorators.idempotent_id('d50ef8e8-4bce-11e7-b114-b2f933d5fe66')122 def test_unlock_server(self):123 """Test unlock server, part of os-lock-server."""124 self.servers_client.lock_server(self.server_id)125 self.addCleanup(self.servers_client.unlock_server, self.server_id)126 self.rbac_utils.switch_role(self, toggle_rbac_role=True)127 self.servers_client.unlock_server(self.server_id)128 @rbac_rule_validation.action(129 service="nova",130 rule="os_compute_api:os-lock-server:unlock:unlock_override")131 @decorators.idempotent_id('40dfeef9-73ee-48a9-be19-a219875de457')132 def test_unlock_server_override(self):133 """Test force unlock server, part of os-lock-server.134 In order to trigger the unlock:unlock_override policy instead135 of the unlock policy, the server must be locked by a different136 user than the one who is attempting to unlock it.137 """138 self.os_admin.servers_client.lock_server(self.server_id)139 self.addCleanup(self.servers_client.unlock_server, self.server_id)140 self.rbac_utils.switch_role(self, toggle_rbac_role=True)141 self.servers_client.unlock_server(self.server_id)142 @test.requires_ext(extension='os-rescue', service='compute')143 @rbac_rule_validation.action(144 service="nova",145 rule="os_compute_api:os-rescue")146 @decorators.idempotent_id('fbbb2afc-ed0e-4552-887d-ac00fb5d436e')147 def test_rescue_server(self):148 """Test rescue server, part of os-rescue."""149 self.rbac_utils.switch_role(self, toggle_rbac_role=True)150 self.servers_client.rescue_server(self.server_id)151 @test.requires_ext(extension='os-server-diagnostics', service='compute')152 @rbac_rule_validation.action(153 service="nova",154 rule="os_compute_api:os-server-diagnostics")155 @decorators.idempotent_id('5dabfcc4-bedb-417b-8247-b3ee7c5c0f3e')...

Full Screen

Full Screen

server.py

Source:server.py Github

copy

Full Screen

...94# lock server95def lock_server(server_id):96 conn.compute.lock_server(server_id)97# unlock server98def unlock_server(server_id):99 conn.compute.unlock_server(server_id)100# start server101def start_server(server_id):102 conn.compute.start_server(server_id)103# stop server104def stop_server(server_id):105 conn.compute.stop_server(server_id)106# set server metadata107def set_server_metadata(server_id):108 metadata = {"metadata_key": "metadata_value"}109 server = conn.compute.set_server_metadata(server_id, **metadata)110 print(server)111# get server metadata112def get_server_metadata(server_id):113 server_metadata = conn.compute.get_server_metadata(server_id)114 print(server_metadata)115# get server metadata with specified key116def get_server_metadata_with_key(server_id, key):117 server_metadata = conn.compute.get_server_metadata(server_id, key)118 print(server_metadata)119# delete server metadata120def delete_server_metadata(server_id):121 keys = ["metadata_key"]122 if type(keys) != list:123 message = "keys must be a list"124 raise exceptions.SDKException(message)125 server = conn.compute.delete_server_metadata(server_id, keys)126 print(server)127# wait for server128def wait_for_server(server, status):129 if type(server) == str:130 server = conn.compute.get_server(server.id)131 server = conn.compute.wait_for_server(server, status=status)132 return server133# delete server134def delete_server(server_id):135 server = conn.compute.delete_server(server_id)136 print(server)137if __name__ == "__main__":138 newflavor_id = "c2.medium"139 newimage_id = "228b642c-7538-4364-99b4-a88f271234a4"140 newserver_name = "name_test2"141 admin_password = None142 status = "VERIFY_RESIZE"143 address = "10.154.118.136"144 image_name = "image_name"145 key = "test_key"146 list_servers()147 server = create_server()148 find_server(server.id)149 show_server(server.id)150 update_server(server.id, newserver_name)151 reboot_server(server.id, type="SOFT")152 rebuild_server(server.id, newserver_name, admin_password, newimage_id)153 resize_server(server.id, newflavor_id)154 confirm_server_resize(server.id, status)155 revert_server_resize(server.id, status)156 create_server_image(server.id, image_name)157 add_floating_ip_to_server(server.id, address)158 remove_floating_ip_from_server(server.id, address)159 lock_server(server.id)160 unlock_server(server.id)161 start_server(server.id)162 stop_server(server.id)163 get_server_metadata(server.id)164 get_server_metadata_with_key(server.id, key)165 set_server_metadata(server.id)166 delete_server_metadata(server.id)167 wait_for_server(server, status)...

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