def do_image_list(client, args): """ List images in glance """ kwargs = {} if not args.admin and not args.tenant and not args.owner_id: if client.default_tenant.is_system_admin(): kwargs['owner'] = client.default_tenant.get_id() else: if not client.default_tenant.is_system_admin(): raise Exception('System admin ONLY option') if args.tenant: t = client.tenants.get(args.tenant) kwargs['owner'] = t.id elif args.owner_id is not None: kwargs['owner'] = args.owner_id if args.is_public is not None: kwargs['is_public'] = args.is_public if args.name: kwargs['name'] = args.name if args.marker is not None: kwargs['marker'] = args.marker kwargs['limit'] = args.limit if args.history is not None and args.history: kwargs['history'] = args.history images = client.images.list(**kwargs) utils.print_list(images, client.images.columns)
def do_baremetal_list(client, args): """ List Baremetals """ page_info = utils.get_paging_info(args) if args.agent: page_info['agent'] = args.agent baremetals = client.baremetals.list(**page_info) utils.print_list(baremetals, client.baremetals.columns)
def do_network_list(client, args): """ List all virtual networks """ page_info = utils.get_paging_info(args) if args.type: page_info['server_type'] = args.type nets = client.networks.list(**page_info) utils.print_list(nets, client.networks.columns)
def do_notify_log_list(client, args): """ List all notify sending histories """ page_info = utils.get_paging_info(args) if args.datetime is not None: page_info['datetime'] = args.datetime histories = client.notify_log.list(**page_info) utils.print_list(histories, client.notify_log.columns)
def do_dns_list(client, args): """ List all dns records """ page_info = utils.get_paging_info(args) if args.is_public: page_info['is_public'] = 1 dns_list = client.dns.list(**page_info) utils.print_list(dns_list, client.dns.columns)
def do_notify_request_list(client, args): """ List all notify request histories """ page_info = utils.get_paging_info(args) if args.datetime is not None: page_info['datetime'] = args.datetime requests = client.notify_request.list(**page_info) utils.print_list(requests, client.notify_request.columns)
def do_tenant_list(client, args): """ List keystone users """ kwargs = {} if args.limit: kwargs['limit'] = args.limit tlist = client.tenants.list(**kwargs) utils.print_list(tlist, client.tenants.columns)
def do_monitor_check_summary(client, args): """ Count""" kwargs = {} if args.tenant: kwargs['tenant'] = args.tenant counts = client.checksummary.list(**kwargs) utils.print_list(counts, client.checksummary.columns)
def do_baremetal_storage_list(client, args): """ List all storages of a baremetal """ page_info = utils.get_paging_info(args) if args.id != 'all': bss = client.baremetalstorages.list_descendent(args.id, **page_info) else: bss = client.baremetalstorages.list(**page_info) utils.print_list(bss, client.baremetalstorages.columns)
def do_user_topic_list(client, args): params = {} if args.user is not None: params['user'] = args.user if args.topic is not None: params['topic'] = args.topic items = client.user_topics.list(**params) utils.print_list(items, client.user_topics.columns)
def do_disk_list(client, args): """ List all virtual disk """ page_info = utils.get_paging_info(args) unused = getattr(args, 'unused', None) if unused: page_info['unused'] = True disks = client.disks.list(**page_info) utils.print_list(disks, client.disks.columns)
def do_server_disk_list(client, args): """ List all virtual disks of a virtual server """ page_info = utils.get_paging_info(args) if args.id != 'all': guestdisks = client.guestdisks.list_descendent(args.id, **page_info) else: guestdisks = client.guestdisks.list(**page_info) utils.print_list(guestdisks, client.guestdisks.columns)
def do_baremetal_network_list(client, args): """ List all virtual networks of a baremetal """ page_info = utils.get_paging_info(args) if args.id != 'all': baremetalnetworks = client.baremetalnetworks.list_descendent( args.id, **page_info) else: baremetalnetworks = client.baremetalnetworks.list(**page_info) utils.print_list(baremetalnetworks, client.baremetalnetworks.columns)
def do_group_network_list(client, args): """ List all virtual networks of a virtual group """ page_info = utils.get_paging_info(args) if args.id != 'all': groupnetworks = client.groupnetworks.list_descendent( args.id, **page_info) else: groupnetworks = client.groupnetworks.list(**page_info) utils.print_list(groupnetworks, client.groupnetworks.columns)
def do_group_server_list(client, args): """ List group-server relationship of all or given group """ page_info = utils.get_paging_info(args) if args.group is not None: groupguests = client.groupguests.list_descendent( args.group, **page_info) else: groupguests = client.groupguests.list(**page_info) utils.print_list(groupguests, client.groupguests.columns)
def do_schedtag_host_list(client, args): page_info = utils.get_paging_info(args) if args.id != 'all': schedtag_hosts = client.schedtag_hosts.list_descendent( args.id, **page_info) else: schedtag_hosts = client.schedtag_hosts.list(**page_info) utils.print_list(schedtag_hosts, client.schedtag_hosts.columns)
def do_user_role_list(client, args): """ Get roles of a keystone user """ u = client.users.get(args.id) if args.tenant: t = client.tenants.get(args.tenant) tid = t['id'] else: tid = None rlist = client.users.roles_for_user(u['id'], tid=tid) utils.print_list(rlist, client.roles.columns)
def do_monitor_tcp_check_list(client, args): """ List monitor items """ kwargs = {} if args.tenant: kwargs['tenant'] = args.tenant if args.system: kwargs['is_system'] = True monitors = client.tcpcheck.list(**kwargs) utils.print_list(monitors, client.tcpcheck.columns)
def do_notify_quota_list(client, args): params = {} if args.user is not None: params['user'] = args.user if args.date is not None: import re if not re.match(r'^\d{4}-\d{2}$', args.date): print('Usage: notify-quota-list [--user xx] [--date yyyy-mm]') return params['datetime'] = args.date items = client.notify_quota.list(**params) utils.print_list(items, client.notify_quota.columns)
def do_server_list(client, args): """ List VM servers """ page_info = utils.get_paging_info(args) if args.baremetal: page_info['baremetal'] = True if args.host: page_info['host'] = args.host elif args.cluster: page_info['cluster'] = args.cluster elif args.zone: page_info['zone'] = args.zone guests = client.guests.list(**page_info) utils.print_list(guests, client.guests.columns)
def do_monitor_metrics_list(client, args): """ List available metrics """ kwargs = {} if args.tenant: kwargs['tenant'] = args.tenant if args.server_id: kwargs = {'server_id': args.server_id} if args.group_id: kwargs = {'group_id': args.group_id} if args.system: kwargs['is_system'] = True if args.mtype: kwargs['type'] = args.mtype metrics = client.metrics.list(**kwargs) utils.print_list(metrics, client.metrics.columns)
def do_schedtag_host_list_by_metadata(client, args): # Search sequence: metadata_key -> schedtag -> hosts target_agg_ids = [] schedtags = client.schedtags.list(limit=0) if len(schedtags) > 0: schedtags = schedtags[0] for schedtag in schedtags: schedtag_detail = client.schedtags.get(schedtag['id'], with_meta=True) if 'metadata' in schedtag_detail: metadata = schedtag_detail['metadata'] for k, v in metadata.iteritems(): if args.key == k: target_agg_ids.append(schedtag['id']) for schedtag in target_agg_ids: schedtag_hosts = client.schedtag_hosts.list_descendent(schedtag, limit=0) utils.print_list(schedtag_hosts, client.schedtag_hosts.columns)
def do_metadata_list(client, args): """ List all metadata """ kwargs = {} if args.limit: kwargs['limit'] = args.limit if args.offset: kwargs['offset'] = args.offset if args.admin: kwargs['admin'] = True if args.sys_meta: kwargs['sys_meta'] = True if args.user_meta: kwargs['user_meta'] = True if args.cloud_meta: kwargs['cloud_meta'] = True metadatas = client.metadatas.list(**kwargs) utils.print_list(metadatas, client.metadatas.columns)
def do_monitor_data(client, args): """ List monitor data """ kwargs = {} kwargs['instance_id'] = args.instance_id kwargs['metric'] = args.metric kwargs['mtype'] = args.mtype if args.since: kwargs['since'] = args.since if args.until: kwargs['until'] = args.until if args.stat_func: kwargs['stat_func'] = args.stat_func if args.interval_unit: kwargs['interval_unit'] = args.interval_unit if args.count: kwargs['count'] = args.count datas = client.datahistory.list(**kwargs) utils.print_list(datas, client.datahistory.columns)
def do_event_show(client, args): """ Show operation events of a virtual server """ kwargs = {} if args.type is not None: kwargs['obj_type'] = args.type if args.id is not None: kwargs['obj_id'] = args.id if args.since is not None: kwargs['since'] = args.since if args.until is not None: kwargs['until'] = args.until if args.limit and int(args.limit) > 0: kwargs['limit'] = int(args.limit) if args.offset and int(args.offset) > 0: kwargs['offset'] = int(args.offset) if args.ascending: kwargs['order'] = 'asc' if args.action is not None: kwargs['action'] = args.action logs = client.logs.list(**kwargs) utils.print_list(logs, client.logs.columns)
def do_monitor_event_list(client, args): """List event history""" kwargs = {} if args.id: kwargs['monitorid'] = args.id if args.tenant: kwargs['tenant'] = args.tenant if args.server_id: kwargs['server_id'] = args.server_id if args.time_from and args.time_till: kwargs['time_from'] = args.time_from kwargs['time_till'] = args.time_till if args.limit: kwargs['limit'] = args.limit if args.offset: kwargs['offset'] = args.offset if args.order: kwargs['order'] = args.order if args.system: kwargs['is_system'] = True events = client.eventhistory.list(**kwargs) utils.print_list(events, client.eventhistory.columns)
def do_group_list(client, args): """ List groups """ page_info = utils.get_paging_info(args) groups = client.groups.list(**page_info) utils.print_list(groups, client.groups.columns)
def do_schedtag_list(client, args): page_info = utils.get_paging_info(args) schedtags = client.schedtags.list(**page_info) utils.print_list(schedtags, client.schedtags.columns)
def do_scheduler_test(client, args): """ Emulate scheduler """ kwargs = {} kwargs['suggestion'] = True if args.flavor and args.image: kwargs['flavor'] = args.flavor kwargs['root'] = glanceutils.parse_disk_desc(client, args.image) if args.guest_os: kwargs['os'] = args.guest_os elif args.mem and args.disk: kwargs['vmem_size'] = args.mem if args.ncpu: kwargs['vcpu_count'] = int(args.ncpu) disk_idx = 0 for d in args.disk: kwargs['disk.%d' % disk_idx] = glanceutils \ .parse_disk_desc(client, d) disk_idx += 1 if args.net: net_idx = 0 for n in args.net: kwargs['net.%d' % net_idx] = n net_idx += 1 else: raise Exception('Please specify either memory, disk or falvor, image') if args.group: group_idx = 0 for g in args.group: kwargs['group.%d' % group_idx] = g group_idx += 1 if args.host: kwargs['prefer_host'] = args.host else: if args.aggregate: index = 0 for aggregate in args.aggregate: if len(aggregate.split(':')) == 2: kwargs['aggregate.%d' % index] = aggregate index += 1 else: print 'Aggregate format error: %s' % aggregate return if args.cluster: kwargs['prefer_cluster'] = args.cluster elif args.zone: kwargs['prefer_zone'] = args.zone if args.tenant: kwargs['tenant'] = args.tenant kwargs['cpu_bound'] = args.cpu_bound kwargs['io_bound'] = args.io_bound if args.baremetal: kwargs['baremetal'] = True if args.baremetal_disk_config: kwargs['baremetal_disk_config'] = args.baremetal_disk_config mdict = kwargs['__meta__'] = {} if args.kvm is not None and args.kvm: mdict['kvm'] = 'enabled' else: mdict['kvm'] = 'disabled' if args.ssd is not None and args.ssd: mdict['storage_type'] = 'ssd' else: mdict['storage_type'] = 'rotational' result = client.scheduler.schedule(**kwargs) utils.print_list(result)
def do_template_list(client, args): """ List notify templates """ page_info = utils.get_paging_info(args) templates = client.notify_templates.list(**page_info) utils.print_list(templates, client.notify_templates.columns)