本文整理汇总了Python中SoftLayer.CLI.Table.align["name"]方法的典型用法代码示例。如果您正苦于以下问题:Python Table.align["name"]方法的具体用法?Python Table.align["name"]怎么用?Python Table.align["name"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.CLI.Table
的用法示例。
在下文中一共展示了Table.align["name"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import align["name"] [as 别名]
#.........这里部分代码省略.........
os_price = self._get_price_id_from_options(bmi_options, "os", args["--os"])
if os_price:
order["os"] = os_price
else:
raise CLIAbort("Invalid operating system specified.")
order["location"] = args["--datacenter"] or "FIRST_AVAILABLE"
# Set the disk size
disk_prices = []
for disk in args.get("--disk"):
disk_price = self._get_price_id_from_options(bmi_options, "disk", disk)
if disk_price:
disk_prices.append(disk_price)
if not disk_prices:
disk_prices.append(self._get_default_value(bmi_options, "disk0"))
order["disks"] = disk_prices
# Set the port speed
port_speed = args.get("--network") or 100
nic_price = self._get_price_id_from_options(bmi_options, "nic", str(port_speed))
if nic_price:
order["port_speed"] = nic_price
else:
raise CLIAbort("Invalid network speed specified.")
# Get the SSH keys
if args.get("--key"):
keys = []
for key in args.get("--key"):
key_id = resolve_id(SshKeyManager(self.client).resolve_ids, key, "SshKey")
keys.append(key_id)
order["ssh_keys"] = keys
if args.get("--vlan_public"):
order["public_vlan"] = args["--vlan_public"]
if args.get("--vlan_private"):
order["private_vlan"] = args["--vlan_private"]
# Begin output
t = Table(["Item", "cost"])
t.align["Item"] = "r"
t.align["cost"] = "r"
if args.get("--test"):
result = mgr.verify_order(**order)
total_monthly = 0.0
total_hourly = 0.0
for price in result["prices"]:
monthly_fee = float(price.get("recurringFee", 0.0))
hourly_fee = float(price.get("hourlyRecurringFee", 0.0))
total_monthly += monthly_fee
total_hourly += hourly_fee
if args.get("--hourly"):
rate = "%.2f" % hourly_fee
else:
rate = "%.2f" % monthly_fee
t.add_row([price["item"]["description"], rate])
if args.get("--hourly"):
total = total_hourly
else:
total = total_monthly
billing_rate = "monthly"
if args.get("--hourly"):
billing_rate = "hourly"
t.add_row(["Total %s cost" % billing_rate, "%.2f" % total])
output = SequentialOutput()
output.append(t)
output.append(
FormattedItem(
"",
" -- ! Prices reflected here are retail and do not "
"take account level discounts and are not guaranteed.",
)
)
elif args["--really"] or confirm("This action will incur charges on your account. Continue?"):
result = mgr.place_order(**order)
t = KeyValueTable(["name", "value"])
t.align["name"] = "r"
t.align["value"] = "l"
t.add_row(["id", result["orderId"]])
t.add_row(["created", result["orderDate"]])
output = t
else:
raise CLIAbort("Aborting bare metal instance order.")
return output