コード例 #1
0
    def execute(self, args):
        image_mgr = ImageManager(self.client)

        neither = not any([args['--private'], args['--public']])
        mask = 'id,accountId,name,globalIdentifier,blockDevices,parentId'

        images = []
        if args['--private'] or neither:
            for image in image_mgr.list_private_images(mask=mask):
                image['visibility'] = 'private'
                images.append(image)

        if args['--public'] or neither:
            for image in image_mgr.list_public_images(mask=mask):
                image['visibility'] = 'public'
                images.append(image)

        t = Table(['id', 'account', 'visibility', 'name', 'global_identifier'])

        images = filter(lambda x: x['parentId'] == '', images)
        for image in images:
            t.add_row([
                image['id'],
                image.get('accountId', blank()),
                image['visibility'],
                image['name'].strip(),
                image.get('globalIdentifier', blank()),
            ])

        return t
コード例 #2
0
    def execute(self, args):
        mgr = NetworkManager(self.client)

        table = Table([
            'id', 'number', 'datacenter', 'name', 'IPs', 'hardware', 'ccis',
            'networking', 'firewall'
        ])
        table.sortby = args.get('--sortby') or 'id'

        vlans = mgr.list_vlans(
            datacenter=args.get('--datacenter'),
            vlan_number=args.get('--number'),
            name=args.get('--name'),
        )
        for vlan in vlans:
            table.add_row([
                vlan['id'],
                vlan['vlanNumber'],
                vlan['primaryRouter']['datacenter']['name'],
                vlan.get('name') or blank(),
                vlan['totalPrimaryIpAddressCount'],
                len(vlan['hardware']),
                len(vlan['virtualGuests']),
                len(vlan['networkComponents']),
                'Yes' if vlan['firewallInterfaces'] else 'No',
            ])

        return table
コード例 #3
0
    def execute(self, args):
        image_mgr = ImageManager(self.client)
        image_id = resolve_id(image_mgr.resolve_ids,
                              args.get('<identifier>'),
                              'image')

        image = image_mgr.get_image(image_id)

        t = KeyValueTable(['Name', 'Value'])
        t.align['Name'] = 'r'
        t.align['Value'] = 'l'

        t.add_row(['id', image['id']])
        t.add_row(['account', image.get('accountId', blank())])
        t.add_row(['name', image['name'].strip()])
        t.add_row(['global_identifier',
                   image.get('globalIdentifier', blank())])

        return t
コード例 #4
0
ファイル: cdn.py プロジェクト: MayaY2014/softlayer-python
    def execute(self, args):
        manager = CDNManager(self.client)
        origins = manager.get_origins(args.get('<account>'))

        table = Table(['id', 'media_type', 'cname', 'origin_url'])

        for origin in origins:
            table.add_row([origin['id'],
                           origin['mediaType'],
                           origin.get('cname', blank()),
                           origin['originUrl']])

        return table
コード例 #5
0
ファイル: cdn.py プロジェクト: MayaY2014/softlayer-python
    def execute(self, args):
        manager = CDNManager(self.client)
        account = manager.get_account(args.get('<account>'))

        table = KeyValueTable(['Name', 'Value'])
        table.align['Name'] = 'r'
        table.align['Value'] = 'l'

        table.add_row(['id', account['id']])
        table.add_row(['account_name', account['cdnAccountName']])
        table.add_row(['type', account['cdnSolutionName']])
        table.add_row(['status', account['status']['name']])
        table.add_row(['created', account['createDate']])
        table.add_row(['notes', account.get('cdnAccountNote', blank())])

        return table
コード例 #6
0
ファイル: cdn.py プロジェクト: MayaY2014/softlayer-python
    def execute(self, args):
        manager = CDNManager(self.client)
        accounts = manager.list_accounts()

        table = Table(['id', 'account_name', 'type', 'created', 'notes'])
        for account in accounts:
            table.add_row([
                account['id'],
                account['cdnAccountName'],
                account['cdnSolutionName'],
                account['createDate'],
                account.get('cdnAccountNote', blank())
            ])

        table.sortby = args['--sortby']
        return table