本文整理汇总了Python中SoftLayer.DNSManager.get_records方法的典型用法代码示例。如果您正苦于以下问题:Python DNSManager.get_records方法的具体用法?Python DNSManager.get_records怎么用?Python DNSManager.get_records使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftLayer.DNSManager
的用法示例。
在下文中一共展示了DNSManager.get_records方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_zone
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def list_zone(client, zone, args):
manager = DNSManager(client)
t = Table([
"record",
"type",
"ttl",
"value",
])
t.align['ttl'] = 'l'
t.align['record'] = 'r'
t.align['value'] = 'l'
zone_id = resolve_id(manager.resolve_ids, args['<zone>'], name='zone')
try:
records = manager.get_records(
zone_id,
type=args.get('--type'),
host=args.get('--record'),
ttl=args.get('--ttl'),
data=args.get('--data'),
)
except DNSZoneNotFound:
raise CLIAbort("No zone found matching: %s" % args['<zone>'])
for rr in records:
t.add_row([
rr['host'],
rr['type'].upper(),
rr['ttl'],
rr['data']
])
return t
示例2: on_delete
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def on_delete(self, req, resp, tenant_id, domain, entry):
client = req.env['sl_client']
mgr = DNSManager(client)
domain = unquote_plus(domain)
zone_id = mgr._get_zone_id_from_name(domain)[0]
record = mgr.get_records(zone_id, host=entry)[0]
mgr.delete_record(record['id'])
resp.status = 204
示例3: on_get
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def on_get(self, req, resp, tenant_id, domain, entry=None):
client = req.env['sl_client']
mgr = DNSManager(client)
domain = unquote_plus(domain)
zone_id = mgr._get_zone_id_from_name(domain)[0]
if entry:
record = mgr.get_records(zone_id, host=entry)[0]
result = get_dns_entry_dict(domain, record['host'], record['data'],
record['type'], entry_id=record['id'])
resp.body = {'dns_entry': result}
示例4: execute
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def execute(self, args):
manager = DNSManager(self.client)
zone_id = resolve_id(manager.resolve_ids, args['<zone>'], name='zone')
try:
results = manager.get_records(
zone_id,
host=args['<record>'])
except DNSZoneNotFound:
raise CLIAbort("No zone found matching: %s" % args['<zone>'])
for r in results:
if args['--id'] and str(r['id']) != args['--id']:
continue
r['data'] = args['--data'] or r['data']
r['ttl'] = args['--ttl'] or r['ttl']
manager.edit_record(r)
示例5: on_put
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def on_put(self, req, resp, tenant_id, domain, entry):
client = req.env['sl_client']
mgr = DNSManager(client)
body = json.loads(req.stream.read().decode())
ip = lookup(body, 'dns_entry', 'ip')
record_type = lookup(body, 'dns_entry', 'type')
if not record_type:
record_type = 'A'
domain = unquote_plus(domain)
zone_id = mgr._get_zone_id_from_name(domain)[0]
mgr.create_record(zone_id=zone_id, record=entry,
record_type=record_type, data=ip)
new_record = mgr.get_records(zone_id, host=entry)[0]
result = get_dns_entry_dict(domain, entry, ip, record_type,
entry_id=new_record['id'])
resp.body = {'dns_entry': result}
示例6: list_zone
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
def list_zone(self, args):
""" list records for a particular zone """
manager = DNSManager(self.client)
table = Table([
"id",
"record",
"type",
"ttl",
"value",
])
table.align['ttl'] = 'l'
table.align['record'] = 'r'
table.align['value'] = 'l'
zone_id = resolve_id(manager.resolve_ids, args['<zone>'], name='zone')
try:
records = manager.get_records(
zone_id,
record_type=args.get('--type'),
host=args.get('--record'),
ttl=args.get('--ttl'),
data=args.get('--data'),
)
except DNSZoneNotFound:
raise CLIAbort("No zone found matching: %s" % args['<zone>'])
for record in records:
table.add_row([
record['id'],
record['host'],
record['type'].upper(),
record['ttl'],
record['data']
])
return table
示例7: DNSTests
# 需要导入模块: from SoftLayer import DNSManager [as 别名]
# 或者: from SoftLayer.DNSManager import get_records [as 别名]
#.........这里部分代码省略.........
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
)
def test_dump_zone(self):
f = self.client['Dns_Domain'].getZoneFileContents
f.return_value = 'lots of text'
self.dns_client.dump_zone(1)
f.assert_called_once_with(id=1)
def test_get_record(self):
records = [
{'ttl': 7200, 'data': 'd', 'host': 'a', 'type': 'cname'},
{'ttl': 900, 'data': '1', 'host': 'b', 'type': 'a'},
{'ttl': 900, 'data': 'x', 'host': 'c', 'type': 'ptr'},
{'ttl': 86400, 'data': 'b', 'host': 'd', 'type': 'txt'},
{'ttl': 86400, 'data': 'b', 'host': 'e', 'type': 'txt'},
{'ttl': 600, 'data': 'b', 'host': 'f', 'type': 'txt'},
]
D = self.client['Dns_Domain'].getResourceRecords
# maybe valid domain, but no records matching
D.return_value = []
self.assertEqual(self.dns_client.get_records(12345),
[])
D.reset_mock()
D.return_value = [records[1]]
self.dns_client.get_records(12345, type='a')
D.assert_called_once_with(
id=12345,
filter={'resourceRecords': {'type': {"operation": "_= a"}}},
mask=ANY)
D.reset_mock()
D.return_value = [records[0]]
self.dns_client.get_records(12345, host='a')
D.assert_called_once_with(
id=12345,
filter={'resourceRecords': {'host': {"operation": "_= a"}}},
mask=ANY)
D.reset_mock()
D.return_value = records[3:5]
self.dns_client.get_records(12345, data='a')
D.assert_called_once_with(
id=12345,
filter={'resourceRecords': {'data': {"operation": "_= a"}}},
mask=ANY)
D.reset_mock()
D.return_value = records[3:5]
self.dns_client.get_records(12345, ttl='86400')
D.assert_called_once_with(
id=12345,
filter={'resourceRecords': {'ttl': {"operation": 86400}}},
mask=ANY)