Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/configurations/cord-pod/cdn/README.md b/xos/configurations/cord-pod/cdn/README.md
index a7730f9..af5b38d 100644
--- a/xos/configurations/cord-pod/cdn/README.md
+++ b/xos/configurations/cord-pod/cdn/README.md
@@ -65,3 +65,4 @@
 ## Restart CDN after power-down
 
 To do...
+test
diff --git a/xos/services/cord/admin.py b/xos/services/cord/admin.py
index 4195aaa..3cccc6c 100644
--- a/xos/services/cord/admin.py
+++ b/xos/services/cord/admin.py
@@ -108,6 +108,7 @@
     wan_container_gateway_mac = forms.CharField(required=False)
     wan_container_netbits = forms.CharField(required=False)
     dns_servers = forms.CharField(required=False)
+    url_filter_kind = forms.ChoiceField(choices=VSGService.URL_FILTER_KIND_CHOICES, required=False)
     node_label = forms.CharField(required=False)
 
     def __init__(self,*args,**kwargs):
@@ -122,6 +123,7 @@
             self.fields['wan_container_gateway_mac'].initial = self.instance.wan_container_gateway_mac
             self.fields['wan_container_netbits'].initial = self.instance.wan_container_netbits
             self.fields['dns_servers'].initial = self.instance.dns_servers
+            self.fields['url_filter_kind']. initial = self.instance.url_filter_kind
             self.fields['node_label'].initial = self.instance.node_label
 
     def save(self, commit=True):
@@ -134,6 +136,7 @@
         self.instance.wan_container_gateway_mac = self.cleaned_data.get("wan_container_gateway_mac")
         self.instance.wan_container_netbits = self.cleaned_data.get("wan_container_netbits")
         self.instance.dns_servers = self.cleaned_data.get("dns_servers")
+        self.instance.url_filter_kind = self.cleaned_data.get("url_filter_kind")
         self.instance.node_label = self.cleaned_data.get("node_label")
         return super(VSGServiceForm, self).save(commit=commit)
 
@@ -148,7 +151,7 @@
     list_display_links = ('backend_status_icon', 'name', )
     fieldsets = [(None,             {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "service_specific_attribute", "node_label"],
                                      'classes':['suit-tab suit-tab-general']}),
-                 ("backend config", {'fields': [ "backend_network_label", "bbs_api_hostname", "bbs_api_port", "bbs_server", "bbs_slice"],
+                 ("backend config", {'fields': [ "backend_network_label", "url_filter_kind", "bbs_api_hostname", "bbs_api_port", "bbs_server", "bbs_slice"],
                                      'classes':['suit-tab suit-tab-backend']}),
                  ("vSG config", {'fields': [ "wan_container_gateway_ip", "wan_container_gateway_mac", "wan_container_netbits", "dns_servers"],
                                      'classes':['suit-tab suit-tab-vsg']}) ]
diff --git a/xos/services/cord/models.py b/xos/services/cord/models.py
index b7f25af..9b98262 100644
--- a/xos/services/cord/models.py
+++ b/xos/services/cord/models.py
@@ -362,6 +362,8 @@
 class VSGService(Service):
     KIND = VCPE_KIND
 
+    URL_FILTER_KIND_CHOICES = ( (None, "None"), ("safebrowsing", "Safe Browsing"), ("answerx", "AnswerX") )
+
     simple_attributes = ( ("bbs_api_hostname", None),
                           ("bbs_api_port", None),
                           ("bbs_server", None),
@@ -370,6 +372,7 @@
                           ("wan_container_gateway_mac", ""),
                           ("wan_container_netbits", "24"),
                           ("dns_servers", "8.8.8.8"),
+                          ("url_filter_kind", None),
                           ("node_label", None) )
 
     def __init__(self, *args, **kwargs):
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant.py b/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
index a8c6b4f..2f2147b 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
@@ -22,7 +22,6 @@
 
 logger = Logger(level=logging.INFO)
 
-PARENTAL_MECHANISM="dnsmasq"
 ENABLE_QUICK_UPDATE=False
 
 CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
@@ -145,13 +144,14 @@
             full_setup = True
 
         safe_macs=[]
-        if o.volt and o.volt.subscriber:
-            for user in o.volt.subscriber.users:
-                level = user.get("level",None)
-                mac = user.get("mac",None)
-                if level in ["G", "PG"]:
-                    if mac:
-                        safe_macs.append(mac)
+        if vcpe_service.url_filter_kind == "safebrowsing":
+            if o.volt and o.volt.subscriber:
+                for user in o.volt.subscriber.users:
+                    level = user.get("level",None)
+                    mac = user.get("mac",None)
+                    if level in ["G", "PG"]:
+                        if mac:
+                            safe_macs.append(mac)
 
         wan_vm_ip=""
         wan_vm_mac=""
@@ -181,7 +181,8 @@
                 "wan_vm_ip": wan_vm_ip,
                 "safe_browsing_macs": safe_macs,
                 "container_name": "vcpe-%s-%s" % (s_tags[0], c_tags[0]),
-                "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")] }
+                "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")],
+                "url_filter_kind": vcpe_service.url_filter_kind }
 
         # add in the sync_attributes that come from the SubscriberRoot object
 
@@ -218,7 +219,7 @@
             url_filter_level = o.volt.subscriber.url_filter_level
             url_filter_users = o.volt.subscriber.users
 
-        if PARENTAL_MECHANISM=="broadbandshield":
+        if service.url_filter_kind == "broadbandshield":
             # disable url_filter if there are no bbs_addrs
             if url_filter_enable and (not fields.get("bbs_addrs",[])):
                 logger.info("disabling url_filter because there are no bbs_addrs")
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant.yaml
index 945e7cb..3823328 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant.yaml
@@ -62,6 +62,7 @@
       downlink_speed: {{ downlink_speed }}
       status: {{ status }}
       enable_uverse: {{ enable_uverse }}
+      url_filter_kind: {{ url_filter_kind }}
 
   tasks:
 {% if full_setup %}
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant_new.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant_new.yaml
index fe11405..324e274 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant_new.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant_new.yaml
@@ -63,6 +63,7 @@
       downlink_speed: {{ downlink_speed }}
       status: {{ status }}
       enable_uverse: {{ enable_uverse }}
+      url_filter_kind: {{ url_filter_kind }}
 
   tasks:
   - name: Verify if vcpe_stats_notifier ([] is to avoid capturing the shell process) cron job is already running
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
index f042e5d..04521dc 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant_vtn.yaml
@@ -68,6 +68,7 @@
       downlink_speed: {{ downlink_speed }}
       status: {{ status }}
       enable_uverse: {{ enable_uverse }}
+      url_filter_kind: {{ url_filter_kind }}
 
 
   tasks:
diff --git a/xos/synchronizers/vcpe/templates/dnsmasq_servers.j2 b/xos/synchronizers/vcpe/templates/dnsmasq_servers.j2
index 004576f..5d6839e 100644
--- a/xos/synchronizers/vcpe/templates/dnsmasq_servers.j2
+++ b/xos/synchronizers/vcpe/templates/dnsmasq_servers.j2
@@ -11,6 +11,11 @@
 {% endif %}
 {% endif %}
 
+{% if url_filter_kind=="answerx" %}
+cache-size=0
+add-mac
+{% endif %}
+
 # use google's DNS service
 {% for dns_server in dns_servers %}
 server={{ dns_server }}