[CORD-2550] Fixing bugs
Change-Id: I386148f2b1173f5c646b94d05f629a50531ae468
diff --git a/xos/synchronizer/steps/sync_progranserviceinstance.py b/xos/synchronizer/steps/sync_progranserviceinstance.py
index 69a860e..656cae1 100644
--- a/xos/synchronizer/steps/sync_progranserviceinstance.py
+++ b/xos/synchronizer/steps/sync_progranserviceinstance.py
@@ -50,10 +50,10 @@
log.debug("Sync'ing profile with data", request_data=data)
if o.previously_sync == False:
- log.debug("Sending POST")
+ log.debug("Sending POST", url=profile_url, data=json.dumps(data))
r = requests.post(profile_url, data=json.dumps(data), auth=HTTPBasicAuth(onos['username'], onos['password']))
else:
- log.debug("Sending PUT")
+ log.debug("Sending PUT", url=profile_url, data=json.dumps(data))
r = requests.put(profile_url, data=json.dumps(data),
auth=HTTPBasicAuth(onos['username'], onos['password']))
diff --git a/xos/synchronizer/steps/sync_progranserviceinstance_back.py b/xos/synchronizer/steps/sync_progranserviceinstance_back.py
index bc94976..8b38d74 100644
--- a/xos/synchronizer/steps/sync_progranserviceinstance_back.py
+++ b/xos/synchronizer/steps/sync_progranserviceinstance_back.py
@@ -25,7 +25,6 @@
from xosconfig import Config
from multistructlog import create_logger
-import json
import requests
from requests.auth import HTTPBasicAuth
@@ -89,6 +88,13 @@
try:
si = ProgranServiceInstance.objects.get(name=p['Name'])
log.debug("Profile %s already exists, updating it" % p['Name'])
+
+ # if the model has not been synchronizer yet, skip it
+ if si.no_sync is True:
+ log.info("Skipping profile %s as not synchronized" % p['Name'])
+ # NOTE add it to the removed profiles to avoid deletion (this is ugly, I know)
+ updated_profiles.append(si.name)
+ continue
except IndexError:
si = ProgranServiceInstance()
@@ -124,6 +130,8 @@
si.no_sync = True
si.previously_sync = True
+ si.enacted = time.mktime(datetime.datetime.now().timetuple())
+
si.save()
updated_profiles.append(si.name)
@@ -138,4 +146,5 @@
if si.created_by == 'XOS' and si.previously_sync == False:
# don't delete if the profile has been created by XOS and it hasn't been sync'ed yet
continue
+ # TODO delete also the associated Handover
si.delete()