Exemplo n.º 1
0
    def __init__(self, cfg):
        self.cfg = cfg

        try:
            self.name = cfg['name']
            try:
                self.interval = int(cfg['interval'])
            except ValueError:
                raise PipelineException("Invalid interval value", cfg)
            # Support 'counters' for backward compatibility
            self.meters = cfg.get('meters', cfg.get('counters'))
            self.sinks = cfg.get('sinks')
        except KeyError as err:
            raise PipelineException(
                "Required field %s not specified" % err.args[0], cfg)

        if self.interval <= 0:
            raise PipelineException("Interval value should > 0", cfg)

        self.resources = cfg.get('resources') or []
        if not isinstance(self.resources, list):
            raise PipelineException("Resources should be a list", cfg)

        self.discovery = cfg.get('discovery') or []
        if not isinstance(self.discovery, list):
            raise PipelineException("Discovery should be a list", cfg)

        self._check_meters()
Exemplo n.º 2
0
    def __init__(self, cfg, transformer_manager):
        self.cfg = cfg

        try:
            self.name = cfg["name"]
            try:
                self.interval = int(cfg["interval"])
            except ValueError:
                raise PipelineException("Invalid interval value", cfg)
            # Support 'counters' for backward compatibility
            self.meters = cfg.get("meters", cfg.get("counters"))
            # It's legal to have no transformer specified
            self.transformer_cfg = cfg["transformers"] or []
        except KeyError as err:
            raise PipelineException("Required field %s not specified" % err.args[0], cfg)

        if self.interval <= 0:
            raise PipelineException("Interval value should > 0", cfg)

        self._check_meters()

        if not cfg.get("publishers"):
            raise PipelineException("No publisher specified", cfg)

        self.publishers = []
        for p in cfg["publishers"]:
            if "://" not in p:
                # Support old format without URL
                p = p + "://"
            try:
                self.publishers.append(publisher.get_publisher(p))
            except Exception:
                LOG.exception("Unable to load publisher %s", p)

        self.transformers = self._setup_transformers(cfg, transformer_manager)
Exemplo n.º 3
0
    def __init__(self, cfg):
        self.cfg = cfg

        try:
            self.name = cfg["name"]
            try:
                self.interval = int(cfg["interval"])
            except ValueError:
                raise PipelineException("Invalid interval value", cfg)
            # Support 'counters' for backward compatibility
            self.meters = cfg.get("meters", cfg.get("counters"))
            self.sinks = cfg.get("sinks")
        except KeyError as err:
            raise PipelineException("Required field %s not specified" % err.args[0], cfg)
        if self.interval <= 0:
            raise PipelineException("Interval value should > 0", cfg)

        self.resources = cfg.get("resources") or []
        if not isinstance(self.resources, list):
            raise PipelineException("Resources should be a list", cfg)

        self.discovery = cfg.get("discovery") or []
        if not isinstance(self.discovery, list):
            raise PipelineException("Discovery should be a list", cfg)
        self._check_meters()
Exemplo n.º 4
0
    def __init__(self, cfg, transformer_manager):
        self.cfg = cfg

        try:
            self.name = cfg['name']
            # It's legal to have no transformer specified
            self.transformer_cfg = cfg['transformers'] or []
        except KeyError as err:
            raise PipelineException(
                "Required field %s not specified" % err.args[0], cfg)

        if not cfg.get('publishers'):
            raise PipelineException("No publisher specified", cfg)

        self.publishers = []
        for p in cfg['publishers']:
            if '://' not in p:
                # Support old format without URL
                p = p + "://"
            try:
                self.publishers.append(publisher.get_publisher(p))
            except Exception:
                LOG.exception(_("Unable to load publisher %s"), p)

        self.transformers = self._setup_transformers(cfg, transformer_manager)
Exemplo n.º 5
0
    def __init__(self, cfg, transformer_manager):
        self.cfg = cfg

        try:
            self.name = cfg['name']
            try:
                self.interval = int(cfg['interval'])
            except ValueError:
                raise PipelineException("Invalid interval value", cfg)
            self.counters = cfg['counters']
            # It's legal to have no transformer specified
            self.transformer_cfg = cfg['transformers'] or []
        except KeyError as err:
            raise PipelineException(
                "Required field %s not specified" % err.args[0], cfg)

        if self.interval <= 0:
            raise PipelineException("Interval value should > 0", cfg)

        self._check_counters()

        if not cfg.get('publishers'):
            raise PipelineException("No publisher specified", cfg)

        self.publishers = []
        for p in cfg['publishers']:
            if '://' not in p:
                # Support old format without URL
                p = p + "://"
            try:
                self.publishers.append(publisher.get_publisher(p))
            except Exception:
                LOG.exception("Unable to load publisher %s", p)

        self.transformers = self._setup_transformers(cfg, transformer_manager)
