本文整理汇总了Python中SoftLayer.CLI.Table.align['Value']方法的典型用法代码示例。如果您正苦于以下问题:Python Table.align['Value']方法的具体用法?Python Table.align['Value']怎么用?Python Table.align['Value']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.CLI.Table
的用法示例。
在下文中一共展示了Table.align['Value']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import align['Value'] [as 别名]
def execute(client, args):
meta = MetadataManager()
if args['<public>']:
t = Table(['Name', 'Value'])
t.align['Name'] = 'r'
t.align['Value'] = 'l'
network = meta.public_network()
t.add_row([
'mac addresses',
listing(network['mac_addresses'], separator=',')])
t.add_row([
'router', network['router']])
t.add_row([
'vlans', listing(network['vlans'], separator=',')])
t.add_row([
'vlan ids',
listing(network['vlan_ids'], separator=',')])
return t
if args['<private>']:
t = Table(['Name', 'Value'])
t.align['Name'] = 'r'
t.align['Value'] = 'l'
network = meta.private_network()
t.add_row([
'mac addresses',
listing(network['mac_addresses'], separator=',')])
t.add_row([
'router', network['router']])
t.add_row([
'vlans', listing(network['vlans'], separator=',')])
t.add_row([
'vlan ids',
listing(network['vlan_ids'], separator=',')])
return t
示例2: execute
# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import align['Value'] [as 别名]
def execute(cls, client, args):
t = Table(['Name', 'Value'])
t.align['Name'] = 'r'
t.align['Value'] = 'l'
config = cls.env.config
t.add_row(['Username', config.get('username', 'none set')])
t.add_row(['API Key', config.get('api_key', 'none set')])
t.add_row(['Endpoint URL', config.get('endpoint_url', 'none set')])
return t
示例3: execute
# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import align['Value'] [as 别名]
def execute(cls, client, args):
cci = CCIManager(client)
result = cci.get_create_options()
show_all = True
for opt_name in cls.options:
if args.get("--" + opt_name):
show_all = False
break
if args['--all']:
show_all = True
t = Table(['Name', 'Value'])
t.align['Name'] = 'r'
t.align['Value'] = 'l'
if args['--datacenter'] or show_all:
datacenters = [dc['template']['datacenter']['name']
for dc in result['datacenters']]
t.add_row(['datacenter', listing(datacenters, separator=',')])
if args['--cpu'] or show_all:
standard_cpu = filter(
lambda x: not x['template'].get(
'dedicatedAccountHostOnlyFlag', False),
result['processors'])
ded_cpu = filter(
lambda x: x['template'].get(
'dedicatedAccountHostOnlyFlag', False),
result['processors'])
def cpus_row(c, name):
cpus = []
for x in c:
cpus.append(str(x['template']['startCpus']))
t.add_row(['cpus (%s)' % name, listing(cpus, separator=',')])
cpus_row(ded_cpu, 'private')
cpus_row(standard_cpu, 'standard')
if args['--memory'] or show_all:
memory = [
str(m['template']['maxMemory']) for m in result['memory']]
t.add_row(['memory', listing(memory, separator=',')])
if args['--os'] or show_all:
op_sys = [
o['template']['operatingSystemReferenceCode'] for o in
result['operatingSystems']]
op_sys = sorted(op_sys)
os_summary = set()
for o in op_sys:
os_summary.add(o[0:o.find('_')])
for summary in sorted(os_summary):
t.add_row([
'os (%s)' % summary,
linesep.join(sorted(filter(
lambda x: x[0:len(summary)] == summary, op_sys))
)
])
if args['--disk'] or show_all:
local_disks = filter(
lambda x: x['template'].get('localDiskFlag', False),
result['blockDevices'])
san_disks = filter(
lambda x: not x['template'].get('localDiskFlag', False),
result['blockDevices'])
def block_rows(blocks, name):
simple = {}
for block in blocks:
b = block['template']['blockDevices'][0]
bid = b['device']
size = b['diskImage']['capacity']
if bid not in simple:
simple[bid] = []
simple[bid].append(str(size))
for b in sorted(simple.keys()):
t.add_row([
'%s disk(%s)' % (name, b),
listing(simple[b], separator=',')]
)
block_rows(local_disks, 'local')
block_rows(san_disks, 'san')
if args['--nic'] or show_all:
speeds = []
for x in result['networkComponents']:
#.........这里部分代码省略.........