except ValueError:
log.warning(
"Could not find resource_uuid for vdur %s, vnf_member_index %s, nsr_id %s. "
- "Was it recently deleted?".format(
- vdur['name'], vnf_member_index, nsr_id))
+ "Was it recently deleted?",
+ vdur['name'], vnf_member_index, nsr_id)
continue
if self.backend == 'ceilometer':
measures = self.client.samples.list(meter_name=openstack_metric_name, limit=1, q=[
{'field': 'resource_id', 'op': 'eq', 'value': resource_id}])
- if len(measures):
+ if measures:
metric = VnfMetric(nsr_id, vnf_member_index, vdur['name'], metric_name,
measures[0].counter_volume)
metrics.append(metric)
start=start_date,
resource_id=interface['id'],
granularity=self.granularity)
- if len(measures):
+ if measures:
total_measure += measures[-1][2]
except gnocchiclient.exceptions.NotFound as e:
start=start_date,
resource_id=resource_id,
granularity=self.granularity)
- if len(measures):
+ if measures:
metric = VnfMetric(nsr_id, vnf_member_index, vdur['name'], metric_name,
measures[-1][2])
metrics.append(metric)
class VIOCollector(BaseVimCollector):
def __init__(self, config: Config, vim_account_id: str):
super().__init__(config, vim_account_id)
- self.common_db = CommonDbClient()
- self.auth_manager = AuthManager()
+ self.common_db = CommonDbClient(config)
+ self.auth_manager = AuthManager(config)
vim_account_info = self.auth_manager.get_credentials(vim_account_id)
cfg = json.loads(vim_account_info.config)
self.vrops_site = cfg['vrops_site']
"packets_sent": "net:Aggregate of all instances|packetsTxPerSec",
}
-# Disable warnings from self-signed certificates.
-requests.packages.urllib3.disable_warnings()
-
class VMwareCollector(BaseVimCollector):
def __init__(self, config: Config, vim_account_id: str):
json_response = r.json()
if json_response['status'] == 'success':
result = json_response['data']['result']
- if len(result):
+ if result:
metric_value = float(result[0]['value'][1])
log.info("Metric value: %s", metric_value)
if alarm.operation.upper() == 'GT':
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
-envlist = py3, flake8
+envlist = py3, flake8, pylint
toxworkdir={homedir}/.tox
[testenv]
install_command = python3 -m pip install -r requirements.txt -U {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
+[testenv:pylint]
+basepython = python3
+deps = pylint
+commands =
+ pylint -E osm_mon
+
[testenv:flake8]
basepython = python3
deps = flake8