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


Python Proxy.ComponentProxy类代码示例

本文整理汇总了Python中Cobalt.Proxy.ComponentProxy的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy类的具体用法?Python ComponentProxy怎么用?Python ComponentProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: update

    def update (self, spec):
        if spec.has_key("users"):
            qm = ComponentProxy("queue-manager")
            try:
                qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
            except ComponentLookupError:
                logger.error("unable to contact queue manager when updating reservation users")
                raise
        # try the above first -- if we can't contact the queue-manager, don't update the users
        if spec.has_key('cycle') and not self.cycle:
            #we have just turned this into a cyclic reservation and need a cycle_id.
            spec['cycle_id'] = self.cycle_id_gen.get()
        #get the user name of whoever issued the command
        user_name = None
        if spec.has_key('__cmd_user'):
            user_name = spec['__cmd_user']
            del spec['__cmd_user']

        #if we're defering, pull out the 'defer' entry and send a cobalt db message.
        #there really isn't a corresponding field to update
        deferred = False
        if spec.has_key('defer'):
            logger.info("Res %s/%s: Deferring cyclic reservation: %s",
                        self.res_id, self.cycle_id, self.name) 
            dbwriter.log_to_db(user_name, "deferred", "reservation", self)
            del spec['defer']
            deferred = True

        Data.update(self, spec)

        if not deferred or not self.running:
            #we only want this if we aren't defering.  If we are, the cycle will 
            #take care of the new data object creation.
            dbwriter.log_to_db(user_name, "modifying", "reservation", self)
开发者ID:ido,项目名称:cobalt-svn-old,代码行数:34,代码来源:bgsched.py

示例2: metricmon

class metricmon(Component):
    """metrics mointor: monitors the real time statistics of interested metrics such as average waiting time and system utilization rate"""
    
    implementation = "imon"
    name = "imon"
    
    def __init__(self, *args, **kwargs):
        
        Component.__init__(self, *args, **kwargs)
        self.event_manager = ComponentProxy("event-manager")
        self.bqsim = ComponentProxy("queue-manager")
        self.mmon_logger = None
        
    def get_current_time_sec(self):
        return self.event_manager.get_current_time()
    
    def get_current_time_date(self):
        return self.event_manager.get_current_date_time()
    
    def init_mmon_logger(self):
        if self.mon_logger == None:
            self.mmon_logger = PBSlogger(self.bqsim.get_outputlog_string() + "-mmon")
          
    def metric_monitor(self):
        self.bqsim.monitor_metrics()
        
开发者ID:benmcclelland,项目名称:cobalt,代码行数:25,代码来源:metric_mon.py

示例3: fetch_hardware

def fetch_hardware():
    '''Autodetect which system we are trying to contact and perform hardware
    information fetch'''
    global partition_table
    global node_state
    global indexes
    global system_type
    # Generate a list of all possible nodecards in all possible partitions
    system = ComponentProxy('system', defer=True)
    if system_type is None:
        # We are self-discovering.  Can save this step if we
        # already know the system type.
        system_type = system.get_implementation()
    if system_type in bg_types:
        partition_table = dict((part['name'], part['node_card_names'])
            for part in system.get_partitions([{'name': '*',
                                                'node_card_names': '*'}]))
        node_state = {}
    elif system_type in cluster_types:
        partition_table = {}
        node_state = dict((node[0], node[1]) for node in system.get_node_status())
    elif system_type in cray_types:
        partition_table = {}
        # Using JSON for speed and avoinding the XML-RPC marshaller.
        stst = json.loads(system.get_nodes(True, None, alps_system_query_fields, True))
        indexes = {}
        for idx in stst:
            r = stst[idx]
            if r['status'] == 'busy':
                indexes[idx] = r['name']
        node_state = dict((k, v['status']) for k, v in stst.iteritems())
    else:
        raise RuntimeError('The %s system implementation is not supported by cweb')
    return system_type
开发者ID:ido,项目名称:cobalt,代码行数:34,代码来源:cweb.py

