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


Python gettextutils._函数代码示例

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


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

示例1: monitor_thread_pool

 def monitor_thread_pool(self, thread_info=None, condition=None):
     global launchd_threads_info
     if thread_info is None:
         thread_info = launchd_threads_info
     if condition is None:
         condition = self._condition
     while True:
         condition.acquire()
         for each_thread in iter(thread_info.keys()):
             if 'result' in thread_info[each_thread].keys():
                 LOG.debug(_("Worker Thread # for VNF configuration Ending"), thread_info[each_thread])
                 LOG.debug(_("%s"), thread_info)
                 #print "Result:  "+str(thread_info[each_thread]['result'])+'\n'
                 ## TODO(padmaja, anirudh): The return value to be standardized, 
                 #                          to enable support crosss language drivers.
                 status = 'ERROR' if 'Error' in str(thread_info[each_thread]['result']) else 'COMPLETE' 
                 self.vplugin_rpc.send_ack(self.ctx,
                                            thread_info[each_thread]['vnfd'],
                                            thread_info[each_thread]['vdu'],
                                            thread_info[each_thread]['vm_name'],
                                            status,
                                            self.nsd_id)
                 if thread_info[each_thread]['thread_obj'].isAlive():
                     thread_info[each_thread]['thread_obj'].kill()
                 del(thread_info[each_thread])
         condition.wait()
         condition.release()
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:27,代码来源:vnf_manager.py

示例2: _inner

        def _inner():
            if initial_delay:
                greenthread.sleep(initial_delay)

            try:
                while self._running:
                    start = timeutils.utcnow()
                    self.f(*self.args, **self.kw)
                    end = timeutils.utcnow()
                    if not self._running:
                        break
                    delay = interval - timeutils.delta_seconds(start, end)
                    if delay <= 0:
                        LOG.warn(_('task run outlasted interval by %s sec') %
                                 -delay)
                    greenthread.sleep(delay if delay > 0 else 0)
            except LoopingCallDone as e:
                self.stop()
                done.send(e.retvalue)
            except Exception:
                LOG.exception(_('in fixed duration looping call'))
                done.send_exception(*sys.exc_info())
                return
            else:
                done.send(True)
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:25,代码来源:loopingcall.py

示例3: monitor_thread_pool

 def monitor_thread_pool(self, thread_info=None, condition=None):
     global launchd_threads_info
     if thread_info is None:
         thread_info = launchd_threads_info
     if condition is None:
         condition = self._condition
     while True:
         condition.acquire()
         for each_thread in iter(thread_info.keys()):
             if 'result' in thread_info[each_thread].keys():
                 LOG.debug(_("Worker Thread # for VNF configuration Ending"), thread_info[each_thread])
                 LOG.debug(_("%s"), thread_info)
                 status = 'ERROR' if 'ERROR' in str(thread_info[each_thread]['result']) else 'COMPLETE' 
                 self.vplugin_rpc.send_ack(self.ctx,
                                            thread_info[each_thread]['vnfd'],
                                            thread_info[each_thread]['vdu'],
                                            thread_info[each_thread]['vm_name'],
                                            status,
                                            self.nsd_id, self.ns_config)
                 if status == "COMPLETE":
                     self.drv_conf[thread_info[each_thread]['vdu']]['COMPLETE'].append(thread_info[each_thread]['vm_name'])
                 if thread_info[each_thread]['thread_obj'].isAlive():
                     thread_info[each_thread]['thread_obj'].kill()
                 del(thread_info[each_thread])
         condition.wait()
         condition.release()
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:26,代码来源:vnf_manager.py

示例4: inner

 def inner(*args, **kwargs):
     try:
         with lock(name, lock_file_prefix, external, lock_path):
             LOG.debug(_('Got semaphore / lock "%(function)s"'),
                       {'function': f.__name__})
             return f(*args, **kwargs)
     finally:
         LOG.debug(_('Semaphore / lock released "%(function)s"'),
                   {'function': f.__name__})
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:9,代码来源:lockutils.py

