Best Python code snippet using tempest_python
admin_actions.py
Source:admin_actions.py
...46 raise exc.HTTPConflict(explanation=e.format_message())47 return webob.Response(status_int=202)48 @extensions.expected_errors((404, 409))49 @wsgi.action('inject_network_info')50 def _inject_network_info(self, req, id, body):51 """Permit admins to inject network info into a server."""52 context = req.environ['nova.context']53 authorize(context, 'inject_network_info')54 try:55 instance = common.get_instance(self.compute_api, context, id,56 want_objects=True)57 self.compute_api.inject_network_info(context, instance)58 except exception.InstanceIsLocked as e:59 raise exc.HTTPConflict(explanation=e.format_message())60 return webob.Response(status_int=202)61 @extensions.expected_errors((400, 404))62 @wsgi.action('reset_state')63 def _reset_state(self, req, id, body):64 """Permit admins to reset the state of a server."""65 context = req.environ["nova.context"]66 authorize(context, 'reset_state')67 # Identify the desired state from the body68 try:69 state = state_map[body["reset_state"]["state"]]70 except (TypeError, KeyError):71 msg = _("Desired state must be specified. Valid states "...
test_admin_server_actions_rbac.py
Source:test_admin_server_actions_rbac.py
...42 @rbac_rule_validation.action(43 service="nova",44 rule="os_compute_api:os-admin-actions:inject_network_info")45 @decorators.idempotent_id('ce48c340-51c1-4cff-9b6e-0cc5ef008630')46 def test_inject_network_info(self):47 self.rbac_utils.switch_role(self, toggle_rbac_role=True)48 self.servers_client.inject_network_info(self.server_id)49 @rbac_rule_validation.action(50 service="nova",51 rule="os_compute_api:os-admin-actions:reset_network")52 @decorators.idempotent_id('2911a242-15c4-4fcb-80d5-80a8930661b0')53 def test_reset_network(self):54 self.rbac_utils.switch_role(self, toggle_rbac_role=True)...
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!!