Пример #1
0
 def _populate_vnfd_drivers(self, drv_conf):
     vnfd_drv_cls_path = drv_conf['_driver']
     try:
         drv_conf['_drv_obj'] = importutils.import_object(vnfd_drv_cls_path,
                                                          self.ns_config)
     except Exception:
         LOG.warn(_("%s driver not Loaded"), vnfd_drv_cls_path)
         raise
Пример #2
0
 def _populate_vnfd_drivers(self, drv_conf):
     vnfd_drv_cls_path = drv_conf['_driver']
     username = drv_conf['_username']
     password = drv_conf['_password']
     lf_events = drv_conf['_lc_events']
     try:
         drv_conf['_drv_obj'] = importutils.import_object(vnfd_drv_cls_path,
                                                          self.ns_config,
                                                          username = username, 
                                                          password = password)
     except Exception:
         LOG.warn(_("%s driver not Loaded"), vnfd_drv_cls_path)
         raise
Пример #3
0
    def _populate_vnfd_drivers(self, drv_conf):
        vnfd_drv_cls_path = {}
        for event in drv_conf['_lc_events']:
            vnfd_drv_cls_path[event] = drv_conf[event]['_driver']
        username = drv_conf['_username']
        password = drv_conf['_password']
        lf_events = drv_conf['_lc_events']
        try:
            for event in drv_conf['_lc_events']:
                kwargs = {
                    'conf': self.ns_config,
                    'username': username,
                    'password': password
                }

                drv_conf[event]['_drv_obj'] = importutils.import_object(
                    vnfd_drv_cls_path[event], **kwargs)
        except Exception:
            LOG.warn(_("%s driver not Loaded"), vnfd_drv_cls_path[event])
            raise
Пример #4
0
    def postConfigure(self, context, conf):
        LOG.debug(_(" In post configure"))
        for instance in conf['instances_list']:
            mgmt_ip = conf['mgmt-ip'][instance]
            _thr_id = str(uuid.generate_uuid()).split('-')[1]
            vdu = {}
            vdu['name'] = conf['vdu']
            kwargs = {
                'conf': self.ns_config,
                'username': self.drv_conf[vdu['name']]['_username'],
                'password': self.drv_conf[vdu['name']]['_password']
            }

            drv_obj = importutils.import_object(conf['driver'], **kwargs)
            self.drv_conf[vdu['name']]['config'] = {}
            self.drv_conf[vdu['name']]['config']['_driver'] = conf['driver']
            vdu['config'] = {}
            vdu['config']['_drv_obj'] = drv_obj
            method = 'postconfigure'
            arguments = conf['data']
            configThread = ImplThread(self._configure_service,
                                      self._condition,
                                      vdu,
                                      instance,
                                      mgmt_ip,
                                      method,
                                      arguments,
                                      conf['event'],
                                      _id=_thr_id)
            self._condition.acquire()
            launchd_threads_info[_thr_id] = {
                'vm_name': instance,
                'thread_obj': configThread,
                'vnfd': conf['vnf'],
                'vdu': conf['vdu'],
                'conf': conf,
                'event': "postconfigure"
            }
            self._condition.release()
            configThread.start()
