Esempio n. 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
Esempio n. 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
Esempio n. 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")
Esempio n. 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)
Esempio n. 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)
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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)
Esempio 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)
Esempio 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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()
Esempio n. 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()
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 20
0
 def exec_task(self, auth, ctx, node_id):
     manager = Basic.getGridManager()
     m_node = manager.getNode(auth, node_id)
     m_node._init_environ()
Esempio n. 21
0
 def exec_task(self, auth, ctx, node_id, file):
     manager = Basic.getGridManager()
     return manager.restore_dom(auth, node_id, file)    
Esempio n. 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)
Esempio n. 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;
Esempio n. 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;
Esempio n. 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)
Esempio n. 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)
Esempio n. 27
0
 def exec_task(self, auth, ctx, node_id, **kw):
     manager = Basic.getGridManager()
     return manager.removeNode(auth, node_id, kw.get("force", False))
Esempio n. 28
0
 def exec_task(self, auth, ctx, node_id, file):
     manager = Basic.getGridManager()
     return manager.restore_dom(auth, node_id, file)    
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 33
0
 def exec_task(self, auth, ctx, node_id, **kw):
     manager = Basic.getGridManager()
     return manager.removeNode(auth, node_id, kw.get("force", False))
Esempio n. 34
0
 def exec_task(self, auth, ctx, node_id):
     manager = Basic.getGridManager()
     m_node = manager.getNode(auth, node_id)
     m_node._init_environ()
Esempio n. 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)
Esempio n. 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)