parser script and step class in backend code of testing-scheduler
[bottlenecks.git] / testing-scheduler / server / src / step / test_step.py
diff --git a/testing-scheduler/server/src/step/test_step.py b/testing-scheduler/server/src/step/test_step.py
new file mode 100644 (file)
index 0000000..363c480
--- /dev/null
@@ -0,0 +1,56 @@
+##############################################################################\r
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Apache License, Version 2.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+##############################################################################\r
+\r
+import os\r
+\r
+\r
+class TestStep(object):\r
+    def __init__(self, type, id, name, service, action, args, context):\r
+        self._type = type\r
+        self._id = id\r
+        self._name = name\r
+        self._serviceName = service['name']\r
+        self._serviceInterface = service['interface']\r
+        self._action = action\r
+        self._args = args\r
+        self._context = context\r
+\r
+    def getId(self):\r
+        return self._id\r
+\r
+    def getName(self):\r
+        return self._name\r
+\r
+    def getServiceName(self):\r
+        return self._serviceName\r
+\r
+    def getCallFunction(self):\r
+        return self._callType\r
+\r
+    def getArgs(self):\r
+        return self._args\r
+\r
+    def action(self):\r
+        f = getattr(self, self._action)\r
+        f()\r
+\r
+    def _argsParse(self):\r
+        pass\r
+\r
+    def _getCurrentDir(self):\r
+        return os.path.dirname(__file__)\r
+\r
+    def __str__(self):\r
+        return str(self.__dict__)\r
+\r
+\r
+if __name__ == "__main__":\r
+    args = {'command': 'start'}\r
+    stepObj = TestStep('test_cpu', 'ansible', 'REST', **args)\r
+    print stepObj\r