-##############################################################################\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 json\r
-import os\r
-from src.step.test_step import TestStep\r
-\r
-\r
-class MonitorStep(TestStep):\r
- __step_type__ = 'monitor'\r
-\r
- def __init__(self, name, service, action, args):\r
- super(MonitorStep, self).__init__(name, service, action, args)\r
- self._argsParse()\r
- self.action()\r
-\r
- def _argsParse(self):\r
- if self._call == "REST":\r
- currentDirPath = os.path.dirname(os.path.abspath(__file__))\r
- envDirPath = os.path.abspath(os.path.join(\r
- currentDirPath, os.pardir, os.pardir, 'env'))\r
- envFilePath = os.path.join(\r
- envDirPath, "%s.json" % self._service['name'])\r
- with open(envFilePath) as f:\r
- propDict = json.load(f)\r
- self._args['ip'] = propDict['ip']\r
- self._args['port'] = propDict['port']\r
- self._args['api'] = "%s/%s" % (\r
- propDict['api_map']['workload'], self._args['command'])\r
- exclude = {'ip', 'port', 'api', 'command', 'method'}\r
- self._args['req_body'] = {\r
- key: value for key, value in\r
- self._args.items() if key not in exclude}\r
-\r
- def setUp(self):\r
- print "monitor setUp"\r
-\r
- def uninstall(self):\r
- print "monitor uninstall"\r
-\r
- def start(self):\r
- print "monitor start...."\r
-\r
- def stop(self):\r
- print "monitor stop"\r
-\r
-\r
-if __name__ == "__main__":\r
- service = {"name": "ansible", "call": "REST"}\r
- monitor = MonitorStep(\r
- "monitor_cpu", service, "start", **{"target": "abc:qq"})\r
+##############################################################################
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# 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
+##############################################################################
+
+import json
+import os
+from src.step.test_step import TestStep
+
+
+class MonitorStep(TestStep):
+ __step_type__ = 'monitor'
+
+ def __init__(self, name, service, action, args):
+ super(MonitorStep, self).__init__(name, service, action, args)
+ self._argsParse()
+ self.action()
+
+ def _argsParse(self):
+ if self._call == "REST":
+ currentDirPath = os.path.dirname(os.path.abspath(__file__))
+ envDirPath = os.path.abspath(os.path.join(
+ currentDirPath, os.pardir, os.pardir, 'env'))
+ envFilePath = os.path.join(
+ envDirPath, "%s.json" % self._service['name'])
+ with open(envFilePath) as f:
+ propDict = json.load(f)
+ self._args['ip'] = propDict['ip']
+ self._args['port'] = propDict['port']
+ self._args['api'] = "%s/%s" % (
+ propDict['api_map']['workload'], self._args['command'])
+ exclude = {'ip', 'port', 'api', 'command', 'method'}
+ self._args['req_body'] = {
+ key: value for key, value in
+ self._args.items() if key not in exclude}
+
+ def setUp(self):
+ print "monitor setUp"
+
+ def uninstall(self):
+ print "monitor uninstall"
+
+ def start(self):
+ print "monitor start...."
+
+ def stop(self):
+ print "monitor stop"
+
+
+if __name__ == "__main__":
+ service = {"name": "ansible", "call": "REST"}
+ monitor = MonitorStep(
+ "monitor_cpu", service, "start", **{"target": "abc:qq"})