Пример #5
0
def _setup_logging_from_conf(project, version):
    log_root = getLogger(None).logger
    for handler in log_root.handlers:
        log_root.removeHandler(handler)

    if CONF.use_syslog:
        facility = _find_facility_from_conf()
        if CONF.use_syslog_rfc_format:
            syslog = RFCSysLogHandler(address='/dev/log',
                                      facility=facility)
        else:
            syslog = logging.handlers.SysLogHandler(address='/dev/log',
                                                    facility=facility)
        log_root.addHandler(syslog)

    logpath = _get_log_file_path()
    if logpath:
        filelog = logging.handlers.WatchedFileHandler(logpath)
        log_root.addHandler(filelog)

    if CONF.use_stderr:
        streamlog = ColorHandler()
        log_root.addHandler(streamlog)

    elif not logpath:
        # pass sys.stdout as a positional argument
        # python2.6 calls the argument strm, in 2.7 it's stream
        streamlog = logging.StreamHandler(sys.stdout)
        log_root.addHandler(streamlog)

    if CONF.publish_errors:
        try:
            handler = importutils.import_object(
                "vnfmanager.openstack.common.log_handler.PublishErrorsHandler",
                logging.ERROR)
        except ImportError:
            handler = importutils.import_object(
                "oslo.messaging.notify.log_handler.PublishErrorsHandler",
                logging.ERROR)
        log_root.addHandler(handler)

    datefmt = CONF.log_date_format
    for handler in log_root.handlers:
        # NOTE(alaski): CONF.log_format overrides everything currently.  This
        # should be deprecated in favor of context aware formatting.
        if CONF.log_format:
            handler.setFormatter(logging.Formatter(fmt=CONF.log_format,
                                                   datefmt=datefmt))
            log_root.info('Deprecated: log_format is now deprecated and will '
                          'be removed in the next release')
        else:
            handler.setFormatter(ContextFormatter(project=project,
                                                  version=version,
                                                  datefmt=datefmt))

    if CONF.debug:
        log_root.setLevel(logging.DEBUG)
    elif CONF.verbose:
        log_root.setLevel(logging.INFO)
    else:
        log_root.setLevel(logging.WARNING)

    for pair in CONF.default_log_levels:
        mod, _sep, level_name = pair.partition('=')
        logger = logging.getLogger(mod)
        # NOTE(AAzza) in python2.6 Logger.setLevel doesn't convert string name
        # to integer code.
        if sys.version_info < (2, 7):
            level = logging.getLevelName(level_name)
            logger.setLevel(level)
        else:
            logger.setLevel(level_name)
Пример #6
0
def _setup_logging_from_conf(project, version):
    log_root = getLogger(None).logger
    for handler in log_root.handlers:
        log_root.removeHandler(handler)

    if CONF.use_syslog:
        facility = _find_facility_from_conf()
        if CONF.use_syslog_rfc_format:
            syslog = RFCSysLogHandler(address="/dev/log", facility=facility)
        else:
            syslog = logging.handlers.SysLogHandler(address="/dev/log", facility=facility)
        log_root.addHandler(syslog)

    logpath = _get_log_file_path()
    if logpath:
        filelog = logging.handlers.WatchedFileHandler(logpath)
        log_root.addHandler(filelog)

    if CONF.use_stderr:
        streamlog = ColorHandler()
        log_root.addHandler(streamlog)

    elif not logpath:
        # pass sys.stdout as a positional argument
        # python2.6 calls the argument strm, in 2.7 it's stream
        streamlog = logging.StreamHandler(sys.stdout)
        log_root.addHandler(streamlog)

    if CONF.publish_errors:
        try:
            handler = importutils.import_object(
                "vnfmanager.openstack.common.log_handler.PublishErrorsHandler", logging.ERROR
            )
        except ImportError:
            handler = importutils.import_object("oslo.messaging.notify.log_handler.PublishErrorsHandler", logging.ERROR)
        log_root.addHandler(handler)

    datefmt = CONF.log_date_format
    for handler in log_root.handlers:
        # NOTE(alaski): CONF.log_format overrides everything currently.  This
        # should be deprecated in favor of context aware formatting.
        if CONF.log_format:
            handler.setFormatter(logging.Formatter(fmt=CONF.log_format, datefmt=datefmt))
            log_root.info("Deprecated: log_format is now deprecated and will " "be removed in the next release")
        else:
            handler.setFormatter(ContextFormatter(project=project, version=version, datefmt=datefmt))

    if CONF.debug:
        log_root.setLevel(logging.DEBUG)
    elif CONF.verbose:
        log_root.setLevel(logging.INFO)
    else:
        log_root.setLevel(logging.WARNING)

    for pair in CONF.default_log_levels:
        mod, _sep, level_name = pair.partition("=")
        logger = logging.getLogger(mod)
        # NOTE(AAzza) in python2.6 Logger.setLevel doesn't convert string name
        # to integer code.
        if sys.version_info < (2, 7):
            level = logging.getLevelName(level_name)
            logger.setLevel(level)
        else:
            logger.setLevel(level_name)
Пример #7
0
 def _extract_monitor_drv(self):
     global _monitor_drv
     if self.monitor:
         LOG.debug(_("Loading Monitoring driver for the network service"))
         self._monitor_drv_path = _monitor_drv + self.monitor['driver']
         self._monitor_driver = importutils.import_object(self._monitor_drv_path)