Пример #1
0
def make_app(global_conf, full_stack=True, **app_conf):
    """
    Set convirt up with the settings found in the PasteDeploy configuration
    file used.
    
    :param global_conf: The global settings for convirt (those
        defined under the ``[DEFAULT]`` section).
    :type global_conf: dict
    :param full_stack: Should the whole TG2 stack be set up?
    :type full_stack: str or bool
    :return: The convirt application with all the relevant middleware
        loaded.
    
    This is the PasteDeploy factory for the convirt application.
    
    ``app_conf`` contains all the application-specific settings (those defined
    under ``[app:main]``.
    
   
    """
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    setup_deployment()
    update_vm_status()
    try:
        Basic.getImageStore().init_scan_dirs()
    except Exception, e:
        print "Error while scanning the image store ", e
Пример #2
0
def make_app(global_conf, full_stack=True, **app_conf):
    """
    Set convirt up with the settings found in the PasteDeploy configuration
    file used.
    
    :param global_conf: The global settings for convirt (those
        defined under the ``[DEFAULT]`` section).
    :type global_conf: dict
    :param full_stack: Should the whole TG2 stack be set up?
    :type full_stack: str or bool
    :return: The convirt application with all the relevant middleware
        loaded.
    
    This is the PasteDeploy factory for the convirt application.
    
    ``app_conf`` contains all the application-specific settings (those defined
    under ``[app:main]``.
    
   
    """
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    setup_deployment()
    update_vm_status()
    try:
        Basic.getImageStore().init_scan_dirs()
    except Exception, e:
        print "Error while scanning the image store ", e
Пример #3
0
 def exec_task(self, auth, ctx, node_id, action):
     manager = Basic.getGridManager()
     managed_node = manager.getNode(auth, node_id)
     if managed_node is not None:
         if not managed_node.is_authenticated():
             managed_node.connect()
         return manager.do_node_action(auth, node_id, action)
     else:
         raise Exception("Can not find the managed node")
Пример #4
0
 def resume_task(self, auth, ctx, dom_list, source_node_id,\
                dest_node_id, live, force, all):
     try:
         manager = Basic.getGridManager()
         return manager.resume_migrate_vm(auth, dom_list, source_node_id,\
                                   dest_node_id, live, force, all)
     except Exception, e:
         msg=constants.RESUME_TASK+to_str(e)
         raise Exception(msg)
Пример #5
0
 def resume_task(self, auth, ctx, dom_list, source_node_id,\
                dest_node_id, live, force, all):
     try:
         manager = Basic.getGridManager()
         return manager.resume_migrate_vm(auth, dom_list, source_node_id,\
                                   dest_node_id, live, force, all)
     except Exception, e:
         msg=constants.RESUME_TASK+to_str(e)
         raise Exception(msg)
Пример #6
0
 def exec_task(self, auth, ctx, node_id, action):
     manager = Basic.getGridManager()
     managed_node = manager.getNode(auth, node_id)
     if managed_node is not None:
         if not managed_node.is_authenticated():
             managed_node.connect()
         return manager.do_node_action(auth, node_id, action)
     else:
         raise Exception("Can not find the managed node")
Пример #7
0
    def exec_task(self, auth, ctx, node_id, directory,filenames):
        manager = Basic.getGridManager()
        managed_node = manager.getNode(auth, node_id)
        if managed_node is not None:
            if not managed_node.is_authenticated():
                managed_node.connect()
                NodeService().import_vm_config(auth,node_id, directory,filenames)
#            return manager.do_node_action(auth, node_id, action)
        else:
            raise Exception("Can not find the managed node")
Пример #8
0
    def exec_task(self, auth, ctx, node_id, directory,filenames):
        manager = Basic.getGridManager()
        managed_node = manager.getNode(auth, node_id)
        if managed_node is not None:
            if not managed_node.is_authenticated():
                managed_node.connect()
                NodeService().import_vm_config(auth,node_id, directory,filenames)
