summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources/pod_models.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-10-18 17:30:31 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-10-18 17:30:31 +0800
commitd30f7afdd2d39302174a788e9e008feb61b25596 (patch)
treeeed10dd17021d0f4ee87fb90089dab6eed5b5071 /utils/test/testapi/opnfv_testapi/resources/pod_models.py
parent307a8f07e8c17800ed1214394a3aacf02045a03a (diff)
rename result_collection_api to testapi
Change-Id: Iec4e3db23cd44f30831e17c127eda74e9d9b5d14 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources/pod_models.py')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/pod_models.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_models.py b/utils/test/testapi/opnfv_testapi/resources/pod_models.py
new file mode 100644
index 000000000..7231806f6
--- /dev/null
+++ b/utils/test/testapi/opnfv_testapi/resources/pod_models.py
@@ -0,0 +1,85 @@
+##############################################################################
+# Copyright (c) 2015 Orange
+# guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+from opnfv_testapi.tornado_swagger import swagger
+
+# name: name of the POD e.g. zte-1
+# mode: metal or virtual
+# details: any detail
+# role: ci-pod or community-pod or single-node
+
+
+@swagger.model()
+class PodCreateRequest(object):
+ def __init__(self, name, mode='', details='', role=""):
+ self.name = name
+ self.mode = mode
+ self.details = details
+ self.role = role
+
+ def format(self):
+ return {
+ "name": self.name,
+ "mode": self.mode,
+ "details": self.details,
+ "role": self.role,
+ }
+
+
+@swagger.model()
+class Pod(PodCreateRequest):
+ def __init__(self,
+ name='', mode='', details='',
+ role="", _id='', create_date=''):
+ super(Pod, self).__init__(name, mode, details, role)
+ self._id = _id
+ self.creation_date = create_date
+
+ @staticmethod
+ def from_dict(pod_dict):
+ if pod_dict is None:
+ return None
+
+ p = Pod()
+ p._id = pod_dict.get('_id')
+ p.creation_date = str(pod_dict.get('creation_date'))
+ p.name = pod_dict.get('name')
+ p.mode = pod_dict.get('mode')
+ p.details = pod_dict.get('details')
+ p.role = pod_dict.get('role')
+ return p
+
+ def format(self):
+ f = super(Pod, self).format()
+ f['creation_date'] = str(self.creation_date)
+ return f
+
+ def format_http(self):
+ f = self.format()
+ f['_id'] = str(self._id)
+ return f
+
+
+@swagger.model()
+class Pods(object):
+ """
+ @property pods:
+ @ptype pods: C{list} of L{Pod}
+ """
+ def __init__(self):
+ self.pods = list()
+
+ @staticmethod
+ def from_dict(res_dict):
+ if res_dict is None:
+ return None
+
+ res = Pods()
+ for pod in res_dict.get('pods'):
+ res.pods.append(Pod.from_dict(pod))
+ return res