aboutsummaryrefslogtreecommitdiffstats
path: root/booking_communication_agent.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-10-24 15:12:32 -0400
committerParker Berberian <pberberian@iol.unh.edu>2018-11-07 10:32:56 -0500
commit7b15aed77c6675286fd75b8832af58c992717ef9 (patch)
treef4597f72433ce75ab46a1fd80f3635c987b38205 /booking_communication_agent.py
parentebc42347105caa2be52a8337372ae4793fe9182c (diff)
Rewrite Notification subsystem
In this commit: - delete a lot of really bad and / or unused code - redesign a much simpler Notification model - create and send notifications to the user's inbox on booking start & end - migrations - emails user when booking is ready and when it ends Not in this commit: - Creating notifications from lab messages - warning messages when a booking is about to end - creating "summary" notifications when e.g. a booking has been fulfilled by a lab Change-Id: I69b4dc36c3f2bce76d810106baadeef5a562cc7d Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'booking_communication_agent.py')
-rw-r--r--booking_communication_agent.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/booking_communication_agent.py b/booking_communication_agent.py
deleted file mode 100644
index dc4ea4d..0000000
--- a/booking_communication_agent.py
+++ /dev/null
@@ -1,50 +0,0 @@
-##############################################################################
-# Copyright (c) 2018 Sawyer Bergeron and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-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()