summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
f4017d5)
Change-Id: I656a67864d821454e5ecc1ed60ce601c872da23d
Signed-off-by: Pawel Tomaszewski <pawelx.tomaszewski@intel.com>
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
# Volodymyr Mytnyk <volodymyrx.mytnyk@intel.com>
#
# Volodymyr Mytnyk <volodymyrx.mytnyk@intel.com>
#
import logging
import datetime
import time
import logging
import datetime
import time
# import YAML loader
try:
# import YAML loader
try:
- from yaml import CLoader as Loader
+ from .yaml import CLoader as Loader
- from yaml import Loader
+ from .yaml import Loader
# import synchronized queue
# import synchronized queue
-try:
- # python 2.x
- import Queue as queue
-except ImportError:
- # python 3.x
- import queue
self._collector = collector
self._index = 0
self._collector = collector
self._index = 0
"""Returns next item from the list"""
if self._index == len(self._items):
raise StopIteration
"""Returns next item from the list"""
if self._index == len(self._items):
raise StopIteration
def _check_aging(self):
"""Check aging time for all items"""
self.lock()
def _check_aging(self):
"""Check aging time for all items"""
self.lock()
- for data_hash, data in self._metrics.items():
+ for data_hash, data in list(self._metrics.items()):
age, item = data
if ((time.time() - age) >= self._age_timeout):
# aging time has expired, remove the item from the collector
age, item = data
if ((time.time() - age) >= self._age_timeout):
# aging time has expired, remove the item from the collector
"""Returns locked (safe) item iterator"""
metrics = []
self.lock()
"""Returns locked (safe) item iterator"""
metrics = []
self.lock()
- for k, item in self._metrics.items():
+ for k, item in list(self._metrics.items()):
_, value = item
for select in select_list:
if value.match(**select):
_, value = item
for select in select_list:
if value.match(**select):
def match(self, **kargs):
# compare the metric
def match(self, **kargs):
# compare the metric
- for key, value in kargs.items():
+ for key, value in list(kargs.items()):
if self.is_regular_expression(value):
if re.match(value[1:-1], getattr(self, key)) is None:
return False
if self.is_regular_expression(value):
if re.match(value[1:-1], getattr(self, key)) is None:
return False
class ValueItem(Item):
"""Class to process VlaueItem tag"""
class ValueItem(Item):
"""Class to process VlaueItem tag"""
- yaml_tag = u'!ValueItem'
+ yaml_tag = '!ValueItem'
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
# if VALUE key isn't given, use default VALUE key
# format: `VALUE: !Number '{vl.value}'`
if value_desc is None:
# if VALUE key isn't given, use default VALUE key
# format: `VALUE: !Number '{vl.value}'`
if value_desc is None:
- value_desc = yaml.ScalarNode(tag=u'!Number', value=u'{vl.value}')
+ value_desc = yaml.ScalarNode(tag='!Number', value='{vl.value}')
# select collectd metric based on SELECT condition
metrics = loader.collector.items(select)
assert len(metrics) < 2, \
# select collectd metric based on SELECT condition
metrics = loader.collector.items(select)
assert len(metrics) < 2, \
class ArrayItem(Item):
"""Class to process ArrayItem tag"""
class ArrayItem(Item):
"""Class to process ArrayItem tag"""
- yaml_tag = u'!ArrayItem'
+ yaml_tag = '!ArrayItem'
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
class Measurements(ArrayItem):
"""Class to process Measurements tag"""
class Measurements(ArrayItem):
"""Class to process Measurements tag"""
- yaml_tag = u'!Measurements'
+ yaml_tag = '!Measurements'
class Events(Item):
"""Class to process Events tag"""
class Events(Item):
"""Class to process Events tag"""
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
class Bytes2Kibibytes(yaml.YAMLObject):
"""Class to process Bytes2Kibibytes tag"""
class Bytes2Kibibytes(yaml.YAMLObject):
"""Class to process Bytes2Kibibytes tag"""
- yaml_tag = u'!Bytes2Kibibytes'
+ yaml_tag = '!Bytes2Kibibytes'
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
class Number(yaml.YAMLObject):
"""Class to process Number tag"""
class Number(yaml.YAMLObject):
"""Class to process Number tag"""
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
class StripExtraDash(yaml.YAMLObject):
"""Class to process StripExtraDash tag"""
class StripExtraDash(yaml.YAMLObject):
"""Class to process StripExtraDash tag"""
- yaml_tag = u'!StripExtraDash'
+ yaml_tag = '!StripExtraDash'
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
class MapValue(yaml.YAMLObject):
"""Class to process MapValue tag"""
class MapValue(yaml.YAMLObject):
"""Class to process MapValue tag"""
- yaml_tag = u'!MapValue'
@classmethod
def from_yaml(cls, loader, node):
@classmethod
def from_yaml(cls, loader, node):
assert val is not None, "Mandatory VALUE key isn't set"
assert val in mapping, \
'Value "{}" cannot be mapped to any of {} values'.format(
assert val is not None, "Mandatory VALUE key isn't set"
assert val in mapping, \
'Value "{}" cannot be mapped to any of {} values'.format(
+ val, list(mapping.keys()))
measurements.append((key, value))
if value.tag == Events.yaml_tag:
events.append((key, value))
measurements.append((key, value))
if value.tag == Events.yaml_tag:
events.append((key, value))
- measurements_yaml = yaml.MappingNode(u'tag:yaml.org,2002:map',
+ measurements_yaml = yaml.MappingNode('tag:yaml.org,2002:map',
measurements)
measurements_stream = yaml.serialize(measurements_yaml)
measurements)
measurements_stream = yaml.serialize(measurements_yaml)
- events_yaml = yaml.MappingNode(u'tag:yaml.org,2002:map', events)
+ events_yaml = yaml.MappingNode('tag:yaml.org,2002:map', events)
events_stream = yaml.serialize(events_yaml)
# return event & measurements definition
return events_stream, measurements_stream
events_stream = yaml.serialize(events_yaml)
# return event & measurements definition
return events_stream, measurements_stream
import json
import sys
import base64
import json
import sys
import base64
import logging
import argparse
from distutils.util import strtobool
from kafka import KafkaConsumer
import logging
import argparse
from distutils.util import strtobool
from kafka import KafkaConsumer
-from normalizer import Normalizer
-from normalizer import CollectdValue
-
-try:
- # For Python 3.0 and later
- import urllib.request as url
-except ImportError:
- # Fall back to Python 2's urllib2
- import urllib2 as url
+from .normalizer import Normalizer
+from .normalizer import CollectdValue
+import urllib.request as url
class VESApp(Normalizer):
"""VES Application"""
class VESApp(Normalizer):
"""VES Application"""
def init(self, configfile, schema_file):
if configfile is not None:
# read VES configuration file if provided
def init(self, configfile, schema_file):
if configfile is not None:
# read VES configuration file if provided
- config = ConfigParser.ConfigParser()
+ config = configparser.ConfigParser()
config.optionxform = lambda option: option
config.read(configfile)
self.config(config)
config.optionxform = lambda option: option
config.read(configfile)
self.config(config)