blob: 4859d2765168d45488f3c04f62eac5dd0502781b [file] [log] [blame]
Zsolt Haraszti66862032016-11-28 14:28:39 -08001#
Zsolt Haraszti3eb27a52017-01-03 21:56:48 -08002# Copyright 2017 the original author or authors.
Zsolt Haraszti66862032016-11-28 14:28:39 -08003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17"""
18Agent to play gateway between CORE and an individual adapter.
19"""
20from uuid import uuid4
Stephane Barbarie52198b92017-03-02 13:44:46 -050021import arrow
22import re
Zsolt Haraszti66862032016-11-28 14:28:39 -080023
24import structlog
Zsolt Harasztief05ad22017-01-07 22:08:06 -080025from google.protobuf.json_format import MessageToJson
Zsolt Haraszti8925d1f2016-12-21 00:45:19 -080026from scapy.packet import Packet
Zsolt Haraszti66862032016-11-28 14:28:39 -080027from twisted.internet.defer import inlineCallbacks, returnValue
28from zope.interface import implementer
29
Zsolt Haraszti89a27302016-12-08 16:53:06 -080030from common.event_bus import EventBusClient
Zsolt Harasztief05ad22017-01-07 22:08:06 -080031from common.frameio.frameio import hexify
Zsolt Haraszti66862032016-11-28 14:28:39 -080032from voltha.adapters.interface import IAdapterAgent
33from voltha.protos import third_party
34from voltha.protos.device_pb2 import Device, Port
Stephane Barbariecc6b2e62017-03-02 14:35:55 -050035from voltha.protos.events_pb2 import KpiEvent, AlarmEvent, AlarmEventType, \
36 AlarmEventSeverity, AlarmEventState, AlarmEventCategory
Zsolt Haraszti66862032016-11-28 14:28:39 -080037from voltha.protos.voltha_pb2 import DeviceGroup, LogicalDevice, \
Khen Nursimulud068d812017-03-06 11:44:18 -050038 LogicalPort, AdminState, OperStatus
Zsolt Haraszti66862032016-11-28 14:28:39 -080039from voltha.registry import registry
Zsolt Haraszti656ecc62016-12-28 15:08:23 -080040from voltha.core.flow_decomposer import OUTPUT
Zsolt Haraszti66862032016-11-28 14:28:39 -080041
42
Zsolt Haraszti66862032016-11-28 14:28:39 -080043@implementer(IAdapterAgent)
44class AdapterAgent(object):
45 """
46 Gate-keeper between CORE and device adapters.
47
48 On one side it interacts with Core's internal model and update/dispatch
49 mechanisms.
50
51 On the other side, it interacts with the adapters standard interface as
52 defined in
53 """
54
55 def __init__(self, adapter_name, adapter_cls):
56 self.adapter_name = adapter_name
57 self.adapter_cls = adapter_cls
58 self.core = registry('core')
59 self.adapter = None
60 self.adapter_node_proxy = None
61 self.root_proxy = self.core.get_proxy('/')
Zsolt Haraszti89a27302016-12-08 16:53:06 -080062 self._rx_event_subscriptions = {}
63 self._tx_event_subscriptions = {}
64 self.event_bus = EventBusClient()
Khen Nursimulud068d812017-03-06 11:44:18 -050065 self.packet_out_subscription = None
Zsolt Haraszti89a27302016-12-08 16:53:06 -080066 self.log = structlog.get_logger(adapter_name=adapter_name)
Zsolt Haraszti66862032016-11-28 14:28:39 -080067
68 @inlineCallbacks
69 def start(self):
Zsolt Haraszti89a27302016-12-08 16:53:06 -080070 self.log.debug('starting')
Zsolt Haraszti66862032016-11-28 14:28:39 -080071 config = self._get_adapter_config() # this may be None
Zsolt Haraszti89a27302016-12-08 16:53:06 -080072 try:
73 adapter = self.adapter_cls(self, config)
74 yield adapter.start()
Zsolt Haraszti656ecc62016-12-28 15:08:23 -080075 self.adapter = adapter
76 self.adapter_node_proxy = self._update_adapter_node()
77 self._update_device_types()
Zsolt Haraszti89a27302016-12-08 16:53:06 -080078 except Exception, e:
79 self.log.exception(e)
Zsolt Haraszti89a27302016-12-08 16:53:06 -080080 self.log.info('started')
Zsolt Haraszti66862032016-11-28 14:28:39 -080081 returnValue(self)
82
83 @inlineCallbacks
84 def stop(self):
Zsolt Haraszti89a27302016-12-08 16:53:06 -080085 self.log.debug('stopping')
Zsolt Haraszti66862032016-11-28 14:28:39 -080086 if self.adapter is not None:
87 yield self.adapter.stop()
88 self.adapter = None
Zsolt Haraszti89a27302016-12-08 16:53:06 -080089 self.log.info('stopped')
Zsolt Haraszti66862032016-11-28 14:28:39 -080090
91 def _get_adapter_config(self):
92 """
93 Opportunistically load persisted adapter configuration.
94 Return None if no configuration exists yet.
95 """
96 proxy = self.core.get_proxy('/')
97 try:
98 config = proxy.get('/adapters/' + self.adapter_name)
99 return config
100 except KeyError:
101 return None
102
103 def _update_adapter_node(self):
104 """
105 Creates or updates the adapter node object based on self
106 description from the adapter.
107 """
108
109 adapter_desc = self.adapter.adapter_descriptor()
110 assert adapter_desc.id == self.adapter_name
111 path = self._make_up_to_date(
112 '/adapters', self.adapter_name, adapter_desc)
113 return self.core.get_proxy(path)
114
115 def _update_device_types(self):
116 """
117 Make sure device types are registered in Core
118 """
119 device_types = self.adapter.device_types()
120 for device_type in device_types.items:
121 key = device_type.id
122 self._make_up_to_date('/device_types', key, device_type)
123
124 def _make_up_to_date(self, container_path, key, data):
125 full_path = container_path + '/' + str(key)
126 root_proxy = self.core.get_proxy('/')
127 try:
128 root_proxy.get(full_path)
129 root_proxy.update(full_path, data)
130 except KeyError:
131 root_proxy.add(container_path, data)
132 return full_path
133
Khen Nursimulud068d812017-03-06 11:44:18 -0500134 def _remove_node(self, container_path, key):
135 """
136 Remove a node from the data model
137 :param container_path: path to node
138 :param key: node
139 :return: None
140 """
141 full_path = container_path + '/' + str(key)
142 root_proxy = self.core.get_proxy('/')
143 try:
144 root_proxy.get(full_path)
145 root_proxy.remove(full_path)
146 except KeyError:
147 # Node does not exist
148 pass
149
Zsolt Haraszti66862032016-11-28 14:28:39 -0800150 # ~~~~~~~~~~~~~~~~~~~~~ Core-Facing Service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151
152 def adopt_device(self, device):
153 return self.adapter.adopt_device(device)
154
155 def abandon_device(self, device):
156 return self.adapter.abandon_device(device)
157
Khen Nursimulud068d812017-03-06 11:44:18 -0500158 def disable_device(self, device):
159 return self.adapter.disable_device(device)
160
161 def reenable_device(self, device):
162 return self.adapter.reenable_device(device)
163
164 def reboot_device(self, device):
165 return self.adapter.reboot_device(device)
166
167 def delete_device(self, device):
168 return self.adapter.delete_device(device)
169
170 def get_device_details(self, device):
171 return self.adapter.get_device_details(device)
Zsolt Haraszti66862032016-11-28 14:28:39 -0800172
Zsolt Harasztic5c5d102016-12-07 21:12:27 -0800173 def update_flows_bulk(self, device, flows, groups):
174 return self.adapter.update_flows_bulk(device, flows, groups)
175
176 def update_flows_incrementally(self, device, flow_changes, group_changes):
177 return self.update_flows_incrementally(
178 device, flow_changes, group_changes)
179
Zsolt Haraszti66862032016-11-28 14:28:39 -0800180 # ~~~~~~~~~~~~~~~~~~~ Adapter-Facing Service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
182 def get_device(self, device_id):
183 return self.root_proxy.get('/devices/{}'.format(device_id))
184
185 def add_device(self, device):
186 assert isinstance(device, Device)
187 self._make_up_to_date('/devices', device.id, device)
188
alshabibbe8ca2e2017-02-01 18:28:57 -0800189 # Ultimately, assign devices to device grpups.
190 # see https://jira.opencord.org/browse/CORD-838
Zsolt Haraszti66862032016-11-28 14:28:39 -0800191
192 dg = DeviceGroup(id='1')
193 self._make_up_to_date('/device_groups', dg.id, dg)
194
195 # add device to device group
alshabibbe8ca2e2017-02-01 18:28:57 -0800196 # see https://jira.opencord.org/browse/CORD-838
Zsolt Haraszti66862032016-11-28 14:28:39 -0800197
198 def update_device(self, device):
199 assert isinstance(device, Device)
200
201 # we run the update through the device_agent so that the change
202 # does not loop back to the adapter unnecessarily
203 device_agent = self.core.get_device_agent(device.id)
204 device_agent.update_device(device)
205
Zsolt Haraszti66862032016-11-28 14:28:39 -0800206 def add_port(self, device_id, port):
207 assert isinstance(port, Port)
208
209 # for referential integrity, add/augment references
210 port.device_id = device_id
211 me_as_peer = Port.PeerPort(device_id=device_id, port_no=port.port_no)
212 for peer in port.peers:
213 peer_port_path = '/devices/{}/ports/{}'.format(
214 peer.device_id, peer.port_no)
215 peer_port = self.root_proxy.get(peer_port_path)
216 if me_as_peer not in peer_port.peers:
217 new = peer_port.peers.add()
218 new.CopyFrom(me_as_peer)
219 self.root_proxy.update(peer_port_path, peer_port)
220
221 self._make_up_to_date('/devices/{}/ports'.format(device_id),
222 port.port_no, port)
223
Khen Nursimulud068d812017-03-06 11:44:18 -0500224 def disable_all_ports(self, device_id):
225 """
226 Disable all ports on that device, i.e. change the admin status to
227 disable and operational status to UNKNOWN
228 :param device_id: device id
229 :return: None
230 """
231
232 # get all device ports
233 ports = self.root_proxy.get('/devices/{}/ports'.format(device_id))
234 for port in ports:
235 port.admin_state = AdminState.DISABLED
236 port.oper_status = OperStatus.UNKNOWN
237 self._make_up_to_date('/devices/{}/ports'.format(device_id),
238 port.port_no, port)
239
240 def reenable_all_ports(self, device_id):
241 """
242 Re-enable all ports on that device, i.e. change the admin status to
243 enabled and operational status to ACTIVE
244 :param device_id: device id
245 :return: None
246 """
247
248 # get all device ports
249 ports = self.root_proxy.get('/devices/{}/ports'.format(device_id))
250 for port in ports:
251 port.admin_state = AdminState.ENABLED
252 port.oper_status = OperStatus.ACTIVE
253 self._make_up_to_date('/devices/{}/ports'.format(device_id),
254 port.port_no, port)
255
256 def delete_all_peer_references(self, device_id):
257 """
258 Remove all peer port references for that device
259 :param device_id: device_id of device
260 :return: None
261 """
262 ports = self.root_proxy.get('/devices/{}/ports'.format(device_id))
263 for port in ports:
264 port_path = '/devices/{}/ports/{}'.format(device_id, port.port_no)
265 for peer in port.peers:
266 port.peers.remove(peer)
267 self.root_proxy.update(port_path, port)
268
269 def delete_port_reference_from_parent(self, device_id, port):
270 """
271 Delete the port reference from the parent device
272 :param device_id: id of device containing the port
273 :param port: port to remove
274 :return: None
275 """
276 assert isinstance(port, Port)
277 self.log.info('delete-port-reference', device_id=device_id, port=port)
278
279 # for referential integrity, remove references
280 me_as_peer = Port.PeerPort(device_id=device_id, port_no=port.port_no)
281 for peer in port.peers:
282 peer_port_path = '/devices/{}/ports/{}'.format(
283 peer.device_id, peer.port_no)
284 peer_port = self.root_proxy.get(peer_port_path)
285 if me_as_peer in peer_port.peers:
286 peer_port.peers.remove(me_as_peer)
287 self.root_proxy.update(peer_port_path, peer_port)
288
Zsolt Harasztid036b7e2016-12-23 15:36:01 -0800289 def _find_first_available_id(self):
290 logical_devices = self.root_proxy.get('/logical_devices')
291 existing_ids = set(ld.id for ld in logical_devices)
292 existing_datapath_ids = set(ld.datapath_id for ld in logical_devices)
293 i = 1
294 while True:
295 if i not in existing_datapath_ids and str(i) not in existing_ids:
296 return i
297 i += 1
298
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800299 def get_logical_device(self, logical_device_id):
300 return self.root_proxy.get('/logical_devices/{}'.format(
301 logical_device_id))
302
Khen Nursimulud068d812017-03-06 11:44:18 -0500303 def get_logical_port(self, logical_device_id, port_id):
304 return self.root_proxy.get('/logical_devices/{}/ports/{}'.format(
305 logical_device_id, port_id))
306
Zsolt Haraszti66862032016-11-28 14:28:39 -0800307 def create_logical_device(self, logical_device):
308 assert isinstance(logical_device, LogicalDevice)
Zsolt Harasztid036b7e2016-12-23 15:36:01 -0800309
310 if not logical_device.id:
311 id = self._find_first_available_id()
312 logical_device.id = str(id)
313 logical_device.datapath_id = id
314
Zsolt Haraszti66862032016-11-28 14:28:39 -0800315 self._make_up_to_date('/logical_devices',
316 logical_device.id, logical_device)
317
Khen Nursimulud068d812017-03-06 11:44:18 -0500318 # Keep a reference to the packet out subscription as it will be
319 # referred during removal
320 self.packet_out_subscription = self.event_bus.subscribe(
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800321 topic='packet-out:{}'.format(logical_device.id),
322 callback=lambda _, p: self.receive_packet_out(logical_device.id, p)
323 )
324
Zsolt Harasztid036b7e2016-12-23 15:36:01 -0800325 return logical_device
326
Khen Nursimulud068d812017-03-06 11:44:18 -0500327
328 def delete_logical_device(self, logical_device):
329 """
330 This will remove the logical device as well as all logical ports
331 associated with it
332 :param logical_device: The logical device to remove
333 :return: None
334 """
335 assert isinstance(logical_device, LogicalDevice)
336
337 # Remove packet out subscription
338 self.event_bus.unsubscribe(self.packet_out_subscription)
339
340 # Remove node from the data model - this will trigger the logical
341 # device 'remove callbacks' as well as logical ports 'remove
342 # callbacks' if present
343 self._remove_node('/logical_devices', logical_device.id)
344
345
Zsolt Haraszti656ecc62016-12-28 15:08:23 -0800346 def receive_packet_out(self, logical_device_id, ofp_packet_out):
347
348 def get_port_out(opo):
349 for action in opo.actions:
350 if action.type == OUTPUT:
351 return action.output.port
352
353 out_port = get_port_out(ofp_packet_out)
354 frame = ofp_packet_out.data
355 self.adapter.receive_packet_out(logical_device_id, out_port, frame)
356
Zsolt Haraszti66862032016-11-28 14:28:39 -0800357 def add_logical_port(self, logical_device_id, port):
358 assert isinstance(port, LogicalPort)
359 self._make_up_to_date(
360 '/logical_devices/{}/ports'.format(logical_device_id),
361 port.id, port)
362
Khen Nursimulud068d812017-03-06 11:44:18 -0500363 def delete_logical_port(self, logical_device_id, port):
364 assert isinstance(port, LogicalPort)
365 self._remove_node('/logical_devices/{}/ports'.format(
366 logical_device_id), port.id)
367
368 def update_logical_port(self, logical_device_id, port):
369 assert isinstance(port, LogicalPort)
370 self.log.debug('update-logical-port',
371 logical_device_id=logical_device_id,
372 port=port)
373
374 self._make_up_to_date(
375 '/logical_devices/{}/ports'.format(logical_device_id),
376 port.id, port)
377
Zsolt Haraszti66862032016-11-28 14:28:39 -0800378 def child_device_detected(self,
379 parent_device_id,
380 parent_port_no,
381 child_device_type,
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800382 proxy_address,
383 **kw):
Zsolt Haraszti66862032016-11-28 14:28:39 -0800384 # we create new ONU device objects and insert them into the config
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800385 # TODO should we auto-enable the freshly created device? Probably.
Zsolt Haraszti66862032016-11-28 14:28:39 -0800386 device = Device(
387 id=uuid4().hex[:12],
388 type=child_device_type,
389 parent_id=parent_device_id,
390 parent_port_no=parent_port_no,
391 admin_state=AdminState.ENABLED,
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800392 proxy_address=proxy_address,
393 **kw
Zsolt Haraszti66862032016-11-28 14:28:39 -0800394 )
395 self._make_up_to_date(
396 '/devices', device.id, device)
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800397
398 topic = self._gen_tx_proxy_address_topic(proxy_address)
399 self._tx_event_subscriptions[topic] = self.event_bus.subscribe(
400 topic, lambda t, m: self._send_proxied_message(proxy_address, m))
401
Khen Nursimulud068d812017-03-06 11:44:18 -0500402 def remove_all_logical_ports(self, logical_device_id):
403 """ Remove all logical ports from a given logical device"""
404 ports = self.root_proxy.get('/logical_devices/{}/ports')
405 for port in ports:
406 self._remove_node('/logical_devices/{}/ports', port.id)
407
408 def delete_all_child_devices(self, parent_device_id):
409 """ Remove all ONUs from a given OLT """
410 devices = self.root_proxy.get('/devices')
411 children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
412 self.log.debug('devices-to-delete',
413 parent_id=parent_device_id,
414 children_ids=children_ids)
415 for child_id in children_ids:
416 self._remove_node('/devices', child_id)
417
418 def reenable_all_child_devices(self, parent_device_id):
419 """ Re-enable all ONUs from a given OLT """
420 devices = self.root_proxy.get('/devices')
421 children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
422 self.log.debug('devices-to-reenable',
423 parent_id=parent_device_id,
424 children_ids=children_ids)
425 for child_id in children_ids:
426 device = self.get_device(child_id)
427 device.admin_state = AdminState.ENABLED
428 self._make_up_to_date(
429 '/devices', device.id, device)
430
431 def disable_all_child_devices(self, parent_device_id):
432 """ Disable all ONUs from a given OLT """
433 devices = self.root_proxy.get('/devices')
434 children_ids = set(d.id for d in devices if d.parent_id == parent_device_id)
435 self.log.debug('devices-to-disable',
436 parent_id=parent_device_id,
437 children_ids=children_ids)
438 for child_id in children_ids:
439 # Change the admin state pf the device to DISABLE
440 device = self.get_device(child_id)
441 device.admin_state = AdminState.DISABLED
442 self._make_up_to_date(
443 '/devices', device.id, device)
444
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800445 def _gen_rx_proxy_address_topic(self, proxy_address):
446 """Generate unique topic name specific to this proxy address for rx"""
Zsolt Harasztief05ad22017-01-07 22:08:06 -0800447 topic = 'rx:' + MessageToJson(proxy_address)
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800448 return topic
449
450 def _gen_tx_proxy_address_topic(self, proxy_address):
451 """Generate unique topic name specific to this proxy address for tx"""
Zsolt Harasztief05ad22017-01-07 22:08:06 -0800452 topic = 'tx:' + MessageToJson(proxy_address)
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800453 return topic
454
455 def register_for_proxied_messages(self, proxy_address):
456 topic = self._gen_rx_proxy_address_topic(proxy_address)
457 self._rx_event_subscriptions[topic] = self.event_bus.subscribe(
Stephane Barbariecc6b2e62017-03-02 14:35:55 -0500458 topic,
459 lambda t, m: self._receive_proxied_message(proxy_address, m))
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800460
Khen Nursimulud068d812017-03-06 11:44:18 -0500461 def unregister_for_proxied_messages(self, proxy_address):
462 topic = self._gen_rx_proxy_address_topic(proxy_address)
463 self.event_bus.unsubscribe(self._rx_event_subscriptions[topic])
464 del self._rx_event_subscriptions[topic]
465
Zsolt Haraszti89a27302016-12-08 16:53:06 -0800466 def _receive_proxied_message(self, proxy_address, msg):
467 self.adapter.receive_proxied_message(proxy_address, msg)
468
469 def send_proxied_message(self, proxy_address, msg):
470 topic = self._gen_tx_proxy_address_topic(proxy_address)
471 self.event_bus.publish(topic, msg)
472
473 def _send_proxied_message(self, proxy_address, msg):
474 self.adapter.send_proxied_message(proxy_address, msg)
475
476 def receive_proxied_message(self, proxy_address, msg):
477 topic = self._gen_rx_proxy_address_topic(proxy_address)
478 self.event_bus.publish(topic, msg)
Zsolt Haraszti8925d1f2016-12-21 00:45:19 -0800479
480 # ~~~~~~~~~~~~~~~~~~ Handling packet-in and packet-out ~~~~~~~~~~~~~~~~~~~~
481
482 def send_packet_in(self, logical_device_id, logical_port_no, packet):
483 self.log.debug('send-packet-in', logical_device_id=logical_device_id,
Zsolt Harasztief05ad22017-01-07 22:08:06 -0800484 logical_port_no=logical_port_no, packet=hexify(packet))
Zsolt Haraszti8925d1f2016-12-21 00:45:19 -0800485
486 if isinstance(packet, Packet):
487 packet = str(packet)
488
489 topic = 'packet-in:' + logical_device_id
490 self.event_bus.publish(topic, (logical_port_no, packet))
Zsolt Haraszti749b0952017-01-18 09:02:35 -0800491
492 # ~~~~~~~~~~~~~~~~~~~ Handling KPI metric submissions ~~~~~~~~~~~~~~~~~~~~~
Zsolt Harasztic5f740b2017-01-18 09:53:17 -0800493
Zsolt Haraszti749b0952017-01-18 09:02:35 -0800494 def submit_kpis(self, kpi_event_msg):
495 try:
496 assert isinstance(kpi_event_msg, KpiEvent)
497 self.event_bus.publish('kpis', kpi_event_msg)
498 except Exception as e:
499 self.log.exception('failed-kpi-submission',
500 type=type(kpi_event_msg))
Stephane Barbarie52198b92017-03-02 13:44:46 -0500501
502 # ~~~~~~~~~~~~~~~~~~~ Handle alarm submissions ~~~~~~~~~~~~~~~~~~~~~
503
Stephane Barbariecc6b2e62017-03-02 14:35:55 -0500504 def create_alarm(self, id=None, resource_id=None, description=None,
505 raised_ts=0, changed_ts=0,
506 type=AlarmEventType.EQUIPMENT,
Stephane Barbariebf3e10c2017-03-03 10:15:58 -0500507 category=AlarmEventCategory.PON,
Stephane Barbariecc6b2e62017-03-02 14:35:55 -0500508 severity=AlarmEventSeverity.MINOR,
509 state=AlarmEventState.RAISED,
Stephane Barbarie52198b92017-03-02 13:44:46 -0500510 context=None):
511
512 # Construct the ID if it is not provided
513 if id == None:
514 id = 'voltha.{}.{}'.format(self.adapter_name, resource_id)
515
516 return AlarmEvent(
517 id=id,
518 resource_id=resource_id,
519 type=type,
520 category=category,
521 severity=severity,
522 state=state,
523 description=description,
524 reported_ts=arrow.utcnow().timestamp,
525 raised_ts=raised_ts,
526 changed_ts=changed_ts,
527 context=context
528 )
529
530 def submit_alarm(self, alarm_event_msg):
531 try:
532 assert isinstance(alarm_event_msg, AlarmEvent)
533 self.event_bus.publish('alarms', alarm_event_msg)
534
535 except Exception as e:
536 self.log.exception('failed-alarm-submission',
537 type=type(alarm_event_msg))