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


Python NetworkManager.assign_global_ip方法代碼示例

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


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

示例1: execute

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import assign_global_ip [as 別名]
    def execute(client, args):
        mgr = NetworkManager(client)

        id = mgr.resolve_global_ip_ids(args.get('<identifier>'))
        if not id:
            raise CLIAbort("Unable to find global IP record for " +
                           args['<identifier>'])
        mgr.assign_global_ip(id, args['<target>'])
開發者ID:loles,項目名稱:softlayer-api-python-client,代碼行數:10,代碼來源:globalip.py

示例2: execute

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import assign_global_ip [as 別名]
 def execute(self, args):
     mgr = NetworkManager(self.client)
     global_ip_id = resolve_id(mgr.resolve_global_ip_ids,
                               args.get('<identifier>'),
                               name='global ip')
     if not global_ip_id:
         raise CLIAbort("Unable to find global IP record for " +
                        args['<identifier>'])
     mgr.assign_global_ip(global_ip_id, args['<target>'])
開發者ID:TimurNurlygayanov,項目名稱:softlayer-python,代碼行數:11,代碼來源:globalip.py

示例3: NetworkTests

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

#.........這裏部分代碼省略.........
                'item': {
                    'capacity': '64',
                    'description': '/64 Block Portable Public IPv6 Addresses',
                    'id': 66464},
                'itemId': 66464,
                'recurringFee': '0'}]}

        result = self.network.add_subnet('public',
                                         quantity=64,
                                         vlan_id=45678,
                                         version=6,
                                         test_order=True)

        self.assertEqual(expected, result)

        # Test a global IPv6 order
        expected = {'packageId': 0,
                    'prices': [{
                        'categories': [{
                            'categoryCode': 'global_ipv6'}],
                        'id': 611,
                        'item': {'capacity': '0',
                                 'description': 'Global IPv6',
                                 'id': 610},
                        'itemId': 610,
                        'recurringFee': '0'}]}

        result = self.network.add_subnet('global',
                                         version=6,
                                         test_order=True)

        self.assertEqual(expected, result)

    def test_assign_global_ip(self):
        id = 9876
        target = '172.16.24.76'

        self.network.assign_global_ip(id, target)

        service = self.client['Network_Subnet_IpAddress_Global']
        service.route.assert_called_with(target, id=id)

    def test_cancel_global_ip(self):
        id = 9876
        mcall = call(id=1056)
        service = self.client['Billing_Item']

        self.client['Network_Subnet'].getObject.return_value = {
            'id': id,
            'billingItem': {'id': 1056}
        }
        self.network.cancel_global_ip(id)
        service.cancelService.assert_has_calls(mcall)

    def test_cancel_subnet(self):
        id = 9876
        mcall = call(id=1056)
        service = self.client['Billing_Item']

        self.client['Network_Subnet'].getObject.return_value = {
            'id': id,
            'billingItem': {'id': 1056}
        }
        self.network.cancel_subnet(id)
        service.cancelService.assert_has_calls(mcall)
開發者ID:crvidya,項目名稱:softlayer-api-python-client,代碼行數:69,代碼來源:network_tests.py

