{
"mac-address": "fa:16:3e:71:fd:b8",
"name": "eth0",
- "ip-address": "192.168.160.2"
+ "ip-address": "192.168.160.2",
}
],
"status": "ACTIVE",
"name": "cirros_ns-1-cirros_vnfd-VM-1",
"status-detailed": None,
"ip-address": "192.168.160.2",
- "vdu-id-ref": "cirros_vnfd-VM"
+ "vdu-id-ref": "cirros_vnfd-VM",
}
],
"id": "0d9d06ad-3fc2-418c-9934-465e815fafe2",
"vnfd-id": "63f44c41-45ee-456b-b10d-5f08fb1796e0",
"_admin": {
"created": 1535392482.0067868,
- "projects_read": [
- "admin"
- ],
+ "projects_read": ["admin"],
"modified": 1535392482.0067868,
- "projects_write": [
- "admin"
- ]
+ "projects_write": ["admin"],
},
"nsr-id-ref": "87776f33-b67c-417a-8119-cb08e4098951",
"member-vnf-index-ref": "1",
- "connection-point": [
- {
- "name": "eth0",
- "id": None,
- "connection-point-id": None
- }
- ]
+ "connection-point": [{"name": "eth0", "id": None, "connection-point-id": None}],
}
vnfd_record_mock = {
"name": "cirros_vnfd-VM",
"int-cpd": [
{
- "virtual-network-interface-requirement": [
- {
- "name": "vdu-eth0"
- }
- ],
- "id": "vdu-eth0-int"
+ "virtual-network-interface-requirement": [{"name": "vdu-eth0"}],
+ "id": "vdu-eth0-int",
}
],
"virtual-compute-desc": "cirros_vnfd-VM-compute",
- "virtual-storage-desc": [
- "cirros_vnfd-VM-storage"
- ],
+ "virtual-storage-desc": ["cirros_vnfd-VM-storage"],
"sw-image-desc": "cirros034",
"monitoring-parameter": [
{
"id": "cirros_vnfd-VM_memory_util",
"name": "cirros_vnfd-VM_memory_util",
- "performance-metric": "average_memory_utilization"
+ "performance-metric": "average_memory_utilization",
}
- ]
+ ],
}
],
"virtual-compute-desc": [
{
"id": "cirros_vnfd-VM-compute",
- "virtual-cpu": {
- "num-virtual-cpu": 1
- },
- "virtual-memory": {
- "size": 1
- }
- }
- ],
- "virtual-storage-desc": [
- {
- "id": "cirros_vnfd-VM-storage",
- "size-of-storage": 2
- }
- ],
- "sw-image-desc": [
- {
- "id": "cirros034",
- "name": "cirros034",
- "image": "cirros034"
+ "virtual-cpu": {"num-virtual-cpu": 1},
+ "virtual-memory": {"size": 1},
}
],
+ "virtual-storage-desc": [{"id": "cirros_vnfd-VM-storage", "size-of-storage": 2}],
+ "sw-image-desc": [{"id": "cirros034", "name": "cirros034", "image": "cirros034"}],
"ext-cpd": [
{
- "int-cpd": {
- "vdu-id": "cirros_vnfd-VM",
- "cpd": "vdu-eth0-int"
- },
- "id": "vnf-cp0-ext"
+ "int-cpd": {"vdu-id": "cirros_vnfd-VM", "cpd": "vdu-eth0-int"},
+ "id": "vnf-cp0-ext",
}
],
"df": [
{
"id": "default-df",
- "vdu-profile": [
- {
- "id": "cirros_vnfd-VM"
- }
- ],
+ "vdu-profile": [{"id": "cirros_vnfd-VM"}],
"instantiation-level": [
{
"id": "default-instantiation-level",
- "vdu-level": [
- {
- "vdu-id": "cirros_vnfd-VM"
- }
- ]
+ "vdu-level": [{"vdu-id": "cirros_vnfd-VM"}],
}
- ]
+ ],
}
],
"description": "Simple VNF example with a cirros and a scaling group descriptor",
- "mgmt-cp": "vnf-cp0-ext"
+ "mgmt-cp": "vnf-cp0-ext",
}
@mock.patch.object(EvaluatorService, "_get_metric_value")
def test_evaluate_metric(self, get_metric_value):
mock_alarm = mock.Mock()
- mock_alarm.operation = 'gt'
+ mock_alarm.operation = "gt"
mock_alarm.threshold = 50.0
- mock_alarm.metric = 'metric_name'
+ mock_alarm.metric = "metric_name"
get_metric_value.return_value = 100.0
service = EvaluatorService(self.config)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.ALARM))
service.queue.reset_mock()
- mock_alarm.operation = 'lt'
+ mock_alarm.operation = "lt"
service._evaluate_metric(mock_alarm)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.OK))
service.queue.reset_mock()
service._evaluate_metric(mock_alarm)
service.queue.put.assert_called_with((mock_alarm, AlarmStatus.INSUFFICIENT))
- @mock.patch('multiprocessing.Process')
+ @mock.patch("multiprocessing.Process")
@mock.patch.object(EvaluatorService, "_evaluate_metric")
@mock.patch.object(CommonDbClient, "get_vnfd")
@mock.patch.object(CommonDbClient, "get_vnfr")
@mock.patch.object(CommonDbClient, "get_alarms")
- def test_evaluate_alarms(self, alarm_list, get_vnfr, get_vnfd, evaluate_metric, process):
+ def test_evaluate_alarms(
+ self, alarm_list, get_vnfr, get_vnfd, evaluate_metric, process
+ ):
mock_alarm = mock.Mock()
- mock_alarm.vdur_name = 'cirros_ns-1-cirros_vnfd-VM-1'
- mock_alarm.monitoring_param = 'cirros_vnf_memory_util'
- mock_alarm.tags = {'name': 'value'}
+ mock_alarm.vdur_name = "cirros_ns-1-cirros_vnfd-VM-1"
+ mock_alarm.monitoring_param = "cirros_vnf_memory_util"
+ mock_alarm.tags = {"name": "value"}
alarm_list.return_value = [mock_alarm]
get_vnfr.return_value = vnfr_record_mock
get_vnfd.return_value = vnfd_record_mock
@mock.patch.object(PrometheusBackend, "get_metric_value")
def test_get_metric_value_prometheus(self, get_metric_value):
- self.config.set('evaluator', 'backend', 'prometheus')
+ self.config.set("evaluator", "backend", "prometheus")
evaluator = EvaluatorService(self.config)
- evaluator._get_metric_value('test', {})
+ evaluator._get_metric_value("test", {})
- get_metric_value.assert_called_with('test', {})
+ get_metric_value.assert_called_with("test", {})