当前位置: 首页>>代码示例>>Python>>正文


Python Table.add_row方法代码示例

本文整理汇总了Python中SoftLayer.CLI.Table.add_row方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_row方法的具体用法?Python Table.add_row怎么用?Python Table.add_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SoftLayer.CLI.Table的用法示例。


在下文中一共展示了Table.add_row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(client, args):
        f = FirewallManager(client)
        fwvlans = f.get_firewalls()
        t = Table(['vlan', 'type', 'features'])

        dedicatedfws = filter(lambda x: x['dedicatedFirewallFlag'], fwvlans)
        for vlan in dedicatedfws:
            features = []
            if vlan['highAvailabilityFirewallFlag']:
                features.append('HA')

            if features:
                feature_list = listing(features, separator=',')
            else:
                feature_list = blank()

            t.add_row([
                vlan['vlanNumber'],
                'dedicated',
                feature_list,
            ])

        shared_vlan = filter(lambda x: not x['dedicatedFirewallFlag'], fwvlans)
        for vlan in shared_vlan:
            t.add_row([vlan['vlanNumber'], 'standard', blank()])

        return t
开发者ID:loles,项目名称:softlayer-api-python-client,代码行数:29,代码来源:firewall.py

示例2: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        iscsi_mgr = ISCSIManager(self.client)
        table = KeyValueTable(['Name', 'Value'])
        table.align['Name'] = 'r'
        table.align['Value'] = 'l'

        iscsi_id = resolve_id(
            iscsi_mgr.resolve_ids,
            args.get('<identifier>'),
            'iSCSI')
        result = iscsi_mgr.get_iscsi(iscsi_id)
        result = NestedDict(result)

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

        return table
开发者ID:MayaY2014,项目名称:softlayer-python,代码行数:37,代码来源:iscsi.py

示例3: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(client, args):
        account = client['Account']

        neither = not any([args['--private'], args['--public']])

        results = []
        if args['--private'] or neither:
            account = client['Account']
            mask = 'id,accountId,name,globalIdentifier,blockDevices,parentId'
            r = account.getPrivateBlockDeviceTemplateGroups(mask=mask)

            results.append(r)

        if args['--public'] or neither:
            vgbd = client['Virtual_Guest_Block_Device_Template_Group']
            r = vgbd.getPublicImages()

            results.append(r)

        t = Table(['id', 'account', 'type', 'name', 'guid', ])
        t.sortby = 'name'

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

        return t
开发者ID:hugomatic,项目名称:softlayer-api-python-client,代码行数:36,代码来源:image.py

