Exemplo n.º 1
0
 def test_detaching_volume_to_instance_when_response_is_not_ok(self):
     responses.add(responses.POST,
                   'https://local.atmo.cloud/api/v2/instances/ecdcdd9e-cf0e-42c4-9a7c-a950c6d8b822/actions',
                   status=403,
                   json={"errors": [{"code": 403, "message": "Instance ecdcdd9e-cf0e-42c4-9a7c-a950c6d8b822 must be active, suspended, or stopped before detaching a volume. (Current: shelved_offloaded) Retry request when instance is active."}]})
     api = AtmosphereAPI('token')
     options = {'volume_id': 'b94a0146-10d3-4c91-8482-3c9758c81ddf'}
     response = api.do_instance_volume_action('detach_volume', 'ecdcdd9e-cf0e-42c4-9a7c-a950c6d8b822', options=options)
     assert not response.ok
     assert response.message['errors'][0]['message'] == "Instance ecdcdd9e-cf0e-42c4-9a7c-a950c6d8b822 must be active, suspended, or stopped before detaching a volume. (Current: shelved_offloaded) Retry request when instance is active."
Exemplo n.º 2
0
 def take_action(self, parsed_args):
     api = AtmosphereAPI(self.app_args.auth_token,
                         base_url=self.app_args.base_url,
                         timeout=self.app_args.api_server_timeout,
                         verify=self.app_args.verify_cert)
     options = {'volume_id': parsed_args.volume_id}
     data = api.do_instance_volume_action('detach_volume',
                                          parsed_args.id,
                                          options=options)
     if data.ok and data.message['result'] == 'success':
         self.app.stdout.write('{}\n'.format(data.message['message']))
     else:
         self.app.stdout.write('Error: {}\n'.format(data.message))
Exemplo n.º 3
0
 def test_detaching_volume_to_instance_when_response_is_ok(self):
     api = AtmosphereAPI('token', base_url=self.mock_users_base_url)
     options = {'volume_id': 'b94a0146-10d3-4c91-8482-3c9758c81ddf'}
     response = api.do_instance_volume_action('detach_volume', 'ecdcdd9e-cf0e-42c4-9a7c-a950c6d8b822', options=options)
     assert response.ok
     assert response.message['result'] == 'success' and response.message['message'] == 'The requested action <detach_volume> was run successfully'