diff options
author | Yu Yang (Gabriel) <Gabriel.yuyang@huawei.com> | 2017-01-12 08:42:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-01-12 08:42:52 +0000 |
commit | b2bab28cd8c8e72b230a6286f7d951f1c873bd83 (patch) | |
tree | 032549981f284d00c008d4e21f399fb6901bfc35 /utils | |
parent | e1a54d34819563946d1ff1ec673d1d261b826ad8 (diff) | |
parent | 08b12e7a7f0b5971282c371b0d0b9320030f3874 (diff) |
Merge "Modify utils/ code into PEP8 style"
Diffstat (limited to 'utils')
-rw-r--r-- | utils/__init__.py | 2 | ||||
-rw-r--r-- | utils/dashboard/process_data.py | 4 | ||||
-rwxr-xr-x | utils/dashboard/rubbos_collector.py | 22 | ||||
-rwxr-xr-x | utils/dashboard/uploader.py | 4 | ||||
-rw-r--r-- | utils/infra_setup/__init__.py | 2 | ||||
-rwxr-xr-x | utils/infra_setup/heat/common.py | 3 | ||||
-rwxr-xr-x | utils/infra_setup/heat/consts/parameters.py | 1 | ||||
-rwxr-xr-x | utils/infra_setup/heat/template.py | 4 |
8 files changed, 26 insertions, 16 deletions
diff --git a/utils/__init__.py b/utils/__init__.py index 38727287..b124dfa9 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -5,4 +5,4 @@ # 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 -##############################################################################
\ No newline at end of file +############################################################################## diff --git a/utils/dashboard/process_data.py b/utils/dashboard/process_data.py index e71a1e82..6ca6ee1e 100644 --- a/utils/dashboard/process_data.py +++ b/utils/dashboard/process_data.py @@ -8,14 +8,14 @@ ############################################################################## -import subprocess as subp import sys from rubbos_collector import RubbosCollector from uploader import Uploader def printUsage(): - print "Usage: python process_data.py required_params(**) optional_params([])" + print ("Usage: python process_data.py required_params(**)" + " optional_params([])") print " ** -i|--input input_data_dir" print " ** -s|--suite suite_name" print " ** -c|--conf conf_file" diff --git a/utils/dashboard/rubbos_collector.py b/utils/dashboard/rubbos_collector.py index d9f86032..140700e3 100755 --- a/utils/dashboard/rubbos_collector.py +++ b/utils/dashboard/rubbos_collector.py @@ -17,19 +17,27 @@ def exec_shell(cmd): def get_onetime_data(dir_name): - cmd = "grep -in 'remote client nodes' %s/index.html|awk '{print $5}'|awk -F '<' '{print $1}'" % dir_name + cmd = ("grep -in 'remote client nodes' %s/index.html|awk " + "'{print $5}'|awk -F '<' '{print $1}'" % dir_name) client_node_num = int(exec_shell(cmd)) - cmd = "grep -n 'Number of clients' %s/index.html|awk '{print $5}'|awk -F '<' '{print $1}'" % dir_name + cmd = ("grep -n 'Number of clients' %s/index.html|awk " + "'{print $5}'|awk -F '<' '{print $1}'" % dir_name) each_client_num = int(exec_shell(cmd)) total_client = (client_node_num + 1) * each_client_num - cmd = 'grep -n "throughput" %s/stat_client*.html |awk -F "<B>" \'{if (FNR%%2==0 && FNR%%4!=0) {printf "%%s\\n", $3}}\'|awk \'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name + cmd = ('grep -n "throughput" %s/stat_client*.html |awk -F "<B>"' + ' \'{if (FNR%%2==0 && FNR%%4!=0) {printf "%%s\\n", $3}}\'|awk \'' + 'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name) throughput = int(exec_shell(cmd)) - cmd = 'grep -n "Total" %s/stat_client*.html |awk -F "<B>" \'{if (FNR==4) {printf "%%s\\n", $4}}\'|awk -F "</B>" \'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name + cmd = ('grep -n "Total" %s/stat_client*.html |awk -F "<B>"' + ' \'{if (FNR==4) {printf "%%s\\n", $4}}\'|awk -F "</B>"' + ' \'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name) request = int(exec_shell(cmd)) - cmd = 'grep -n "Total" %s/stat_client*.html |awk -F "<B>" \'{if (FNR==4) {printf "%%s\\n", $5}}\'|awk -F "</B>" \'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name + cmd = ('grep -n "Total" %s/stat_client*.html |awk -F "<B>"' + ' \'{if (FNR==4) {printf "%%s\\n", $5}}\'|awk -F "</B>"' + ' \'BEGIN{sum=0;}{sum=sum+$1;}END{print sum}\'' % dir_name) error_request = int(exec_shell(cmd)) return total_client, throughput, request, error_request @@ -44,8 +52,8 @@ class RubbosCollector(object): cmd = 'ls -l %s |grep ^d|awk \'{print $9}\'' % data_home result = [] for subdir in exec_shell(cmd).split('\n'): - total_client, throughput, request, error_request = get_onetime_data( - data_home + '/' + subdir) + total_client, throughput, request, error_request = \ + get_onetime_data(data_home + '/' + subdir) result.append({'client': total_client, 'throughput': throughput, 'request': request, diff --git a/utils/dashboard/uploader.py b/utils/dashboard/uploader.py index a4686560..97ffd38c 100755 --- a/utils/dashboard/uploader.py +++ b/utils/dashboard/uploader.py @@ -51,7 +51,8 @@ class Uploader(object): def _test(): - #data = '{"details": [{"client": 200, "throughput": 20}, {"client": 300, "throughput": 20}], "case_name": "rubbos"}' + # data = '{"details": [{"client": 200, "throughput": 20}, + # {"client": 300, "throughput": 20}], "case_name": "rubbos"}' if len(sys.argv) < 2: print ("no argumens input!!") exit(1) @@ -60,5 +61,6 @@ def _test(): data = json.load(stream) Uploader().upload_result(data) + if __name__ == "__main__": _test() diff --git a/utils/infra_setup/__init__.py b/utils/infra_setup/__init__.py index 38727287..b124dfa9 100644 --- a/utils/infra_setup/__init__.py +++ b/utils/infra_setup/__init__.py @@ -5,4 +5,4 @@ # 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 -##############################################################################
\ No newline at end of file +############################################################################## diff --git a/utils/infra_setup/heat/common.py b/utils/infra_setup/heat/common.py index 28257ac7..ab0dadf5 100755 --- a/utils/infra_setup/heat/common.py +++ b/utils/infra_setup/heat/common.py @@ -97,6 +97,7 @@ def get_heat_api_version(): return api_version return DEFAULT_HEAT_API_VERSION + def get_nova_api_version(): api_version = os.getenv('OS_COMPUTE_API_VERSION') if api_version is not None: @@ -110,4 +111,4 @@ def get_glance_api_version(): if api_version is not None: log.info("GLANCE_API_VERSION is set in env as '%s'", api_version) return api_version - return DEFAULT_GLANCE_API_VERSION
\ No newline at end of file + return DEFAULT_GLANCE_API_VERSION diff --git a/utils/infra_setup/heat/consts/parameters.py b/utils/infra_setup/heat/consts/parameters.py index f275c25b..15aa5b5d 100755 --- a/utils/infra_setup/heat/consts/parameters.py +++ b/utils/infra_setup/heat/consts/parameters.py @@ -7,7 +7,6 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import files # ------------------------------------------------------ # Directories and file locations diff --git a/utils/infra_setup/heat/template.py b/utils/infra_setup/heat/template.py index 28c20b72..cc652fb4 100755 --- a/utils/infra_setup/heat/template.py +++ b/utils/infra_setup/heat/template.py @@ -114,9 +114,9 @@ class HeatStack(HeatObject): i += 1 if self.uuid is not None: - sys.exit("delete stack failed!!!") + sys.exit("delete stack failed!!!") else: - HeatStack.stacks.remove(self) + HeatStack.stacks.remove(self) @staticmethod def delete_all(): |