示例4: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(client, args):
        mgr = NetworkManager(client)

        version = 4
        if args.get('--v6'):
            version = 6
        if not args.get('--test') and not args['--really']:
            if not confirm("This action will incur charges on your account."
                           "Continue?"):
                raise CLIAbort('Cancelling order.')
        result = mgr.add_global_ip(version=version,
                                   test_order=args.get('--test'))
        if not result:
            return 'Unable to place order: No valid price IDs found.'
        t = Table(['Item', 'cost'])
        t.align['Item'] = 'r'
        t.align['cost'] = 'r'

        total = 0.0
        for price in result['orderDetails']['prices']:
            total += float(price.get('recurringFee', 0.0))
            rate = "%.2f" % float(price['recurringFee'])

            t.add_row([price['item']['description'], rate])

        t.add_row(['Total monthly cost', "%.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 guarenteed.')
        )
        return t
开发者ID:loles,项目名称:softlayer-api-python-client,代码行数:36,代码来源:globalip.py

示例5: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        ticket_mgr = TicketManager(self.client)

        tickets = ticket_mgr.list_tickets(
            open_status=not args.get('--closed'),
            closed_status=args.get('--closed'))

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

        for ticket in tickets:
            if ticket['assignedUser']:
                table.add_row([
                    ticket['id'],
                    "%s %s" % (ticket['assignedUser']['firstName'],
                               ticket['assignedUser']['lastName']),
                    wrap_string(ticket['title']),
                    ticket['createDate'],
                    ticket['lastEditDate']
                ])
            else:
                table.add_row([
                    ticket['id'],
                    'N/A',
                    wrap_string(ticket['title']),
                    ticket['createDate'],
                    ticket['lastEditDate']
                ])

        return table
开发者ID:MayaY2014,项目名称:softlayer-python,代码行数:32,代码来源:ticket.py

示例6: list_zone

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def list_zone(client, zone, args):
        manager = DNSManager(client)
        t = Table([
            "record",
            "type",
            "ttl",
            "value",
        ])

        t.align['ttl'] = 'l'
        t.align['record'] = 'r'
        t.align['value'] = 'l'

        zone_id = resolve_id(manager.resolve_ids, args['<zone>'], name='zone')

        try:
            records = manager.get_records(
                zone_id,
                type=args.get('--type'),
                host=args.get('--record'),
                ttl=args.get('--ttl'),
                data=args.get('--data'),
            )
        except DNSZoneNotFound:
            raise CLIAbort("No zone found matching: %s" % args['<zone>'])

        for rr in records:
            t.add_row([
                rr['host'],
                rr['type'].upper(),
                rr['ttl'],
                rr['data']
            ])

        return t
开发者ID:loles,项目名称:softlayer-api-python-client,代码行数:37,代码来源:dns.py

示例7: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        mgr = NetworkManager(self.client)

        t = Table([
            'id', 'identifier', 'type', 'datacenter', 'vlan id', 'IPs',
            'hardware', 'ccis',
        ])
        t.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:
            t.add_row([
                subnet['id'],
                subnet['networkIdentifier'] + '/' + str(subnet['cidr']),
                subnet.get('subnetType', '-'),
                subnet['datacenter']['name'],
                subnet['networkVlanId'],
                subnet['ipAddressCount'],
                len(subnet['hardware']),
                len(subnet['virtualGuests']),
            ])

        return t
开发者ID:crvidya,项目名称:softlayer-api-python-client,代码行数:37,代码来源:subnet.py

示例8: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(client, args):
        account = client["Account"]

        neither = not any([args["--private"], args["--public"]])

        result = []
        if args["--private"] or neither:
            account = client["Account"]
            private = "privateBlockDeviceTemplateGroups"
            mask = private + "[id,accountId,name,globalIdentifier,blockDevices,parentId]"

            result += account.getObject(mask=mask)[private]

        if args["--public"] or neither:
            vgbd = client["Virtual_Guest_Block_Device_Template_Group"]
            result += vgbd.getPublicImages()

        t = Table(["id", "account", "type", "name", "guid"])
        t.sortby = "name"

        images = filter(lambda x: x["parentId"] == "", result)
        for image in images:
            t.add_row(
                [
                    image["id"],
                    image.get("accountId", "-"),
                    image.get("type", "-"),
                    image["name"].strip(),
                    image.get("globalIdentifier", "-"),
                ]
            )

        return t
开发者ID:quiteliderally,项目名称:softlayer-api-python-client,代码行数:35,代码来源:image.py

示例9: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(client, args):
        account = client['Account']

        iscsi = account.getIscsiNetworkStorage(
            mask='eventCount,serviceResource[datacenter.name]')
        iscsi = [NestedDict(n) for n in iscsi]

        t = Table([
            'id',
            'datacenter',
            'size',
            'username',
            'password',
            'server'
        ])

        for n in iscsi:
            t.add_row([
                n['id'],
                n['serviceResource']['datacenter'].get('name', blank()),
                FormattedItem(
                    n.get('capacityGb', blank()),
                    "%dGB" % n.get('capacityGb', 0)),
                n.get('username', blank()),
                n.get('password', blank()),
                n.get('serviceResourceBackendIpAddress', blank())])

        return t
开发者ID:hugomatic,项目名称:softlayer-api-python-client,代码行数:30,代码来源:iscsi.py

示例10: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    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
开发者ID:anil-kumbhar,项目名称:softlayer-python,代码行数:32,代码来源:image.py

示例11: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        table = KeyValueTable(['Name', 'Value'])
        table.align['Name'] = 'r'
        table.align['Value'] = 'l'

        show_all = True
        for opt_name in self.options:
            if args.get("--" + opt_name):
                show_all = False
                break

        mgr = HardwareManager(self.client)

        bmi_options = mgr.get_bare_metal_create_options()

        if args['--all']:
            show_all = True

        if args['--datacenter'] or show_all:
            results = self.get_create_options(bmi_options, 'datacenter')[0]

            table.add_row([results[0], listing(sorted(results[1]))])

        if args['--cpu'] or args['--memory'] or show_all:
            results = self.get_create_options(bmi_options, 'cpu')
            memory_cpu_table = Table(['memory', 'cpu'])
            for result in results:
                memory_cpu_table.add_row([
                    result[0],
                    listing(
                        [item[0] for item in sorted(
                            result[1], key=lambda x: int(x[0])
                        )])])
            table.add_row(['memory/cpu', memory_cpu_table])

        if args['--os'] or show_all:
            results = self.get_create_options(bmi_options, 'os')

            for result in results:
                table.add_row([
                    result[0],
                    listing(
                        [item[0] for item in sorted(result[1])],
                        separator=linesep
                    )])

        if args['--disk'] or show_all:
            results = self.get_create_options(bmi_options, 'disk')[0]

            table.add_row([results[0], listing(
                [item[0] for item in sorted(results[1])])])

        if args['--nic'] or show_all:
            results = self.get_create_options(bmi_options, 'nic')

            for result in results:
                table.add_row([result[0], listing(
                    [item[0] for item in sorted(result[1],)])])

        return table
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:62,代码来源:bmc.py

示例12: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        mgr = NetworkManager(self.client)

        version = 4
        if args.get('--v6'):
            version = 6
        if not args.get('--test') and not args['--really']:
            if not confirm("This action will incur charges on your account."
                           "Continue?"):
                raise CLIAbort('Cancelling order.')
        result = mgr.add_global_ip(version=version,
                                   test_order=args.get('--test'))
        if not result:
            return 'Unable to place order: No valid price IDs found.'
        table = Table(['Item', 'cost'])
        table.align['Item'] = 'r'
        table.align['cost'] = 'r'

        total = 0.0
        for price in result['orderDetails']['prices']:
            total += float(price.get('recurringFee', 0.0))
            rate = "%.2f" % float(price['recurringFee'])

            table.add_row([price['item']['description'], rate])

        table.add_row(['Total monthly cost', "%.2f" % total])
        return table
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:29,代码来源:globalip.py

示例13: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        account = self.client['Account']

        iscsi_list = account.getIscsiNetworkStorage(
            mask='eventCount,serviceResource[datacenter.name]')
        iscsi_list = [NestedDict(iscsi) for iscsi in iscsi_list]

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

        for iscsi in iscsi_list:
            table.add_row([
                iscsi['id'],
                iscsi['serviceResource']['datacenter'].get('name', blank()),
                FormattedItem(
                    iscsi.get('capacityGb', blank()),
                    "%dGB" % iscsi.get('capacityGb', 0)),
                iscsi.get('username', blank()),
                iscsi.get('password', blank()),
                iscsi.get('serviceResourceBackendIpAddress', blank())])

        return table
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:30,代码来源:iscsi.py

示例14: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    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
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:30,代码来源:vlan.py

示例15: execute

# 需要导入模块: from SoftLayer.CLI import Table [as 别名]
# 或者: from SoftLayer.CLI.Table import add_row [as 别名]
    def execute(self, args):
        mgr = FirewallManager(self.client)
        fwvlans = mgr.get_firewalls()
        table = Table(['vlan', 'type', 'features'])

        dedicatedfws = [vlan['dedicatedFirewallFlag'] for vlan in fwvlans]
        for vlan in dedicatedfws:
            features = []
            if vlan['highAvailabilityFirewallFlag']:
                features.append('HA')

            if features:
                feature_list = listing(features, separator=',')
            else:
                feature_list = blank()

            table.add_row([
                vlan['vlanNumber'],
                'dedicated',
                feature_list,
            ])

        shared_vlan = [vlan['dedicatedFirewallFlag'] for vlan in fwvlans]
        for vlan in shared_vlan:
            table.add_row([vlan['vlanNumber'], 'standard', blank()])

        return table
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:29,代码来源:firewall.py


注:本文中的SoftLayer.CLI.Table.add_row方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。