Example #1
0
 def get_vm_restore_task_result(self, auth, vm_id):
     task_backup_info = {}
     tasklist_info = []
     msg = " Number of VM's backed up= 2 \n Number of VM backup suceeded = 2\n Number of VM backup failed = 0"
     vmrestore_result_obj_list = DBSession.query(VMRestoreResult, VMBackupResult).join((VMBackupResult, VMRestoreResult.backup_result_id == VMBackupResult.id)).filter(VMRestoreResult.vm_id == vm_id).order_by(VMRestoreResult.start_time).all()
     if vmrestore_result_obj_list:
         for vm_result_obj in vmrestore_result_obj_list:
             vmrestore_result_obj = vm_result_obj[0]
             vmbackup_result_obj = vm_result_obj[1]
             sp_bkp_conf = DBSession.query(SPBackupConfig).filter_by(id=vmrestore_result_obj.backup_id).first()
             if sp_bkp_conf:
                 detailResult_obj_list = DBSession.query(VMRestoreDetailResult).filter_by(result_id=vmrestore_result_obj.id).order_by(VMRestoreDetailResult.details).all()
                 msg2 = ''
                 if detailResult_obj_list:
                     for detailResult_obj in detailResult_obj_list:
                         if detailResult_obj:
                             msg2 += detailResult_obj.details + '\n'
                 task_info = {}
                 task_info['taskid'] = vmrestore_result_obj.id
                 task_info['status'] = vmrestore_result_obj.status
                 task_info['name'] = sp_bkp_conf.name
                 location = ''
                 exec_context = vmbackup_result_obj.execution_context
                 location = exec_context['SERVER'] + ':' + exec_context['BACKUP_DESTINATION']
                 task_info['location'] = location
                 task_info['backup_size'] = 0
                 task_info['starttime'] = vmrestore_result_obj.start_time
                 task_info['endtime'] = vmrestore_result_obj.end_time
                 task_info['errmsg'] = msg2
                 task_info['restore'] = vmrestore_result_obj.id
                 tasklist_info.append(task_info)
     task_backup_info['rows'] = tasklist_info
     return task_backup_info
Example #2
0
    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)
Example #3
0
 def sync_defn(self, auth, server_ids, def_id, site_id, group_id):
     server_id_list = server_ids.split(',')
     for server_id in server_id_list:
         node = DBSession.query(ManagedNode).filter_by(id=server_id).first()
         defn = DBSession.query(StorageDef).filter_by(id=def_id).first()
         self.sync_manager.sync_node_defn(auth, node, group_id, site_id, defn, constants.STORAGE, constants.ATTACH, self.storage_manager)
     return dict(success='true')
Example #4
0
 def get_next_id(self, pool_tag, context):
     available_id = None
     interface = None
     if pool_tag == constants.VLAN_ID_POOL:
         LOGGER.info("Get next vlan id from pool...")
         pool_id = context.get("pool_id")
         nw_def_id = context.get("nw_def_id")
         null_value = None
         LOGGER.info("Getting CMS Lock...")
         LockManager().get_lock(
             constants.VLAN_ID_POOL, pool_id, constants.NEXT_VLAN_ID, constants.Table_vlan_id_pools
         )
         interface = VLANManager().get_interface(pool_id)
         rs = (
             DBSession.query(func.min(VLANID.vlan_id).label("vlan_id"))
             .join((VLANIDPool, VLANIDPool.id == VLANID.vlan_id_pool_id))
             .filter(VLANID.used_by == null_value)
             .filter(VLANIDPool.id == pool_id)
             .first()
         )
         is_tuple = isinstance(rs, tuple)
         if is_tuple and rs[0]:
             available_id = rs.vlan_id
             LOGGER.info("Available vlan id is " + to_str(available_id))
             context["vlan_id"] = available_id
             self.mark_used(pool_tag, context)
             vlan = DBSession.query(VLANIDPool).filter(VLANIDPool.id == pool_id).first()
             if vlan:
                 vlan.used = int(vlan.used) + 1
         LOGGER.info("Releasing CMS Lock...")
         LockManager().release_lock()
     return (available_id, interface)
