1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from dashboard_notification.notification import Notification
10 from dashboard_api.api import DashboardAPI
13 'dashboard_ip': '127.0.0.1',
14 'dashboard_url': 'http://127.0.0.1',
15 'api_token': 'f33ff43c85ecb13f5d0632c05dbb0a7d85a5a8d1',
17 'password': 'opnfvopnfv'
20 api = DashboardAPI(CONFIG['dashboard_url'], api_token=CONFIG['api_token'], verbose=True)
23 def booking_start(message):
24 content = message.content
25 booking = api.get_booking(id=content['booking_id'])
27 # do something here...
30 api.post_resource_status(resource_id=booking['resource_id'], type='info', title='pod setup',
34 def booking_end(message):
35 # do something here...
38 api.post_resource_status(resource_id=message.content['resource_id'], type='info',
39 title='booking end', content='details')
43 with Notification(CONFIG['dashboard_ip'], CONFIG['user'], CONFIG['password']) as notification:
44 notification.register(booking_start, 'Arm POD 2', 'booking_start')
45 notification.register(booking_end, 'Arm POD 2', 'booking_end')
46 notification.receive() # wait for notifications
49 if __name__ == "__main__":