本文整理汇总了Python中stackone.model.DBSession.flush方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.flush方法的具体用法?Python DBSession.flush怎么用?Python DBSession.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stackone.model.DBSession
的用法示例。
在下文中一共展示了DBSession.flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_node_defn
# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import flush [as 别名]
def update_node_defn(self, auth, node_id, group_id, site_id, def_id, def_type, status, dt_time, details, scope, defType, csep_id=None):
LOGGER.info('Updating server definition status...')
node_defn = DBSession.query(ServerDefLink).filter_by(server_id=node_id, def_id=def_id).first()
if node_defn:
if status:
node_defn.status = status
node_defn.dt_time = datetime.now()
if details:
node_defn.details = details
transaction.commit()
LOGGER.info('Server definition status is updated. Status is ' + to_str(status))
LOGGER.info('Updating server pool definition status...')
oos_count_g = 0
g_status = to_unicode(constants.IN_SYNC)
if group_id:
group_entity = auth.get_entity(group_id)
if group_entity is not None:
group = DBSession.query(ServerGroup).filter_by(id=group_id).first()
if group:
group.credential = None
for node in group.getNodeList(auth).itervalues():
rowNodeDefn = DBSession.query(ServerDefLink).filter_by(server_id=node.id, def_id=def_id, def_type=to_unicode(defType), status=to_unicode(constants.OUT_OF_SYNC))
if rowNodeDefn:
oos_count_g += rowNodeDefn.count()
if oos_count_g > 0:
g_status = to_unicode(constants.OUT_OF_SYNC)
else:
g_status = to_unicode(constants.IN_SYNC)
group_sd = DBSession.query(SPDefLink).filter_by(group_id=group_id, def_id=def_id, def_type=to_unicode(defType)).first()
if group_sd:
group_sd.status = g_status
group_sd.dt_time = datetime.now()
group_sd.oos_count = oos_count_g
transaction.commit()
LOGGER.info('Server pool level definition status is updated')
LOGGER.info('Updating data center definition status...')
oos_count_dc = 0
dc_status = to_unicode(constants.IN_SYNC)
rowNodeDefn = DBSession.query(ServerDefLink).filter_by(def_id=def_id, def_type=to_unicode(defType), status=to_unicode(constants.OUT_OF_SYNC))
if rowNodeDefn:
oos_count_dc = rowNodeDefn.count()
if oos_count_dc > 0:
dc_status = to_unicode(constants.OUT_OF_SYNC)
else:
dc_status = to_unicode(constants.IN_SYNC)
dc_sd = DBSession.query(DCDefLink).filter_by(site_id=site_id, def_id=def_id, def_type=to_unicode(defType)).first()
if dc_sd:
dc_sd.status = dc_status
dc_sd.dt_time = datetime.now()
dc_sd.oos_count = oos_count_dc
DBSession.flush()
transaction.commit()
LOGGER.info('Data center level definition status is updated')
if csep_id:
csep_sd = DBSession.query(CSEPDefLink).filter_by(csep_id=csep_id, def_id=def_id, def_type=to_unicode(defType)).first()
if csep_sd:
csep_sd.status = dc_status
csep_sd.dt_time = datetime.now()
csep_sd.oos_count = oos_count_dc
DBSession.flush()
transaction.commit()
LOGGER.info('CSEP level definition status is updated')