示例5: _configure_service

 def _configure_service(self, vdu, instance, mgmt_ip, configuration_event):
     status = "ERROR"
     try:
         #vdu['_drv_obj'].configure_service(instance)
         LOG.debug(_("Configuration of VNF being carried out on VDU:%s with IP:%s"), vdu, mgmt_ip)
         status = vdu['_drv_obj'].push_configuration(instance, mgmt_ip, configuration_event)
     except exceptions.DriverException or Exception:
         LOG.exception(_("Configuration of VNF Failed!!"))
     finally:
         return status
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:10,代码来源:vnf_manager_latest_with_update.py

示例6: configure_service

    def configure_service(self, *args, **kwargs):
         """configure the service """
         self._check_connection()
         conf_dict = {"private_ip": self.localip , "public_ip": self.localip , "chronos_ip": self.localip, "homer_ip": self.localip , "service_name": "homer"}
         confstr = templates.homer_settings.format(**conf_dict)
         conf_dict1 = {"service_homer": "cassandra"}
         confstr1 = templates.homer_service.format(**conf_dict1)
         configuration_done = False
         while not configuration_done:
             try:
                 with manager.connect(host=self.mgmtip, username=self.username, password=self.password, port=830, hostkey_verify=False) as m:
                     print "VM is UP"
                     LOG.debug(_("VM is UP"))
                     configuration_done = True
                     c = m.get_config(source='running').data_xml
                     LOG.debug(_("config %s"), c)
                     #c1 = m.edit_config(target='candidate', config=confstr1)
                     #m.commit()
                     c2 = m.edit_config(target='candidate', config=confstr)
                     m.commit(confirmed=False, timeout=300)
             except Exception as e:
                 LOG.debug(_("VM is DOWN %s"), e)
                 LOG.debug(_("VM is DOWN"))
                 print e
                 print "VM is down"
                 time.sleep(5)      
             

         """
         with manager.connect(host=self.mgmtip, username=self.username, password=self.password, port=830, hostkey_verify=False) as m:
             c = m.get_config(source='running').data_xml
             #c1 = m.edit_config(target='candidate', config=confstr1)
             #m.commit()
             c2 = m.edit_config(target='candidate', config=confstr)
             m.commit()
         """


         """
         with manager.connect(host=self.mgmtip, port=830, username=self.username, password=self.password, hostkey_verify=False) as m:
         #m = manager.connect(self.mgmtip, port=830, username=self.username, password=self.password,hostkey_verify=False)
             try:
                 print(m)
                 print("in try")
                 c = m.get_config(source='running').data_xml
                 print c
                 c1 = m.edit_config(target='candidate', config=confstr)
                 print c1
             finally:
                 print("in final")
             m.commit()
             #m.close_session()
         """

         """
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:55,代码来源:homer_driver.py

示例7: _invoke_driver_thread

 def _invoke_driver_thread(self, vdu, instance, vdu_name):
     global launchd_threads_info
     LOG.debug(_("Configuration of the remote VNF %s being intiated"), instance)
     _thr_id = str(uuid.generate_uuid()).split('-')[1]   
     try:
        driver_thread = ImplThread(self._configure_service, self._condition, vdu, instance, _id = _thr_id)
        self._condition.acquire()
        launchd_threads_info[_thr_id] = {'vm_name': instance, 'thread_obj': driver_thread, 'vnfd': vdu['_vnfd'], 'vdu':vdu_name}
        self._condition.release()
        driver_thread.start()
     except RuntimeError:
        LOG.warning(_("Configuration by the Driver Failed!"))
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:12,代码来源:vnf_manager.py

示例8: __init__

    def __init__(self, conf):
        LOG.debug(_("Bono __init__"))
        LOG.debug(_(conf))
        self.__ncport = "830"
        self.retries = 10
        self.homerip = "0.0.0.0"
        self.hsip = "0.0.0.0"
        self.sproutip = "0.0.0.0"

        self.parse(conf)
        try:
            self.__uname = "user="+self.username
            self.__pswd = "password="+self.password
        except KeyError:
            raise
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:15,代码来源:bono_driver.py

示例9: _report_state

 def _report_state(self):
     try:
         self.agent_state.get('configurations').update(
             self.cache.get_state())
         ctx = context.get_admin_context_without_session()
         self.state_rpc.report_state(ctx, self.agent_state, self.use_call)
     except AttributeError:
         # This means the server does not support report_state
         LOG.warn(_("VNF server does not support state report."
                    " State report for this agent will be disabled."))
         self.heartbeat.stop()
         return
     except Exception:
         LOG.exception(_("Failed reporting state!"))
         return
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:15,代码来源:vnf_manager.py

示例10: bool_from_string

def bool_from_string(subject, strict=False, default=False):
    """Interpret a string as a boolean.

    A case-insensitive match is performed such that strings matching 't',
    'true', 'on', 'y', 'yes', or '1' are considered True and, when
    `strict=False`, anything else returns the value specified by 'default'.

    Useful for JSON-decoded stuff and config file parsing.

    If `strict=True`, unrecognized values, including None, will raise a
    ValueError which is useful when parsing values passed in from an API call.
    Strings yielding False are 'f', 'false', 'off', 'n', 'no', or '0'.
    """
    if not isinstance(subject, six.string_types):
        subject = six.text_type(subject)

    lowered = subject.strip().lower()

    if lowered in TRUE_STRINGS:
        return True
    elif lowered in FALSE_STRINGS:
        return False
    elif strict:
        acceptable = ', '.join(
            "'%s'" % s for s in sorted(TRUE_STRINGS + FALSE_STRINGS))
        msg = _("Unrecognized value '%(val)s', acceptable values are:"
                " %(acceptable)s") % {'val': subject,
                                      'acceptable': acceptable}
        raise ValueError(msg)
    else:
        return default
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:31,代码来源:strutils.py

示例11: main

def main(manager='vnfmanager.vnf_manager.VNFMgrWithStateReport'):

    # placebo func to replace the server/__init__ with project startup. 
    # pool of threads needed to spawn worker threads for RPC.
    # Default action for project's startup, explictly maintainly a pool
    # for manager as it cannot inherit the vnfsvc's thread pool.
    pool = eventlet.GreenPool()
    pool.waitall()

    conf_params = read_sys_args(sys.argv)
    _register_opts(cfg.CONF)
    common_config.init(sys.argv[1:])
    uuid = conf_params['uuid']
    config.setup_logging(cfg.CONF)
    LOG.warn(_("UUID: %s"), uuid)
    vnfm_conf_dir = conf_params['vnfm_conf_dir'].split("/")
    vnfm_conf_dir[-2] = uuid
    vnfm_conf_dir = "/".join(vnfm_conf_dir)
    vnfm_conf_path = vnfm_conf_dir+uuid+'.yaml'
    load_vnfm_conf(vnfm_conf_path)
    server = vnfsvc_service.Service.create(
                binary='vnf-manager',
                topic=topics.set_topic_name(uuid, prefix=topics.VNF_MANAGER),
                report_interval=60, manager=manager)
    service.launch(server).wait()
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:25,代码来源:vnf_manager.py

示例12: execute

def execute(cmd, root_helper=None, process_input=None, addl_env=None,
            check_exit_code=True, return_stderr=False):
    try:
        obj, cmd = create_process(cmd, root_helper=root_helper,
                                  addl_env=addl_env)
        _stdout, _stderr = (process_input and
                            obj.communicate(process_input) or
                            obj.communicate())
        obj.stdin.close()
        m = _("\nCommand: %(cmd)s\nExit code: %(code)s\nStdout: %(stdout)r\n"
              "Stderr: %(stderr)r") % {'cmd': cmd, 'code': obj.returncode,
                                       'stdout': _stdout, 'stderr': _stderr}
        if obj.returncode:
            LOG.error(m)
            if check_exit_code:
                raise RuntimeError(m)
        else:
            LOG.debug(m)
    finally:
        # NOTE(termie): this appears to be necessary to let the subprocess
        #               call clean something up in between calls, without
        #               it two execute calls in a row hangs the second one
        greenthread.sleep(0)

    return return_stderr and (_stdout, _stderr) or _stdout
开发者ID:hemanthnakkina,项目名称:vnfmanager,代码行数:25,代码来源:utils.py

示例13: deprecated

    def deprecated(self, msg, *args, **kwargs):
        """Call this method when a deprecated feature is used.

        If the system is configured for fatal deprecations then the message
        is logged at the 'critical' level and :class:`DeprecatedConfig` will
        be raised.

        Otherwise, the message will be logged (once) at the 'warn' level.

        :raises: :class:`DeprecatedConfig` if the system is configured for
                 fatal deprecations.

        """
        stdmsg = _("Deprecated: %s") % msg
        if CONF.fatal_deprecations:
            self.critical(stdmsg, *args, **kwargs)
            raise DeprecatedConfig(msg=stdmsg)

        # Using a list because a tuple with dict can't be stored in a set.
        sent_args = self._deprecated_messages_sent.setdefault(msg, list())

        if args in sent_args:
            # Already logged this message, so don't log it again.
            return

        sent_args.append(args)
        self.warn(stdmsg, *args, **kwargs)
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:27,代码来源:log.py

示例14: _configure_vdu

 def _configure_vdu(self, vdu_name, method, arguments ,scale=False, update=False):    ## ARGS ADDED BY ANIRUDH
     status = ""
     for instance in range(0,len(self.drv_conf[vdu_name]['_instances'])):
         instance_name = self.drv_conf[vdu_name]['_instances'][instance]
         if instance_name not in self.drv_conf[vdu_name]['COMPLETE'] or update:
             try:
                 if not self.drv_conf[vdu_name]['_driver']:
                     status = 'COMPLETE'
                     self.vplugin_rpc.send_ack(self.ctx, self.drv_conf[vdu_name]['_vnfd'],
                                           vdu_name,
                                           instance_name,
                                           #self.drv_conf[vdu_name]['_mgmt_ips'][instance_name],
                                           status,
                                           self.nsd_id, self.ns_config)
                     self.drv_conf[vdu_name][status].append(instance_name)
                 else:
                     self._invoke_driver_thread(self.drv_conf[vdu_name],
                                            instance_name,
                                            vdu_name,
                                            self.drv_conf[vdu_name]['_mgmt_ips'][instance_name],
                                            method,
                                            arguments,
                                            scale)
                     status = 'COMPLETE'
             except Exception:
                 status = 'ERROR'
                 LOG.warn(_("Configuration Failed for VNF %s"), instance_name)
                 self.vplugin_rpc.send_ack(self.ctx,
                                           self.drv_conf[vdu_name]['_vnfd'],
                                           vdu_name,
                                       instance_name,
                                       status,
                                       self.nsd_id, self.ns_config)
     return status
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:34,代码来源:vnf_manager.py

示例15: parse

    def parse(self,cfg):
        for i in range(0, len(cfg['Ims'])):
            regex = re.compile('^(vBono)\_\d*$')
            #if(cfg['Ims'][i]['name']=="vBono"):
            if re.search(regex, cfg['Ims'][i]['name']):
                LOG.debug(_("CONDITION*********************************SATISFIED"))
                self.username=cfg['Ims'][i]['vm_details']['image_details']['username']
                self.password=cfg['Ims'][i]['vm_details']['image_details']['password']
                #self.pkt_in_ips_key = cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'].keys()[0]
                self.localip=cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips']['ims-'+cfg['Ims'][i]['name']]
                self.publicip=cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips']['ims-'+cfg['Ims'][i]['name']]
                self.mgmtip=cfg['Ims'][i]['vm_details']['network_interfaces']['management-interface']['ips']['ims-'+cfg['Ims'][i]['name']]
         
                     
            if(cfg['Ims'][i]['name']=="vSprout"):
                self.pkt_in_ips_key = cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'].keys()[0]
                self.sproutip=cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'][self.pkt_in_ips_key]

            if(cfg['Ims'][i]['name']=="vHomer"):
                self.pkt_in_ips_key = cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'].keys()[0]
                self.homerip=cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'][self.pkt_in_ips_key]

            if(cfg['Ims'][i]['name']=="vHS"):
                self.pkt_in_ips_key = cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'].keys()[0]
                self.hsip=cfg['Ims'][i]['vm_details']['network_interfaces']['pkt-in']['ips'][self.pkt_in_ips_key]
开发者ID:MounikaPandiri,项目名称:mybackup,代码行数:25,代码来源:bono_driver.py


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