Exemplo n.º 6
0
    def __init__(self, cfg, transformer_manager):
        self.cfg = cfg

        try:
            self.name = cfg['name']
            # It's legal to have no transformer specified
            self.transformer_cfg = cfg['transformers'] or []
        except KeyError as err:
            raise PipelineException(
                "Required field %s not specified" % err.args[0], cfg)

        if not cfg.get('publishers'):
            raise PipelineException("No publisher specified", cfg)

        self.publishers = []
        for p in cfg['publishers']:
            if '://' not in p:
                # Support old format without URL
                p = p + "://"
            try:
                
                self.publishers.append(publisher.get_publisher(p))
            except Exception:
                LOG.exception(_("Unable to load publisher %s"), p)
        LOG.error("***********************the publisher is %s"%self.publishers)
        self.transformers = self._setup_transformers(cfg, transformer_manager)
Exemplo n.º 7
0
    def __init__(self, cfg, transformer_manager):
        self.cfg = cfg

        try:
            self.name = cfg['name']
            try:
                self.interval = int(cfg['interval'])
            except ValueError:
                raise PipelineException("Invalid interval value", cfg)
            # Support 'counters' for backward compatibility
            self.meters = cfg.get('meters', cfg.get('counters'))
            # It's legal to have no transformer specified
            self.transformer_cfg = cfg['transformers'] or []
        except KeyError as err:
            raise PipelineException(
                "Required field %s not specified" % err.args[0], cfg)

        if self.interval <= 0:
            raise PipelineException("Interval value should > 0", cfg)

        self._check_meters()

        if not cfg.get('publishers'):
            raise PipelineException("No publisher specified", cfg)

        self.publishers = []
        for p in cfg['publishers']:
            if '://' not in p:
                # Support old format without URL
                p = p + "://"
            try:
                self.publishers.append(publisher.get_publisher(p))
            except Exception:
                LOG.exception(_("Unable to load publisher %s"), p)

        self.transformers = self._setup_transformers(cfg, transformer_manager)

        self.resources = cfg.get('resources') or []
        if not isinstance(self.resources, list):
            raise PipelineException("Resources should be a list", cfg)
