1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
"""List packages."""
# :license: MIT, see LICENSE for more details.
import click
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.managers import ordering
COLUMNS = ['id', 'dc', 'description', 'keyName']
@click.command()
@click.argument('package_keyname')
@environment.pass_env
def cli(env, package_keyname):
"""List Datacenters a package can be ordered in.
Use the location Key Name to place orders
"""
manager = ordering.OrderingManager(env.client)
table = formatting.Table(COLUMNS)
locations = manager.package_locations(package_keyname)
for region in locations:
for datacenter in region['locations']:
table.add_row([
datacenter['location']['id'],
datacenter['location']['name'],
region['description'],
region['keyname']
])
env.fout(table)
|