当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.add方法代码示例

本文整理汇总了Python中stackone.model.DBSession.add方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.add方法的具体用法?Python DBSession.add怎么用?Python DBSession.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stackone.model.DBSession的用法示例。


在下文中一共展示了DBSession.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_for_updates

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
    def check_for_updates(self, send_mail=False):
        update_items = []
        dep = None
        try:
            deps = DBSession.query(Deployment).all()
            if len(deps) > 0:
                dep = deps[0]
                edition = get_product_edition()
                new_updates,max_dt = self.get_new_updates(dep.deployment_id, dep.update_checked_date, edition)
                if send_mail and new_updates:
                    self.send_update_mails(new_updates)
            else:
                LOGGER.error('Deployment table is not set. Update can not proceed.')
                return None
        except Exception as ex:
            traceback.print_exc()
            LOGGER.error('Error fetching updates:' + to_str(ex))
            return None

        try:
            dep.update_checked_date = datetime.now()
            DBSession.add(dep)
        except:
            pass

        return update_items
开发者ID:smarkm,项目名称:ovm,代码行数:28,代码来源:UpdateManager.py

示例2: create_vmw_server_pool

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
    def create_vmw_server_pool(self, auth, name, actual_name, moid, vcenter_id, parent_ent=None):
        msg = ''
        entityType = to_unicode(constants.SERVER_POOL)
        sp = None
        update_name = False
        sp_ent = auth.get_entity_by_entity_attributes(self.get_entity_attributes_dict(vcenter_id, moid), entityType)
        if not sp_ent:
            dup_ent = auth.get_entity_by_name(name, entityType=entityType)
            if dup_ent:
                msg += '\nERROR: Could not import Server Pool:%s. It is already exist,please choose different name' % name
                return (msg, None, None)

        if sp_ent:
            update_name = self.can_update_managed_object_name(auth, name, actual_name, sp_ent.name)
            msg += '\nServer Pool: %s already exist' % name
            sp = DBSession.query(VMWServerGroup).filter(VMWServerGroup.id == sp_ent.entity_id).first()
            if sp:
                if update_name:
                    sp.name = name
        if not sp:
            msg += '\nCreating Server Pool: %s' % name
            sp = VMWServerGroup(name)
        DBSession.add(sp)
        if not sp_ent:
            cntx = {'external_manager_id': vcenter_id, 'external_id': moid}
            sp_ent = self.add_vcenter_entity(auth, cntx, sp.name, sp.id, to_unicode(constants.SERVER_POOL), parent_ent)
        else:
            if not update_name:
                name = None
            auth.update_entity(sp_ent, name=name, parent=parent_ent)
        return (msg, sp, sp_ent)
开发者ID:smarkm,项目名称:ovm,代码行数:33,代码来源:VcenterManager.py

示例3: create_vlan_network_info

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def create_vlan_network_info(self, vlan_id_pool, cidr, num_networks, network_size, vlan_start, interface):
     vlan_nw_infos = self.get_vlan_network_info(cidr, num_networks, network_size, vlan_start, interface)
     for info_dict in vlan_nw_infos:
         vlan_nw_info_db = self.create_vlan_network_info_db(info_dict)
         vlan_nw_info_db.vlan_pool_id = vlan_id_pool.id
         DBSession.add(vlan_nw_info_db)
     LOGGER.info("created vlan_network_info for vlan_id_pool:%s" % vlan_id_pool.name)
开发者ID:yangliang913,项目名称:ovm,代码行数:9,代码来源:VLANManager.py

示例4: update_dc_params

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
    def update_dc_params(self, res_id, fencing_name, fencing_id, params):
        try:
            params = json.loads(params).get('param_obj')
            hafr = DBSession.query(HAFenceResource).filter(HAFenceResource.id == res_id).one()
            hafr.name = fencing_name
            params_list = []
            for hp in hafr.params:
                params_list.append(hp)
            for i in range(len(params_list)):
                hafr.params.remove(params_list[i])
            for param in params:
                name = param.get('attribute')
                value = param.get('value')
                type = param.get('type')
                field = param.get('field')
                field_datatype = param.get('field_datatype')
                sequence = param.get('sequence')
                harp = HAFenceResourceParam(name, value, type, field, field_datatype, sequence)
                hafr.params.append(harp)
                
            DBSession.add(hafr)

        except Exception as ex:
            print_traceback()
            LOGGER.error(to_str(ex).replace("'", ''))
            return ("{success: false,msg: '", to_str(ex).replace("'", ''), "'}")

        return dict(success=True)
开发者ID:smarkm,项目名称:ovm,代码行数:30,代码来源:HAService.py

示例5: reset_maintenance_mode

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def reset_maintenance_mode(self):
     LOGGER.debug('In reset_maintenance_mode')
     node = DBSession.query(ManagedNode).filter(ManagedNode.id == self.node.id).first()
     node.maintenance = False
     node.maintenance_mig_node_id = None
     node.maintenance_operation = 0
     node.maintenance_migrate_back = False
     node.maintenance_user = None
     DBSession.add(node)
     transaction.commit()
开发者ID:smarkm,项目名称:ovm,代码行数:12,代码来源:Maintenance.py

示例6: update_restore_status

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def update_restore_status(self, rec):
     sStatus = 'Failed'
     details = 'Restore failed : CMS restarted.'
     rec.status = sStatus
     msg = rec.result
     if msg:
         rec.result = msg + '. ' + details
     rec.result = details
     self.add_restore_detail_result(rec.id, None, sStatus, details, cms_start=True)
     DBSession.add(rec)
     transaction.commit()
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:Restore.py

