本文整理汇总了Python中SoftLayer.NetworkManager.list_subnets方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.list_subnets方法的具体用法?Python NetworkManager.list_subnets怎么用?Python NetworkManager.list_subnets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.list_subnets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_subnets [as 别名]
def execute(self, args):
mgr = NetworkManager(self.client)
t = Table([
'id', 'identifier', 'type', 'datacenter', 'vlan id', 'IPs',
'hardware', 'ccis',
])
t.sortby = args.get('--sortby') or 'id'
version = 0
if args.get('--v4'):
version = 4
elif args.get('--v6'):
version = 6
subnets = mgr.list_subnets(
datacenter=args.get('--datacenter'),
version=version,
identifier=args.get('--identifier'),
subnet_type=args.get('--type'),
)
for subnet in subnets:
t.add_row([
subnet['id'],
subnet['networkIdentifier'] + '/' + str(subnet['cidr']),
subnet.get('subnetType', '-'),
subnet['datacenter']['name'],
subnet['networkVlanId'],
subnet['ipAddressCount'],
len(subnet['hardware']),
len(subnet['virtualGuests']),
])
return t
示例2: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_subnets [as 别名]
#.........这里部分代码省略.........
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)
service.getGlobalIpRecords.assert_has_calls(mcall)
def test_list_subnets_default(self):
_filter = {"subnets": {"subnetType": {"operation": "!= GLOBAL_IP"}}}
mask = "hardware,datacenter,ipAddressCount,virtualGuests"
mcall = call(filter=_filter, mask=mask)
service = self.client["Account"]
self.network.list_subnets()
service.getSubnets.assert_has_calls(mcall)
def test_list_subnets_with_filters(self):
identifier = "10.0.0.1"
datacenter = "dal00"
subnet_type = "PRIMARY"
version = 4
service = self.client["Account"]
service.getSubnets.return_value = [
{
"id": 100,
"networkIdentifier": "10.0.0.1",
"datacenter": {"name": "dal00"},
"version": 4,
"subnetType": "PRIMARY",
}
]
result = self.network.list_subnets(
identifier=identifier, datacenter=datacenter, subnet_type=subnet_type, version=version
)
_filter = {
"subnets": {
示例3: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_subnets [as 别名]
#.........这里部分代码省略.........
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},
}
}
}
}
mcall = call(filter=_filter, mask=mask)
service = self.client['Account']
self.network.list_global_ips(version=4)
service.getGlobalIpRecords.assert_has_calls(mcall)
def test_list_subnets_default(self):
_filter = {'subnets': {'subnetType': {'operation': 'not null'}}}
mask = 'mask[hardware,datacenter,ipAddressCount,virtualGuests]'
mcall = call(filter=_filter,
mask=mask)
service = self.client['Account']
self.network.list_subnets()
service.getSubnets.assert_has_calls(mcall)
def test_list_subnets_with_filters(self):
identifier = '10.0.0.1'
datacenter = 'dal00'
subnet_type = 'PRIMARY'
version = 4
service = self.client['Account']
service.getSubnets.return_value = [
{
'id': 100,
'networkIdentifier': '10.0.0.1',
'datacenter': {'name': 'dal00'},
'version': 4,
'subnetType': 'PRIMARY',
},
]
result = self.network.list_subnets(
identifier=identifier,
datacenter=datacenter,
subnet_type=subnet_type,
version=version,
示例4: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import list_subnets [as 别名]
#.........这里部分代码省略.........
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},
}
}
}
}
service = self.client['Account']
service.getGlobalIpRecords.assert_has_calls(call(filter=_filter,
mask=mask))
def test_list_subnets_default(self):
_filter = {'subnets': {'subnetType': {'operation': '!= GLOBAL_IP'}}}
mask = 'hardware,datacenter,ipAddressCount,virtualGuests'
service = self.client['Account']
self.network.list_subnets()
service.getSubnets.assert_has_calls(call(filter=_filter, mask=mask))
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)