Example #5
0
 def get_fw_info(self):
     fw_main_data = []
     LOGGER.info("Getting firewall rules info for all csep and Data Center...")
     print "Getting firewall rules info for all csep and Data Center..."
     sites = DBSession.query(Site)
     if sites[0]:
         LOGGER.info("Got the site. Site name is " + to_str(sites[0L].name))
         site_id = sites[0L].id
         site_name = sites[0L].name
         nw_service_host = get_cms_network_service_node()
         if nw_service_host:
             fw = self.get_firewall(site_id)
             fw.set_chain_name(site_name)
             fw_data = self.dump(fw)
             fw_main_data.append(fw_data)
     csep_list = DBSession.query(CSEP)
     for each_csep in csep_list:
         LOGGER.info("Got the CSEP. CSEP name is " + to_str(each_csep.name))
         nw_service_host = each_csep.get_nw_service_host()
         if nw_service_host:
             fw = self.get_firewall(each_csep.id)
             fw.set_chain_name(each_csep.name)
             fw_data = self.dump(fw)
             fw_main_data.append(fw_data)
     return fw_main_data
Example #6
0
 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)
Example #7
0
 def delete_pool(self, pool_ids):
     if not isinstance(pool_ids, list):
         pool_ids = [pool_ids]
     pools = DBSession.query(IPPool).filter(IPPool.id.in_(pool_ids)).all()
     DBSession.query(IPS).filter(IPS.pool_id.in_(pool_ids)).delete()
     for pool in pools:
         DBSession.delete(pool)
Example #8
0
 def add_firewall_for_entity(self, entity_id):
     LOGGER.info("Add firewall for CSEP/ Data Center...")
     if entity_id:
         csep = DBSession.query(CSEP).filter_by(id=entity_id).first()
         if csep:
             LOGGER.info("Got CSEP")
             nw_service_host = csep.get_nw_service_host()
             if nw_service_host:
                 fw = IptablesManager(csep.name)
                 self.fw_map[entity_id] = fw
                 LOGGER.info("Firewall is added to CSEP")
                 self.set_nw_service_host(fw, nw_service_host)
                 LOGGER.info("Network service host is added to firewall")
             return fw
         dc = DBSession.query(Site).filter_by(id=entity_id).first()
         if dc:
             LOGGER.info("Got DC")
             nw_service_host = get_cms_network_service_node()
             if nw_service_host:
                 fw = IptablesManager(dc.name)
                 self.fw_map[entity_id] = fw
                 LOGGER.info("Firewall is added to DC")
                 self.set_nw_service_host(fw, nw_service_host)
                 LOGGER.info("Network service host is added to firewall")
             return fw
Example #9
0
File: Entity.py Project: smarkm/ovm
 def remove_context(cls, context_id):
     try:
         DBSession.query(cls).filter(cls.id == context_id).delete()
     except Exception as e:
         LOGGER.error(e)
         traceback.print_exc()
         raise e
Example #10
0
def update_avail(node, new_state, monit_state, timestamp, reason, logger, update=True, auth=None):
    sv_point = transaction.savepoint()
    try:
        strt = p_task_timing_start(logger, "UpdateAvailability", node.id, log_level="DEBUG")
        node.current_state.avail_state = new_state
        node.current_state.timestamp = timestamp
        node.current_state.description = reason
        avh=DBSession.query(AvailHistory).filter(AvailHistory.entity_id==node.id).\
            order_by(AvailHistory.timestamp.desc()).first()
        if avh is not None:
            avh.endtime=timestamp
            time_diff=timestamp-avh.timestamp
            avh.period=time_diff.days*24*60+time_diff.seconds/60
            DBSession.add(avh)
        #insert availability history
        ah = AvailHistory(node.id, new_state, monit_state, timestamp, reason)
        DBSession.add(ah)
        DBSession.add(node)
        if update==True:
            487
            ev_contents = {'state':new_state}
            ev = AvailabilityEvent(node.id, ev_contents, timestamp)
            DBSession.add(ev)
            ent = DBSession.query(Entity).filter(Entity.entity_id==node.id).first()
            from stackone.model.ManagedNode import ManagedNode
            if ent.type.name == constants.MANAGED_NODE and new_state == ManagedNode.DOWN:
                if node.is_maintenance():
                    logger.info('Node:%s is in Maintenance mode' %node.hostname)
                else:
                    notify_node_down(ent,reason)
    except Exception, e:
        import traceback
        traceback.print_exc()
        logger.error(e)
        sv_point.rollback()