示例4: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import assign_global_ip [as 別名]
class NetworkTests(unittest.TestCase):
    def setUp(self):
        self.client = FixtureClient()
        self.network = NetworkManager(self.client)

    def test_ip_lookup(self):
        service = self.client["Network_Subnet_IpAddress"]

        self.network.ip_lookup("10.0.1.37")
        service.getByIpAddress.assert_called_with("10.0.1.37", mask=ANY)

    def test_add_subnet_raises_exception_on_failure(self):
        self.assertRaises(TypeError, self.network.add_subnet, ("bad"))

    def test_add_global_ip(self):
        # Test a global IPv4 order
        result = self.network.add_global_ip(test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_add_subnet_for_ipv4(self):
        # Test a four public address IPv4 order
        result = self.network.add_subnet("public", quantity=4, vlan_id=1234, version=4, test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

        result = self.network.add_subnet("public", quantity=4, vlan_id=1234, version=4, test_order=False)

        self.assertEqual(Product_Order.verifyOrder, result)

        result = self.network.add_subnet("global", test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_add_subnet_for_ipv6(self):
        # Test a public IPv6 order
        result = self.network.add_subnet("public", quantity=64, vlan_id=45678, version=6, test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

        # Test a global IPv6 order
        result = self.network.add_subnet("global", version=6, test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_assign_global_ip(self):
        id = 9876
        target = "172.16.24.76"

        self.network.assign_global_ip(id, target)

        service = self.client["Network_Subnet_IpAddress_Global"]
        service.route.assert_called_with(target, id=id)

    def test_cancel_global_ip(self):
        service = self.client["Billing_Item"]

        self.network.cancel_global_ip(1234)
        service.cancelService.assert_called_with(id=1234)

    def test_cancel_subnet(self):
        service = self.client["Billing_Item"]

        self.network.cancel_subnet(1234)
        service.cancelService.assert_called_with(id=1056)

    def test_edit_rwhois(self):
        self.client["Account"].getRwhoisData.return_value = {"id": 954}

        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",
        }

        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)

#.........這裏部分代碼省略.........
開發者ID:ryanrhanson,項目名稱:softlayer-python,代碼行數:103,代碼來源:network_tests.py

示例5: NetworkTests

# 需要導入模塊: from SoftLayer import NetworkManager [as 別名]
# 或者: from SoftLayer.NetworkManager import assign_global_ip [as 別名]
class NetworkTests(unittest.TestCase):

    def setUp(self):
        self.client = FixtureClient()
        self.network = NetworkManager(self.client)

    def test_ip_lookup(self):
        service = self.client['Network_Subnet_IpAddress']

        self.network.ip_lookup('10.0.1.37')
        service.getByIpAddress.assert_called_with('10.0.1.37', mask=ANY)

    def test_add_subnet_raises_exception_on_failure(self):
        self.assertRaises(TypeError, self.network.add_subnet, ('bad'))

    def test_add_global_ip(self):
        # Test a global IPv4 order
        result = self.network.add_global_ip(test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_add_subnet_for_ipv4(self):
        # Test a four public address IPv4 order
        result = self.network.add_subnet('public',
                                         quantity=4,
                                         vlan_id=1234,
                                         version=4,
                                         test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

        result = self.network.add_subnet('public',
                                         quantity=4,
                                         vlan_id=1234,
                                         version=4,
                                         test_order=False)

        self.assertEqual(Product_Order.verifyOrder, result)

        result = self.network.add_subnet('global',
                                         test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_add_subnet_for_ipv6(self):
        # Test a public IPv6 order
        result = self.network.add_subnet('public',
                                         quantity=64,
                                         vlan_id=45678,
                                         version=6,
                                         test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

        # Test a global IPv6 order
        result = self.network.add_subnet('global',
                                         version=6,
                                         test_order=True)

        self.assertEqual(Product_Order.verifyOrder, result)

    def test_assign_global_ip(self):
        self.network.assign_global_ip(9876, '172.16.24.76')

        service = self.client['Network_Subnet_IpAddress_Global']
        service.route.assert_called_with('172.16.24.76', id=9876)

    def test_cancel_global_ip(self):
        self.network.cancel_global_ip(1234)

        service = self.client['Billing_Item']
        service.cancelService.assert_called_with(id=1234)

    def test_cancel_subnet(self):
        self.network.cancel_subnet(1234)

        service = self.client['Billing_Item']
        service.cancelService.assert_called_with(id=1056)

    def test_edit_rwhois(self):
        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',
#.........這裏部分代碼省略.........
開發者ID:MayaY2014,項目名稱:softlayer-python,代碼行數:103,代碼來源:network_tests.py


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