本文整理汇总了Python中SoftLayer.CLI.Table类的典型用法代码示例。如果您正苦于以下问题:Python Table类的具体用法?Python Table怎么用?Python Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self, args):
mgr = NetworkManager(self.client)
t = Table([
'id', 'identifier', 'type', 'datacenter', 'vlan id', 'IPs',
'hardware', 'ccis',
])
t.sortby = args.get('--sortby') or 'id'
version = 0
if args.get('--v4'):
version = 4
elif args.get('--v6'):
version = 6
subnets = mgr.list_subnets(
datacenter=args.get('--datacenter'),
version=version,
identifier=args.get('--identifier'),
subnet_type=args.get('--type'),
)
for subnet in subnets:
t.add_row([
subnet['id'],
subnet['networkIdentifier'] + '/' + str(subnet['cidr']),
subnet.get('subnetType', '-'),
subnet['datacenter']['name'],
subnet['networkVlanId'],
subnet['ipAddressCount'],
len(subnet['hardware']),
len(subnet['virtualGuests']),
])
return t
示例2: execute
def execute(self, args):
mgr = FirewallManager(self.client)
fwvlans = mgr.get_firewalls()
table = Table(['vlan', 'type', 'features'])
dedicatedfws = [vlan['dedicatedFirewallFlag'] for vlan in fwvlans]
for vlan in dedicatedfws:
features = []
if vlan['highAvailabilityFirewallFlag']:
features.append('HA')
if features:
feature_list = listing(features, separator=',')
else:
feature_list = blank()
table.add_row([
vlan['vlanNumber'],
'dedicated',
feature_list,
])
shared_vlan = [vlan['dedicatedFirewallFlag'] for vlan in fwvlans]
for vlan in shared_vlan:
table.add_row([vlan['vlanNumber'], 'standard', blank()])
return table
示例3: execute
def execute(client, args):
account = client["Account"]
neither = not any([args["--private"], args["--public"]])
result = []
if args["--private"] or neither:
account = client["Account"]
private = "privateBlockDeviceTemplateGroups"
mask = private + "[id,accountId,name,globalIdentifier,blockDevices,parentId]"
result += account.getObject(mask=mask)[private]
if args["--public"] or neither:
vgbd = client["Virtual_Guest_Block_Device_Template_Group"]
result += vgbd.getPublicImages()
t = Table(["id", "account", "type", "name", "guid"])
t.sortby = "name"
images = filter(lambda x: x["parentId"] == "", result)
for image in images:
t.add_row(
[
image["id"],
image.get("accountId", "-"),
image.get("type", "-"),
image["name"].strip(),
image.get("globalIdentifier", "-"),
]
)
return t
示例4: execute
def execute(client, args):
mgr = NetworkManager(client)
t = Table([
'id', 'ip', 'assigned', 'target'
])
t.sortby = args.get('--sortby') or 'id'
version = 0
if args.get('--v4'):
version = 4
elif args.get('--v6'):
version = 6
ips = mgr.list_global_ips(version=version)
for ip in ips:
assigned = 'No'
target = 'None'
if ip.get('destinationIpAddress'):
dest = ip['destinationIpAddress']
assigned = 'Yes'
target = dest['ipAddress']
if dest.get('virtualGuest'):
vg = dest['virtualGuest']
target += ' (' + vg['fullyQualifiedDomainName'] + ')'
elif ip['destinationIpAddress'].get('hardware'):
target += ' (' + \
dest['hardware']['fullyQualifiedDomainName'] + \
')'
t.add_row([ip['id'], ip['ipAddress']['ipAddress'], assigned,
target])
return t
示例5: execute
def execute(self, args):
mgr = NetworkManager(self.client)
table = Table([
'id', 'number', 'datacenter', 'name', 'IPs', 'hardware', 'ccis',
'networking', 'firewall'
])
table.sortby = args.get('--sortby') or 'id'
vlans = mgr.list_vlans(
datacenter=args.get('--datacenter'),
vlan_number=args.get('--number'),
name=args.get('--name'),
)
for vlan in vlans:
table.add_row([
vlan['id'],
vlan['vlanNumber'],
vlan['primaryRouter']['datacenter']['name'],
vlan.get('name') or blank(),
vlan['totalPrimaryIpAddressCount'],
len(vlan['hardware']),
len(vlan['virtualGuests']),
len(vlan['networkComponents']),
'Yes' if vlan['firewallInterfaces'] else 'No',
])
return table
示例6: execute
def execute(self, args):
account = self.client['Account']
iscsi_list = account.getIscsiNetworkStorage(
mask='eventCount,serviceResource[datacenter.name]')
iscsi_list = [NestedDict(iscsi) for iscsi in iscsi_list]
table = Table([
'id',
'datacenter',
'size',
'username',
'password',
'server'
])
for iscsi in iscsi_list:
table.add_row([
iscsi['id'],
iscsi['serviceResource']['datacenter'].get('name', blank()),
FormattedItem(
iscsi.get('capacityGb', blank()),
"%dGB" % iscsi.get('capacityGb', 0)),
iscsi.get('username', blank()),
iscsi.get('password', blank()),
iscsi.get('serviceResourceBackendIpAddress', blank())])
return table
示例7: execute
def execute(self, args):
ticket_mgr = TicketManager(self.client)
tickets = ticket_mgr.list_tickets(
open_status=not args.get('--closed'),
closed_status=args.get('--closed'))
table = Table(['id', 'assigned user', 'title',
'creation date', 'last edit date'])
for ticket in tickets:
if ticket['assignedUser']:
table.add_row([
ticket['id'],
"%s %s" % (ticket['assignedUser']['firstName'],
ticket['assignedUser']['lastName']),
wrap_string(ticket['title']),
ticket['createDate'],
ticket['lastEditDate']
])
else:
table.add_row([
ticket['id'],
'N/A',
wrap_string(ticket['title']),
ticket['createDate'],
ticket['lastEditDate']
])
return table
示例8: execute
def execute(self, args):
table = KeyValueTable(['Name', 'Value'])
table.align['Name'] = 'r'
table.align['Value'] = 'l'
show_all = True
for opt_name in self.options:
if args.get("--" + opt_name):
show_all = False
break
mgr = HardwareManager(self.client)
bmi_options = mgr.get_bare_metal_create_options()
if args['--all']:
show_all = True
if args['--datacenter'] or show_all:
results = self.get_create_options(bmi_options, 'datacenter')[0]
table.add_row([results[0], listing(sorted(results[1]))])
if args['--cpu'] or args['--memory'] or show_all:
results = self.get_create_options(bmi_options, 'cpu')
memory_cpu_table = Table(['memory', 'cpu'])
for result in results:
memory_cpu_table.add_row([
result[0],
listing(
[item[0] for item in sorted(
result[1], key=lambda x: int(x[0])
)])])
table.add_row(['memory/cpu', memory_cpu_table])
if args['--os'] or show_all:
results = self.get_create_options(bmi_options, 'os')
for result in results:
table.add_row([
result[0],
listing(
[item[0] for item in sorted(result[1])],
separator=linesep
)])
if args['--disk'] or show_all:
results = self.get_create_options(bmi_options, 'disk')[0]
table.add_row([results[0], listing(
[item[0] for item in sorted(results[1])])])
if args['--nic'] or show_all:
results = self.get_create_options(bmi_options, 'nic')
for result in results:
table.add_row([result[0], listing(
[item[0] for item in sorted(result[1],)])])
return table
示例9: execute
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
示例10: execute
def execute(client, args):
f = FirewallManager(client)
fwvlans = f.get_firewalls()
t = Table(['vlan', 'type', 'features'])
dedicatedfws = filter(lambda x: x['dedicatedFirewallFlag'], fwvlans)
for vlan in dedicatedfws:
features = []
if vlan['highAvailabilityFirewallFlag']:
features.append('HA')
if features:
feature_list = listing(features, separator=',')
else:
feature_list = blank()
t.add_row([
vlan['vlanNumber'],
'dedicated',
feature_list,
])
shared_vlan = filter(lambda x: not x['dedicatedFirewallFlag'], fwvlans)
for vlan in shared_vlan:
t.add_row([vlan['vlanNumber'], 'standard', blank()])
return t
示例11: execute
def execute(client, args):
account = client['Account']
neither = not any([args['--private'], args['--public']])
results = []
if args['--private'] or neither:
account = client['Account']
mask = 'id,accountId,name,globalIdentifier,blockDevices,parentId'
r = account.getPrivateBlockDeviceTemplateGroups(mask=mask)
results.append(r)
if args['--public'] or neither:
vgbd = client['Virtual_Guest_Block_Device_Template_Group']
r = vgbd.getPublicImages()
results.append(r)
t = Table(['id', 'account', 'type', 'name', 'guid', ])
t.sortby = 'name'
for result in results:
images = filter(lambda x: x['parentId'] == '', result)
for image in images:
t.add_row([
image['id'],
image.get('accountId', blank()),
image.get('type', blank()),
image['name'].strip(),
image.get('globalIdentifier', blank()),
])
return t
示例12: execute
def execute(client, args):
account = client['Account']
iscsi = account.getIscsiNetworkStorage(
mask='eventCount,serviceResource[datacenter.name]')
iscsi = [NestedDict(n) for n in iscsi]
t = Table([
'id',
'datacenter',
'size',
'username',
'password',
'server'
])
for n in iscsi:
t.add_row([
n['id'],
n['serviceResource']['datacenter'].get('name', blank()),
FormattedItem(
n.get('capacityGb', blank()),
"%dGB" % n.get('capacityGb', 0)),
n.get('username', blank()),
n.get('password', blank()),
n.get('serviceResourceBackendIpAddress', blank())])
return t
示例13: execute
def execute(self, args):
image_mgr = ImageManager(self.client)
neither = not any([args['--private'], args['--public']])
mask = 'id,accountId,name,globalIdentifier,blockDevices,parentId'
images = []
if args['--private'] or neither:
for image in image_mgr.list_private_images(mask=mask):
image['visibility'] = 'private'
images.append(image)
if args['--public'] or neither:
for image in image_mgr.list_public_images(mask=mask):
image['visibility'] = 'public'
images.append(image)
t = Table(['id', 'account', 'visibility', 'name', 'global_identifier'])
images = filter(lambda x: x['parentId'] == '', images)
for image in images:
t.add_row([
image['id'],
image.get('accountId', blank()),
image['visibility'],
image['name'].strip(),
image.get('globalIdentifier', blank()),
])
return t
示例14: execute
def execute(self, args):
mgr = NetworkManager(self.client)
vlan = mgr.get_vlan(args.get('<identifier>'))
t = KeyValueTable(['Name', 'Value'])
t.align['Name'] = 'r'
t.align['Value'] = 'l'
t.add_row(['id', vlan['id']])
t.add_row(['number', vlan['vlanNumber']])
t.add_row(['datacenter',
vlan['primaryRouter']['datacenter']['longName']])
t.add_row(['primary router',
vlan['primaryRouter']['fullyQualifiedDomainName']])
t.add_row(['firewall', 'Yes' if vlan['firewallInterfaces'] else 'No'])
subnets = []
for subnet in vlan['subnets']:
subnet_table = KeyValueTable(['Name', 'Value'])
subnet_table.align['Name'] = 'r'
subnet_table.align['Value'] = 'l'
subnet_table.add_row(['id', subnet['id']])
subnet_table.add_row(['identifier', subnet['networkIdentifier']])
subnet_table.add_row(['netmask', subnet['netmask']])
subnet_table.add_row(['gateway', subnet.get('gateway', '-')])
subnet_table.add_row(['type', subnet['subnetType']])
subnet_table.add_row(['usable ips',
subnet['usableIpAddressCount']])
subnets.append(subnet_table)
t.add_row(['subnets', subnets])
if not args.get('--no-cci'):
if vlan['virtualGuests']:
cci_table = KeyValueTable(['Hostname', 'Domain', 'IP'])
cci_table.align['Hostname'] = 'r'
cci_table.align['IP'] = 'l'
for cci in vlan['virtualGuests']:
cci_table.add_row([cci['hostname'],
cci['domain'],
cci.get('primaryIpAddress')])
t.add_row(['ccis', cci_table])
else:
t.add_row(['cci', 'none'])
if not args.get('--no-hardware'):
if vlan['hardware']:
hw_table = Table(['Hostname', 'Domain', 'IP'])
hw_table.align['Hostname'] = 'r'
hw_table.align['IP'] = 'l'
for hw in vlan['hardware']:
hw_table.add_row([hw['hostname'],
hw['domain'],
hw.get('primaryIpAddress')])
t.add_row(['hardware', hw_table])
else:
t.add_row(['hardware', 'none'])
return t
示例15: execute
def execute(self, args):
manager = MessagingManager(self.client)
mq_client = manager.get_connection(args['<account_id>'])
topics = mq_client.get_topics()['items']
table = Table(['name'])
for topic in topics:
table.add_row([topic['name']])
return table