Example #11
0
    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)
Example #12
0
 def delete_restore_single_result(self, result_id):
     try:
         DBSession.query(VMRestoreResult).filter(VMRestoreResult.id == result_id).delete()
         LOGGER.info('VM restore single result is deleted.')
         transaction.commit()
     except Exception as ex:
         LOGGER.error(to_str(ex).replace("'", ''))
Example #13
0
    def get_storage_usage(self, auth, site_id, group_id, scope, defn):
        usage = 0
        vm_id_list = []
        if scope==constants.SCOPE_DC:
            site_entity = auth.get_entity(site_id)
            groups = auth.get_entities(constants.SERVER_POOL, parent=site_entity)
            for eachgroup in groups:
                nodes = auth.get_entities(constants.MANAGED_NODE, parent=eachgroup)
                vm_id_list = self.get_vm_id_list(auth, nodes, vm_id_list)
        if scope == constants.SCOPE_SP:
            group_entity = auth.get_entity(group_id)
            nodes = auth.get_entities(constants.MANAGED_NODE, parent=group_entity)
            vm_id_list = self.get_vm_id_list(auth, nodes, vm_id_list)

        storage_disks = DBSession.query(StorageDisks).filter_by(storage_id=defn.id)
        if storage_disks:
            for each_disk in storage_disks:
                vm_storage_link = DBSession.query(VMStorageLinks).filter_by(storage_disk_id=each_disk.id).first()
                if vm_storage_link:
                    vm_id = None
                    vm_disk = DBSession.query(VMDisks).filter_by(id=vm_storage_link.vm_disk_id).first()
                    if vm_disk:
                        vm_id = vm_disk.vm_id
                    for each_vm_id in vm_id_list:
                        if each_vm_id == vm_id:
                            usage += vm_disk.disk_size
        return usage
Example #14
0
 def delete_vlan_network_info(self, vlan_id_pool, vlan_ids):
     if not isinstance(vlan_ids, list):
         vlan_ids = [vlan_ids]
     DBSession.query(VLANNetworkInfo).filter(VLANNetworkInfo.vlan_id.in_(vlan_ids)).filter(
         VLANNetworkInfo.vlan_pool_id == vlan_id_pool.id
     ).delete()
     LOGGER.info("deleted vlan_network_info for vlan_id_pool:%s" % vlan_id_pool.name)
Example #15
0
    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
Example #16
0
 def on_add_node(self, nodeId, groupId, site_id, auth, def_manager):
     op = constants.ATTACH
     if not(nodeId or groupId):
         return None
     defn_list = []
     errs = []
     sync_manager = SyncDef()
     defType = def_manager.getType()
     sp_defns = DBSession.query(SPDefLink).filter_by(group_id=to_unicode(groupId))
     if sp_defns:
         for eachdefn in sp_defns:
             defn = def_manager.get_defn(eachdefn.def_id)
             if defn:
                 defn_list.append(defn)
                 status = to_unicode(constants.OUT_OF_SYNC)
                 details = None
                 sync_manager.add_node_defn(nodeId, defn.id, defType, status, details)
     node = DBSession.query(ManagedNode).filter_by(id=nodeId).first()
     if node:
         update_status = True
         try:
             sync_manager.sync_node(defn_list, node, groupId, site_id, auth, defType, op, def_manager, update_status, errs)
         except Exception as ex:
             if errs:
                 if len(errs)>0:
                     LOGGER.error('Error in syncing definition while adding node: ' + to_str(errs))