Exemplo n.º 8
0
def _load_config():
    # Don't load in global context, since we can't assume
    # these modules are accessible when distutils uses
    # this module
    import ConfigParser

    from oslo.config import cfg

    from nova.openstack.common import log as logging

    global loaded, NOVA_VENDOR, NOVA_PRODUCT, NOVA_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = ConfigParser.RawConfigParser()
        cfg.read(cfgfile)

        NOVA_VENDOR = cfg.get("Nova", "vendor")
        if cfg.has_option("Nova", "vendor"):
            NOVA_VENDOR = cfg.get("Nova", "vendor")

        NOVA_PRODUCT = cfg.get("Nova", "product")
        if cfg.has_option("Nova", "product"):
            NOVA_PRODUCT = cfg.get("Nova", "product")

        NOVA_PACKAGE = cfg.get("Nova", "package")
        if cfg.has_option("Nova", "package"):
            NOVA_PACKAGE = cfg.get("Nova", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error("Failed to load %(cfgfile)s: %(ex)s", {
            'cfgfile': cfgfile,
            'ex': ex
        })
Exemplo n.º 9
0
def _load_config():
    # Don't load in global context, since we can't assume
    # these modules are accessible when distutils uses
    # this module
    import ConfigParser

    from oslo.config import cfg

    from nova.openstack.common import log as logging

    global loaded, NOVA_VENDOR, NOVA_PRODUCT, NOVA_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = ConfigParser.RawConfigParser()
        cfg.read(cfgfile)

        NOVA_VENDOR = cfg.get("Nova", "vendor")
        if cfg.has_option("Nova", "vendor"):
            NOVA_VENDOR = cfg.get("Nova", "vendor")

        NOVA_PRODUCT = cfg.get("Nova", "product")
        if cfg.has_option("Nova", "product"):
            NOVA_PRODUCT = cfg.get("Nova", "product")

        NOVA_PACKAGE = cfg.get("Nova", "package")
        if cfg.has_option("Nova", "package"):
            NOVA_PACKAGE = cfg.get("Nova", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error(_("Failed to load %(cfgfile)s: %(ex)s"),
                  {'cfgfile': cfgfile, 'ex': ex})
Exemplo n.º 10
0
def _load_config():
    import ConfigParser

    from oslo.config import cfg

    from xdrs.openstack.common import log as logging

    global loaded, XDRS_LD, XDRS_PRODUCT, XDRS_PACKAGE
    if loaded:
        return

    loaded = True

    cfgfile = cfg.CONF.find_file("release")
    if cfgfile is None:
        return

    try:
        cfg = ConfigParser.RawConfigParser()
        cfg.read(cfgfile)

        XDRS_LD = cfg.get("Xdrs", "vendor")
        if cfg.has_option("Xdrs", "vendor"):
            XDRS_LD = cfg.get("Xdrs", "vendor")

        XDRS_PRODUCT = cfg.get("Xdrs", "product")
        if cfg.has_option("Xdrs", "product"):
            XDRS_PRODUCT = cfg.get("Xdrs", "product")

        XDRS_PACKAGE = cfg.get("Xdrs", "package")
        if cfg.has_option("Xdrs", "package"):
            XDRS_PACKAGE = cfg.get("Xdrs", "package")
    except Exception as ex:
        LOG = logging.getLogger(__name__)
        LOG.error(_("Failed to load %(cfgfile)s: %(ex)s"), {
            'cfgfile': cfgfile,
            'ex': ex
        })
Exemplo n.º 11
0
    def __init__(self, cfg, transformer_manager):
        """Setup the pipelines according to config.

        The configuration is supported in one of two forms:

        1. Deprecated: the source and sink configuration are conflated
           as a list of consolidated pipelines.

           The pipelines are defined as a list of dictionaries each
           specifying the target samples, the transformers involved,
           and the target publishers, for example:

           [{"name": pipeline_1,
             "interval": interval_time,
             "meters" : ["meter_1", "meter_2"],
             "resources": ["resource_uri1", "resource_uri2"],
             "transformers": [
                              {"name": "Transformer_1",
                               "parameters": {"p1": "value"}},

                              {"name": "Transformer_2",
                               "parameters": {"p1": "value"}},
                              ],
             "publishers": ["publisher_1", "publisher_2"]
            },
            {"name": pipeline_2,
             "interval": interval_time,
             "meters" : ["meter_3"],
             "publishers": ["publisher_3"]
            },
           ]

        2. Decoupled: the source and sink configuration are separately
           specified before being linked together. This allows source-
           specific configuration, such as resource discovery, to be
           kept focused only on the fine-grained source while avoiding
           the necessity for wide duplication of sink-related config.

           The configuration is provided in the form of separate lists
           of dictionaries defining sources and sinks, for example:

           {"sources": [{"name": source_1,
                         "interval": interval_time,
                         "meters" : ["meter_1", "meter_2"],
                         "resources": ["resource_uri1", "resource_uri2"],
                         "sinks" : ["sink_1", "sink_2"]
                        },
                        {"name": source_2,
                         "interval": interval_time,
                         "meters" : ["meter_3"],
                         "sinks" : ["sink_2"]
                        },
                       ],
            "sinks": [{"name": sink_1,
                       "transformers": [
                              {"name": "Transformer_1",
                               "parameters": {"p1": "value"}},

                              {"name": "Transformer_2",
                               "parameters": {"p1": "value"}},
                             ],
                        "publishers": ["publisher_1", "publisher_2"]
                       },
                       {"name": sink_2,
                        "publishers": ["publisher_3"]
                       },
                      ]
           }

        The semantics of the common individual configuration elements
        are identical in the deprecated and decoupled version.

        The interval determines the cadence of sample injection into
        the pipeline where samples are produced under the direct control
        of an agent, i.e. via a polling cycle as opposed to incoming
        notifications.

        Valid meter format is '*', '!meter_name', or 'meter_name'.
        '*' is wildcard symbol means any meters; '!meter_name' means
        "meter_name" will be excluded; 'meter_name' means 'meter_name'
        will be included.

        The 'meter_name" is Sample name field. For meter names with
        variable like "instance:m1.tiny", it's "instance:*".

        Valid meters definition is all "included meter names", all
        "excluded meter names", wildcard and "excluded meter names", or
        only wildcard.

        The resources is list of URI indicating the resources from where
        the meters should be polled. It's optional and it's up to the
        specific pollster to decide how to use it.

        Transformer's name is plugin name in setup.cfg.

        Publisher's name is plugin name in setup.cfg

        """
        self.pipelines = []
        if 'sources' in cfg or 'sinks' in cfg:
            if not ('sources' in cfg and 'sinks' in cfg):
                raise PipelineException("Both sources & sinks are required",
                                        cfg)
            LOG.info(_('detected decoupled pipeline config format'))
            sources = [Source(s) for s in cfg.get('sources', [])]
            sinks = dict((s['name'], Sink(s, transformer_manager))
                         for s in cfg.get('sinks', []))
            for source in sources:
                source.check_sinks(sinks)
                for target in source.sinks:
                    self.pipelines.append(Pipeline(source, sinks[target]))
        else:
            LOG.warning(_('detected deprecated pipeline config format'))
            for pipedef in cfg:
                source = Source(pipedef)
                sink = Sink(pipedef, transformer_manager)
                self.pipelines.append(Pipeline(source, sink))
Exemplo n.º 12
0
    def __init__(self, cfg, transformer_manager):
        """Setup the pipelines according to config.

        The configuration is supported in one of two forms:

        1. Deprecated: the source and sink configuration are conflated
           as a list of consolidated pipelines.

           The pipelines are defined as a list of dictionaries each
           specifying the target samples, the transformers involved,
           and the target publishers, for example:

           [{"name": pipeline_1,
             "interval": interval_time,
             "meters" : ["meter_1", "meter_2"],
             "resources": ["resource_uri1", "resource_uri2"],
             "transformers": [
                              {"name": "Transformer_1",
                               "parameters": {"p1": "value"}},

                              {"name": "Transformer_2",
                               "parameters": {"p1": "value"}},
                              ],
             "publishers": ["publisher_1", "publisher_2"]
            },
            {"name": pipeline_2,
             "interval": interval_time,
             "meters" : ["meter_3"],
             "publishers": ["publisher_3"]
            },
           ]

        2. Decoupled: the source and sink configuration are separately
           specified before being linked together. This allows source-
           specific configuration, such as resource discovery, to be
           kept focused only on the fine-grained source while avoiding
           the necessity for wide duplication of sink-related config.

           The configuration is provided in the form of separate lists
           of dictionaries defining sources and sinks, for example:

           {"sources": [{"name": source_1,
                         "interval": interval_time,
                         "meters" : ["meter_1", "meter_2"],
                         "resources": ["resource_uri1", "resource_uri2"],
                         "sinks" : ["sink_1", "sink_2"]
                        },
                        {"name": source_2,
                         "interval": interval_time,
                         "meters" : ["meter_3"],
                         "sinks" : ["sink_2"]
                        },
                       ],
            "sinks": [{"name": sink_1,
                       "transformers": [
                              {"name": "Transformer_1",
                               "parameters": {"p1": "value"}},

                              {"name": "Transformer_2",
                               "parameters": {"p1": "value"}},
                             ],
                        "publishers": ["publisher_1", "publisher_2"]
                       },
                       {"name": sink_2,
                        "publishers": ["publisher_3"]
                       },
                      ]
           }

        The semantics of the common individual configuration elements
        are identical in the deprecated and decoupled version.

        The interval determines the cadence of sample injection into
        the pipeline where samples are produced under the direct control
        of an agent, i.e. via a polling cycle as opposed to incoming
        notifications.

        Valid meter format is '*', '!meter_name', or 'meter_name'.
        '*' is wildcard symbol means any meters; '!meter_name' means
        "meter_name" will be excluded; 'meter_name' means 'meter_name'
        will be included.

        The 'meter_name" is Sample name field. For meter names with
        variable like "instance:m1.tiny", it's "instance:*".

        Valid meters definition is all "included meter names", all
        "excluded meter names", wildcard and "excluded meter names", or
        only wildcard.

        The resources is list of URI indicating the resources from where
        the meters should be polled. It's optional and it's up to the
        specific pollster to decide how to use it.

        Transformer's name is plugin name in setup.cfg.

        Publisher's name is plugin name in setup.cfg

        """
        self.pipelines = []
        if "sources" in cfg or "sinks" in cfg:
            if not ("sources" in cfg and "sinks" in cfg):
                raise PipelineException("Both sources & sinks are required", cfg)
            LOG.info(_("detected decoupled pipeline config format"))
            sources = [Source(s) for s in cfg.get("sources", [])]
            sinks = dict((s["name"], Sink(s, transformer_manager)) for s in cfg.get("sinks", []))
            for source in sources:
                source.check_sinks(sinks)
                for target in source.sinks:
                    self.pipelines.append(Pipeline(source, sinks[target]))
        else:
            LOG.warning(_("detected deprecated pipeline config format"))
            for pipedef in cfg:
                source = Source(pipedef)
                sink = Sink(pipedef, transformer_manager)
                self.pipelines.append(Pipeline(source, sink))