當前位置: 首頁>>代碼示例>>Python>>正文


Python NetworkManager.get_subnet方法代碼示例

本文整理匯總了Python中SoftLayer.NetworkManager.get_subnet方法的典型用法代碼示例。如果您正苦於以下問題:Python NetworkManager.get_subnet方法的具體用法?Python NetworkManager.get_subnet怎麽用?Python NetworkManager.get_subnet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SoftLayer.NetworkManager的用法示例。


在下文中一共展示了NetworkManager.get_subnet方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 別名]
    def execute(self, args):
        mgr = NetworkManager(self.client)
        subnet_id = resolve_id(mgr.resolve_subnet_ids,
                               args.get('<identifier>'),
                               name='subnet')
        subnet = mgr.get_subnet(subnet_id)

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

        table.add_row(['id', subnet['id']])
        table.add_row(['identifier',
                       '%s/%s' % (subnet['networkIdentifier'],
                                  str(subnet['cidr']))])
        table.add_row(['subnet type', subnet['subnetType']])
        table.add_row(['gateway', subnet.get('gateway', blank())])
        table.add_row(['broadcast', subnet.get('broadcastAddress', blank())])
        table.add_row(['datacenter', subnet['datacenter']['name']])
        table.add_row(['usable ips',
                       subnet.get('usableIpAddressCount', blank())])

        if not args.get('--no-cci'):
            if subnet['virtualGuests']:
                cci_table = Table(['Hostname', 'Domain', 'IP'])
                cci_table.align['Hostname'] = 'r'
                cci_table.align['IP'] = 'l'
                for cci in subnet['virtualGuests']:
                    cci_table.add_row([cci['hostname'],
                                       cci['domain'],
                                       cci.get('primaryIpAddress')])
                table.add_row(['ccis', cci_table])
            else:
                table.add_row(['cci', 'none'])

        if not args.get('--no-hardware'):
            if subnet['hardware']:
                hw_table = Table(['Hostname', 'Domain', 'IP'])
                hw_table.align['Hostname'] = 'r'
                hw_table.align['IP'] = 'l'
                for hardware in subnet['hardware']:
                    hw_table.add_row([hardware['hostname'],
                                      hardware['domain'],
                                      hardware.get('primaryIpAddress')])
                table.add_row(['hardware', hw_table])
            else:
                table.add_row(['hardware', 'none'])

        return table
開發者ID:TimurNurlygayanov,項目名稱:softlayer-python,代碼行數:51,代碼來源:subnet.py

示例2: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 別名]

#.........這裏部分代碼省略.........
            "address1": "123 Test Street",
            "address2": "Apt. #31",
            "city": "Anywhere",
            "companyName": "TestLayer",
            "country": "US",
            "firstName": "Bob",
            "lastName": "Bobinson",
            "postalCode": "9ba62",
            "privateResidenceFlag": False,
            "state": "TX",
        }

        self.network.edit_rwhois(
            abuse_email="[email protected]",
            address1="123 Test Street",
            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 = "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)
開發者ID:ryanrhanson,項目名稱:softlayer-python,代碼行數:70,代碼來源:network_tests.py

示例3: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 別名]

#.........這裏部分代碼省略.........
            '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',
        }

        self.network.edit_rwhois(
            abuse_email='[email protected]',
            address1='123 Test Street',
            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},
                    }
開發者ID:crvidya,項目名稱:softlayer-api-python-client,代碼行數:70,代碼來源:network_tests.py

示例4: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 別名]

#.........這裏部分代碼省略.........
        self.network.edit_rwhois(
            abuse_email='[email protected]',
            address1='123 Test Street',
            address2='Apt. #31',
            city='Anywhere',
            company_name='TestLayer',
            country='US',
            first_name='Bob',
            last_name='Bobinson',
            postal_code='9ba62',
            private_residence=False,
            state='TX')

        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},
                    }
                }
            }
        }
開發者ID:MayaY2014,項目名稱:softlayer-python,代碼行數:70,代碼來源:network_tests.py


注:本文中的SoftLayer.NetworkManager.get_subnet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。