本文整理汇总了Python中SoftLayer.DNSManager.list_zones方法的典型用法代码示例。如果您正苦于以下问题:Python DNSManager.list_zones方法的具体用法?Python DNSManager.list_zones怎么用?Python DNSManager.list_zones使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.DNSManager
的用法示例。
在下文中一共展示了DNSManager.list_zones方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_get
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import list_zones [as 别名]
def on_get(self, req, resp, tenant_id):
client = req.env['sl_client']
mgr = DNSManager(client)
results = []
for zone in mgr.list_zones():
results.append({
'project': None,
'scope': 'public',
'domain': zone['name'],
'availability_zone': None,
})
resp.body = {'domain_entries': results}
示例2: list_all_zones
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import list_zones [as 别名]
def list_all_zones(self):
manager = DNSManager(self.client)
zones = manager.list_zones()
t = Table([
"id",
"zone",
"serial",
"updated",
])
t.align['serial'] = 'c'
t.align['updated'] = 'c'
for z in zones:
t.add_row([
z['id'],
z['name'],
z['serial'],
z['updateDate'],
])
return t
示例3: list_all_zones
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import list_zones [as 别名]
def list_all_zones(self):
""" List all zones """
manager = DNSManager(self.client)
zones = manager.list_zones()
table = Table([
"id",
"zone",
"serial",
"updated",
])
table.align['serial'] = 'c'
table.align['updated'] = 'c'
for zone in zones:
table.add_row([
zone['id'],
zone['name'],
zone['serial'],
zone['updateDate'],
])
return table
示例4: DNSTests
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import list_zones [as 别名]
class DNSTests(unittest.TestCase):
def setUp(self):
self.client = MagicMock()
self.dns_client = DNSManager(self.client)
def test_init_exercise(self):
self.assertTrue(hasattr(self.dns_client, 'service'))
self.assertTrue(hasattr(self.dns_client, 'record'))
def test_list_zones(self):
zone_list = ['test']
self.client['Account'].getDomains.return_value = zone_list
zones = self.dns_client.list_zones()
self.assertEqual(zones, zone_list)
def test_get_zone(self):
zone_list = [
{'id': 98765, 'name': 'test-example.com'},
{'id': 12345, 'name': 'example.com', "resourceRecords": ["test"]},
]
# match, with defaults
self.client['Account'].getObject.return_value = zone_list[1]
res = self.dns_client.get_zone(12345)
self.assertEqual(res, zone_list[1])
self.client['Account'].getObject.assert_called_once_with(
id=12345,
mask='resourceRecords')
# No records masked in
self.client['Account'].getObject.reset_mock()
self.client['Account'].getObject.return_value = [zone_list[1]]
self.dns_client.get_zone(12345, records=False)
self.client['Account'].getObject.assert_called_once_with(
id=12345,
mask=None)
def test_resolve_zone_name(self):
zone_list = [{'name': 'example.com', 'id': 12345}]
# matching domain
self.client['Account'].getDomains.return_value = zone_list
res = self.dns_client._get_zone_id_from_name('example.com')
self.assertEqual([12345], res)
self.client['Account'].getDomains.assert_called_once_with(
filter={"domains": {"name": {"operation": "_= example.com"}}})
# no matches
self.client['Account'].getDomains.reset_mock()
self.client['Account'].getDomains.return_value = []
res = self.dns_client._get_zone_id_from_name('example.com')
self.assertEqual([], res)
self.client['Account'].getDomains.assert_called_once_with(
filter={"domains": {"name": {"operation": "_= example.com"}}})
def test_create_zone(self):
call = self.client['Dns_Domain'].createObject
call.return_value = {'name': 'example.com'}
res = self.dns_client.create_zone('example.com')
call.assert_called_once_with({
'name': 'example.com', "resourceRecords": {}, "serial": ANY
})
self.assertEqual(res, {'name': 'example.com'})
def test_delete_zone(self):
self.dns_client.delete_zone(1)
self.client['Dns_Domain'].deleteObject.assert_called_once_with(id=1)
def test_edit_zone(self):
self.dns_client.edit_zone('example.com')
self.client['Dns_Domain'].editObject.assert_called_once_with(
'example.com')
def test_create_record(self):
self.dns_client.create_record(1, 'test', 'TXT', 'testing', ttl=1200)
f = self.client['Dns_Domain_ResourceRecord'].createObject
f.assert_called_once_with(
{
'domainId': 1,
'ttl': 1200,
'host': 'test',
'type': 'TXT',
'data': 'testing'
})
def test_delete_record(self):
self.dns_client.delete_record(1)
f = self.client['Dns_Domain_ResourceRecord'].deleteObject
f.assert_called_once_with(id=1)
def test_edit_record(self):
self.dns_client.edit_record({'id': 1, 'name': 'test', 'ttl': '1800'})
f = self.client['Dns_Domain_ResourceRecord'].editObject
f.assert_called_once_with(
{'id': 1, 'name': 'test', 'ttl': '1800'},
id=1
#.........这里部分代码省略.........