本文整理汇总了Python中aquilon.worker.processes.DSDBRunner.update_host_details方法的典型用法代码示例。如果您正苦于以下问题:Python DSDBRunner.update_host_details方法的具体用法?Python DSDBRunner.update_host_details怎么用?Python DSDBRunner.update_host_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aquilon.worker.processes.DSDBRunner
的用法示例。
在下文中一共展示了DSDBRunner.update_host_details方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from aquilon.worker.processes import DSDBRunner [as 别名]
# 或者: from aquilon.worker.processes.DSDBRunner import update_host_details [as 别名]
def render(self, session, logger, fqdn, ip, reverse_ptr, dns_environment,
network_environment, comments, **arguments):
dbnet_env, dbdns_env = get_net_dns_env(session, network_environment,
dns_environment)
dbdns_rec = ARecord.get_unique(session, fqdn=fqdn,
dns_environment=dbdns_env, compel=True)
old_ip = dbdns_rec.ip
old_comments = dbdns_rec.comments
if ip:
if dbdns_rec.hardware_entity:
raise ArgumentError("{0} is a primary name, and its IP address "
"cannot be changed.".format(dbdns_rec))
if dbdns_rec.assignments:
ifaces = ", ".join(["%s/%s" % (addr.interface.hardware_entity,
addr.interface)
for addr in dbdns_rec.assignments])
raise ArgumentError("{0} is already used by the following "
"interfaces, and its IP address cannot be "
"changed: {1!s}."
.format(dbdns_rec, ifaces))
dbnetwork = get_net_id_from_ip(session, ip, dbnet_env)
q = session.query(ARecord)
q = q.filter_by(network=dbnetwork)
q = q.filter_by(ip=ip)
q = q.join(ARecord.fqdn)
q = q.filter_by(dns_environment=dbdns_env)
existing = q.first()
if existing:
raise ArgumentError("IP address {0!s} is already used by "
"{1:l}." .format(ip, existing))
dbdns_rec.network = dbnetwork
old_ip = dbdns_rec.ip
dbdns_rec.ip = ip
if reverse_ptr:
old_reverse = dbdns_rec.reverse_ptr
set_reverse_ptr(session, logger, dbdns_rec, reverse_ptr)
if old_reverse and old_reverse != dbdns_rec.reverse_ptr:
delete_target_if_needed(session, old_reverse)
if comments:
dbdns_rec.comments = comments
session.flush()
if dbdns_env.is_default and (dbdns_rec.ip != old_ip or
dbdns_rec.comments != old_comments):
dsdb_runner = DSDBRunner(logger=logger)
dsdb_runner.update_host_details(dbdns_rec.fqdn, new_ip=dbdns_rec.ip,
old_ip=old_ip,
new_comments=dbdns_rec.comments,
old_comments=old_comments)
dsdb_runner.commit_or_rollback()
return