Esempio n. 1
0
def cli(env):
    """List all zones."""

    manager = SoftLayer.DNSManager(env.client)
    object_mask = "mask[id,name,serial,updateDate,resourceRecordCount]"
    zones = manager.list_zones(mask=object_mask)
    table = formatting.Table(['id', 'zone', 'serial', 'updated', 'records'])
    table.align = 'l'
    for zone in zones:
        zone_serial = str(zone.get('serial'))
        zone_date = zone.get('updateDate', None)
        if zone_date is None:
            # The serial is just YYYYMMDD##, and since there is no createDate, just format it like it was one.
            zone_date = "{}-{}-{}T00:00:00-06:00".format(
                zone_serial[0:4], zone_serial[4:6], zone_serial[6:8])
        table.add_row([
            zone['id'], zone['name'], zone_serial,
            clean_time(zone_date),
            zone.get('resourceRecordCount', 0)
        ])

    env.fout(table)
Esempio n. 2
0
def cli(env, identifier, password):
    """Get details for an iSCSI target."""

    iscsi_mgr = SoftLayer.ISCSIManager(env.client)

    iscsi_id = helpers.resolve_id(iscsi_mgr.resolve_ids, identifier, 'iSCSI')
    result = iscsi_mgr.get_iscsi(iscsi_id)
    result = utils.NestedDict(result)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    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 password:
        pass_table = formatting.Table(['username', 'password'])
        pass_table.add_row([result['username'], result['password']])
        table.add_row(['users', pass_table])

    env.fout(table)
Esempio n. 3
0
def cli(env, prices, location=None):
    """Server order options for a given chassis."""

    hardware_manager = hardware.HardwareManager(env.client)
    account_manager = account.AccountManager(env.client)
    options = hardware_manager.get_create_options(location)
    routers = account_manager.get_routers(location=location)
    network_manager = network.NetworkManager(env.client)

    pods = network_manager.get_closed_pods()

    tables = []

    # Datacenters
    dc_table = formatting.Table(['Datacenter', 'Value', 'Note'],
                                title="Datacenters")
    dc_table.sortby = 'Value'
    dc_table.align = 'l'
    for location_info in options['locations']:
        closure = []
        for pod in pods:
            if location_info['key'] in str(pod['name']):
                closure.append(pod['name'])

        notes = '-'
        if len(closure) > 0:
            notes = 'closed soon: %s' % (', '.join(closure))
        dc_table.add_row([location_info['name'], location_info['key'], notes])
    tables.append(dc_table)

    tables.append(_preset_prices_table(options['sizes'], prices))
    tables.append(_os_prices_table(options['operating_systems'], prices))
    tables.append(_port_speed_prices_table(options['port_speeds'], prices))
    tables.append(_extras_prices_table(options['extras'], prices))
    tables.append(_get_routers(routers))

    # since this is multiple tables, this is required for a valid JSON object to be rendered.
    env.fout(formatting.listing(tables, separator='\n'))
Esempio n. 4
0
    def execute(self, args):
        manager = SoftLayer.HardwareManager(self.client)

        tags = None
        if args.get('--tags'):
            tags = [tag.strip() for tag in args.get('--tags').split(',')]

        servers = manager.list_hardware(hostname=args.get('--hostname'),
                                        domain=args.get('--domain'),
                                        cpus=args.get('--cpu'),
                                        memory=args.get('--memory'),
                                        datacenter=args.get('--datacenter'),
                                        nic_speed=args.get('--network'),
                                        tags=tags)

        table = formatting.Table([
            'id', 'datacenter', 'host', 'cores', 'memory', 'primary_ip',
            'backend_ip', 'active_transaction', 'owner'
        ])
        table.sortby = args.get('--sortby') or 'host'

        for server in servers:
            server = utils.NestedDict(server)

            table.add_row([
                server['id'],
                server['datacenter']['name'] or formatting.blank(),
                server['fullyQualifiedDomainName'],
                server['processorPhysicalCoreAmount'],
                formatting.gb(server['memoryCapacity'] or 0),
                server['primaryIpAddress'] or formatting.blank(),
                server['primaryBackendIpAddress'] or formatting.blank(),
                formatting.active_txn(server),
                utils.lookup(server, 'billingItem', 'orderItem', 'order',
                             'userRecord', 'username') or formatting.blank(),
            ])

        return table
