本文整理汇总了Python中SoftLayer.NetworkManager.add_global_ip方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.add_global_ip方法的具体用法?Python NetworkManager.add_global_ip怎么用?Python NetworkManager.add_global_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.add_global_ip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import add_global_ip [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
示例2: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import add_global_ip [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
示例3: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import add_global_ip [as 别名]
class NetworkTests(unittest.TestCase):
def setUp(self):
self.client = MagicMock()
self.network = NetworkManager(self.client)
def test_ip_lookup(self):
ip = '10.0.1.37'
mcall = call(ip, mask=ANY)
service = self.client['Network_Subnet_IpAddress']
self.network.ip_lookup(ip)
service.getByIpAddress.assert_has_calls(mcall)
def test_add_subnet_returns_none_on_failure(self):
self._setup_add_subnet_mocks()
self.assertEqual(None, self.network.add_subnet('bad'))
def test_add_global_ip(self):
self._setup_add_subnet_mocks()
# Test a global IPv4 order
expected = {'packageId': 0,
'prices': [{
'categories': [{
'categoryCode': 'global_ipv4'}],
'id': 11,
'item': {'capacity': '0',
'description': 'Global IPv4',
'id': 10},
'itemId': 10,
'recurringFee': '0'}]}
result = self.network.add_global_ip(test_order=True)
self.assertEqual(expected, result)
def test_add_subnet_for_ipv4(self):
self._setup_add_subnet_mocks()
# Test a four public address IPv4 order
expected = {'packageId': 0,
'prices': [{
'categories': [{
'categoryCode': 'sov_sec_ip_addresses_pub'}],
'id': 4444,
'item': {
'capacity': '4',
'description': '4 Portable Public IP Addresses',
'id': 4440},
'itemId': 4440,
'recurringFee': '0'}]}
result = self.network.add_subnet('public',
quantity=4,
vlan_id=1234,
version=4,
test_order=True)
self.assertEqual(expected, result)
# Test a global IPv4 order
expected = {'packageId': 0,
'prices': [{
'categories': [{
'categoryCode': 'global_ipv4'}],
'id': 11,
'item': {'capacity': '0',
'description': 'Global IPv4',
'id': 10},
'itemId': 10,
'recurringFee': '0'}]}
result = self.network.add_subnet('global',
test_order=True)
self.assertEqual(expected, result)
def test_add_subnet_for_ipv6(self):
self._setup_add_subnet_mocks()
# Test a public IPv6 order
expected = {
'packageId': 0,
'prices': [{
'categories': [{'categoryCode': 'static_ipv6_addresses'}],
'id': 664641,
'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)
#.........这里部分代码省略.........
示例4: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import add_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)
#.........这里部分代码省略.........
示例5: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import add_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',
#.........这里部分代码省略.........