metric_name = self._get_metric_name(
vnf_monitoring_param
)
+ alarm_action = dict()
+ for action_type in ["ok", "insufficient-data", "alarm"]:
+ if "actions" in alarm_descriptor and action_type in alarm_descriptor["actions"]:
+ for url in alarm_descriptor["actions"][action_type]:
+ if "webhook" in alarm_action:
+ alarm_action["webhook"].append(url["url"])
+ else:
+ alarm_action["webhook"] = [url["url"]]
alarm_uuid = await self.mon_client.create_alarm(
metric_name=metric_name,
ns_id=nsr_id,
vnf_member_index=vnfr["member-vnf-index-ref"],
threshold=alarm_descriptor["value"],
operation=alarm_descriptor["operation"],
+ action=str(alarm_action),
)
alarm = VnfAlarmRepository.create(
alarm_id=alarm_descriptor["alarm-id"],
operation=scaling_criteria[
"scale-in-relational-operation"
],
+ action="scale_in"
)
)
alarm = ScalingAlarmRepository.create(
operation=scaling_criteria[
"scale-out-relational-operation"
],
+ action="scale_out",
)
alarm = ScalingAlarmRepository.create(
alarm_uuid=alarm_uuid,
threshold: int,
operation: str,
statistic: str = "AVERAGE",
+ action: str = '',
):
cor_id = random.randint(1, 10e7)
msg = self._build_create_alarm_payload(
threshold,
statistic,
operation,
+ action,
)
log.debug("Sending create_alarm_request %s", msg)
producer = AIOKafkaProducer(
threshold: int,
statistic: str,
operation: str,
+ action: str,
):
alarm_create_request = {
"severity": "critical",
"threshold_value": threshold,
"statistic": statistic,
+ "action": action,
"tags": {
"ns_id": ns_id,
"vdu_name": vdu_name,
threshold=80,
vdu_name="cirros_ns-1-cirros_vnfd-VM-1",
vnf_member_index="1",
+ action="scale_out",
)
create_alarm.assert_not_called_with(
metric_name="average_memory_utilization",
threshold=20,
vdu_name="cirros_ns-1-cirros_vnfd-VM-1",
vnf_member_index="1",
+ action="scale_out",
)
create_alarm.assert_any_call(
metric_name="average_memory_utilization",
threshold=80,
vdu_name="cirros_ns-2-cirros_vnfd-VM-1",
vnf_member_index="2",
+ action="scale_out",
)
create_alarm.assert_not_called_with(
metric_name="average_memory_utilization",
threshold=20,
vdu_name="cirros_ns-2-cirros_vnfd-VM-1",
vnf_member_index="2",
+ action="scale_out",
)
scaling_record = ScalingGroup.get()
self.assertEqual(scaling_record.name, "scale_cirros_vnfd-VM")
vnf_member_index="1",
threshold=20.0,
operation="LT",
+ action="{'webhook': ['localhost:9090', 'localhost:9090', 'localhost:9090']}"
)
create_alarm.assert_any_call(
metric_name="average_memory_utilization",
vnf_member_index="2",
threshold=20.0,
operation="LT",
+ action="{'webhook': ['localhost:9090', 'localhost:9090', 'localhost:9090']}"
)