#            return manager.do_node_action(auth, node_id, action)
        else:
            raise Exception("Can not find the managed node")
Пример #9
0
    def exec_task(self, auth, ctx):
        manager = Basic.getGridManager()
        groups = manager.getGroupList(auth)
        for group in groups:
            nodes = manager.getNodeList(auth, group.id)
            for n in nodes:
                manager.refreshNodeMetrics(auth,n)

        ungrouped_nodes = manager.getNodeList(auth)
        for n in ungrouped_nodes:
            manager.refreshNodeMetrics(auth,n)
Пример #10
0
    def exec_task(self, auth, ctx):
        manager = Basic.getGridManager()
        groups = manager.getGroupList(auth)
        for group in groups:
            nodes = manager.getNodeList(auth, group.id)
            for n in nodes:
                manager.refreshNodeMetrics(auth,n)

        ungrouped_nodes = manager.getNodeList(auth)
        for n in ungrouped_nodes:
            manager.refreshNodeMetrics(auth,n)
Пример #11
0
 def resume_task(self, auth, ctx, dom_id, node_id, force):
     try:
         vm=DBSession.query(VM).filter(VM.id==dom_id).first()
         LOGGER.debug('resuming remove vm')
         if vm is None:
             LOGGER.debug('vm is already removed')
         else:
             manager = Basic.getGridManager()
             return manager.remove_vm(auth, dom_id, node_id, force)
     except Exception, e:
         msg=constants.RESUME_TASK+to_str(e)
         raise Exception(msg)
Пример #12
0
 def resume_task(self, auth, ctx, dom_id, node_id, force):
     try:
         vm=DBSession.query(VM).filter(VM.id==dom_id).first()
         LOGGER.debug('resuming remove vm')
         if vm is None:
             LOGGER.debug('vm is already removed')
         else:
             manager = Basic.getGridManager()
             return manager.remove_vm(auth, dom_id, node_id, force)
     except Exception, e:
         msg=constants.RESUME_TASK+to_str(e)
         raise Exception(msg)
Пример #13
0
    def do_nmap_ping(self, node_names, port=22):
        try:
            src_script_dir = os.path.abspath(tg.config.get('common_script'))
            ping_script_file = tg.config.get('nmap_script')

            src_script_file = os.path.join(src_script_dir,ping_script_file)
            cmd = src_script_file + " " + str(port) + " " + node_names

            local = Basic.getManagedNode()
            (output, exit_code) = local.node_proxy.exec_cmd(cmd, timeout=30)

            return (output, exit_code)
        except Exception, e:
            return ("", -1)
Пример #14
0
 def exec_task(self, auth, ctx):
     manager = Basic.getGridManager()
     groups = manager.getGroupList(auth)
     for group in groups:
         nodes = manager.getNodeList(auth, group.id)
         for n in nodes:
             try:
                 transaction.begin()
                 n=DBSession.query(ManagedNode).filter(ManagedNode.id==n.id).one()
                 n.refresh_environ()
                 n.get_running_vms()
                 n.socket=n.get_socket_info()
                 DBSession.add(n)
                 transaction.commit()
             except Exception, e:
                 LOGGER.error(to_str(e))
                 DBSession.rollback()
Пример #15
0
 def exec_task(self, auth, ctx):
     manager = Basic.getGridManager()
     groups = manager.getGroupList(auth)
     for group in groups:
         nodes = manager.getNodeList(auth, group.id)
         for n in nodes:
             try:
                 transaction.begin()
                 n=DBSession.query(ManagedNode).filter(ManagedNode.id==n.id).one()
                 n.refresh_environ()
                 n.get_running_vms()
                 n.socket=n.get_socket_info()
                 if n.is_up():
                     n.isHVM = n.is_HVM()
                 DBSession.add(n)
                 transaction.commit()
             except Exception, e:
                 LOGGER.error(to_str(e))
                 DBSession.rollback()
