本文整理汇总了Python中SoftLayer.NetworkManager.cancel_subnet方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.cancel_subnet方法的具体用法?Python NetworkManager.cancel_subnet怎么用?Python NetworkManager.cancel_subnet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.cancel_subnet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import cancel_subnet [as 别名]
def execute(self, args):
mgr = NetworkManager(self.client)
subnet_id = mgr.resolve_subnet_ids(args.get('<identifier>'))
if args['--really'] or no_going_back(subnet_id):
mgr.cancel_subnet(subnet_id)
else:
CLIAbort('Aborted')
示例2: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import cancel_subnet [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)
#.........这里部分代码省略.........
示例3: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import cancel_subnet [as 别名]
#.........这里部分代码省略.........
'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)
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',
示例4: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import cancel_subnet [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',
#.........这里部分代码省略.........