Tomáš Pecka | 6a2334b | 2022-07-12 13:57:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 CESNET, https://photonics.cesnet.cz/ |
| 3 | * |
| 4 | * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz> |
| 5 | * |
| 6 | */ |
| 7 | #include "alarms.h" |
| 8 | |
| 9 | using namespace std::string_literals; |
| 10 | |
| 11 | namespace { |
| 12 | const auto alarmRpc = "/sysrepo-ietf-alarms:create-or-update-alarm"; |
| 13 | } |
| 14 | |
| 15 | namespace velia::health { |
| 16 | void createOrUpdateAlarm(sysrepo::Session session, const std::string& alarmId, const std::optional<std::string>& alarmTypeQualifier, const std::string& resource, const std::string& severity, const std::string& text) |
| 17 | { |
| 18 | auto inputNode = session.getContext().newPath(alarmRpc, std::nullopt); |
| 19 | |
| 20 | inputNode.newPath(alarmRpc + "/resource"s, resource); |
| 21 | inputNode.newPath(alarmRpc + "/alarm-type-id"s, alarmId); |
| 22 | inputNode.newPath(alarmRpc + "/alarm-type-qualifier"s, alarmTypeQualifier.value_or("")); |
| 23 | inputNode.newPath(alarmRpc + "/severity"s, severity); |
| 24 | inputNode.newPath(alarmRpc + "/alarm-text"s, text); |
| 25 | |
| 26 | session.sendRPC(inputNode); |
| 27 | } |
| 28 | } |