def execute(self, args): iscsi_mgr = ISCSIManager(self.client) table = KeyValueTable(['Name', 'Value']) table.align['Name'] = 'r' table.align['Value'] = 'l' iscsi_id = resolve_id( iscsi_mgr.resolve_ids, args.get('<identifier>'), 'iSCSI') result = iscsi_mgr.get_iscsi(iscsi_id) result = NestedDict(result) table.add_row(['id', result['id']]) table.add_row(['serviceResourceName', result['serviceResourceName']]) table.add_row(['createDate', result['createDate']]) table.add_row(['nasType', result['nasType']]) table.add_row(['capacityGb', result['capacityGb']]) if result['snapshotCapacityGb']: table.add_row(['snapshotCapacityGb', result['snapshotCapacityGb']]) table.add_row(['mountableFlag', result['mountableFlag']]) table.add_row( ['serviceResourceBackendIpAddress', result['serviceResourceBackendIpAddress']]) table.add_row(['price', result['billingItem']['recurringFee']]) table.add_row(['BillingItemId', result['billingItem']['id']]) if result.get('notes'): table.add_row(['notes', result['notes']]) if args.get('--password'): pass_table = Table(['username', 'password']) pass_table.add_row([result['username'], result['password']]) table.add_row(['users', pass_table]) return table
def execute(self, args): hardware = HardwareManager(self.client) table = KeyValueTable(['Name', 'Value']) table.align['Name'] = 'r' table.align['Value'] = 'l' hardware_id = resolve_id( hardware.resolve_ids, args.get('<identifier>'), 'hardware') result = hardware.get_hardware(hardware_id) result = NestedDict(result) table.add_row(['id', result['id']]) table.add_row(['hostname', result['fullyQualifiedDomainName']]) table.add_row(['status', result['hardwareStatus']['status']]) table.add_row(['datacenter', result['datacenter']['name'] or blank()]) table.add_row(['cores', result['processorPhysicalCoreAmount']]) table.add_row(['memory', gb(result['memoryCapacity'])]) table.add_row(['public_ip', result['primaryIpAddress'] or blank()]) table.add_row( ['private_ip', result['primaryBackendIpAddress'] or blank()]) table.add_row(['ipmi_ip', result['networkManagementIpAddress'] or blank()]) table.add_row([ 'os', FormattedItem( result['operatingSystem']['softwareLicense'] ['softwareDescription']['referenceCode'] or blank(), result['operatingSystem']['softwareLicense'] ['softwareDescription']['name'] or blank() )]) table.add_row(['created', result['provisionDate'] or blank()]) vlan_table = Table(['type', 'number', 'id']) for vlan in result['networkVlans']: vlan_table.add_row([ vlan['networkSpace'], vlan['vlanNumber'], vlan['id']]) table.add_row(['vlans', vlan_table]) if result.get('notes'): table.add_row(['notes', result['notes']]) if args.get('--price'): table.add_row(['price rate', result['billingItem']['recurringFee']]) if args.get('--passwords'): user_strs = [] for item in result['operatingSystem']['passwords']: user_strs.append( "%s %s" % (item['username'], item['password'])) table.add_row(['users', listing(user_strs)]) tag_row = [] for tag in result['tagReferences']: tag_row.append(tag['tag']['name']) if tag_row: table.add_row(['tags', listing(tag_row, separator=',')]) if not result['privateNetworkOnlyFlag']: ptr_domains = self.client['Hardware_Server']\ .getReverseDomainRecords(id=hardware_id) for ptr_domain in ptr_domains: for ptr in ptr_domain['resourceRecords']: table.add_row(['ptr', ptr['data']]) return table
def execute(self, args): cci = CCIManager(self.client) table = KeyValueTable(['Name', 'Value']) table.align['Name'] = 'r' table.align['Value'] = 'l' cci_id = resolve_id(cci.resolve_ids, args.get('<identifier>'), 'CCI') result = cci.get_instance(cci_id) result = NestedDict(result) table.add_row(['id', result['id']]) table.add_row(['hostname', result['fullyQualifiedDomainName']]) table.add_row(['status', FormattedItem( result['status']['keyName'] or blank(), result['status']['name'] or blank() )]) table.add_row(['active_transaction', active_txn(result)]) table.add_row(['state', FormattedItem( lookup(result, 'powerState', 'keyName'), lookup(result, 'powerState', 'name'), )]) table.add_row(['datacenter', result['datacenter']['name'] or blank()]) operating_system = lookup(result, 'operatingSystem', 'softwareLicense', 'softwareDescription') or {} table.add_row([ 'os', FormattedItem( operating_system.get('version') or blank(), operating_system.get('name') or blank() )]) table.add_row(['os_version', operating_system.get('version') or blank()]) table.add_row(['cores', result['maxCpu']]) table.add_row(['memory', mb_to_gb(result['maxMemory'])]) table.add_row(['public_ip', result['primaryIpAddress'] or blank()]) table.add_row(['private_ip', result['primaryBackendIpAddress'] or blank()]) table.add_row(['private_only', result['privateNetworkOnlyFlag']]) table.add_row(['private_cpu', result['dedicatedAccountHostOnlyFlag']]) table.add_row(['created', result['createDate']]) table.add_row(['modified', result['modifyDate']]) vlan_table = Table(['type', 'number', 'id']) for vlan in result['networkVlans']: vlan_table.add_row([ vlan['networkSpace'], vlan['vlanNumber'], vlan['id']]) table.add_row(['vlans', vlan_table]) if result.get('notes'): table.add_row(['notes', result['notes']]) if args.get('--price'): table.add_row(['price rate', result['billingItem']['recurringFee']]) if args.get('--passwords'): pass_table = Table(['username', 'password']) for item in result['operatingSystem']['passwords']: pass_table.add_row([item['username'], item['password']]) table.add_row(['users', pass_table]) tag_row = [] for tag in result['tagReferences']: tag_row.append(tag['tag']['name']) if tag_row: table.add_row(['tags', listing(tag_row, separator=',')]) if not result['privateNetworkOnlyFlag']: ptr_domains = self.client['Virtual_Guest'].\ getReverseDomainRecords(id=cci_id) for ptr_domain in ptr_domains: for ptr in ptr_domain['resourceRecords']: table.add_row(['ptr', ptr['data']]) return table
def execute(client, args): cci = CCIManager(client) t = Table(['Name', 'Value']) t.align['Name'] = 'r' t.align['Value'] = 'l' cci_id = resolve_id(cci, args.get('<identifier>')) result = cci.get_instance(cci_id) result = NestedDict(result) t.add_row(['id', result['id']]) t.add_row(['hostname', result['fullyQualifiedDomainName']]) t.add_row(['status', result['status']['name']]) t.add_row(['state', result['powerState']['name']]) t.add_row(['datacenter', result['datacenter'].get('name', blank())]) t.add_row(['cores', result['maxCpu']]) t.add_row(['memory', mb_to_gb(result['maxMemory'])]) t.add_row(['public_ip', result.get('primaryIpAddress', blank())]) t.add_row( ['private_ip', result.get('primaryBackendIpAddress', blank())]) t.add_row([ 'os', FormattedItem( result['operatingSystem']['softwareLicense'] ['softwareDescription'].get('referenceCode', blank()), result['operatingSystem']['softwareLicense'] ['softwareDescription'].get('name', blank()) )]) t.add_row(['private_only', result['privateNetworkOnlyFlag']]) t.add_row(['private_cpu', result['dedicatedAccountHostOnlyFlag']]) t.add_row(['created', result['createDate']]) t.add_row(['modified', result['modifyDate']]) if result.get('notes'): t.add_row(['notes', result['notes']]) if args.get('--price'): t.add_row(['price rate', result['billingItem']['recurringFee']]) if args.get('--passwords'): user_strs = [] for item in result['operatingSystem']['passwords']: user_strs.append( "%s %s" % (item['username'], item['password'])) t.add_row(['users', listing(user_strs)]) tag_row = [] for tag in result['tagReferences']: tag_row.append(tag['tag']['name']) if tag_row: t.add_row(['tags', listing(tag_row, separator=',')]) ptr_domains = client['Virtual_Guest'].\ getReverseDomainRecords(id=cci_id) for ptr_domain in ptr_domains: for ptr in ptr_domain['resourceRecords']: t.add_row(['ptr', ptr['data']]) return t