CORD-1951 fix and cleanup vEG synchronizer
Change-Id: I938edf40da13192614fa16ecf350bd18bea84f8d
diff --git a/xos/synchronizer/steps/sync_vegtenant.py b/xos/synchronizer/steps/sync_vegtenant.py
index 6741518..0959073 100644
--- a/xos/synchronizer/steps/sync_vegtenant.py
+++ b/xos/synchronizer/steps/sync_vegtenant.py
@@ -25,6 +25,8 @@
from synchronizers.new_base.modelaccessor import *
from synchronizers.new_base.ansible_helper import run_template_ssh
from xos.logger import Logger, logging
+import wrappers.vegtenant
+import wrappers.veeserviceinstance
# hpclibrary will be in steps/..
parentdir = os.path.join(os.path.dirname(__file__),"..")
@@ -49,7 +51,7 @@
if not o.owner:
return None
- vegs = VEGService.objects.filter(id=o.provider_service.id)
+ vegs = VEGService.objects.filter(id=o.owner.id)
if not vegs:
return None
@@ -89,7 +91,7 @@
safe_macs=[]
if veg_service.url_filter_kind == "safebrowsing":
- if o.volt and o.volt.subscriber:
+ if o.volt and o.volt.subscriber and hasattr(o.volt.subscriber, "devices"):
for user in o.volt.subscriber.devices:
level = user.get("level",None)
mac = user.get("mac",None)
@@ -117,8 +119,18 @@
"dns_servers": [x.strip() for x in veg_service.dns_servers.split(",")],
"url_filter_kind": veg_service.url_filter_kind }
- # add in the sync_attributes that come from the SubscriberRoot object
+ # Some subscriber models may not implement all fields that we look for, so specify some defaults.
+ fields["firewall_rules"] = ""
+ fields["firewall_enable"] = False
+ fields["url_filter_enable"] = False
+ fields["url_filter_level"] = "PG"
+ fields["cdn_enable"] = False
+ fields["uplink_speed"] = 1000000000
+ fields["downlink_speed"] = 1000000000
+ fields["enable_uverse"] = True
+ fields["status"] = "enabled"
+ # add in the sync_attributes that come from the SubscriberRoot object
if o.volt and o.volt.subscriber and hasattr(o.volt.subscriber, "sync_attributes"):
for attribute_name in o.volt.subscriber.sync_attributes:
fields[attribute_name] = getattr(o.volt.subscriber, attribute_name)