Esempio n. 5
0
def cli(env):
    """List NAS accounts."""

    account = env.client['Account']

    nas_accounts = account.getNasNetworkStorage(
        mask='eventCount,serviceResource[datacenter.name]')

    table = formatting.Table(['id', 'datacenter', 'size', 'server'])

    for nas_account in nas_accounts:
        table.add_row([
            nas_account['id'],
            utils.lookup(nas_account, 'serviceResource', 'datacenter', 'name')
            or formatting.blank(),
            formatting.FormattedItem(
                nas_account.get('capacityGb', formatting.blank()),
                "%dGB" % nas_account.get('capacityGb', 0)),
            nas_account.get('serviceResourceBackendIpAddress',
                            formatting.blank())
        ])

    env.fout(table)
Esempio n. 6
0
def _location_item_prices(location_prices, location, tables):
    """Add a location prices table to tables.

    :param list location_prices : Location prices.
    :param string location : Location.
    :param list tables: Table list to add location prices table.
    """
    location_prices_table = formatting.Table(COLUMNS_ITEM_PRICES_LOCATION,
                                             title="Item Prices for %s" %
                                             location)
    location_prices_table.sortby = 'keyName'
    location_prices_table.align = 'l'
    for price in location_prices:
        cr_max = get_item_price_data(price, 'capacityRestrictionMaximum')
        cr_min = get_item_price_data(price, 'capacityRestrictionMinimum')
        cr_type = get_item_price_data(price, 'capacityRestrictionType')
        location_prices_table.add_row([
            price['item']['keyName'], price['id'],
            get_item_price_data(price, 'hourlyRecurringFee'),
            get_item_price_data(price, 'recurringFee'),
            "%s - %s %s" % (cr_min, cr_max, cr_type)
        ])
    tables.append(location_prices_table)
Esempio n. 7
0
def cli(env, access_id):
    """List block storage assigned subnets for the given host id.

    access_id is the host_id obtained by: slcli block access-list <volume_id>
    """

    try:
        block_manager = SoftLayer.BlockStorageManager(env.client)
        subnets = block_manager.get_subnets_in_acl(access_id)

        table = formatting.Table(COLUMNS)
        for subnet in subnets:
            row = ["{0}".format(subnet['id']),
                   "{0}".format(subnet['createDate']),
                   "{0}".format(subnet['networkIdentifier']),
                   "{0}".format(subnet['cidr'])]
            table.add_row(row)

        env.fout(table)

    except SoftLayer.SoftLayerAPIError as ex:
        message = "Unable to list assigned subnets for access-id: {}.\nReason: {}".format(access_id, ex.faultString)
        click.echo(message)
Esempio n. 8
0
def generate_lbaas_table(lbaas):
    """Takes a list of SoftLayer_Network_LBaaS_LoadBalancer and makes a table"""
    table = formatting.Table([
        'Id', 'Location', 'Name', 'Description', 'Public', 'Create Date', 'Members', 'Listeners'
    ], title="IBM Cloud LoadBalancer")

    table.align['Name'] = 'l'
    table.align['Description'] = 'l'
    table.align['Location'] = 'l'
    for this_lb in sorted(lbaas, key=location_sort):
        table.add_row([
            this_lb.get('id'),
            utils.lookup(this_lb, 'datacenter', 'longName'),
            this_lb.get('name'),
            this_lb.get('description'),
            'Yes' if this_lb.get('isPublic', 1) == 1 else 'No',
            utils.clean_time(this_lb.get('createDate')),
            this_lb.get('memberCount', 0),
            this_lb.get('listenerCount', 0)


        ])
    return table
Esempio n. 9
0
def unplanned_event_table(events):
    """Formats a table for events"""
    unplanned_table = formatting.Table([
        'Id', 'Event ID', 'Subject', 'Status', 'Items', 'Start Date',
        'Last Updated', 'Acknowledged', 'Updates'
    ],
                                       title="Unplanned Events")
    unplanned_table.align['Subject'] = 'l'
    unplanned_table.align['Impacted Resources'] = 'l'
    for event in events:
        unplanned_table.add_row([
            event.get('id'),
            event.get('systemTicketId'),
            # Some subjects can have \r\n for some reason.
            utils.clean_splitlines(event.get('subject')),
            utils.lookup(event, 'statusCode', 'name'),
            event.get('impactedResourceCount'),
            utils.clean_time(event.get('startDate')),
            utils.clean_time(event.get('modifyDate')),
            event.get('acknowledgedFlag'),
            event.get('updateCount'),
        ])
    return unplanned_table