Пример #16
0
class StorageController(ControllerBase):

    tc = TaskCreator()
    manager = Basic.getGridManager()
    storage_service = StorageService()

    #    @expose(template='json')
    def get_storage_def_list(self,
                             site_id=None,
                             op_level=None,
                             group_id=None,
                             _dc=None):
        try:
            result = None
            self.authenticate()
            result = self.storage_service.get_storage_def_list(
                session['auth'], site_id, group_id, op_level)
        except Exception, ex:
            print_traceback()
            return {'success': False, 'msg': to_str(ex).replace("'", "")}
        return result
Пример #17
0
    def exec_task(self, auth, ctx,node_ids,sp_id):
        LOGGER.debug('entered in excec task for CollectMetricsForNodes task')
        strt = p_task_timing_start(MTR_LOGGER, "CollectMetrics", node_ids)
        try:
            manager = Basic.getGridManager()
            self.completed_nodes = []
            self.pending_nodes = [node_id for node_id in node_ids]
            self.exc_node_ids = [node_id for node_id in node_ids]
            index = 0
            node_id = self.get_next_node_id(index)
            while node_id is not None:
                self.pending_nodes.remove(node_id)
                m_node=DBSession.query(ManagedNode).filter(ManagedNode.id==node_id).one()
                index+=1
                node_id = self.get_next_node_id(index)
                if m_node is None :
                    continue
                self.current_node = m_node
                self.start_time = datetime.utcnow()
                try:
                    try:
                        strt1 = p_task_timing_start(MTR_LOGGER, "NodeGetMterics", m_node.id)
                        #call function to store the Server metrics into the database
                        node_snapshot=manager.collectServerMetrics(auth, m_node,filter=True)

                        #call function to store the VM metrics into the database table
                        manager.collectVMMetrics(auth, m_node.id, node_snapshot)
                        #collect metrics at serverpool level
                        manager.collectServerPoolMetrics(auth, sp_id)
                        DBSession.flush()
                        transaction.commit()
                        p_task_timing_end(MTR_LOGGER, strt1)
                    except Exception, e:
                        LOGGER.error("Error updating metrics . Server :"+m_node.hostname)
                        traceback.print_exc()
                finally:
                    self.completed_nodes.append(m_node.id)
        finally:
            self.check_if_hung()
            p_task_timing_end(MTR_LOGGER, strt)
Пример #18
0
    def exec_task(self, auth, ctx,node_ids,sp_id):
        LOGGER.debug('entered in excec task for CollectMetricsForNodes task')
        strt = p_task_timing_start(MTR_LOGGER, "CollectMetrics", node_ids)
        try:
            manager = Basic.getGridManager()
            self.completed_nodes = []
            self.pending_nodes = [node_id for node_id in node_ids]
            self.exc_node_ids = [node_id for node_id in node_ids]
            index = 0
            node_id = self.get_next_node_id(index)
            while node_id is not None:
                self.pending_nodes.remove(node_id)
                m_node=DBSession.query(ManagedNode).filter(ManagedNode.id==node_id).one()
                index+=1
                node_id = self.get_next_node_id(index)
                if m_node is None :
                    continue
                self.current_node = m_node
                self.start_time = datetime.utcnow()
                try:
                    try:
                        strt1 = p_task_timing_start(MTR_LOGGER, "NodeGetMterics", m_node.id)
                        #call function to store the Server metrics into the database
                        node_snapshot=manager.collectServerMetrics(auth, m_node,filter=True)

                        #call function to store the VM metrics into the database table
                        manager.collectVMMetrics(auth, m_node.id, node_snapshot)
                        #collect metrics at serverpool level
                        manager.collectServerPoolMetrics(auth, sp_id)
                        DBSession.flush()
                        transaction.commit()
                        p_task_timing_end(MTR_LOGGER, strt1)
                    except Exception, e:
                        LOGGER.error("Error updating metrics . Server :"+m_node.hostname)
                        traceback.print_exc()
                finally:
                    self.completed_nodes.append(m_node.id)
        finally:
            self.check_if_hung()
            p_task_timing_end(MTR_LOGGER, strt)
