CORD-1010 add wrappers for user, port, and slice models
Change-Id: I5832b33bc440c9be6d378071e1474c4d05811c32
diff --git a/xos/xos_client/xosapi/convenience/port.py b/xos/xos_client/xosapi/convenience/port.py
new file mode 100644
index 0000000..e6d56ed
--- /dev/null
+++ b/xos/xos_client/xosapi/convenience/port.py
@@ -0,0 +1,13 @@
+import json
+from xosapi.orm import ORMWrapper, register_convenience_wrapper
+
+class ORMWrapperPort(ORMWrapper):
+ def get_parameters(self):
+ parameter_dict = {}
+
+ for param in self.stub.NetworkParameter.objects.filter(content_type_id=self.self_content_type_id, object_id=self.id):
+ parameter_dict[param.parameter.name] = param.value
+
+ return parameter_dict
+
+register_convenience_wrapper("Port", ORMWrapperPort)
diff --git a/xos/xos_client/xosapi/convenience/slice.py b/xos/xos_client/xosapi/convenience/slice.py
new file mode 100644
index 0000000..b27b971
--- /dev/null
+++ b/xos/xos_client/xosapi/convenience/slice.py
@@ -0,0 +1,10 @@
+import json
+from xosapi.orm import ORMWrapper, register_convenience_wrapper
+
+class ORMWrapperSlice(ORMWrapper):
+ # TODO: this looks to be incorrect
+ @property
+ def slicename(self):
+ return "%s_%s" % (self.site.login_base, self.name)
+
+register_convenience_wrapper("Slice", ORMWrapperSlice)
diff --git a/xos/xos_client/xosapi/convenience/user.py b/xos/xos_client/xosapi/convenience/user.py
new file mode 100644
index 0000000..082a8c1
--- /dev/null
+++ b/xos/xos_client/xosapi/convenience/user.py
@@ -0,0 +1,10 @@
+import hashlib
+import json
+from xosapi.orm import ORMWrapper, register_convenience_wrapper
+
+class ORMWrapperUser(ORMWrapper):
+ @property
+ def remote_password(self):
+ return hashlib.md5(self.password).hexdigest()[:12]
+
+register_convenience_wrapper("User", ORMWrapperUser)
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index c21a994..3daed94 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -462,4 +462,7 @@
import convenience.tenant
import convenience.onosapp
import convenience.controller
+import convenience.user
+import convenience.slice
+import convenience.port