本文整理汇总了Python中aquilon.worker.processes.DSDBRunner.del_campus_building方法的典型用法代码示例。如果您正苦于以下问题:Python DSDBRunner.del_campus_building方法的具体用法?Python DSDBRunner.del_campus_building怎么用?Python DSDBRunner.del_campus_building使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aquilon.worker.processes.DSDBRunner
的用法示例。
在下文中一共展示了DSDBRunner.del_campus_building方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from aquilon.worker.processes import DSDBRunner [as 别名]
# 或者: from aquilon.worker.processes.DSDBRunner import del_campus_building [as 别名]
def render(self, session, logger, building, **arguments):
dbbuilding = get_location(session, building=building)
city = dbbuilding.city
address = dbbuilding.address
campus = dbbuilding.campus
result = CommandDelLocation.render(self, session=session, name=building,
type='building', **arguments)
session.flush()
dsdb_runner = DSDBRunner(logger=logger)
if campus:
dsdb_runner.del_campus_building(campus.name, building)
dsdb_runner.del_building(building, city.name, address)
dsdb_runner.commit_or_rollback()
return result
示例2: render
# 需要导入模块: from aquilon.worker.processes import DSDBRunner [as 别名]
# 或者: from aquilon.worker.processes.DSDBRunner import del_campus_building [as 别名]
def render(self, session, logger, building, city, address,
fullname, default_dns_domain, comments, **arguments):
dbbuilding = get_location(session, building=building)
old_city = dbbuilding.city
dsdb_runner = DSDBRunner(logger=logger)
if address is not None:
old_address = dbbuilding.address
dbbuilding.address = address
dsdb_runner.update_building(dbbuilding.name, dbbuilding.address,
old_address)
if fullname is not None:
dbbuilding.fullname = fullname
if comments is not None:
dbbuilding.comments = comments
if default_dns_domain is not None:
if default_dns_domain:
dbdns_domain = DnsDomain.get_unique(session, default_dns_domain,
compel=True)
dbbuilding.default_dns_domain = dbdns_domain
else:
dbbuilding.default_dns_domain = None
plenaries = PlenaryCollection(logger=logger)
if city:
dbcity = get_location(session, city=city)
# This one would change the template's locations hence forbidden
if dbcity.hub != dbbuilding.hub:
# Doing this both to reduce user error and to limit
# testing required.
raise ArgumentError("Cannot change hubs. {0} is in {1} "
"while {2} is in {3}.".format(
dbcity, dbcity.hub,
dbbuilding, dbbuilding.hub))
# issue svcmap warnings
maps = 0
for map_type in [ServiceMap, PersonalityServiceMap]:
maps = maps + session.query(map_type).\
filter_by(location=old_city).count()
if maps > 0:
logger.client_info("There are {0} service(s) mapped to the "
"old location of the ({1:l}), please "
"review and manually update mappings for "
"the new location as needed.".format(
maps, dbbuilding.city))
dbbuilding.update_parent(parent=dbcity)
if old_city.campus and (old_city.campus != dbcity.campus):
dsdb_runner.del_campus_building(old_city.campus, building)
if dbcity.campus and (old_city.campus != dbcity.campus):
dsdb_runner.add_campus_building(dbcity.campus, building)
query = session.query(Machine)
query = query.filter(Machine.location_id.in_(dbcity.offspring_ids()))
for dbmachine in query:
plenaries.append(Plenary.get_plenary(dbmachine))
session.flush()
if plenaries.plenaries:
with plenaries.get_key():
plenaries.stash()
try:
plenaries.write(locked=True)
dsdb_runner.commit_or_rollback()
except:
plenaries.restore_stash()
raise
else:
dsdb_runner.commit_or_rollback()
return