예제 #1
0
    def take_action(self, parsed_args):
        column_headers = ('uuid', 'name', 'status', 'activity', 'ip_address',
                          'size', 'provider', 'project', 'launched')
        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)
        data = api.get_instances()
        instances = []
        if data.ok:
            for instance in data.message['results']:
                launched = ts_to_isodate(instance['start_date'])
                instances.append(
                    (instance['uuid'], instance['name'], instance['status'],
                     instance['activity'], instance['ip_address'],
                     instance['size']['name'], instance['provider']['name'],
                     instance['project']['name'], launched))

        return (column_headers, tuple(instances))
예제 #2
0
 def test_getting_instances_when_response_is_ok(self):
     api = AtmosphereAPI('token', base_url=self.mock_users_base_url)
     response = api.get_instances()
     assert response.ok
     assert response.message['count'] == 1 and response.message['results'][0]['name'] == 'BioLinux 8'
예제 #3
0
 def test_getting_instances_when_response_is_not_ok(self):
     api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url)
     response = api.get_instances()
     assert not response.ok