Пример #19
0
 def exec_task(self, auth, ctx, dom_list, source_node_id,\
                dest_node_id, live, force, all):
     manager = Basic.getGridManager()
     return manager.migrate_vm(auth, dom_list, source_node_id,\
                               dest_node_id, live, force, all)
Пример #20
0
 def exec_task(self, auth, ctx, node_id):
     manager = Basic.getGridManager()
     m_node = manager.getNode(auth, node_id)
     m_node._init_environ()
Пример #21
0
 def exec_task(self, auth, ctx, node_id, file):
     manager = Basic.getGridManager()
     return manager.restore_dom(auth, node_id, file)    
Пример #22
0
 def exec_task(self, auth, ctx, dom_id, node_id, file, directory):
     manager = Basic.getGridManager()
     return manager.save_dom(auth, dom_id, node_id, file, directory)
Пример #23
0
 def exec_task(self, auth, ctx, dom_id, node_id, snapshot_tag):
     manager = Basic.getGridManager()
     return manager.qcow2_snapshot_restore(auth, dom_id, node_id, snapshot_tag)
     return None;
Пример #24
0
 def exec_task(self, auth, ctx, dom_id, node_id, snapshot_name):
     manager = Basic.getGridManager()
     return manager.snapshot_qcow2_vm(auth, dom_id, node_id, snapshot_name)
     return None;
Пример #25
0
 def exec_task(self, auth, ctx, dom_id, node_id, file, directory):
     manager = Basic.getGridManager()
     return manager.save_dom(auth, dom_id, node_id, file, directory)
Пример #26
0
 def exec_task(self, auth, ctx, dom_list, source_node_id,\
                dest_node_id, live, force, all):
     manager = Basic.getGridManager()
     return manager.migrate_vm(auth, dom_list, source_node_id,\
                               dest_node_id, live, force, all)
Пример #27
0
 def exec_task(self, auth, ctx, node_id, **kw):
     manager = Basic.getGridManager()
     return manager.removeNode(auth, node_id, kw.get("force", False))
Пример #28
0
 def exec_task(self, auth, ctx, node_id, file):
     manager = Basic.getGridManager()
     return manager.restore_dom(auth, node_id, file)    
Пример #29
0
 def exec_task(self, auth, ctx, dom_id, node_id, action):
     manager = Basic.getGridManager()
     return manager.do_dom_action(auth, dom_id, node_id, action)
Пример #30
0
 def exec_task(self, auth, ctx, dom_id, node_id, force):
     manager = Basic.getGridManager()
     return manager.remove_vm(auth, dom_id, node_id, force)
Пример #31
0
 def exec_task(self, auth, ctx, dom_id, node_id, action):
     manager = Basic.getGridManager()
     return manager.do_dom_action(auth, dom_id, node_id, action)
Пример #32
0
 def exec_task(self, auth, ctx, dom_id, node_id, force):
     manager = Basic.getGridManager()
     return manager.remove_vm(auth, dom_id, node_id, force)
Пример #33
0
 def exec_task(self, auth, ctx, node_id, **kw):
     manager = Basic.getGridManager()
     return manager.removeNode(auth, node_id, kw.get("force", False))
Пример #34
0
 def exec_task(self, auth, ctx, node_id):
     manager = Basic.getGridManager()
     m_node = manager.getNode(auth, node_id)
     m_node._init_environ()
Пример #35
0
 def exec_task(self, auth, ctx):
     LOGGER.debug('entered in excec task E-mail sending task')
     manager = Basic.getGridManager()
     manager.send_notifications(auth)
Пример #36
0
 def exec_task(self, auth, ctx):
     LOGGER.debug('entered in excec task E-mail sending task')
     manager = Basic.getGridManager()
     manager.send_notifications(auth)