示例4: q_add

    def q_add (self, *args, **kwargs):
        '''Add a reservation to tracking.
        Side Efffects:
            -Add a queue to be tracked
            -If no cqm associated queue, create a reservation queue
            -set policies for new queue
            -emit numerous creation messages

        '''

        qm = ComponentProxy("queue-manager")
        try:
            queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
        except ComponentLookupError:
            logger.error("unable to contact queue manager when adding reservation")
            raise

        try:
            specs = args[0]
            for spec in specs:
                if "res_id" not in spec or spec['res_id'] == '*':
                    spec['res_id'] = bgsched_id_gen.get()
            reservations = Cobalt.Data.DataDict.q_add(self, *args, **kwargs)

        except KeyError, err:
            raise ReservationError("Error: a reservation named %s already exists" % err)
开发者ID:yfan000,项目名称:cobalt,代码行数:26,代码来源:bgsched.py

示例5: __init__

 def __init__(self, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     self.event_manager = ComponentProxy("event-manager")
     self.bqsim = ComponentProxy("queue-manager")
     self.powmon_logger = None
     self.total_cost = 0.0
     self.time_power_list =[{"unixtime":0, "power":0, "count":0, "utilization":0}]
开发者ID:zzhou,项目名称:Qsim_PowerAware,代码行数:7,代码来源:pwmonitor.py

示例6: update

 def update (self, spec):
     if spec.has_key("users"):
         qm = ComponentProxy(self.COMP_QUEUE_MANAGER)
         try:
             qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
         except ComponentLookupError:
             logger.error("unable to contact queue manager when updating reservation users")
             raise
     # try the above first -- if we can't contact the queue-manager, don't update the users
     Data.update(self, spec)
开发者ID:zzhou,项目名称:Qsim_Topology,代码行数:10,代码来源:bgsched.py

示例7: _start_job

    def _start_job(self, job, partition_list):
        cqm = ComponentProxy(self.COMP_QUEUE_MANAGER)
        
        try:
            self.logger.info("trying to start job %d on partition %r" % (job.jobid, partition_list))
            cqm.run_jobs([{'tag':"job", 'jobid':job.jobid}], partition_list)
        except ComponentLookupError:
            self.logger.error("failed to connect to queue manager")
            return

        self.started_jobs[job.jobid] = self.get_current_time()
开发者ID:zzhou,项目名称:Qsim_Topology,代码行数:11,代码来源:bgsched.py

示例8: q_del

 def q_del (self, *args, **kwargs):
     reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
     qm = ComponentProxy('queue-manager')
     queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
     spec = [{'name': reservation.queue} for reservation in reservations \
             if reservation.createdQueue and reservation.queue in queues and \
             not self.q_get([{'queue':reservation.queue}])]
     try:
         qm.set_queues(spec, {'state':"dead"}, "bgsched")
     except Exception, e:
         logger.error("problem disabling reservation queue (%s)" % e)
开发者ID:zzhou,项目名称:Qsim_Topology,代码行数:11,代码来源:bgsched.py

示例9: q_add

 def q_add (self, *args, **kwargs):
     qm = ComponentProxy(self.COMP_QUEUE_MANAGER)
     try:
         queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
     except ComponentLookupError:
         logger.error("unable to contact queue manager when adding reservation")
         raise
     
     try:
         reservations = Cobalt.Data.DataDict.q_add(self, *args, **kwargs)
     except KeyError, e:
         raise ReservationError("Error: a reservation named %s already exists" % e)
开发者ID:zzhou,项目名称:Qsim_Topology,代码行数:12,代码来源:bgsched.py

示例10: _start_job

    def _start_job(self, job, partition_list, resid=None):
        """Get the queue manager to start a job."""

        cqm = ComponentProxy("queue-manager")
        
        try:
            self.logger.info("trying to start job %d on partition %r" % (job.jobid, partition_list))
            cqm.run_jobs([{'tag':"job", 'jobid':job.jobid}], partition_list, None, resid)
        except ComponentLookupError:
            self.logger.error("failed to connect to queue manager")
            return

        self.started_jobs[job.jobid] = self.get_current_time()
开发者ID:ido,项目名称:cobalt-svn-old,代码行数:13,代码来源:bgsched.py

示例11: q_add

    def q_add (self, *args, **kwargs):
        qm = ComponentProxy("queue-manager")
        try:
            queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
        except ComponentLookupError:
            logger.error("unable to contact queue manager when adding reservation")
            raise
        
        try:
            specs = args[0]
            for spec in specs:
                if "res_id" not in spec or spec['res_id'] == '*':
                    spec['res_id'] = bgsched_id_gen.get()
            reservations = Cobalt.Data.DataDict.q_add(self, *args, **kwargs)

        except KeyError, e:
            raise ReservationError("Error: a reservation named %s already exists" % e)
开发者ID:ido,项目名称:cobalt-svn-old,代码行数:17,代码来源:bgsched.py

示例12: cobalt_query

def cobalt_query(state):
    cqm = ComponentProxy('queue-manager', defer=True)
    scheduler = ComponentProxy('scheduler', defer=True)
    if state not in ('running', 'queued', 'reservation'):
        return None
    # Templates for queries to coblat

    query_job = dict.fromkeys(job_query_fields, '*')
    query_res = dict.fromkeys(reservation_query_fields, '*')
    if state == 'reservation':
        return scheduler.get_reservations([query_res])
    if state == 'running' or state == 'starting':
        query_job['state'] = 'running'
        query_job['location'] = '*'
    if state == 'queued':
        query_job['state'] = 'queued'
        query_job['score'] = '*'
    return cqm.get_jobs([query_job])
开发者ID:ido,项目名称:cobalt,代码行数:18,代码来源:cweb.py

示例13: q_del

    def q_del (self, *args, **kwargs):
        '''Delete a reservation from tracking.
        Side Effects: Removes a queue from tracking.
                      Logs that the reservation has terminated.
                      Emits a terminated database record
                      Attempts to mark the queue dead in the queue-manager.
                      Marks the reservation as dying

        '''
        reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
        qm = ComponentProxy('queue-manager')
        queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
        spec = [{'name': reservation.queue} for reservation in reservations \
                if reservation.createdQueue and reservation.queue in queues \
                and not self.q_get([{'queue':reservation.queue}])]
        try:
            qm.set_queues(spec, {'state':"dead"}, "bgsched")
        except Exception, err:
            logger.error("problem disabling reservation queue (%s)" % err)
开发者ID:yfan000,项目名称:cobalt,代码行数:19,代码来源:bgsched.py

示例14: PowerMonitor

class PowerMonitor(Component):
    """ Power Monitor. Monitor runtime power consumption, logging into output log or provide to scheduler for power-aware job scheduling"""

    implementation = "powmon"
    name = "powmon"


    def __init__(self, *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.event_manager = ComponentProxy("event-manager")
        self.bqsim = ComponentProxy("queue-manager")
        self.powmon_logger = None
        
    def init_powmon_logger(self):
        if self.iomon_logger == None:
            self.iomon_logger = PBSlogger(self.bqsim.get_outputlog_string() + "-powmon")
        
    
    def monitor_power(self):
        print "monitor_power"
        
        
        
开发者ID:zzhou,项目名称:Qsim_PowerAware,代码行数:20,代码来源:pwmonitor.py

示例15: ComponentProxy

if __name__ == '__main__':
    if '--version' in sys.argv:
        print "partadm %s" % __revision__
        print "cobalt %s" % __version__
        raise SystemExit, 0
    try:
        (opts, args) = getopt.getopt(sys.argv[1:], 'adlrs:',
                                     ['dump', 'free', 'load=', 'enable', 'disable', 'activate', 'deactivate',
                                      'queue=', 'deps=', 'xml', 'diag=', 'fail', 'unfail', 'savestate'])
    except getopt.GetoptError, msg:
        print msg
        print helpmsg
        raise SystemExit, 1
    try:
        system = ComponentProxy("system", defer=False)
    except ComponentLookupError:
        print "Failed to connect to system component"
        raise SystemExit, 1

    whoami = getpass.getuser()
    
    if '-r' in sys.argv:
        partdata = system.get_partitions([{'tag':'partition', 'name':name, 'children':'*'} for name in args])
        parts = args
        
        for part in partdata:
            for child in part['children']:
                if child not in parts:
                    parts.append(child)
    else:
开发者ID:zzhou,项目名称:Qsim_PowerAware,代码行数:30,代码来源:partadm.py


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