Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/cord/models.py b/xos/cord/models.py
index ca010cb..44ced17 100644
--- a/xos/cord/models.py
+++ b/xos/cord/models.py
@@ -197,6 +197,9 @@
         proxy = True
 
     def allocate_bbs_account(self):
+        # XXX fixme XXX
+        return "bbs01@onlab.us"
+
         vcpes = VCPETenant.get_tenant_objects().all()
         bbs_accounts = [vcpe.bbs_account for vcpe in vcpes]
 
diff --git a/xos/core/xoslib/methods/cordsubscriber.py b/xos/core/xoslib/methods/cordsubscriber.py
index 5742c9c..5992a2e 100644
--- a/xos/core/xoslib/methods/cordsubscriber.py
+++ b/xos/core/xoslib/methods/cordsubscriber.py
@@ -311,9 +311,24 @@
         subscriber.save()
         return Response({service: getattr(subscriber, service_attr)})
 
+    def setup_demo_vcpe(self, voltTenant):
+        # nuke the users and start over
+        voltTenant.vcpe.users = []
+        voltTenant.vcpe.create_user(name="Mom's PC",      mac="01020303040506", level="PG_13")
+        voltTenant.vcpe.create_user(name="Dad's PC",      mac="01020304040507", level="PG_13")
+        voltTenant.vcpe.create_user(name="Jack's iPhone", mac="01020304050508", level="PG_13")
+        voltTenant.vcpe.create_user(name="Jill's iPad",   mac="01020304050609", level="PG_13")
+        voltTenant.vcpe.save()
+
     def initdemo(self, request):
         object_list = VOLTTenant.get_tenant_objects().all()
 
+        # reset the parental controls in any existing demo vCPEs
+        for o in object_list:
+            if str(o.service_specific_id) in ["0", "1"]:
+                if o.vcpe is not None:
+                    self.setup_demo_vcpe(o)
+
         demo_subscribers = [o for o in object_list if o.is_demo_user]
 
         if demo_subscribers:
@@ -325,25 +340,21 @@
         voltTenant.caller = User.objects.get(email="padmin@vicci.org")
         voltTenant.save()
 
-        voltTenant.vcpe.create_user(name="Mom's PC",      mac="01020303040506", level="R")
-        voltTenant.vcpe.create_user(name="Dad's PC",      mac="01020304040507", level="R")
-        voltTenant.vcpe.create_user(name="Jack's iPhone", mac="01020304050508", level="PG")
-        voltTenant.vcpe.create_user(name="Jill's iPad",   mac="01020304050609", level="G")
-        voltTenant.vcpe.save()
+        self.setup_demo_vcpe(voltTenant)
 
         return Response({"id": voltTenant.id})
 
     def ssidlist(self, request):
         object_list = VOLTTenant.get_tenant_objects().all()
 
-        ssidmap = [ {"service_specific_id:": x.service_specific_id, "subscriber_id": x.id} for x in object_list ]
+        ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list ]
 
         return Response({"ssidmap": ssidmap})
 
     def ssiddetail(self, pk=None, ssid=None):
         object_list = VOLTTenant.get_tenant_objects().all()
 
-        ssidmap = [ {"service_specific_id:": x.service_specific_id, "subscriber_id": x.id} for x in object_list if str(x.service_specific_id)==str(ssid) ]
+        ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list if str(x.service_specific_id)==str(ssid) ]
 
         if len(ssidmap)==0:
             raise XOSNotFound("didn't find ssid %s" % str(ssid))
diff --git a/xos/core/xoslib/methods/volttenant.py b/xos/core/xoslib/methods/volttenant.py
index a1ae656..ba0e909 100644
--- a/xos/core/xoslib/methods/volttenant.py
+++ b/xos/core/xoslib/methods/volttenant.py
@@ -3,6 +3,7 @@
 from rest_framework.reverse import reverse
 from rest_framework import serializers
 from rest_framework import generics
+from rest_framework import status
 from core.models import *
 from django.forms import widgets
 from cord.models import VOLTTenant, VOLTService
@@ -68,6 +69,21 @@
 
         return queryset
 
+    def post(self, request, format=None):
+        data = request.DATA
+
+        existing_obj = None
+        for obj in VOLTTenant.get_tenant_objects().all():
+            if (obj.vlan_id == data.get("vlan_id", None)) and (obj.service_specific_id == data.get("service_specific_id",None)):
+               existing_obj = obj
+
+        if existing_obj:
+            serializer = VOLTTenantIdSerializer(existing_obj)
+            headers = self.get_success_headers(serializer.data)
+            return Response( serializer.data, status=status.HTTP_200_OK )
+
+        return super(VOLTTenantList, self).post(request, format)
+
 class VOLTTenantDetail(XOSRetrieveUpdateDestroyAPIView):
     serializer_class = VOLTTenantIdSerializer
     queryset = VOLTTenant.get_tenant_objects().select_related().all()
diff --git a/xos/observers/vcpe/broadbandshield.py b/xos/observers/vcpe/broadbandshield.py
index 96f9944..9d08ed8 100644
--- a/xos/observers/vcpe/broadbandshield.py
+++ b/xos/observers/vcpe/broadbandshield.py
@@ -54,7 +54,9 @@
 
 
 class BBS:
-    level_map = {"PG_13": "PG-13",
+    level_map = {"PG_13": "PG13",
+                 "NONE": "OFF",
+                 "ALL": "NONE",
                  None: "NONE"}
 
     def __init__(self, username, password):
@@ -229,6 +231,15 @@
         for device in self.settings["devices"]:
             print "  device", device["name"], "user", device["username"], "rating", device["settings"]["rating"], "mac", device["mac_address"]
 
+def dump():
+    if len(sys.argv)!=3:
+        print "syntax: broadbandshield.py <email> <password>"
+        sys.exit(-1)
+
+    bbs = BBS(sys.argv[1], sys.argv[2])
+
+    bbs.dump()
+
 def self_test():
     if len(sys.argv)!=3:
         print "syntax: broadbandshield.py <email> <password>"
@@ -345,7 +356,8 @@
     #bbs.add_device(name="tom's iphone", mac="010203040506", type="tablet", username="tom")
 
 def main():
-    self_test()
+    dump()
+    #self_test()
 
 if __name__ == "__main__":
     main()