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


Python NetworkManager.list_global_ips方法代码示例

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


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

示例1: execute

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

        t = Table([
            'id', 'ip', 'assigned', 'target'
        ])
        t.sortby = args.get('--sortby') or 'id'

        version = 0
        if args.get('--v4'):
            version = 4
        elif args.get('--v6'):
            version = 6

        ips = mgr.list_global_ips(version=version)

        for ip in ips:
            assigned = 'No'
            target = 'None'
            if ip.get('destinationIpAddress'):
                dest = ip['destinationIpAddress']
                assigned = 'Yes'
                target = dest['ipAddress']
                if dest.get('virtualGuest'):
                    vg = dest['virtualGuest']
                    target += ' (' + vg['fullyQualifiedDomainName'] + ')'
                elif ip['destinationIpAddress'].get('hardware'):
                    target += ' (' + \
                              dest['hardware']['fullyQualifiedDomainName'] + \
                              ')'

            t.add_row([ip['id'], ip['ipAddress']['ipAddress'], assigned,
                       target])
        return t
开发者ID:loles,项目名称:softlayer-api-python-client,代码行数:36,代码来源:globalip.py

示例2: execute

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

        table = Table([
            'id', 'ip', 'assigned', 'target'
        ])
        table.sortby = args.get('--sortby') or 'id'

        version = 0
        if args.get('--v4'):
            version = 4
        elif args.get('--v6'):
            version = 6

        ips = mgr.list_global_ips(version=version)

        for ip_address in ips:
            assigned = 'No'
            target = 'None'
            if ip_address.get('destinationIpAddress'):
                dest = ip_address['destinationIpAddress']
                assigned = 'Yes'
                target = dest['ipAddress']
                virtual_guest = dest.get('virtualGuest')
                if virtual_guest:
                    target += (' (%s)'
                               % virtual_guest['fullyQualifiedDomainName'])
                elif ip_address['destinationIpAddress'].get('hardware'):
                    target += ' (' + \
                              dest['hardware']['fullyQualifiedDomainName'] + \
                              ')'

            table.add_row([ip_address['id'],
                           ip_address['ipAddress']['ipAddress'],
                           assigned,
                           target])
        return table
开发者ID:TimurNurlygayanov,项目名称:softlayer-python,代码行数:39,代码来源:globalip.py

示例3: NetworkTests

# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_global_ips [as 别名]

#.........这里部分代码省略.........
            address2='Apt. #31',
            city='Anywhere',
            company_name='TestLayer',
            country='US',
            first_name='Bob',
            last_name='Bobinson',
            postal_code='9ba62',
            private_residence=False,
            state='TX')

        f = self.client['Network_Subnet_Rwhois_Data'].editObject
        f.assert_called_with(expected, id=954)

    def test_get_rwhois(self):
        self.network.get_rwhois()
        self.client['Account'].getRwhoisData.assert_called()

    def test_get_subnet(self):
        id = 9876
        mcall = call(id=id, mask=ANY)
        service = self.client['Network_Subnet']

        self.network.get_subnet(id)
        service.getObject.assert_has_calls(mcall)

    def test_get_vlan(self):
        id = 1234
        mcall = call(id=id, mask=ANY)
        service = self.client['Network_Vlan']

        self.network.get_vlan(id)
        service.getObject.assert_has_calls(mcall)

    def test_list_global_ips_default(self):
        mask = 'mask[destinationIpAddress[hardware, virtualGuest],ipAddress]'
        mcall = call(filter={}, mask=mask)
        service = self.client['Account']

        self.network.list_global_ips()

        service.getGlobalIpRecords.assert_has_calls(mcall)

    def test_list_global_ips_with_filter(self):
        mask = 'mask[destinationIpAddress[hardware, virtualGuest],ipAddress]'
        _filter = {
            'globalIpRecords': {
                'ipAddress': {
                    'subnet': {
                        'version': {'operation': 4},
                    }
                }
            }
        }

        mcall = call(filter=_filter, mask=mask)
        service = self.client['Account']

        self.network.list_global_ips(version=4)

        service.getGlobalIpRecords.assert_has_calls(mcall)

    def test_list_subnets_default(self):
        _filter = {'subnets': {'subnetType': {'operation': 'not null'}}}
        mask = 'mask[hardware,datacenter,ipAddressCount,virtualGuests]'
        mcall = call(filter=_filter,
                     mask=mask)
开发者ID:crvidya,项目名称:softlayer-api-python-client,代码行数:70,代码来源:network_tests.py

示例4: NetworkTests

# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_global_ips [as 别名]

