"""List block storage volumes.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import storage_utils COLUMNS = [ column_helper.Column('id', ('id', ), mask="id"), column_helper.Column('username', ('username', ), mask="username"), column_helper.Column('datacenter', ('serviceResource', 'datacenter', 'name'), mask="serviceResource.datacenter.name"), column_helper.Column( 'storage_type', lambda b: b['storageType']['keyName'].split('_').pop(0) if 'storageType' in b and 'keyName' in b['storageType'] and isinstance( b['storageType']['keyName'], str) else '-', mask="storageType.keyName"), column_helper.Column('capacity_gb', ('capacityGb', ), mask="capacityGb"), column_helper.Column('bytes_used', ('bytesUsed', ), mask="bytesUsed"), column_helper.Column('IOPs', ('provisionedIops', ), mask="provisionedIops"), column_helper.Column('ip_addr', ('serviceResourceBackendIpAddress', ), mask="serviceResourceBackendIpAddress"), column_helper.Column('lunId', ('lunId', ), mask="lunId"), column_helper.Column('active_transactions', ('activeTransactionCount', ), mask="activeTransactionCount"), column_helper.Column('rep_partner_count', ('replicationPartnerCount', ),
"""List dedicated servers.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting from SoftLayer.CLI import helpers COLUMNS = [ column_helper.Column('datacenter', ('datacenter', 'name')), column_helper.Column( 'created_by', ('billingItem', 'orderItem', 'order', 'userRecord', 'username')), column_helper.Column( 'tags', lambda server: formatting.tags(server.get('tagReferences')), mask="tagReferences.tag.name"), ] DEFAULT_COLUMNS = [ 'id', 'name', 'cpuCount', 'diskCapacity', 'memoryCapacity', 'datacenter', 'guestCount', ]
name = "{0} ({1})".format(name, obj['note']) return name elif obj['type'] == 'IP': name = obj['ipAddress'] if 'note' in obj.keys(): name = "{0} ({1})".format(name, obj['note']) return name else: raise Exception('Unknown type %s' % obj['type']) COLUMNS = [ column_helper.Column('id', ('id', )), column_helper.Column( 'name', _format_name, """ allowedVirtualGuests[hostname,domain], allowedHardware[hostname,domain], allowedSubnets[networkIdentifier,cidr,note], allowedIpAddresses[ipAddress,note], """), column_helper.Column('type', ('type', )), column_helper.Column( 'private_ip_address', ('primaryBackendIpAddress', ), """ allowedVirtualGuests.primaryBackendIpAddress allowedHardware.primaryBackendIpAddress allowedSubnets.primaryBackendIpAddress allowedIpAddresses.primaryBackendIpAddress """),
"""List virtual servers.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting from SoftLayer.CLI import helpers # pylint: disable=unnecessary-lambda COLUMNS = [ column_helper.Column('guid', ('globalIdentifier', )), column_helper.Column('primary_ip', ('primaryIpAddress', )), column_helper.Column('backend_ip', ('primaryBackendIpAddress', )), column_helper.Column('datacenter', ('datacenter', 'name')), column_helper.Column('action', lambda guest: formatting.active_txn(guest), mask=''' activeTransaction[ id,transactionStatus[name,friendlyName] ]'''), column_helper.Column('power_state', ('powerState', 'name')), column_helper.Column( 'created_by', ('billingItem', 'orderItem', 'order', 'userRecord', 'username')), column_helper.Column( 'tags', lambda server: formatting.tags(server.get('tagReferences')),
"""List guests which are in a dedicated host server.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting from SoftLayer.CLI import helpers COLUMNS = [ column_helper.Column('guid', ('globalIdentifier', )), column_helper.Column('cpu', ('maxCpu', )), column_helper.Column('memory', ('maxMemory', )), column_helper.Column('datacenter', ('datacenter', 'name')), column_helper.Column('primary_ip', ('primaryIpAddress', )), column_helper.Column('backend_ip', ('primaryBackendIpAddress', )), column_helper.Column( 'created_by', ('billingItem', 'orderItem', 'order', 'userRecord', 'username')), column_helper.Column('power_state', ('powerState', 'name')), column_helper.Column( 'tags', lambda server: formatting.tags(server.get('tagReferences')), mask="tagReferences.tag.name"), ] DEFAULT_COLUMNS = [ 'id', 'hostname', 'domain', 'primary_ip', 'backend_ip', 'power_state' ]
"""List file storage snapshots.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting from SoftLayer.CLI import helpers COLUMNS = [ column_helper.Column('id', ('id',), mask='id'), column_helper.Column('name', ('notes',), mask='notes'), column_helper.Column('created', ('snapshotCreationTimestamp',), mask='snapshotCreationTimestamp'), column_helper.Column('size_bytes', ('snapshotSizeBytes',), mask='snapshotSizeBytes'), ] DEFAULT_COLUMNS = [ 'id', 'name', 'created', 'size_bytes' ] @click.command(cls=SoftLayer.CLI.command.SLCommand, ) @click.argument('volume_id') @click.option('--sortby', help='Column to sort by', default='created')
"""List Users.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting TWO_FACTO_AUTH = 'externalBindingCount' CLASSIC_API_KEYS = 'apiAuthenticationKeyCount' COLUMNS = [ column_helper.Column('id', ('id', )), column_helper.Column('username', ('username', )), column_helper.Column('email', ('email', )), column_helper.Column('displayName', ('displayName', )), column_helper.Column('status', ('userStatus', 'name')), column_helper.Column('hardwareCount', ('hardwareCount', )), column_helper.Column('virtualGuestCount', ('virtualGuestCount', )), column_helper.Column('2FA', (TWO_FACTO_AUTH, )), column_helper.Column('classicAPIKey', (CLASSIC_API_KEYS, )) ] DEFAULT_COLUMNS = [ 'id', 'username', 'email', 'displayName', '2FA',
"""List block storage volumes.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('id', ('id', ), mask="id"), column_helper.Column('username', ('username', ), mask="username"), column_helper.Column('datacenter', ('serviceResource', 'datacenter', 'name'), mask="serviceResource.datacenter.name"), column_helper.Column( 'storage_type', lambda b: b['storageType']['keyName'].split('_').pop(0), mask="storageType.keyName"), column_helper.Column('capacity_gb', ('capacityGb', ), mask="capacityGb"), column_helper.Column('bytes_used', ('bytesUsed', ), mask="bytesUsed"), column_helper.Column('ip_addr', ('serviceResourceBackendIpAddress', ), mask="serviceResourceBackendIpAddress"), ] DEFAULT_COLUMNS = [ 'id', 'username', 'datacenter', 'storage_type', 'capacity_gb', 'bytes_used', 'ip_addr' ]
"""List Users.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('id', ('id', )), column_helper.Column('username', ('username', )), column_helper.Column('email', ('email', )), column_helper.Column('displayName', ('displayName', )), column_helper.Column('status', ('userStatus', 'name')), column_helper.Column('hardwareCount', ('hardwareCount', )), column_helper.Column('virtualGuestCount', ('virtualGuestCount', )) ] DEFAULT_COLUMNS = ['id', 'username', 'email', 'displayName'] @click.command() @click.option('--columns', callback=column_helper.get_formatter(COLUMNS), help='Columns to display. [options: %s]' % ', '.join(column.name for column in COLUMNS), default=','.join(DEFAULT_COLUMNS), show_default=True) @environment.pass_env
"""List suitable replication datacenters for the given volume.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('ID', ('id', ), mask="id"), column_helper.Column('Long Name', ('longName', ), mask="longName"), column_helper.Column('Short Name', ('name', ), mask="name"), ] DEFAULT_COLUMNS = [ 'ID', 'Long Name', 'Short Name', ] @click.command() @click.argument('volume-id') @click.option('--sortby', help='Column to sort by', default='Long Name') @click.option('--columns', callback=column_helper.get_formatter(COLUMNS), help='Columns to display. Options: {0}'.format(', '.join( column.name for column in COLUMNS)), default=','.join(DEFAULT_COLUMNS)) @environment.pass_env
"""Shows the details of a reserved capacity group""" import click from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI.command import SLCommand as SLCommand from SoftLayer.CLI import environment from SoftLayer.CLI import formatting from SoftLayer.managers.vs_capacity import CapacityManager as CapacityManager COLUMNS = [ column_helper.Column('Id', ('id', )), column_helper.Column('hostname', ('hostname', )), column_helper.Column('domain', ('domain', )), column_helper.Column('primary_ip', ('primaryIpAddress', )), column_helper.Column('backend_ip', ('primaryBackendIpAddress', )), ] DEFAULT_COLUMNS = ['id', 'hostname', 'domain', 'primary_ip', 'backend_ip'] @click.command( cls=SLCommand, epilog= "Once provisioned, virtual guests can be managed with the slcli vs commands" ) @click.argument('identifier') @click.option('--columns', callback=column_helper.get_formatter(COLUMNS), help='Columns to display. [options: %s]' % ', '.join(column.name for column in COLUMNS),
"""List existing replicant volumes for a block volume.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('ID', ('id', )), column_helper.Column('Username', ('username', ), mask="username"), column_helper.Column('Account ID', ('accountId', ), mask="accountId"), column_helper.Column('Capacity (GB)', ('capacityGb', ), mask="capacityGb"), column_helper.Column('Hardware ID', ('hardwareId', ), mask="hardwareId"), column_helper.Column('Guest ID', ('guestId', ), mask="guestId"), column_helper.Column('Host ID', ('hostId', ), mask="hostId"), ] DEFAULT_COLUMNS = [ 'ID', 'Username', 'Account ID', 'Capacity (GB)', 'Hardware ID', 'Guest ID', 'Host ID' ] @click.command() @click.argument('volume-id') @click.option('--sortby', help='Column to sort by', default='Username') @click.option('--columns', callback=column_helper.get_formatter(COLUMNS), help='Columns to display. Options: {0}'.format(', '.join(
"""List file storage volumes.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('id', ('id', ), mask="id"), column_helper.Column('username', ('username', ), mask="username"), column_helper.Column('datacenter', ('serviceResource', 'datacenter', 'name'), mask="serviceResource.datacenter.name"), column_helper.Column( 'storage_type', lambda b: b['storageType']['keyName'].split('_').pop(0) if 'storageType' in b and 'keyName' in b['storageType'] and isinstance( b['storageType']['keyName'], str) else '-', mask="storageType.keyName"), column_helper.Column('capacity_gb', ('capacityGb', ), mask="capacityGb"), column_helper.Column('bytes_used', ('bytesUsed', ), mask="bytesUsed"), column_helper.Column('ip_addr', ('serviceResourceBackendIpAddress', ), mask="serviceResourceBackendIpAddress"), column_helper.Column('active_transactions', ('activeTransactionCount', ), mask="activeTransactionCount"), column_helper.Column( 'mount_addr', ('fileNetworkMountAddress', ), mask="fileNetworkMountAddress",
"""List Users.""" # :license: MIT, see LICENSE for more details. import click import SoftLayer from SoftLayer.CLI import columns as column_helper from SoftLayer.CLI import environment from SoftLayer.CLI import formatting COLUMNS = [ column_helper.Column('id', ('id', )), column_helper.Column('username', ('username', )), column_helper.Column('email', ('email', )), column_helper.Column('displayName', ('displayName', )), column_helper.Column('status', ('userStatus', 'name')), column_helper.Column('hardwareCount', ('hardwareCount', )), column_helper.Column('virtualGuestCount', ('virtualGuestCount', )), column_helper.Column('2FAs', ('externalBindingCount', )), column_helper.Column('classicAPIKeys', ('apiAuthenticationKeyCount', )) ] DEFAULT_COLUMNS = ['id', 'username', 'email', 'displayName'] @click.command() @click.option('--columns', callback=column_helper.get_formatter(COLUMNS), help='Columns to display. [options: %s]' % ', '.join(column.name for column in COLUMNS), default=','.join(DEFAULT_COLUMNS),