示例7: update_execution_context

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def update_execution_context(self):
     
     tid = TaskUtil.get_task_context()
     WRK_LOGGER.debug('in update_execution_context Parent task : ' + str(tid) + ' : child tasks :' + str(self.worker_ids))
     task = Task.get_task(tid)
     if task is not None:
         self.execution_context['start_time'] = self.start_time
         self.execution_context['worker_ids'] = self.worker_ids
         task.context['execution_context'] = self.execution_context
         DBSession.add(task)
         WRK_LOGGER.debug('in update_execution_context updated Parent task : ' + str(tid))
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:WorkManager.py

示例8: add_site_defn

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_site_defn(self, site_id, def_id, def_type, status, oos_count):
     row = DBSession.query(DCDefLink).filter_by(site_id=site_id, def_id=def_id).first()
     if not row:
         DCDL = DCDefLink()
         DCDL.site_id = site_id
         DCDL.def_type = def_type
         DCDL.def_id = def_id
         DCDL.status = to_unicode(status)
         DCDL.oos_count = oos_count
         DCDL.dt_time = datetime.now()
         DBSession.add(DCDL)
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:SyncDefinition.py

示例9: add_group_defn

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_group_defn(self, group_id, def_id, def_type, status, oos_count):
     row = DBSession.query(SPDefLink).filter_by(group_id=group_id, def_id=def_id).first()
     if not row:
         SPDL = SPDefLink()
         SPDL.group_id = group_id
         SPDL.def_type = def_type
         SPDL.def_id = def_id
         SPDL.status = status
         SPDL.oos_count = oos_count
         SPDL.dt_time = datetime.now()
         DBSession.add(SPDL)
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:SyncDefinition.py

示例10: add_node_defn

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_node_defn(self, node_id, def_id, def_type, status, details):
     row = DBSession.query(ServerDefLink).filter_by(server_id=node_id, def_id=def_id).first()
     if not row:
         node_defn = ServerDefLink()
         node_defn.server_id = to_unicode(node_id)
         node_defn.def_type = to_unicode(def_type)
         node_defn.def_id = def_id
         node_defn.status = to_unicode(status)
         node_defn.details = to_unicode(details)
         node_defn.dt_time = datetime.now()
         DBSession.add(node_defn)
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:SyncDefinition.py

示例11: add_entity_attribute

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_entity_attribute(cls, ent_obj, key, value, entity_id=None):
     try:
         if entity_id:
             ent_obj = Entity.get_entity(entity_id)
         ent_atr = cls(key, value)
         ent_obj.attributes.append(ent_atr)
         DBSession.add(ent_atr)
     except Exception as ex:
         traceback.print_exc()
         LOGGER.error(to_str(ex))
         raise ex
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:Entity.py

示例12: add_csep_defn

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_csep_defn(self, csep_id, def_id, def_type, status, oos_count):
     row = DBSession.query(CSEPDefLink).filter_by(csep_id=csep_id, def_id=def_id).first()
     if not row:
         CPDL = CSEPDefLink()
         CPDL.csep_id = csep_id
         CPDL.def_type = def_type
         CPDL.def_id = def_id
         CPDL.status = to_unicode(status)
         CPDL.oos_count = oos_count
         CPDL.dt_time = datetime.now()
         DBSession.add(CPDL)
开发者ID:smarkm,项目名称:ovm,代码行数:13,代码来源:SyncDefinition.py

示例13: add_vCenter

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_vCenter(self, auth, host, port, ssl, username, password):
     try:
         vcenter = DBSession.query(VCenter).filter(VCenter.host == host).first()
         if vcenter:
             raise Exception('vCenter Host already existing')
         else:
             vC = VCenter(host, port, ssl, username, password)
             DBSession.add(vC)
             return vC.id
     except Exception as e:
         traceback.print_exc()
         raise e
开发者ID:smarkm,项目名称:ovm,代码行数:14,代码来源:VcenterManager.py

示例14: add_vm_restore_result

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def add_vm_restore_result(self, backup_id, vm_id, start_time, end_time, status, result, bkp_result_id=None):
     bkp_result = VMRestoreResult()
     bkp_result.id = getHexID()
     bkp_result.backup_id = backup_id
     bkp_result.vm_id = vm_id
     bkp_result.start_time = start_time
     bkp_result.end_time = end_time
     bkp_result.status = status
     bkp_result.result = result
     bkp_result.backup_result_id = bkp_result_id
     DBSession.add(bkp_result)
     transaction.commit()
     return bkp_result.id
开发者ID:smarkm,项目名称:ovm,代码行数:15,代码来源:Restore.py

示例15: save_email_setup_details

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import add [as 别名]
 def save_email_setup_details(self, desc, servername, port, useremail, password, secure):
     SiteRecord = DBSession.query(Site).filter(Site.name == 'Data Center').first()
     if SiteRecord:
         site_id = SiteRecord.id
         EmailRecord = DBSession.query(EmailSetup).filter(EmailSetup.site_id == site_id).filter(EmailSetup.mail_server == servername).first()
         if EmailRecord:
             return dict(success=True, msg='Duplicaate Record found in list')
         else:
             email_setup_obj = EmailSetup(servername, desc, port, secure, site_id, useremail, password)
             DBSession.add(email_setup_obj)
             emailsetupid = email_setup_obj.getEmailSetupId()
             EmailManager().add_entity(to_unicode(servername), emailsetupid, to_unicode(constants.EMAIL), None)
             return dict(success=True, msg='New Record Added Sucessfully')
开发者ID:smarkm,项目名称:ovm,代码行数:15,代码来源:EmailService.py


注:本文中的stackone.model.DBSession.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。