Esempio n. 10
0
def cli(env, sortby):
    """Account summary."""

    mgr = SoftLayer.NetworkManager(env.client)
    datacenters = mgr.summary_by_datacenter()

    table = formatting.Table([
        'datacenter', 'vlans', 'subnets', 'ips', 'networking', 'hardware', 'vs'
    ])
    table.sortby = sortby

    for name, datacenter in datacenters.items():
        table.add_row([
            name,
            datacenter['vlanCount'],
            datacenter['subnetCount'],
            datacenter['primaryIpCount'],
            datacenter['networkingCount'],
            datacenter['hardwareCount'],
            datacenter['virtualGuestCount'],
        ])

    env.fout(table)
Esempio n. 11
0
def cli(env, is_open):
    """List tickets."""
    ticket_mgr = SoftLayer.TicketManager(env.client)

    tickets = ticket_mgr.list_tickets(open_status=not is_open,
                                      closed_status=is_open)

    table = formatting.Table(
        ['id', 'assigned user', 'title', 'creation date', 'last edit date'])

    for ticket in tickets:
        user = '******'
        if ticket.get('assignedUser'):
            user = "******" % (ticket['assignedUser']['firstName'],
                              ticket['assignedUser']['lastName']),

        table.add_row([
            ticket['id'], user,
            click.wrap_text(ticket['title']), ticket['createDate'],
            ticket['lastEditDate']
        ])

    return table
Esempio n. 12
0
def cli(env, prices, location=None):
    """Server order options for a given chassis."""

    hardware_manager = hardware.HardwareManager(env.client)
    options = hardware_manager.get_create_options(location)

    tables = []

    # Datacenters
    dc_table = formatting.Table(['Datacenter', 'Value'], title="Datacenters")
    dc_table.sortby = 'Value'
    dc_table.align = 'l'
    for location_info in options['locations']:
        dc_table.add_row([location_info['name'], location_info['key']])
    tables.append(dc_table)

    tables.append(_preset_prices_table(options['sizes'], prices))
    tables.append(_os_prices_table(options['operating_systems'], prices))
    tables.append(_port_speed_prices_table(options['port_speeds'], prices))
    tables.append(_extras_prices_table(options['extras'], prices))

    # since this is multiple tables, this is required for a valid JSON object to be rendered.
    env.fout(formatting.listing(tables, separator='\n'))
