本文整理汇总了Python中SoftLayer.NetworkManager.get_subnet方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_subnet方法的具体用法?Python NetworkManager.get_subnet怎么用?Python NetworkManager.get_subnet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.get_subnet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 别名]
def execute(self, args):
mgr = NetworkManager(self.client)
subnet_id = resolve_id(mgr.resolve_subnet_ids,
args.get('<identifier>'),
name='subnet')
subnet = mgr.get_subnet(subnet_id)
table = KeyValueTable(['Name', 'Value'])
table.align['Name'] = 'r'
table.align['Value'] = 'l'
table.add_row(['id', subnet['id']])
table.add_row(['identifier',
'%s/%s' % (subnet['networkIdentifier'],
str(subnet['cidr']))])
table.add_row(['subnet type', subnet['subnetType']])
table.add_row(['gateway', subnet.get('gateway', blank())])
table.add_row(['broadcast', subnet.get('broadcastAddress', blank())])
table.add_row(['datacenter', subnet['datacenter']['name']])
table.add_row(['usable ips',
subnet.get('usableIpAddressCount', blank())])
if not args.get('--no-cci'):
if subnet['virtualGuests']:
cci_table = Table(['Hostname', 'Domain', 'IP'])
cci_table.align['Hostname'] = 'r'
cci_table.align['IP'] = 'l'
for cci in subnet['virtualGuests']:
cci_table.add_row([cci['hostname'],
cci['domain'],
cci.get('primaryIpAddress')])
table.add_row(['ccis', cci_table])
else:
table.add_row(['cci', 'none'])
if not args.get('--no-hardware'):
if subnet['hardware']:
hw_table = Table(['Hostname', 'Domain', 'IP'])
hw_table.align['Hostname'] = 'r'
hw_table.align['IP'] = 'l'
for hardware in subnet['hardware']:
hw_table.add_row([hardware['hostname'],
hardware['domain'],
hardware.get('primaryIpAddress')])
table.add_row(['hardware', hw_table])
else:
table.add_row(['hardware', 'none'])
return table
示例2: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 别名]
#.........这里部分代码省略.........
"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)
def test_get_rwhois(self):
self.network.get_rwhois()
self.client["Account"].getRwhoisData.assert_called()
def test_get_subnet(self):
id = 9876
mcall = call(id=id, mask=ANY)
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)
示例3: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 别名]
#.........这里部分代码省略.........
'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)
def test_get_rwhois(self):
self.network.get_rwhois()
self.client['Account'].getRwhoisData.assert_called()
def test_get_subnet(self):
id = 9876
mcall = call(id=id, mask=ANY)
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 = '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},
}
示例4: NetworkTests
# 需要导入模块: from SoftLayer import NetworkManager [as 别名]
# 或者: from SoftLayer.NetworkManager import get_subnet [as 别名]
#.........这里部分代码省略.........
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',
'firstName': 'Bob',
'lastName': 'Bobinson',
'postalCode': '9ba62',
'privateResidenceFlag': False,
'state': 'TX',
}
f = self.client['Network_Subnet_Rwhois_Data'].editObject
f.assert_called_with(expected, id='id')
def test_get_rwhois(self):
self.network.get_rwhois()
self.client['Account'].getRwhoisData.assert_called()
def test_get_subnet(self):
mcall = call(id=9876, mask=ANY)
service = self.client['Network_Subnet']
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},
}
}
}
}