Example #17
0
 def manage_public_ip(self, vm_id, public_ip_id, public_ip, csep_id, add_flag):
     LOGGER.info('Calling network service...')
     if vm_id:
         nw_vm_rel = DBSession.query(NetworkVMRelation).filter_by(vm_id=vm_id).first()
     elif public_ip:
         nw_vm_rel = DBSession.query(NetworkVMRelation).filter_by(public_ip_id=public_ip_id).first()
     if nw_vm_rel:
         LOGGER.info('Got network VM relation')
         nw_def_id = nw_vm_rel.nw_def_id
         private_ip_id = nw_vm_rel.private_ip_id
         nw_defn = NwManager().get_defn(nw_def_id)
         public_interface = ''
         if nw_defn:
             bridge_name = nw_defn.bridge_info.get('name')
         private_ip = ''
         ip_rec = self.get_ip_by_id(private_ip_id)
         if ip_rec:
             private_ip = self.remove_cidr_format_from_ip(ip_rec.ip)
         dom_id = None
         nw_service_host = NwManager().get_nw_service_host(csep_id)
         if nw_service_host:
             LOGGER.info('Got network service host')
             public_interface = self.get_public_interface(csep_id)
             ctx = {}
             ctx['public_ip'] = public_ip
             ctx['private_ip'] = private_ip
             ctx['public_interface'] = public_interface
             ctx['bridge_name'] = bridge_name
             ctx['add_flag'] = add_flag
             ctx['csep_id'] = csep_id
             LOGGER.info('context=' + to_str(ctx))
             NwManager().manage_public_ip(nw_service_host, ctx)
Example #18
0
 def set_transient_state(self, defn, transient_state, op, site_id=None, group_id=None, node_id=None):
     scope = defn.scope
     if op==constants.SCOPE_LEVEL:
         if scope == constants.SCOPE_S:
             def_link = DBSession.query(ServerDefLink).filter_by(server_id=node_id, def_id=defn.id).first()
         else:
             if scope == constants.SCOPE_SP:
                 def_link = DBSession.query(SPDefLink).filter_by(group_id=group_id, def_id=defn.id).first()
             else:
                 if scope == constants.SCOPE_DC:
                     def_link = DBSession.query(DCDefLink).filter_by(site_id=site_id, def_id=defn.id).first()
         if def_link:
             if transient_state:
                 def_link.transient_state = to_unicode(transient_state)
             else:
                 def_link.transient_state = None
             LOGGER.info('Transient state of ' + to_str(defn.name) + ' is changed to ' + to_str(transient_state) + ' at definition scope level')
     if op==constants.NODE_LEVEL:
         def_link = DBSession.query(ServerDefLink).filter_by(server_id=node_id, def_id=defn.id).first()
         if def_link:
             if transient_state:
                 def_link.transient_state = to_unicode(transient_state)
             else:
                 def_link.transient_state = None
             LOGGER.info('Transient state of ' + to_str(defn.name) + ' is changed to ' + to_str(transient_state) + ' at node level')
Example #19
0
 def get_vm_linked_with_storage(self, storage_disk_id):
     vm = None
     if storage_disk_id:
         vm_storage_link = DBSession.query(VMStorageLinks).filter_by(storage_disk_id=storage_disk_id).first()
         if vm_storage_link:
             vm_disk = DBSession.query(VMDisks).filter_by(id=vm_storage_link.vm_disk_id).first()
             if vm_disk:
                 vm = DBSession.query(VM).filter_by(id=vm_disk.vm_id).first()
     return vm
