CORD-879 update csr wrapper to reflect real object change
Change-Id: Ifc7be2a53e7f2902766e86269cfa0f91d1834368
diff --git a/xos/coreapi/apihelper.py b/xos/coreapi/apihelper.py
index 9d9134c..b389f65 100644
--- a/xos/coreapi/apihelper.py
+++ b/xos/coreapi/apihelper.py
@@ -68,7 +68,7 @@
setattr(p_obj, field.name, getattr(obj, field.name))
elif (ftype == "AutoField"):
setattr(p_obj, field.name, int(getattr(obj, field.name)))
- elif (ftype == "IntegerField") or (ftype == "PositiveIntegerField"):
+ elif (ftype == "IntegerField") or (ftype == "PositiveIntegerField") or (ftype == "BigIntegerField"):
setattr(p_obj, field.name, int(getattr(obj, field.name)))
elif (ftype == "ForeignKey"):
setattr(p_obj, field.name+"_id", self.convertForeignKey(getattr(obj, field.name)))
@@ -126,7 +126,7 @@
args[name] = val
elif (ftype == "AutoField"):
args[name] = val
- elif (ftype == "IntegerField") or (ftype == "PositiveIntegerField"):
+ elif (ftype == "IntegerField") or (ftype == "PositiveIntegerField") or (ftype == "BigIntegerField"):
args[name] = val
elif (ftype == "ForeignKey"):
args[name] = val # field name already has "_id" at the end
diff --git a/xos/tools/apigen/protobuf.template.txt b/xos/tools/apigen/protobuf.template.txt
index 060d218..4df40ac 100644
--- a/xos/tools/apigen/protobuf.template.txt
+++ b/xos/tools/apigen/protobuf.template.txt
@@ -47,6 +47,8 @@
int32 {{ field.name }} = {{ loop.index }};
{%- elif field.get_internal_type() == "IntegerField" %}
int32 {{ field.name }} = {{ loop.index }};
+ {%- elif field.get_internal_type() == "BigIntegerField" %}
+ int64 {{ field.name }} = {{ loop.index }};
{%- elif field.get_internal_type() == "PositiveIntegerField" %}
uint32 {{ field.name }} = {{ loop.index }};
{%- elif field.get_internal_type() == "FloatField" %}
diff --git a/xos/xos_client/tests/csr_introspect.py b/xos/xos_client/tests/csr_introspect.py
new file mode 100644
index 0000000..8ca3be5
--- /dev/null
+++ b/xos/xos_client/tests/csr_introspect.py
@@ -0,0 +1,19 @@
+import sys
+sys.path.append("..")
+
+from xosapi import xos_grpc_client
+
+def test_callback():
+ print "TEST: csr_introspect"
+
+ c = xos_grpc_client.coreclient
+
+ for csr in c.xos_orm.CordSubscriberRoot.objects.all():
+ print " csr", csr.id
+ for field_name in ["firewall_enable", "firewall_rules", "url_filter_enable", "url_filter_rules", "cdn_enable", "uplink_speed", "downlink_speed", "enable_uverse", "status"]:
+ print " %s: %s" % (field_name, getattr(csr, field_name))
+
+ print " okay"
+
+xos_grpc_client.start_api_parseargs(test_callback)
+
diff --git a/xos/xos_client/tests/run_tests.sh b/xos/xos_client/tests/run_tests.sh
index 0d4c4f4..ccc3be9 100755
--- a/xos/xos_client/tests/run_tests.sh
+++ b/xos/xos_client/tests/run_tests.sh
@@ -8,3 +8,4 @@
docker run -it --entrypoint python xosproject/xos-client /tmp/xos_client/tests/orm_listall.py -u xosadmin@opencord.org -p $PW -qq
docker run -it --entrypoint python xosproject/xos-client /tmp/xos_client/tests/vtr_crud.py -u xosadmin@opencord.org -p $PW -qq
docker run -it --entrypoint python xosproject/xos-client /tmp/xos_client/tests/vsg_introspect.py -u xosadmin@opencord.org -p $PW -qq
+docker run -it --entrypoint python xosproject/xos-client /tmp/xos_client/tests/csr_introspect.py -u xosadmin@opencord.org -p $PW -qq
\ No newline at end of file
diff --git a/xos/xos_client/xosapi/convenience/cordsubscriberroot.py b/xos/xos_client/xosapi/convenience/cordsubscriberroot.py
index 440925e..876e3c4 100644
--- a/xos/xos_client/xosapi/convenience/cordsubscriberroot.py
+++ b/xos/xos_client/xosapi/convenience/cordsubscriberroot.py
@@ -9,8 +9,6 @@
return volt_tenants[0]
return None
- # all of these will go away when CordSubscriberRoot is made into a real object
-
sync_attributes = ("firewall_enable",
"firewall_rules",
"url_filter_enable",
@@ -21,6 +19,8 @@
"enable_uverse",
"status")
+ # figure out what to do about "devices"... is it still needed?
+
def get_attribute(self, name, default=None):
if self.service_specific_attribute:
attributes = json.loads(self.service_specific_attribute)
@@ -29,51 +29,7 @@
return attributes.get(name, default)
@property
- def firewall_enable(self):
- return self.get_attribute("firewall_enable", False)
-
- @property
- def firewall_rules(self):
- return self.get_attribute("firewall_rules", "accept all anywhere anywhere")
-
- @property
- def url_filter_enable(self):
- return self.get_attribute("url_filter_enable", False)
-
- @property
- def url_filter_rules(self):
- return self.get_attribute("url_filter_rules", "allow all")
-
- @property
- def url_filter_level(self):
- return self.get_attribute("url_filter_level", "PG")
-
- @property
- def cdn_enable(self):
- return self.get_attribute("cdn_enable", False)
-
- @property
def devices(self):
return self.get_attribute("devices", [])
- @property
- def is_demo_user(self):
- return self.get_attribute("is_demo_user", False)
-
- @property
- def uplink_speed(self):
- return self.get_attribute("uplink_speed", 1000000000)
-
- @property
- def downlink_speed(self):
- return self.get_attribute("downlink_speed", 1000000000)
-
- @property
- def enable_uverse(self):
- return self.get_attribute("enable_uverse", True)
-
- @property
- def status(self):
- return self.get_attribute("status", "enabled")
-
register_convenience_wrapper("CordSubscriberRoot", ORMWrapperCordSubscriberRoot)