Adding first progran Xos integration
Change-Id: I2f9f52bff7ed985fe4b76eb928048c9d0cfde03e
diff --git a/xos/synchronizer/steps/sync_imsi.py b/xos/synchronizer/steps/sync_imsi.py
new file mode 100644
index 0000000..bf56767
--- /dev/null
+++ b/xos/synchronizer/steps/sync_imsi.py
@@ -0,0 +1,60 @@
+import os
+import sys
+import requests
+import json
+from django.db.models import Q, F
+from services.progran.models import *
+from synchronizers.base.syncstep import SyncStep
+from xos.logger import Logger, logging
+
+# from core.models import Service
+from requests.auth import HTTPBasicAuth
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+logger = Logger(level=logging.INFO)
+
+
+class SyncVImsiApp(SyncStep):
+ provides = [VProgranImsi]
+
+ observes = VProgranImsi
+
+ requested_interval = 0
+
+ def __init__(self, *args, **kwargs):
+ super(SyncVImsiApp, self).__init__(*args, **kwargs)
+
+ def get_onos_progran_addr(self):
+
+ return "http://%s:%s/onos/" % ("10.6.0.1", "8183")
+
+ def get_onos_progran_auth(self):
+
+ return HTTPBasicAuth("onos", "rocks")
+
+ def sync_record(self, app):
+
+ logger.info("Sync'ing Edited vProgran Imsi")
+
+ onos_addr = self.get_onos_progran_addr()
+
+ data = {}
+ data["imsi"] = app.imsi
+ data["profile"] = app.profile
+
+
+ url = onos_addr + "progran/mwc/connect"
+
+ print "POST %s for app %s" % (url, "Progran Imsi")
+
+ auth = self.get_onos_progran_auth()
+ r = requests.post(url, data=json.dumps(data), auth=auth)
+ if (r.status_code != 200):
+ print r
+ raise Exception("Received error from progran app update (%d)" % r.status_code)
+
+ def delete_record(self, app):
+ logger.info("Deletion is not supported yet")
+