Example #20
0
    def migrate_to_servers(self, grpid, tried_sb_nodes=[], failed_doms=[], dom_ids=[]):
        msg = 'Starting Maintenance migration on Node ' + self.nodename + '. Checking for VMs.'
        self.msg += '\n' + msg
        LOGGER.info(msg)
        node = DBSession.query(ManagedNode).filter(ManagedNode.id == self.entity_id).first()
        grp = DBSession.query(ServerGroup).filter(ServerGroup.id == grpid).first()
        gretry_count = grp.getAttributeValue(constants.retry_count, 3)
        gwait_interval = grp.getAttributeValue(constants.wait_interval, 3)
        if grp.use_standby == True:
            while len(failed_doms) > 0:
                msg = 'Finding standby node.'
                self.msg += '\n' + msg
                LOGGER.info(msg)
                new_node = self.find_standby_node(self.auth, None, node, exclude_ids=tried_sb_nodes)
                if new_node is None:
                    msg = 'All standby nodes are exhausted.'
                    self.msg += '\n' + msg
                    LOGGER.info(msg)
                    break
                failed_doms = self.dom_fail_over(failed_doms, node, new_node, gretry_count, gwait_interval, self.FENCING)
                tried_sb_nodes.append(new_node.id)
        tot_failed = failed_doms

        tmp_failed_doms = [d for d in failed_doms]
        if len(failed_doms) > 0:
            tot_failed = []
            for domid in tmp_failed_doms:
                self.step = self.PAUSE_IN_STANDBY
                dom = DBSession.query(VM).filter(VM.id == domid).first()
                domname = dom.name
                msg = 'Starting initial placement for ' + domname
                self.msg += '\n' + msg
                LOGGER.info(msg)
                new_node = self.get_allocation_candidate(self.auth,dom,node)
                failed = self.dom_fail_over(domid, node, new_node, gretry_count, gwait_interval, self.PAUSE_IN_STANDBY)
                if len(failed) == 1:
                    tot_failed.append(failed[0])

        if len(tot_failed)>0:
            doms = DBSession.query(VM).filter(VM.id.in_(tot_failed)).all()
            domnames = [d.name for d in doms]
            msg = 'Failed to migrate following VMs' + to_str(domnames)
            self.msg += '\n' + msg
            LOGGER.info(msg)
        else:
            self.status = self.SUCCESS
            msg = 'Successfully migrated all VMs'
            self.msg += '\n' + msg
            LOGGER.info(msg)

        if len(tot_failed) != 0 and len(tot_failed) < len(dom_ids):
            self.status = self.PARTIAL
        vm_info_tup = self.get_maint_task_context(key='migrated_vms')
        vm_ids = [x[0] for x in vm_info_tup]
        self.add_vm_states(vm_ids)
        return True
Example #21
0
File: Groups.py Project: smarkm/ovm
 def get_standby_nodes(self):
     standby_nodes = []
     try:
         grp_ent = DBSession.query(Entity).filter(Entity.entity_id == self.id).first()
         node_ids = [x.entity_id for x in grp_ent.children]
         from stackone.model.ManagedNode import ManagedNode
         standby_nodes = DBSession.query(ManagedNode).filter(ManagedNode.id.in_(node_ids)).filter(ManagedNode.standby_status == ManagedNode.STANDBY).all()
     except Exception,e:
         import traceback
         traceback.print_exc()
Example #22
0
 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()
Example #23
0
 def delete_ip(self, exclude_ips, pool_id, cidr=None):
     if not isinstance(exclude_ips, list):
         exclude_ips = [exclude_ips]
     del_ips = DBSession.query(IPS).filter(~IPS.ip.in_(exclude_ips)).filter(IPS.pool_id == pool_id).all()
     for ip in del_ips:
         if not self.can_remove_ip(ip.id):
             LOGGER.info('Can not delete reserved IP:%s' % ip.ip)
             raise Exception('Can not delete reserved IP:%s' % ip.ip)
     for ip in del_ips:
         DBSession.delete(ip)
Example #24
0
 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)
Example #25
0
 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))
Example #26
0
 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()
Example #27
0
File: Entity.py Project: smarkm/ovm
 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
Example #28
0
 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)
Example #29
0
 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)
Example #30
0
 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)