diff options
author | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-09-22 12:23:36 -0700 |
---|---|---|
committer | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-09-22 12:23:36 -0700 |
commit | b07bbdba03fe9b1c3da2f69b8bc28b8071d99ec1 (patch) | |
tree | ed2a67f71eb8f3d3e8e3c284e7d53f91ecd6cd96 /booking_communication_agent.py |
Rename pharos-dashboard and pharos-validator
As subdirectories of the pharos-tools repo, there is little need to keep
the pharos prefix.
Change-Id: Ica3d79411f409df638647300036c0664183c2725
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'booking_communication_agent.py')
-rw-r--r-- | booking_communication_agent.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/booking_communication_agent.py b/booking_communication_agent.py new file mode 100644 index 0000000..c52e98b --- /dev/null +++ b/booking_communication_agent.py @@ -0,0 +1,42 @@ +from dashboard_notification.notification import Notification +from dashboard_api.api import DashboardAPI + +CONFIG = { + 'dashboard_ip': '127.0.0.1', + 'dashboard_url': 'http://127.0.0.1', + 'api_token': 'f33ff43c85ecb13f5d0632c05dbb0a7d85a5a8d1', + 'user': 'opnfv', + 'password': 'opnfvopnfv' +} + +api = DashboardAPI(CONFIG['dashboard_url'], api_token=CONFIG['api_token'], verbose=True) + + +def booking_start(message): + content = message.content + booking = api.get_booking(id=content['booking_id']) + + # do something here... + + # notify dashboard + api.post_resource_status(resource_id=booking['resource_id'], type='info', title='pod setup', + content='details') + + +def booking_end(message): + # do something here... + + # notify dashboard + api.post_resource_status(resource_id=message.content['resource_id'], type='info', + title='booking end', content='details') + + +def main(): + with Notification(CONFIG['dashboard_ip'], CONFIG['user'], CONFIG['password']) as notification: + notification.register(booking_start, 'Arm POD 2', 'booking_start') + notification.register(booking_end, 'Arm POD 2', 'booking_end') + notification.receive() # wait for notifications + + +if __name__ == "__main__": + main() |