def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'renewal_strategy', 'compute_allowed', 'compute_used', 'global_burn_rate', 'user_compute_used', 'user_burn_rate', 'start_date', 'end_date') 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_allocation_source(parsed_args.id) allocation_source = () if data.ok: message = data.message start_date = ts_to_isodate(message['start_date']) end_date = '' if message['end_date']: end_date = ts_to_isodate(message['end_date']) allocation_source = (message['id'], message['uuid'], message['name'], message['renewal_strategy'], message['compute_allowed'], message['compute_used'], message['global_burn_rate'], message['user_compute_used'], message['user_burn_rate'], start_date, end_date) return (column_headers, allocation_source)
def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'description', 'owner', 'created_by', 'start_date', 'end_date', 'leaders', 'users', 'images', 'instances', 'volumes', 'links') 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_project(parsed_args.id) project = () if data.ok: message = data.message start_date = ts_to_isodate(message['start_date']) end_date = '' if message['end_date']: end_date = ts_to_isodate(message['end_date']) project = (message['id'], message['uuid'], message['name'], message['description'], message['owner']['name'], message['created_by']['username'], start_date, end_date, ', '.join([ value['username'] for value in message['leaders'] ]), ', '.join([ value['username'] for value in message['users'] ]), len(message['images']), len(message['instances']), len(message['volumes']), len(message['links'])) return (column_headers, project)
def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'description', 'type', 'virtualization', 'sizes', 'auto_imaging', 'public', 'is_admin', 'active', 'start_date', 'end_date') 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_provider(parsed_args.id) provider = () if data.ok: message = data.message start_date = ts_to_isodate(message['start_date']) end_date = '' if message['end_date']: end_date = ts_to_isodate(message['end_date']) provider = (message['id'], message['uuid'], message['name'], message['description'], message['type']['name'], message['virtualization']['name'], ', '.join([ value['name'] for value in message['sizes'] ]), message['auto_imaging'], message['public'], message['is_admin'], message['active'], start_date, end_date) return (column_headers, provider)
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) data = api.get_version() if data.ok: message = data.message self.app.stdout.write('Atmosphere {} {} [Built: {}]\n'.format( message['git_branch'], message['git_sha_abbrev'], ts_to_isodate(message['commit_date'], include_time=True)))
def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'description', 'created_by', 'versions', 'tags', 'url', 'is_public', 'start_date', 'end_date') 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_image(parsed_args.id) image = () if data.ok: message = data.message versions = '' if parsed_args.show_all_versions: versions = '\n'.join([ '{} ({})'.format(value['name'], value['id']) for value in message['versions'] ]) else: version_data = api.get_image_versions(parsed_args.id) if version_data.ok: versions = '\n'.join([ '{} ({})'.format(value['name'], value['id']) for value in version_data.message['results'] ]) start_date = ts_to_isodate(message['start_date']) end_date = '' if message['end_date']: end_date = ts_to_isodate(message['end_date']) image = (message['id'], message['uuid'], message['name'], message['description'], message['created_by']['username'], versions, ', '.join([value['name'] for value in message['tags']]), message['url'], message['is_public'], start_date, end_date) return (column_headers, image)
def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'compute_allowed', 'compute_used', 'global_burn_rate', 'start_date') 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_allocation_sources() allocation_sources = [] if data.ok: for source in data.message['results']: start_date = ts_to_isodate(source['start_date']) allocation_sources.append( (source['uuid'], source['name'], source['compute_allowed'], source['compute_used'], source['global_burn_rate'], start_date)) return (column_headers, tuple(allocation_sources))
def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'created_by', 'is_public', 'start_date') 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.search_images(parsed_args.search_term) images = [] if data.ok: for image in data.message['results']: start_date = ts_to_isodate(image['start_date']) images.append( (image['uuid'], image['name'], image['created_by']['username'], image['is_public'], start_date if start_date else image['start_date'])) return (column_headers, tuple(images))
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))
def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'type', 'virtualization', 'public', 'active', 'start_date') 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_providers() providers = [] if data.ok: for provider in data.message['results']: start_date = ts_to_isodate(provider['start_date']) providers.append( (provider['id'], provider['uuid'], provider['name'], provider['type']['name'], provider['virtualization']['name'], provider['public'], provider['active'], start_date if start_date else provider['start_date'])) return (column_headers, tuple(providers))
def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'owner', 'created_by', 'start_date', 'images', 'instances', 'volumes', 'links') 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_projects() projects = [] if data.ok: for project in data.message['results']: start_date = ts_to_isodate(project['start_date']) projects.append( (project['uuid'], project['name'], project['owner']['name'], project['created_by']['username'], start_date, len(project['images']), len(project['instances']), len(project['volumes']), len(project['links']))) return (column_headers, tuple(projects))
def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'project', 'provider', 'size', 'user', 'start_date', 'status', 'attached_to') 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_volumes() volumes = [] if data.ok: for volume in data.message['results']: volume_status_info = get_volume_attach_status( api, volume['uuid']) start_date = ts_to_isodate(volume['start_date']) volumes.append( (volume['uuid'], volume['name'], volume['project']['name'], volume['provider']['name'], volume['size'], volume['user']['username'], start_date, volume_status_info[0], volume_status_info[1])) return (column_headers, tuple(volumes))
def take_action(self, parsed_args): column_headers = ('id', 'name', 'image_name', 'created_by', 'machines', 'start_date') 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_image_versions(parsed_args.id) image_versions = [] if data.ok: for version in data.message['results']: start_date = ts_to_isodate(version['start_date']) image_versions.append( (version['id'], version['name'], version['image']['name'], version['user']['username'], '\n'.join([ '{} ({})'.format(value['provider']['name'], value['uuid']) for value in version['machines'] ]), start_date if start_date else version['start_date'])) return (column_headers, tuple(image_versions))
def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'username', 'identity', 'project', 'allocation_source', 'compute_allowed', 'compute_used', 'global_burn_rate', 'user_compute_used', 'user_burn_rate', 'image_id', 'image_version', 'image_usage', 'launched', 'image_size', 'image_cpu', 'image_mem', 'image_disk', 'status', 'activity', 'ip_address', 'provider', 'web_desktop', 'shell', 'vnc') 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_instance(parsed_args.id) instance = () if data.ok: message = data.message launched = ts_to_isodate(message['start_date']) instance = (message['id'], message['uuid'], message['name'], message['user']['username'], message['identity']['key'], message['project']['name'], message['allocation_source']['name'], message['allocation_source']['compute_allowed'], message['allocation_source']['compute_used'], message['allocation_source']['global_burn_rate'], message['allocation_source']['user_compute_used'], message['allocation_source']['user_burn_rate'], message['image']['id'], message['version']['name'], message['usage'], launched, message['size']['name'], message['size']['cpu'], message['size']['mem'], message['size']['disk'], message['status'], message['activity'], message['ip_address'], message['provider']['name'], message['web_desktop'], message['shell'], message['vnc']) return (column_headers, instance)
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) payload = { "name": parsed_args.name, "identity": parsed_args.identity, "size_alias": parsed_args.size_alias, "project": parsed_args.project, "allocation_source_id": parsed_args.allocation_source_id, "deploy": parsed_args.deploy, "scripts": [], "extra": {} } if parsed_args.image: # get the provider from the identity payload['source_alias'] = None id_data = api.get_identity(parsed_args.identity) if id_data.ok: provider_id = id_data.message['provider']['id'] self.log.debug( 'Found provider id {} for identity uuid {}'.format( provider_id, parsed_args.identity)) # get the provider machine from the latest image version v_data = api.get_image_versions(parsed_args.image) if v_data.ok: # get latest image version latest_version = v_data.message['results'][-1] machines = latest_version['machines'] machine_id = next((m['uuid'] for m in machines if m['provider']['id'] == provider_id), None) self.log.debug( 'Found machine id {} for latest image version {} and provider id {}' .format(machine_id, latest_version['name'], provider_id)) payload['source_alias'] = machine_id else: self.app.stdout.write( 'Error, instance not created. Could not lookup latest image version from image uuid supplied: {}' .format(parsed_args.image)) else: self.app.stdout.write( 'Error, instance not created. Could not lookup provider from identity uuid supplied: {}' .format(parsed_args.identity)) else: payload['source_alias'] = parsed_args.source_alias self.log.debug('INPUT: {}'.format(json.dumps(payload))) instance = () column_headers = ('id', 'uuid', 'name', 'username', 'allocation_source', 'image_id', 'image_version', 'launched', 'image_size', 'provider') if payload['source_alias']: data = api.create_instance(json.dumps(payload)) if data.ok: message = data.message launched = ts_to_isodate(message['start_date']) instance = (message['id'], message['uuid'], message['name'], message['user']['username'], message['allocation_source']['name'], message['image']['id'], message['version']['name'], launched, message['size']['name'], message['provider']['name']) else: self.app.stdout.write( 'Error, instance not created! Make sure to supply name, identity, project, size, source (or image), and allocation_source.' ) return (column_headers, instance)