def cli(env):
    """Reset connections on a certain service group."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    table = formatting.Table(['price_id', 'capacity', 'description', 'price'])

    table.sortby = 'price'
    table.align['price'] = 'r'
    table.align['capacity'] = 'r'
    table.align['id'] = 'r'

    packages = mgr.get_lb_pkgs()

    for package in packages:
        table.add_row([
            package['prices'][0]['id'],
            package.get('capacity'),
            package['description'],
            '%.2f' % float(package['prices'][0]['recurringFee'])
        ])

    return table
Esempio n. 14
0
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network,
        hourly, monthly, tag, columns):
    """List virtual servers."""

    vsi = SoftLayer.VSManager(env.client)
    guests = vsi.list_instances(hourly=hourly,
                                monthly=monthly,
                                hostname=hostname,
                                domain=domain,
                                cpus=cpu,
                                memory=memory,
                                datacenter=datacenter,
                                nic_speed=network,
                                tags=tag)

    table = formatting.Table(columns.columns)
    table.sortby = sortby

    for guest in guests:
        table.add_row(
            [value or formatting.blank() for value in columns.row(guest)])

    env.fout(table)
Esempio n. 15
0
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag,
        columns):
    """List hardware servers."""

    manager = SoftLayer.HardwareManager(env.client)

    servers = manager.list_hardware(hostname=hostname,
                                    domain=domain,
                                    cpus=cpu,
                                    memory=memory,
                                    datacenter=datacenter,
                                    nic_speed=network,
                                    tags=tag,
                                    mask=columns.mask())

    table = formatting.Table(columns.columns)
    table.sortby = sortby

    for server in servers:
        table.add_row([value or formatting.blank()
                       for value in columns.row(server)])

    env.fout(table)
Esempio n. 16
0
def cli(env, limit):
    """Lists account orders. Use `slcli order lookup <ID>` to find more details about a specific order."""
    manager = AccountManager(env.client)
    orders = manager.get_account_all_billing_orders(limit)

    order_table = formatting.Table(
        ['Id', 'State', 'User', 'Date', 'Amount', 'Item'], title="orders")
    order_table.align = 'l'

    for order in orders:
        items = []
        for item in order['items']:
            items.append(item['description'])
        create_date = utils.clean_time(order['createDate'],
                                       in_format='%Y-%m-%d',
                                       out_format='%Y-%m-%d')

        order_table.add_row([
            order['id'], order['status'], order['userRecord']['username'],
            create_date, order['orderTotalAmount'],
            utils.trim_to(' '.join(map(str, items)), 50)
        ])
    env.fout(order_table)
Esempio n. 17
0
def cli(env, keyword, package_type):
    """List packages that can be ordered via the placeOrder API.

    \b
    Example:
        # List out all packages for ordering
        slcli order package-list


    Keywords can also be used for some simple filtering functionality
    to help find a package easier.

    \b
    Example:
        # List out all packages with "server" in the name
        slcli order package-list --keyword server

    Package types can be used to remove unwanted packages
    \b
    Example:
        slcli order package-list --package_type BARE_METAL_CPU
    """
    manager = ordering.OrderingManager(env.client)
    table = formatting.Table(COLUMNS)

    _filter = {'type': {'keyName': {'operation': '!= BLUEMIX_SERVICE'}}}
    if keyword:
        _filter['name'] = {'operation': '*= %s' % keyword}
    if package_type:
        _filter['type'] = {'keyName': {'operation': package_type}}

    packages = manager.list_packages(filter=_filter)

    for package in packages:
        table.add_row(
            [package['name'], package['keyName'], package['type']['keyName']])
    env.fout(table)
Esempio n. 18
0
def cli(env, sortby, datacenter, identifier, subnet_type, ipv4, ipv6):
    """List subnets."""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table([
        'id', 'identifier', 'type', 'datacenter', 'vlan_id', 'IPs',
        'hardware', 'vs',
    ])
    table.sortby = sortby

    version = 0
    if ipv4:
        version = 4
    elif ipv6:
        version = 6

    subnets = mgr.list_subnets(
        datacenter=datacenter,
        version=version,
        identifier=identifier,
        subnet_type=subnet_type,
    )

    for subnet in subnets:
        table.add_row([
            subnet['id'],
            '%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])),
            subnet.get('subnetType', formatting.blank()),
            utils.lookup(subnet, 'datacenter', 'name',) or formatting.blank(),
            subnet['networkVlanId'],
            subnet['ipAddressCount'],
            len(subnet['hardware']),
            len(subnet['virtualGuests']),
        ])

    env.fout(table)
Esempio n. 19
0
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag):
    """List hardware servers."""

    manager = SoftLayer.HardwareManager(env.client)

    servers = manager.list_hardware(hostname=hostname,
                                    domain=domain,
                                    cpus=cpu,
                                    memory=memory,
                                    datacenter=datacenter,
                                    nic_speed=network,
                                    tags=tag)

    table = formatting.Table([
        'guid',
        'hostname',
        'primary_ip',
        'backend_ip',
        'datacenter',
        'action',
    ])
    table.sortby = sortby or 'hostname'

    for server in servers:
        server = utils.NestedDict(server)
        # NOTE(kmcdonald): There are cases where a server might not have a
        #                  globalIdentifier.
        table.add_row([
            server['globalIdentifier'] or server['id'],
            server['hostname'],
            server['primaryIpAddress'] or formatting.blank(),
            server['primaryBackendIpAddress'] or formatting.blank(),
            server['datacenter']['name'] or formatting.blank(),
            formatting.active_txn(server),
        ])

    return table
Esempio n. 20
0
def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metadata):
    """Get Event Logs"""
    mgr = SoftLayer.EventLogManager(env.client)
    usrmgr = SoftLayer.UserManager(env.client)
    request_filter = mgr.build_filter(date_min, date_max, obj_event, obj_id, obj_type, utc_offset)
    logs = mgr.get_event_logs(request_filter)

    if logs is None:
        env.fout('None available.')
        return

    if metadata and 'metadata' not in COLUMNS:
        COLUMNS.append('metadata')

    table = formatting.Table(COLUMNS)
    if metadata:
        table.align['metadata'] = "l"

    for log in logs:
        user = log['userType']
        if user == "CUSTOMER":
            user = usrmgr.get_user(log['userId'], "mask[username]")['username']
        if metadata:
            try:
                metadata_data = json.dumps(json.loads(log['metaData']), indent=4, sort_keys=True)
                if env.format == "table":
                    metadata_data = metadata_data.strip("{}\n\t")
            except ValueError:
                metadata_data = log['metaData']

            table.add_row([log['eventName'], log['label'], log['objectName'],
                           log['eventCreateDate'], user, metadata_data])
        else:
            table.add_row([log['eventName'], log['label'], log['objectName'],
                           log['eventCreateDate'], user])
    env.fout(table)
Esempio n. 21
0
    def execute(self, args):
        account = self.client['Account']

        nas_accounts = account.getNasNetworkStorage(
            mask='eventCount,serviceResource[datacenter.name]')

        table = formatting.Table(
            ['id', 'datacenter', 'size', 'username', 'password', 'server'])

        for nas_account in nas_accounts:
            table.add_row([
                nas_account['id'],
                utils.lookup(nas_account, 'serviceResource', 'datacenter',
                             'name') or formatting.blank(),
                formatting.FormattedItem(
                    nas_account.get('capacityGb', formatting.blank()),
                    "%dGB" % nas_account.get('capacityGb', 0)),
                nas_account.get('username', formatting.blank()),
                nas_account.get('password', formatting.blank()),
                nas_account.get('serviceResourceBackendIpAddress',
                                formatting.blank())
            ])

        return table
Esempio n. 22
0
def cli(env, identifier):
    """Get billing for a hardware device."""
    hardware = SoftLayer.HardwareManager(env.client)

    hardware_id = helpers.resolve_id(hardware.resolve_ids, identifier,
                                     'hardware')
    result = hardware.get_hardware(hardware_id)
    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['Id', identifier])

    table.add_row(
        ['Billing Item Id',
         utils.lookup(result, 'billingItem', 'id')])
    table.add_row(
        ['Recurring Fee',
         utils.lookup(result, 'billingItem', 'recurringFee')])
    table.add_row([
        'Total',
        utils.lookup(result, 'billingItem', 'nextInvoiceTotalRecurringAmount')
    ])
    table.add_row([
        'Provision Date',
        utils.lookup(result, 'billingItem', 'provisionDate')
    ])

    price_table = formatting.Table(['Item', 'Recurring Price'])
    for item in utils.lookup(result, 'billingItem',
                             'nextInvoiceChildren') or []:
        price_table.add_row(
            [item['description'], item['nextInvoiceTotalRecurringAmount']])

    table.add_row(['prices', price_table])
    env.fout(table)
Esempio n. 23
0
def generate_l7policies_table(l7policies, identifier):
    """Takes a list of Layer7 policies and makes a table"""
    table = formatting.Table(
        [
            'Id', 'UUID', 'Name', 'Action', 'Redirect', 'Priority',
            'Create Date'
        ],
        title=f"Layer7 policies - protocol ID {identifier}")

    table.align['Name'] = 'l'
    table.align['Action'] = 'l'
    table.align['Redirect'] = 'l'
    for l7policy in sorted(l7policies, key=lambda data: data.get('priority')):
        table.add_row([
            l7policy.get('id'),
            l7policy.get('uuid'),
            l7policy.get('name'),
            l7policy.get('action'),
            l7policy.get('redirectL7PoolId') or l7policy.get('redirectUrl')
            or formatting.blank(),
            l7policy.get('priority'),
            l7policy.get('createDate'),
        ])
    return table
Esempio n. 24
0
def cli(env, identifier):
    """Lists the Virtual Guests running on this server."""

    mgr = SoftLayer.HardwareManager(env.client)
    hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
    hw_guests = mgr.get_hardware_guests(hw_id)

    if not hw_guests:
        raise exceptions.CLIAbort("No Virtual Guests found.")

    table = formatting.Table([
        'id', 'hostname', 'CPU', 'Memory', 'Start Date', 'Status', 'powerState'
    ])
    table.sortby = 'hostname'
    for guest in hw_guests:
        table.add_row([
            guest['id'], guest['hostname'],
            '%i %s' % (guest['maxCpu'], guest['maxCpuUnits']),
            guest['maxMemory'],
            utils.clean_time(guest['createDate']), guest['status']['keyName'],
            guest['powerState']['keyName']
        ])

    env.fout(table)
Esempio n. 25
0
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag):
    """List hardware servers."""

    manager = SoftLayer.HardwareManager(env.client)

    servers = manager.list_hardware(hostname=hostname,
                                    domain=domain,
                                    cpus=cpu,
                                    memory=memory,
                                    datacenter=datacenter,
                                    nic_speed=network,
                                    tags=tag)

    table = formatting.Table([
        'id', 'datacenter', 'host', 'cores', 'memory', 'primary_ip',
        'backend_ip', 'active_transaction', 'owner'
    ])
    table.sortby = sortby

    for server in servers:
        server = utils.NestedDict(server)

        table.add_row([
            server['id'],
            server['datacenter']['name'] or formatting.blank(),
            server['fullyQualifiedDomainName'],
            server['processorPhysicalCoreAmount'],
            formatting.gb(server['memoryCapacity'] or 0),
            server['primaryIpAddress'] or formatting.blank(),
            server['primaryBackendIpAddress'] or formatting.blank(),
            formatting.active_txn(server),
            utils.lookup(server, 'billingItem', 'orderItem', 'order',
                         'userRecord', 'username') or formatting.blank(),
        ])

    return table
Esempio n. 26
0
def cli(env):
    """List all active quotes on an account"""
    table = formatting.Table([
        'Id', 'Name', 'Created', 'Expiration', 'Status', 'Package Name', 'Package Id'
    ])
    table.align['Name'] = 'l'
    table.align['Package Name'] = 'r'
    table.align['Package Id'] = 'l'

    manager = ordering.OrderingManager(env.client)
    items = manager.get_quotes()

    for item in items:
        package = item['order']['items'][0]['package']
        table.add_row([
            item.get('id'),
            item.get('name'),
            clean_time(item.get('createDate')),
            clean_time(item.get('modifyDate')),
            item.get('status'),
            package.get('keyName'),
            package.get('id')
        ])
    env.fout(table)
Esempio n. 27
0
def cli(env, sortby, datacenter, number, name):
    """List VLANs."""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table(COLUMNS)
    table.sortby = sortby

    vlans = mgr.list_vlans(datacenter=datacenter,
                           vlan_number=number,
                           name=name)
    for vlan in vlans:
        table.add_row([
            vlan['id'],
            vlan['vlanNumber'],
            vlan.get('name') or formatting.blank(),
            'Yes' if vlan['firewallInterfaces'] else 'No',
            utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
            vlan['hardwareCount'],
            vlan['virtualGuestCount'],
            vlan['totalPrimaryIpAddressCount'],
        ])

    env.fout(table)
Esempio n. 28
0
def cli(env, is_open):
    """List tickets."""
    ticket_mgr = SoftLayer.TicketManager(env.client)
    table = formatting.Table([
        'id', 'assigned_user', 'title', 'last_edited', 'status', 'updates', 'priority'
    ])

    tickets = ticket_mgr.list_tickets(open_status=is_open, closed_status=not is_open)
    for ticket in tickets:
        user = formatting.blank()
        if ticket.get('assignedUser'):
            user = "******" % (ticket['assignedUser']['firstName'], ticket['assignedUser']['lastName'])

        table.add_row([
            ticket['id'],
            user,
            click.wrap_text(ticket['title']),
            ticket['lastEditDate'],
            ticket['status']['name'],
            ticket.get('updateCount', 0),
            ticket.get('priority', 0)
        ])

    env.fout(table)
Esempio n. 29
0
def cli(env, identifier, columns):
    """Reserved Capacity Group details. Will show which guests are assigned to a reservation."""

    manager = CapacityManager(env.client)
    mask = """mask[instances[id,createDate,guestId,billingItem[id, description, recurringFee, category[name]],
              guest[modifyDate,id, primaryBackendIpAddress, primaryIpAddress,domain, hostname]]]"""
    result = manager.get_object(identifier, mask)

    try:
        flavor = result['instances'][0]['billingItem']['description']
    except KeyError:
        flavor = "Pending Approval..."

    table = formatting.Table(columns.columns,
                             title="%s - %s" % (result.get('name'), flavor))
    # RCI = Reserved Capacity Instance
    for rci in result['instances']:
        guest = rci.get('guest', None)
        if guest is not None:
            table.add_row(
                [value or formatting.blank() for value in columns.row(guest)])
        else:
            table.add_row(['-' for value in columns.columns])
    env.fout(table)
Esempio n. 30
0
    def execute(self, args):
        mgr = SoftLayer.NetworkManager(self.client)

        table = formatting.Table([
            'id', 'identifier', 'type', 'datacenter', 'vlan id', 'IPs',
            'hardware', 'vs',
        ])
        table.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:
            table.add_row([
                subnet['id'],
                '%s/%s' % (subnet['networkIdentifier'], str(subnet['cidr'])),
                subnet.get('subnetType', formatting.blank()),
                utils.lookup(subnet, 'datacenter', 'name',)
                or formatting.blank(),
                subnet['networkVlanId'],
                subnet['ipAddressCount'],
                len(subnet['hardware']),
                len(subnet['virtualGuests']),
            ])

        return table