#.........这里部分代码省略.........
            city="Anywhere",
            company_name="TestLayer",
            country="US",
            first_name="Bob",
            last_name="Bobinson",
            postal_code="9ba62",
            private_residence=False,
            state="TX",
        )

        f = self.client["Network_Subnet_Rwhois_Data"].editObject
        f.assert_called_with(expected, id=954)

    def test_get_rwhois(self):
        self.network.get_rwhois()
        self.client["Account"].getRwhoisData.assert_called()

    def test_get_subnet(self):
        id = 9876
        mcall = call(id=id, mask=ANY)
        service = self.client["Network_Subnet"]

        self.network.get_subnet(id)
        service.getObject.assert_has_calls(mcall)

    def test_get_vlan(self):
        id = 1234
        mcall = call(id=id, mask=ANY)
        service = self.client["Network_Vlan"]

        self.network.get_vlan(id)
        service.getObject.assert_has_calls(mcall)

    def test_list_global_ips_default(self):
        mask = "destinationIpAddress[hardware, virtualGuest],ipAddress"
        mcall = call(filter={}, mask=mask)
        service = self.client["Account"]

        self.network.list_global_ips()

        service.getGlobalIpRecords.assert_has_calls(mcall)

    def test_list_global_ips_with_filter(self):
        mask = "destinationIpAddress[hardware, virtualGuest],ipAddress"
        _filter = {"globalIpRecords": {"ipAddress": {"subnet": {"version": {"operation": 4}}}}}

        mcall = call(filter=_filter, mask=mask)
        service = self.client["Account"]

        self.network.list_global_ips(version=4)

        service.getGlobalIpRecords.assert_has_calls(mcall)

    def test_list_subnets_default(self):
        _filter = {"subnets": {"subnetType": {"operation": "!= GLOBAL_IP"}}}
        mask = "hardware,datacenter,ipAddressCount,virtualGuests"
        mcall = call(filter=_filter, mask=mask)
        service = self.client["Account"]

        self.network.list_subnets()

        service.getSubnets.assert_has_calls(mcall)

    def test_list_subnets_with_filters(self):
        identifier = "10.0.0.1"
        datacenter = "dal00"
开发者ID:ryanrhanson,项目名称:softlayer-python,代码行数:70,代码来源:network_tests.py

示例5: NetworkTests

# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_global_ips [as 别名]

#.........这里部分代码省略.........
        expected = {
            'abuseEmail': '[email protected]',
            'address1': '123 Test Street',
            'address2': 'Apt. #31',
            'city': 'Anywhere',
            'companyName': 'TestLayer',
            'country': 'US',
            'firstName': 'Bob',
            'lastName': 'Bobinson',
            'postalCode': '9ba62',
            'privateResidenceFlag': False,
            'state': 'TX',
        }
        f = self.client['Network_Subnet_Rwhois_Data'].editObject
        f.assert_called_with(expected, id='id')

    def test_get_rwhois(self):
        self.network.get_rwhois()
        self.client['Account'].getRwhoisData.assert_called()

    def test_get_subnet(self):
        mcall = call(id=9876, mask=ANY)
        service = self.client['Network_Subnet']

        self.network.get_subnet(9876)
        service.getObject.assert_has_calls(mcall)

    def test_get_vlan(self):
        service = self.client['Network_Vlan']

        self.network.get_vlan(1234)
        service.getObject.assert_has_calls(call(id=1234, mask=ANY))

    def test_list_global_ips_default(self):
        self.network.list_global_ips()

        mask = 'destinationIpAddress[hardware, virtualGuest],ipAddress'
        service = self.client['Account']
        service.getGlobalIpRecords.assert_has_calls(call(filter={}, mask=mask))

    def test_list_global_ips_with_filter(self):
        self.network.list_global_ips(version=4)

        mask = 'destinationIpAddress[hardware, virtualGuest],ipAddress'
        _filter = {
            'globalIpRecords': {
                'ipAddress': {
                    'subnet': {
                        'version': {'operation': 4},
                    }
                }
            }
        }
        service = self.client['Account']
        service.getGlobalIpRecords.assert_has_calls(call(filter=_filter,
                                                         mask=mask))

    def test_list_subnets_default(self):
        _filter = {'subnets': {'subnetType': {'operation': '!= GLOBAL_IP'}}}
        mask = 'hardware,datacenter,ipAddressCount,virtualGuests'
        service = self.client['Account']

        self.network.list_subnets()

        service.getSubnets.assert_has_calls(call(filter=_filter, mask=mask))
开发者ID:MayaY2014,项目名称:softlayer-python,代码行数:69,代码来源:network_tests.py


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