本文整理汇总了Python中SoftLayer.NetworkManager.unassign_global_ip方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.unassign_global_ip方法的具体用法?Python NetworkManager.unassign_global_ip怎么用?Python NetworkManager.unassign_global_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.unassign_global_ip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import unassign_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.unassign_global_ip(id)
示例2: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import unassign_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.unassign_global_ip(global_ip_id)
示例3: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import unassign_global_ip [as 别名]
#.........这里部分代码省略.........
'id': '200',
'ipAddress': {
'subnet': {
'networkIdentifier': '10.0.0.1',
},
},
},
], []]
_id = self.network.resolve_global_ip_ids('10.0.0.1')
self.assertEqual(_id, '200')
_id = self.network.resolve_global_ip_ids('nope')
self.assertEqual(_id, None)
def test_resolve_subnet_ids(self):
service = self.client['Account']
service.getSubnets.side_effect = [[
{
'id': '100',
'networkIdentifier': '10.0.0.1',
'datacenter': {'name': 'dal00'},
'version': 4,
'subnetType': 'PRIMARY'
},
], []]
_id = self.network.resolve_subnet_ids('10.0.0.1/29')
self.assertEqual(_id, '100')
_id = self.network.resolve_subnet_ids('nope')
self.assertEqual(_id, None)
def test_unassign_global_ip(self):
id = 9876
self.network.unassign_global_ip(id)
service = self.client['Network_Subnet_IpAddress_Global']
service.unroute.assert_called_with(id=id)
def _setup_add_subnet_mocks(self):
package_mock = self.client['Product_Package']
package_mock.getItems.return_value = [
{
'id': 4440,
'capacity': '4',
'description': '4 Portable Public IP Addresses',
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_pub'},
'prices': [{'id': 4444}],
},
{
'id': 8880,
'capacity': '8',
'description': '8 Portable Public IP Addresses',
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_pub'},
'prices': [{'id': 8888}],
},
{
'id': 44400,
'capacity': '4',
'description': '4 Portable Private IP Addresses',
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_priv'},
'prices': [{'id': 44441}],
},
{
示例4: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import unassign_global_ip [as 别名]
#.........这里部分代码省略.........
}
}
mask = "hardware,datacenter,ipAddressCount,virtualGuests"
service.getSubnets.assert_called_with(filter=_filter, mask=mask)
self.assertEqual([service.getSubnets.return_value[0]], result)
def test_list_vlans_default(self):
mcall = call(filter={}, mask=ANY)
service = self.client["Account"]
self.network.list_vlans()
service.getNetworkVlans.assert_has_calls(mcall)
def test_list_vlans_with_filters(self):
self.network.list_vlans(vlan_number=5, datacenter="dal00", name="primary-vlan")
service = self.client["Account"]
service.getNetworkVlans.assert_has_calls(
call(
filter={
"networkVlans": {
"primaryRouter": {"datacenter": {"name": {"operation": "_= dal00"}}},
"vlanNumber": {"operation": 5},
"name": {"operation": "_= primary-vlan"},
}
},
mask=ANY,
)
)
def test_summary_by_datacenter(self):
mcall = call(mask=ANY, filter=ANY)
service = self.client["Account"]
service.getNetworkVlans.return_value = [
{
"name": "dal00",
"hardware": [{"id": 1}],
"networkComponents": [{"id": 2}],
"primaryRouter": {"datacenter": {"name": "dal00"}},
"totalPrimaryIpAddressCount": 3,
"subnets": [],
"virtualGuests": [{"id": 3}],
}
]
expected = {
"dal00": {
"hardwareCount": 1,
"networkingCount": 1,
"primaryIpCount": 3,
"subnetCount": 0,
"virtualGuestCount": 1,
"vlanCount": 1,
}
}
result = self.network.summary_by_datacenter()
service.getNetworkVlans.assert_has_calls(mcall)
self.assertEqual(expected, result)
def test_resolve_global_ip_ids(self):
service = self.client["Account"]
_id = self.network.resolve_global_ip_ids("10.0.0.1")
self.assertEqual(_id, ["200"])
service.getGlobalIpRecords.return_value = []
_id = self.network.resolve_global_ip_ids("nope")
self.assertEqual(_id, [])
def test_resolve_subnet_ids(self):
service = self.client["Account"]
_id = self.network.resolve_subnet_ids("10.0.0.1/29")
self.assertEqual(_id, ["100"])
service.getSubnets.return_value = []
_id = self.network.resolve_subnet_ids("nope")
self.assertEqual(_id, [])
def test_resolve_vlan_ids(self):
service = self.client["Account"]
service.getNetworkVlans.side_effect = [[{"id": "100"}], []]
_id = self.network.resolve_vlan_ids("vlan_name")
self.assertEqual(_id, ["100"])
_id = self.network.resolve_vlan_ids("nope")
self.assertEqual(_id, [])
def test_unassign_global_ip(self):
id = 9876
self.network.unassign_global_ip(id)
service = self.client["Network_Subnet_IpAddress_Global"]
service.unroute.assert_called_with(id=id)
示例5: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import unassign_global_ip [as 别名]
#.........这里部分代码省略.........
def test_list_subnets_with_filters(self):
result = self.network.list_subnets(
identifier='10.0.0.1',
datacenter='dal00',
subnet_type='PRIMARY',
version=4,
)
_filter = {
'subnets': {
'datacenter': {
'name': {'operation': '_= dal00'}
},
'version': {'operation': 4},
'subnetType': {'operation': '_= PRIMARY'},
'networkIdentifier': {'operation': '_= 10.0.0.1'}
}
}
mask = 'hardware,datacenter,ipAddressCount,virtualGuests'
self.client['Account'].getSubnets.assert_called_with(filter=_filter,
mask=mask)
self.assertEqual(self.client['Account'].getSubnets.return_value,
result)
def test_list_vlans_default(self):
service = self.client['Account']
self.network.list_vlans()
service.getNetworkVlans.assert_has_calls(call(filter={}, mask=ANY))
def test_list_vlans_with_filters(self):
self.network.list_vlans(
vlan_number=5,
datacenter='dal00',
name='primary-vlan',
)
service = self.client['Account']
service.getNetworkVlans.assert_has_calls(call(
filter={
'networkVlans': {
'primaryRouter': {
'datacenter': {
'name': {'operation': '_= dal00'}},
},
'vlanNumber': {'operation': 5},
'name': {'operation': '_= primary-vlan'},
},
},
mask=ANY
))
def test_summary_by_datacenter(self):
result = self.network.summary_by_datacenter()
expected = {
'dal00': {
'hardwareCount': 1,
'networkingCount': 1,
'primaryIpCount': 3,
'subnetCount': 0,
'virtualGuestCount': 1,
'vlanCount': 1
}}
self.assertEqual(expected, result)
def test_resolve_global_ip_ids(self):
service = self.client['Account']
_id = self.network.resolve_global_ip_ids('10.0.0.1')
self.assertEqual(_id, ['200'])
service.getGlobalIpRecords.return_value = []
_id = self.network.resolve_global_ip_ids('nope')
self.assertEqual(_id, [])
def test_resolve_subnet_ids(self):
service = self.client['Account']
_id = self.network.resolve_subnet_ids('10.0.0.1/29')
self.assertEqual(_id, ['100'])
service.getSubnets.return_value = []
_id = self.network.resolve_subnet_ids('nope')
self.assertEqual(_id, [])
def test_resolve_vlan_ids(self):
service = self.client['Account']
service.getNetworkVlans.side_effect = [[{'id': '100'}], []]
_id = self.network.resolve_vlan_ids('vlan_name')
self.assertEqual(_id, ['100'])
_id = self.network.resolve_vlan_ids('nope')
self.assertEqual(_id, [])
def test_unassign_global_ip(self):
self.network.unassign_global_ip(9876)
service = self.client['Network_Subnet_IpAddress_Global']
service.unroute.assert_called_with(id=9876)