def do_boot(cs, args): """Boot a new server.""" boot_args, boot_kwargs = _boot(cs, args) extra_boot_kwargs = utils.get_resource_manager_extra_kwargs(do_boot, args) boot_kwargs.update(extra_boot_kwargs) server = cs.servers.create(*boot_args, **boot_kwargs) # Keep any information (like adminPass) returned by create info = server._info server = cs.servers.get(info['id']) info.update(server._info) flavor = info.get('flavor', {}) flavor_id = flavor.get('id', '') info['flavor'] = _find_flavor(cs, flavor_id).name image = info.get('image', {}) image_id = image.get('id', '') info['image'] = _find_image(cs, image_id).name info.pop('links', None) info.pop('addresses', None) utils.print_dict(info)
def _print_server(cs, server): # By default when searching via name we will do a # findall(name=blah) and due a REST /details which is not the same # as a .get() and doesn't get the information about flavors and # images. This fix it as we redo the call with the id which does a # .get() to get all informations. if not 'flavor' in server._info: server = _find_server(cs, server.id) networks = server.networks info = server._info.copy() for network_label, address_list in networks.items(): info['%s network' % network_label] = ', '.join(address_list) flavor = info.get('flavor', {}) flavor_id = flavor.get('id', '') info['flavor'] = _find_flavor(cs, flavor_id).name image = info.get('image', {}) image_id = image.get('id', '') info['image'] = _find_image(cs, image_id).name info.pop('links', None) info.pop('addresses', None) utils.print_dict(info)
def do_zone(cs, args): """Show or edit a child zone. No zone arg for this zone.""" zone = cs.zones.get(args.zone) # If we have some flags, update the zone zone_delta = {} if args.api_url: zone_delta['api_url'] = args.api_url if args.zone_username: zone_delta['username'] = args.zone_username if args.zone_password: zone_delta['password'] = args.zone_password if args.weight_offset: zone_delta['weight_offset'] = args.weight_offset if args.weight_scale: zone_delta['weight_scale'] = args.weight_scale if zone_delta: zone.update(**zone_delta) else: utils.print_dict(zone._info)
def _print_image(image): info = image._info.copy() # ignore links, we don't need to present those info.pop('links') # try to replace a server entity to just an id server = info.pop('server', None) try: info['server'] = server['id'] except (KeyError, TypeError): pass # break up metadata and display each on its own row metadata = info.pop('metadata', {}) try: for key, value in metadata.items(): _key = 'metadata %s' % key info[_key] = value except AttributeError: pass utils.print_dict(info)
def _print_volume_snapshot(cs, snapshot): utils.print_dict(snapshot._info)
def _print_volume(cs, volume): utils.print_dict(volume._info)
def do_zone_add(cs, args): """Add a new child zone.""" zone = cs.zones.create(args.zone_name, args.api_url, args.zone_username, args.zone_password, args.weight_offset, args.weight_scale) utils.print_dict(zone._info)
def do_zone_info(cs, args): """Get this zones name and capabilities.""" zone = cs.zones.info() utils.print_dict(zone._info)
def do_diagnostics(cs, args): """Retrieve server diagnostics.""" utils.print_dict(cs.servers.diagnostics(args.server)[1])