summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xvstf/README.rst2
-rwxr-xr-xvstf/__init__.py8
-rwxr-xr-xvstf/etc/vstf/perf/sw_perf.batch-settings10
-rwxr-xr-xvstf/etc/vstf/perf/sw_perf.device-settings4
-rwxr-xr-xvstf/etc/vstf/reporter/reporter.pdf.story-show32
-rwxr-xr-xvstf/etc/vstf/reporter/reporters.html.data-settings13
-rwxr-xr-xvstf/etc/vstf/reporter/reporters.template-settings36
-rwxr-xr-xvstf/install.sh6
-rwxr-xr-x[-rw-r--r--]vstf/pylint.conf0
-rwxr-xr-xvstf/setup.cfg2
-rwxr-xr-x[-rw-r--r--]vstf/setup.py21
-rwxr-xr-xvstf/vstf/__init__.py21
-rwxr-xr-xvstf/vstf/agent/__init__.py20
-rwxr-xr-xvstf/vstf/agent/agent.py22
-rwxr-xr-xvstf/vstf/agent/env/__init__.py21
-rwxr-xr-xvstf/vstf/agent/env/basic/__init__.py21
-rwxr-xr-xvstf/vstf/agent/env/basic/collect.py9
-rwxr-xr-xvstf/vstf/agent/env/basic/commandline.py9
-rwxr-xr-xvstf/vstf/agent/env/basic/device_manager.py13
-rwxr-xr-xvstf/vstf/agent/env/basic/image_manager.py12
-rwxr-xr-xvstf/vstf/agent/env/basic/source_manager.py12
-rwxr-xr-xvstf/vstf/agent/env/basic/vm9pfs.py12
-rwxr-xr-xvstf/vstf/agent/env/basic/vm_manager.py12
-rwxr-xr-xvstf/vstf/agent/env/basic/vm_xml_help.py12
-rwxr-xr-xvstf/vstf/agent/env/builder.py12
-rwxr-xr-xvstf/vstf/agent/env/driver_plugins/__init__.py8
-rwxr-xr-xvstf/vstf/agent/env/driver_plugins/manager.py12
-rwxr-xr-xvstf/vstf/agent/env/driver_plugins/model.py12
-rwxr-xr-xvstf/vstf/agent/env/driver_plugins/origin_driver.py12
-rwxr-xr-xvstf/vstf/agent/env/fsmonitor/FSMonitor.py13
-rwxr-xr-xvstf/vstf/agent/env/fsmonitor/__init__.py20
-rwxr-xr-xvstf/vstf/agent/env/fsmonitor/constant.py12
-rwxr-xr-xvstf/vstf/agent/env/fsmonitor/utils.py12
-rwxr-xr-xvstf/vstf/agent/env/plugins/__init__.py20
-rwxr-xr-xvstf/vstf/agent/env/plugins/libvirt_plugin.py12
-rwxr-xr-xvstf/vstf/agent/env/plugins/model.py12
-rwxr-xr-xvstf/vstf/agent/env/plugins/tester_env_plugin.py13
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/__init__.py8
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py12
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/manager.py12
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/model.py12
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py12
-rwxr-xr-xvstf/vstf/agent/equalizer/__init__.py21
-rwxr-xr-xvstf/vstf/agent/equalizer/equalizer.py11
-rwxr-xr-xvstf/vstf/agent/equalizer/get_info.py10
-rwxr-xr-xvstf/vstf/agent/equalizer/optimize.py10
-rwxr-xr-xvstf/vstf/agent/perf/__init__.py21
-rwxr-xr-xvstf/vstf/agent/perf/affctl.py13
-rwxr-xr-xvstf/vstf/agent/perf/ethtool.py13
-rwxr-xr-xvstf/vstf/agent/perf/iperf.py13
-rwxr-xr-xvstf/vstf/agent/perf/netmap.py14
-rwxr-xr-xvstf/vstf/agent/perf/netns.py12
-rwxr-xr-xvstf/vstf/agent/perf/netperf.py14
-rwxr-xr-xvstf/vstf/agent/perf/pktgen.py14
-rwxr-xr-xvstf/vstf/agent/perf/qperf.py13
-rwxr-xr-xvstf/vstf/agent/perf/sar.py12
-rwxr-xr-xvstf/vstf/agent/perf/utils.py12
-rwxr-xr-xvstf/vstf/agent/perf/vnstat.py12
-rwxr-xr-xvstf/vstf/agent/perf/vstfperf.py14
-rwxr-xr-xvstf/vstf/agent/softagent.py10
-rwxr-xr-xvstf/vstf/agent/spirent/__init__.py20
-rwxr-xr-xvstf/vstf/agent/spirent/spirent.py15
-rwxr-xr-xvstf/vstf/agent/spirentagent.py10
-rwxr-xr-xvstf/vstf/common/__init__.py21
-rwxr-xr-xvstf/vstf/common/candy_text.py61
-rwxr-xr-xvstf/vstf/common/cfgparser.py12
-rwxr-xr-xvstf/vstf/common/check.py13
-rwxr-xr-xvstf/vstf/common/cliutil.py9
-rwxr-xr-xvstf/vstf/common/cmds.py9
-rwxr-xr-xvstf/vstf/common/constants.py14
-rwxr-xr-xvstf/vstf/common/daemon.py10
-rwxr-xr-xvstf/vstf/common/decorator.py14
-rwxr-xr-xvstf/vstf/common/excepts.py10
-rwxr-xr-xvstf/vstf/common/input.py12
-rwxr-xr-xvstf/vstf/common/log.py9
-rwxr-xr-xvstf/vstf/common/message.py9
-rwxr-xr-xvstf/vstf/common/perfmark.py9
-rwxr-xr-xvstf/vstf/common/pyhtml.py20
-rwxr-xr-xvstf/vstf/common/rsync.py847
-rwxr-xr-xvstf/vstf/common/saltstack.py11
-rwxr-xr-xvstf/vstf/common/ssh.py12
-rwxr-xr-xvstf/vstf/common/test_func.py9
-rwxr-xr-xvstf/vstf/common/unix.py9
-rwxr-xr-xvstf/vstf/common/utils.py15
-rwxr-xr-xvstf/vstf/common/vstfcli.py9
-rwxr-xr-xvstf/vstf/controller/__init__.py20
-rwxr-xr-xvstf/vstf/controller/api_server.py58
-rwxr-xr-xvstf/vstf/controller/database/__init__.py21
-rwxr-xr-xvstf/vstf/controller/database/constants.py10
-rwxr-xr-xvstf/vstf/controller/database/dbinterface.py398
-rwxr-xr-xvstf/vstf/controller/database/tables.py14
-rwxr-xr-xvstf/vstf/controller/env_build/__init__.py20
-rwxr-xr-xvstf/vstf/controller/env_build/cfg_intent_parse.py12
-rwxr-xr-xvstf/vstf/controller/env_build/env_build.py12
-rwxr-xr-xvstf/vstf/controller/env_build/env_collect.py9
-rwxr-xr-xvstf/vstf/controller/fabricant.py13
-rwxr-xr-xvstf/vstf/controller/reporters/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/mail/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/mail/mail.py9
-rwxr-xr-xvstf/vstf/controller/reporters/mail/sendmail.py15
-rwxr-xr-xvstf/vstf/controller/reporters/report/__init__.py22
-rwxr-xr-xvstf/vstf/controller/reporters/report/candy_generator.py138
-rwxr-xr-xvstf/vstf/controller/reporters/report/data_factory.py131
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/html_base.py40
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/html_text.py68
-rwxr-xr-xvstf/vstf/controller/reporters/report/html/htmlcreator.py162
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/__init__.py21
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/element.py14
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/pdfcreator.py515
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/pdftemplate.py31
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/story.py47
-rwxr-xr-xvstf/vstf/controller/reporters/report/pdf/styles.py32
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/__init__.py20
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/html_provider.py68
-rwxr-xr-xvstf/vstf/controller/reporters/report/provider/pdf_provider.py51
-rwxr-xr-xvstf/vstf/controller/reporters/reporter.py58
-rwxr-xr-xvstf/vstf/controller/res/__init__.py14
-rwxr-xr-xvstf/vstf/controller/settings/__init__.py20
-rwxr-xr-xvstf/vstf/controller/settings/cpu_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/data_settings.py31
-rwxr-xr-xvstf/vstf/controller/settings/device_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/flows_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/forwarding_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/html_settings.py14
-rwxr-xr-xvstf/vstf/controller/settings/mail_settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/perf_settings.py17
-rwxr-xr-xvstf/vstf/controller/settings/settings.py13
-rwxr-xr-xvstf/vstf/controller/settings/settings_input.py14
-rwxr-xr-xvstf/vstf/controller/settings/template_settings.py22
-rwxr-xr-xvstf/vstf/controller/settings/tester_settings.py14
-rwxr-xr-xvstf/vstf/controller/settings/tool_settings.py14
-rwxr-xr-xvstf/vstf/controller/spirent/__init__.py21
-rwxr-xr-xvstf/vstf/controller/spirent/appliance.py14
-rwxr-xr-xvstf/vstf/controller/spirent/common/__init__.py20
-rwxr-xr-xvstf/vstf/controller/spirent/common/model.py14
-rwxr-xr-xvstf/vstf/controller/spirent/common/result_analysis.py10
-rwxr-xr-xvstf/vstf/controller/sw_perf/__init__.py21
-rwxr-xr-xvstf/vstf/controller/sw_perf/flow_producer.py14
-rwxr-xr-xvstf/vstf/controller/sw_perf/model.py19
-rwxr-xr-xvstf/vstf/controller/sw_perf/perf_provider.py14
-rwxr-xr-xvstf/vstf/controller/sw_perf/performance.py49
-rwxr-xr-xvstf/vstf/controller/sw_perf/raw_data.py9
-rwxr-xr-xvstf/vstf/controller/unittest/README4
-rwxr-xr-xvstf/vstf/controller/unittest/__init__.py21
-rwxr-xr-xvstf/vstf/controller/unittest/configuration.py12
-rwxr-xr-xvstf/vstf/controller/unittest/model.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_cfg_intent_parse.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_collect.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_driver_function.py13
-rwxr-xr-xvstf/vstf/controller/unittest/test_env_build.py12
-rwxr-xr-xvstf/vstf/controller/unittest/test_perf.py14
-rwxr-xr-xvstf/vstf/controller/unittest/test_ssh.py12
-rwxr-xr-xvstf/vstf/controller/vstfadm.py22
-rwxr-xr-xvstf/vstf/rpc_frame_work/__init__.py21
-rwxr-xr-xvstf/vstf/rpc_frame_work/constant.py9
-rwxr-xr-xvstf/vstf/rpc_frame_work/rpc_consumer.py11
-rwxr-xr-xvstf/vstf/rpc_frame_work/rpc_producer.py11
158 files changed, 2482 insertions, 2235 deletions
diff --git a/vstf/README.rst b/vstf/README.rst
index 0e4e83cc..ae18790e 100755
--- a/vstf/README.rst
+++ b/vstf/README.rst
@@ -1,2 +1,2 @@
-welcome to open vstf(Virtual Switch Test Framwork
+welcome to open vstf(Virtual Switch Test Framework
)
diff --git a/vstf/__init__.py b/vstf/__init__.py
index e69de29b..83b8d15d 100755
--- a/vstf/__init__.py
+++ b/vstf/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/vstf/etc/vstf/perf/sw_perf.batch-settings b/vstf/etc/vstf/perf/sw_perf.batch-settings
index 7926877d..83c6970d 100755
--- a/vstf/etc/vstf/perf/sw_perf.batch-settings
+++ b/vstf/etc/vstf/perf/sw_perf.batch-settings
@@ -4,7 +4,6 @@
"case": "Tn-1",
"tool": "netperf",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -12,7 +11,6 @@
"case": "Tn-2",
"tool": "pktgen",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
}
@@ -22,7 +20,6 @@
"case": "Ti-1",
"tool": "netperf",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -30,7 +27,6 @@
"case": "Ti-2",
"tool": "pktgen",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -38,7 +34,6 @@
"case": "Ti-3",
"tool": "pktgen",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
}
@@ -48,7 +43,6 @@
"case": "Tnv-1",
"tool": "netmap",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -56,7 +50,6 @@
"case": "Tnv-2",
"tool": "netperf",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
}
@@ -66,7 +59,6 @@
"case": "Tu-1",
"tool": "netperf",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -74,7 +66,6 @@
"case": "Tu-2",
"tool": "pktgen",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
},
@@ -82,7 +73,6 @@
"case": "Tu-3",
"tool": "netperf",
"protocol": "udp",
- "profile": "rdp",
"type": "frameloss",
"sizes": [64, 128, 512, 1024]
}
diff --git a/vstf/etc/vstf/perf/sw_perf.device-settings b/vstf/etc/vstf/perf/sw_perf.device-settings
index a91340bd..e0dac25a 100755
--- a/vstf/etc/vstf/perf/sw_perf.device-settings
+++ b/vstf/etc/vstf/perf/sw_perf.device-settings
@@ -28,7 +28,7 @@
]
},
"vm-200":{
- "agent": "192.168.188.200",
+ "agent": "192.168.188.185",
"devs": [
{
"mac": "56:6f:44:a5:3f:a2"
@@ -39,7 +39,7 @@
]
},
"vm-201":{
- "agent": "192.168.188.201",
+ "agent": "192.168.188.186",
"devs": [
{
"mac": "56:6f:44:a5:3f:a4"
diff --git a/vstf/etc/vstf/reporter/reporter.pdf.story-show b/vstf/etc/vstf/reporter/reporter.pdf.story-show
deleted file mode 100755
index 514a0cc2..00000000
--- a/vstf/etc/vstf/reporter/reporter.pdf.story-show
+++ /dev/null
@@ -1,32 +0,0 @@
-[
- {
- "cover":{
- "title":[],
- "logo":[],
- "header": [],
- "footer": [],
- "note": [],
- }
- },
- {
- "chapter":
- {
- "title":[],
- "type":[],
- "content":[
- "paragraph":{
- "type": [],
- "content":[]
- }
- "section"
-
-
- }
-
-
- }
-
- }
-
-
-] \ No newline at end of file
diff --git a/vstf/etc/vstf/reporter/reporters.html.data-settings b/vstf/etc/vstf/reporter/reporters.html.data-settings
deleted file mode 100755
index 5c4e32b0..00000000
--- a/vstf/etc/vstf/reporter/reporters.html.data-settings
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "ovs":{
- "content":{
- "version":3.0
- },
- "title":"Ovs info"
- },
- "result":{
- "content":{},
- "title":"Performance Result"
- },
- "subject":"ATF Performance Test"
-}
diff --git a/vstf/etc/vstf/reporter/reporters.template-settings b/vstf/etc/vstf/reporter/reporters.template-settings
new file mode 100755
index 00000000..f0e4a29e
--- /dev/null
+++ b/vstf/etc/vstf/reporter/reporters.template-settings
@@ -0,0 +1,36 @@
+{
+ "theme":{
+ "style": "default",
+ "title": ["Virtual Switch Test Framework Report", "Scenario Tn"],
+ "logo": ["/root/workspace/esp-atf-2/vstf/controller/res/logo.jpg"],
+ "header": [""],
+ "footer": [""],
+ "note": [""]
+ },
+ "contents":{
+ "enable": true
+ },
+ "context":{
+ "01##chapter#1": {
+ "01##title#1": ["System Environment"],
+ "02##table#1": None
+ },
+ "02##chapter#2": {
+ "01##title#1": ["Scenario Result"],
+ "02##section#1": {
+ "01##title#2": ["Case: Tn-1"],
+ "02##paragraph#2": ["Parameter"],
+ "03##paragraph#2": ["test tool: pktgen", "vswitch: ovs", "protocol: udp", "type: frameloss" ],
+ "04##paragraph#2": ["Result"],
+ "05##table#1":[
+ ["FrameSize (bytes)", "Bandwidth(Mpps)", "Load(%)", "CPU Usage(%)", "Mpps/Ghz"],
+ ["64", "", "", "", "", ""]
+ ],
+ "06##plot#1":[
+ ["64", "", "", "", "", ""]
+ ]
+ }
+ }
+
+ }
+}
diff --git a/vstf/install.sh b/vstf/install.sh
index 2aae6f5d..10a46f4c 100755
--- a/vstf/install.sh
+++ b/vstf/install.sh
@@ -30,7 +30,11 @@ if [ $1 == "manager" ]; then
then
vstf-manager start
else
- vstf-manager start --monitor ${SERVER} --port ${PORT}
+ if [ "${PORT}x" == "x" ]; then
+ vstf-manager start --monitor ${SERVER}
+ else
+ vstf-manager start --monitor ${SERVER} --port ${PORT}
+ fi
fi
elif [ $1 == "agent" ];then
vstf-manager stop
diff --git a/vstf/pylint.conf b/vstf/pylint.conf
index 6514d3c6..6514d3c6 100644..100755
--- a/vstf/pylint.conf
+++ b/vstf/pylint.conf
diff --git a/vstf/setup.cfg b/vstf/setup.cfg
index 4dce3985..662f75f4 100755
--- a/vstf/setup.cfg
+++ b/vstf/setup.cfg
@@ -25,8 +25,6 @@ data_files =
etc/vstf/=
etc/vstf/amqp=
etc/vstf/amqp/amqp.ini
- etc/vstf/driver=
- etc/vstf/driver/drivertest.conf
[global]
setup-hooks =
pbr.hooks.setup_hook
diff --git a/vstf/setup.py b/vstf/setup.py
index 73637574..bdecb375 100644..100755
--- a/vstf/setup.py
+++ b/vstf/setup.py
@@ -1,18 +1,11 @@
-#!/usr/bin/env python
-# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# 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
+##############################################################################
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
diff --git a/vstf/vstf/__init__.py b/vstf/vstf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/__init__.py
+++ b/vstf/vstf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/agent/__init__.py b/vstf/vstf/agent/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/agent/__init__.py
+++ b/vstf/vstf/agent/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/agent/agent.py b/vstf/vstf/agent/agent.py
index 396b571e..b5745995 100755
--- a/vstf/vstf/agent/agent.py
+++ b/vstf/vstf/agent/agent.py
@@ -1,5 +1,15 @@
-#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+# !/usr/bin/env python
# coding=utf-8
+
import logging
import argparse
import signal
@@ -61,11 +71,11 @@ class Client(daemon.Daemon):
def loop_thread(self):
LOG.info("Try to create direct proxy...")
self.proxy = rpc_consumer.VstfConsumer(self.agent,
- self.config.rabbit.user,
- self.config.rabbit.passwd,
- self.config.rabbit.host,
- self.config.rabbit.port,
- self.config.rabbit.id)
+ self.config.rabbit.user,
+ self.config.rabbit.passwd,
+ self.config.rabbit.host,
+ self.config.rabbit.port,
+ self.config.rabbit.id)
self.proxy.run()
def run(self):
diff --git a/vstf/vstf/agent/env/__init__.py b/vstf/vstf/agent/env/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/agent/env/__init__.py
+++ b/vstf/vstf/agent/env/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/agent/env/basic/__init__.py b/vstf/vstf/agent/env/basic/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/agent/env/basic/__init__.py
+++ b/vstf/vstf/agent/env/basic/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/agent/env/basic/collect.py b/vstf/vstf/agent/env/basic/collect.py
index bc4f1ee4..126a7d55 100755
--- a/vstf/vstf/agent/env/basic/collect.py
+++ b/vstf/vstf/agent/env/basic/collect.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 os
import platform
import logging
diff --git a/vstf/vstf/agent/env/basic/commandline.py b/vstf/vstf/agent/env/basic/commandline.py
index 0df037d8..e4df9b27 100755
--- a/vstf/vstf/agent/env/basic/commandline.py
+++ b/vstf/vstf/agent/env/basic/commandline.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 subprocess
import threading
import logging
diff --git a/vstf/vstf/agent/env/basic/device_manager.py b/vstf/vstf/agent/env/basic/device_manager.py
index 3209d7c9..8b5387fe 100755
--- a/vstf/vstf/agent/env/basic/device_manager.py
+++ b/vstf/vstf/agent/env/basic/device_manager.py
@@ -1,8 +1,11 @@
-"""
-Created on 2015-9-25
-
-@author: y00228926
-"""
+##############################################################################
+# Copyright (c) 2015 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 re
import logging
diff --git a/vstf/vstf/agent/env/basic/image_manager.py b/vstf/vstf/agent/env/basic/image_manager.py
index 6c7df709..c3b5c6b3 100755
--- a/vstf/vstf/agent/env/basic/image_manager.py
+++ b/vstf/vstf/agent/env/basic/image_manager.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-7-28
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from vstf.common.utils import check_call
import os
import logging
diff --git a/vstf/vstf/agent/env/basic/source_manager.py b/vstf/vstf/agent/env/basic/source_manager.py
index 4267cbd2..6edd14ca 100755
--- a/vstf/vstf/agent/env/basic/source_manager.py
+++ b/vstf/vstf/agent/env/basic/source_manager.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import os
import logging
import contextlib
diff --git a/vstf/vstf/agent/env/basic/vm9pfs.py b/vstf/vstf/agent/env/basic/vm9pfs.py
index f3a2c2ce..7364f8b2 100755
--- a/vstf/vstf/agent/env/basic/vm9pfs.py
+++ b/vstf/vstf/agent/env/basic/vm9pfs.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import os
import logging
import textwrap
diff --git a/vstf/vstf/agent/env/basic/vm_manager.py b/vstf/vstf/agent/env/basic/vm_manager.py
index e59d6c71..60a3b37b 100755
--- a/vstf/vstf/agent/env/basic/vm_manager.py
+++ b/vstf/vstf/agent/env/basic/vm_manager.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import os
import shutil
import logging
diff --git a/vstf/vstf/agent/env/basic/vm_xml_help.py b/vstf/vstf/agent/env/basic/vm_xml_help.py
index d3116259..6f9131e7 100755
--- a/vstf/vstf/agent/env/basic/vm_xml_help.py
+++ b/vstf/vstf/agent/env/basic/vm_xml_help.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-7-2
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
xml_head = '''
<domain type='kvm'>
<name>VM_NAME</name>
diff --git a/vstf/vstf/agent/env/builder.py b/vstf/vstf/agent/env/builder.py
index ebd3d3d7..a66a8873 100755
--- a/vstf/vstf/agent/env/builder.py
+++ b/vstf/vstf/agent/env/builder.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-7-8
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import logging
import stevedore
diff --git a/vstf/vstf/agent/env/driver_plugins/__init__.py b/vstf/vstf/agent/env/driver_plugins/__init__.py
index e69de29b..fc9802be 100755
--- a/vstf/vstf/agent/env/driver_plugins/__init__.py
+++ b/vstf/vstf/agent/env/driver_plugins/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+############################################################################## \ No newline at end of file
diff --git a/vstf/vstf/agent/env/driver_plugins/manager.py b/vstf/vstf/agent/env/driver_plugins/manager.py
index 3bb3fadd..6f895656 100755
--- a/vstf/vstf/agent/env/driver_plugins/manager.py
+++ b/vstf/vstf/agent/env/driver_plugins/manager.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-15
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import stevedore
diff --git a/vstf/vstf/agent/env/driver_plugins/model.py b/vstf/vstf/agent/env/driver_plugins/model.py
index 3a0b1845..ddc07449 100755
--- a/vstf/vstf/agent/env/driver_plugins/model.py
+++ b/vstf/vstf/agent/env/driver_plugins/model.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-15
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from abc import ABCMeta
from abc import abstractmethod
diff --git a/vstf/vstf/agent/env/driver_plugins/origin_driver.py b/vstf/vstf/agent/env/driver_plugins/origin_driver.py
index 850d7851..bf3c15c8 100755
--- a/vstf/vstf/agent/env/driver_plugins/origin_driver.py
+++ b/vstf/vstf/agent/env/driver_plugins/origin_driver.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-12
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from vstf.agent.env.driver_plugins import model
from vstf.common.utils import check_and_rmmod, check_call
diff --git a/vstf/vstf/agent/env/fsmonitor/FSMonitor.py b/vstf/vstf/agent/env/fsmonitor/FSMonitor.py
index 71029705..e6559362 100755
--- a/vstf/vstf/agent/env/fsmonitor/FSMonitor.py
+++ b/vstf/vstf/agent/env/fsmonitor/FSMonitor.py
@@ -1,8 +1,13 @@
-"""
-Created on 2015-7-13
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
-@author: y00228926
-"""
import os
import time
import logging
diff --git a/vstf/vstf/agent/env/fsmonitor/__init__.py b/vstf/vstf/agent/env/fsmonitor/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/agent/env/fsmonitor/__init__.py
+++ b/vstf/vstf/agent/env/fsmonitor/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/agent/env/fsmonitor/constant.py b/vstf/vstf/agent/env/fsmonitor/constant.py
index d30bb439..33b37eb4 100755
--- a/vstf/vstf/agent/env/fsmonitor/constant.py
+++ b/vstf/vstf/agent/env/fsmonitor/constant.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
VM_UP_Flag_FILE = 'up'
VM_CMD_DONE_FLAG_FILE = 'command_done'
VM_CMD_RESULT_FILE = 'command_result_data'
diff --git a/vstf/vstf/agent/env/fsmonitor/utils.py b/vstf/vstf/agent/env/fsmonitor/utils.py
index e6eb1536..5bdb4159 100755
--- a/vstf/vstf/agent/env/fsmonitor/utils.py
+++ b/vstf/vstf/agent/env/fsmonitor/utils.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-7-8
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import subprocess
from StringIO import StringIO
import re
diff --git a/vstf/vstf/agent/env/plugins/__init__.py b/vstf/vstf/agent/env/plugins/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/agent/env/plugins/__init__.py
+++ b/vstf/vstf/agent/env/plugins/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/agent/env/plugins/libvirt_plugin.py b/vstf/vstf/agent/env/plugins/libvirt_plugin.py
index e7fefb6f..27af8063 100755
--- a/vstf/vstf/agent/env/plugins/libvirt_plugin.py
+++ b/vstf/vstf/agent/env/plugins/libvirt_plugin.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-7-8
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import logging
from vstf.common.utils import ping, my_sleep
diff --git a/vstf/vstf/agent/env/plugins/model.py b/vstf/vstf/agent/env/plugins/model.py
index 5485f970..b19ceb96 100755
--- a/vstf/vstf/agent/env/plugins/model.py
+++ b/vstf/vstf/agent/env/plugins/model.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-15
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from abc import ABCMeta
from abc import abstractmethod
diff --git a/vstf/vstf/agent/env/plugins/tester_env_plugin.py b/vstf/vstf/agent/env/plugins/tester_env_plugin.py
index 0fd4b9a2..0682aac8 100755
--- a/vstf/vstf/agent/env/plugins/tester_env_plugin.py
+++ b/vstf/vstf/agent/env/plugins/tester_env_plugin.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/17
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/agent/env/vswitch_plugins/__init__.py b/vstf/vstf/agent/env/vswitch_plugins/__init__.py
index e69de29b..83b8d15d 100755
--- a/vstf/vstf/agent/env/vswitch_plugins/__init__.py
+++ b/vstf/vstf/agent/env/vswitch_plugins/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
diff --git a/vstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py b/vstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py
index 252f190d..21b8f82c 100755
--- a/vstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py
+++ b/vstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-12
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from vstf.agent.env.vswitch_plugins import model
from vstf.common.utils import check_call, get_eth_by_bdf, check_output
diff --git a/vstf/vstf/agent/env/vswitch_plugins/manager.py b/vstf/vstf/agent/env/vswitch_plugins/manager.py
index 00115dfd..785a1db8 100755
--- a/vstf/vstf/agent/env/vswitch_plugins/manager.py
+++ b/vstf/vstf/agent/env/vswitch_plugins/manager.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-15
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import stevedore
diff --git a/vstf/vstf/agent/env/vswitch_plugins/model.py b/vstf/vstf/agent/env/vswitch_plugins/model.py
index a4d8b3b5..5d700411 100755
--- a/vstf/vstf/agent/env/vswitch_plugins/model.py
+++ b/vstf/vstf/agent/env/vswitch_plugins/model.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-15
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
from abc import ABCMeta
from abc import abstractmethod
diff --git a/vstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py b/vstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py
index 46045950..7ea56d4a 100755
--- a/vstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py
+++ b/vstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-10
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import os
import shutil
import logging
diff --git a/vstf/vstf/agent/equalizer/__init__.py b/vstf/vstf/agent/equalizer/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/agent/equalizer/__init__.py
+++ b/vstf/vstf/agent/equalizer/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/agent/equalizer/equalizer.py b/vstf/vstf/agent/equalizer/equalizer.py
index 8db35df9..30e1de1f 100755
--- a/vstf/vstf/agent/equalizer/equalizer.py
+++ b/vstf/vstf/agent/equalizer/equalizer.py
@@ -1,5 +1,12 @@
-#!/usr/bin/env python
-# coding=utf-8
+##############################################################################
+# Copyright (c) 2015 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 os
import re
import subprocess
diff --git a/vstf/vstf/agent/equalizer/get_info.py b/vstf/vstf/agent/equalizer/get_info.py
index 873f0caf..0c92f979 100755
--- a/vstf/vstf/agent/equalizer/get_info.py
+++ b/vstf/vstf/agent/equalizer/get_info.py
@@ -1,4 +1,12 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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 commands
try:
diff --git a/vstf/vstf/agent/equalizer/optimize.py b/vstf/vstf/agent/equalizer/optimize.py
index 941769a3..5a09900d 100755
--- a/vstf/vstf/agent/equalizer/optimize.py
+++ b/vstf/vstf/agent/equalizer/optimize.py
@@ -1,4 +1,12 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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 commands
import re
diff --git a/vstf/vstf/agent/perf/__init__.py b/vstf/vstf/agent/perf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/agent/perf/__init__.py
+++ b/vstf/vstf/agent/perf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/agent/perf/affctl.py b/vstf/vstf/agent/perf/affctl.py
index e9b96924..5b203632 100755
--- a/vstf/vstf/agent/perf/affctl.py
+++ b/vstf/vstf/agent/perf/affctl.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/26
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
from vstf.common.utils import check_call, call, check_output
diff --git a/vstf/vstf/agent/perf/ethtool.py b/vstf/vstf/agent/perf/ethtool.py
index c214a568..3f4a3728 100755
--- a/vstf/vstf/agent/perf/ethtool.py
+++ b/vstf/vstf/agent/perf/ethtool.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/12
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 vstf.common.utils as utils
diff --git a/vstf/vstf/agent/perf/iperf.py b/vstf/vstf/agent/perf/iperf.py
index 25728b7e..3105be4b 100755
--- a/vstf/vstf/agent/perf/iperf.py
+++ b/vstf/vstf/agent/perf/iperf.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date: 2015-09-15
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 subprocess
import signal
diff --git a/vstf/vstf/agent/perf/netmap.py b/vstf/vstf/agent/perf/netmap.py
index c61d2577..88a25444 100755
--- a/vstf/vstf/agent/perf/netmap.py
+++ b/vstf/vstf/agent/perf/netmap.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-11-09
-# see license for license details
-
+##############################################################################
+# Copyright (c) 2015 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 time
import subprocess
diff --git a/vstf/vstf/agent/perf/netns.py b/vstf/vstf/agent/perf/netns.py
index d5552fa2..c3b73860 100755
--- a/vstf/vstf/agent/perf/netns.py
+++ b/vstf/vstf/agent/perf/netns.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-6
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import logging
from vstf.common.utils import IPCommandHelper
from vstf.agent.perf import ethtool
diff --git a/vstf/vstf/agent/perf/netperf.py b/vstf/vstf/agent/perf/netperf.py
index fab1fc11..99f1c904 100755
--- a/vstf/vstf/agent/perf/netperf.py
+++ b/vstf/vstf/agent/perf/netperf.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date: 2015-09-15
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 time
import subprocess
import vstf.common.constants as cst
diff --git a/vstf/vstf/agent/perf/pktgen.py b/vstf/vstf/agent/perf/pktgen.py
index 58c0e6c8..671e1aa7 100755
--- a/vstf/vstf/agent/perf/pktgen.py
+++ b/vstf/vstf/agent/perf/pktgen.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date: 2015-09-15
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 subprocess
import time
import logging
diff --git a/vstf/vstf/agent/perf/qperf.py b/vstf/vstf/agent/perf/qperf.py
index 3cb9eafd..f84f9c24 100755
--- a/vstf/vstf/agent/perf/qperf.py
+++ b/vstf/vstf/agent/perf/qperf.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date: 2015-09-15
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 subprocess
import time
diff --git a/vstf/vstf/agent/perf/sar.py b/vstf/vstf/agent/perf/sar.py
index c4688c9c..0231d5c1 100755
--- a/vstf/vstf/agent/perf/sar.py
+++ b/vstf/vstf/agent/perf/sar.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-6
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import subprocess
import logging
import time
diff --git a/vstf/vstf/agent/perf/utils.py b/vstf/vstf/agent/perf/utils.py
index 1fb4b92c..4f7ddb6a 100755
--- a/vstf/vstf/agent/perf/utils.py
+++ b/vstf/vstf/agent/perf/utils.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-6
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import logging
import subprocess
from vstf.common.utils import check_call, check_output
diff --git a/vstf/vstf/agent/perf/vnstat.py b/vstf/vstf/agent/perf/vnstat.py
index 7a47af14..b12ac1af 100755
--- a/vstf/vstf/agent/perf/vnstat.py
+++ b/vstf/vstf/agent/perf/vnstat.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-6
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import subprocess
import time
import re
diff --git a/vstf/vstf/agent/perf/vstfperf.py b/vstf/vstf/agent/perf/vstfperf.py
index 224380fe..8be3c4e5 100755
--- a/vstf/vstf/agent/perf/vstfperf.py
+++ b/vstf/vstf/agent/perf/vstfperf.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-08
-# see license for license details
-
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
__doc__ = """
operation: [start, stop, restart]
diff --git a/vstf/vstf/agent/softagent.py b/vstf/vstf/agent/softagent.py
index 6f97239d..6271a097 100755
--- a/vstf/vstf/agent/softagent.py
+++ b/vstf/vstf/agent/softagent.py
@@ -1,3 +1,13 @@
+##############################################################################
+# Copyright (c) 2015 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 logging
import time
from vstf.agent.env.basic.image_manager import ImageManager
diff --git a/vstf/vstf/agent/spirent/__init__.py b/vstf/vstf/agent/spirent/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/agent/spirent/__init__.py
+++ b/vstf/vstf/agent/spirent/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/agent/spirent/spirent.py b/vstf/vstf/agent/spirent/spirent.py
index 3b073cbf..904de736 100755
--- a/vstf/vstf/agent/spirent/spirent.py
+++ b/vstf/vstf/agent/spirent/spirent.py
@@ -1,4 +1,13 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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 Tkinter
@@ -17,7 +26,7 @@ class stcPython():
self.stcpkg = '/home/Spirent_TestCenter_4.46/Spirent_TestCenter_Application_Linux'
self.tclsh.eval("set auto_path [ linsert $auto_path 0 %s ]" %(self.stcpkg))
self.tclsh.eval("package require SpirentTestCenter")
-
+
def build_cmd(self, *args):
cmd = ''
for arg in args:
@@ -107,7 +116,7 @@ class stcPython():
#pdb.set_trace()
cmd = port_name+' -location //'+chassisAddress+'/'+slot+'/'+port+' -UseDefaultHost False'
return self.stc_config(cmd)
- # create streamblock under port
+ # create streamblock under port
# return: streamblock name
def stc_create_streamblock(self,port_name,vlan_tag,ExpectedRxPort,srcMac,dstMac,sourceAddr,destAddr):
#import pdb
diff --git a/vstf/vstf/agent/spirentagent.py b/vstf/vstf/agent/spirentagent.py
index 04a9dc90..8951f96d 100755
--- a/vstf/vstf/agent/spirentagent.py
+++ b/vstf/vstf/agent/spirentagent.py
@@ -1,3 +1,13 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+
from vstf.agent.spirent.tools import Spirent_Tools as Spirent
diff --git a/vstf/vstf/common/__init__.py b/vstf/vstf/common/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/common/__init__.py
+++ b/vstf/vstf/common/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/common/candy_text.py b/vstf/vstf/common/candy_text.py
new file mode 100755
index 00000000..818ae767
--- /dev/null
+++ b/vstf/vstf/common/candy_text.py
@@ -0,0 +1,61 @@
+##############################################################################
+# Copyright (c) 2015 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 sys
+
+THIS = sys.modules[__name__]
+__id_max = 100
+__style_max = 10
+dom = {"chapter", "section", "unit"}
+element = {"title", "table", "figure", "paragraph", "plot", "chart", "space"}
+
+nodes = dom | element
+for _node in nodes:
+ setattr(THIS, _node, _node)
+
+
+def tuple2text(sn, node, style):
+ assert sn in range(__id_max)
+ assert style in range(__style_max)
+ assert node in nodes
+ return "%02d##%s#%d" % (sn, node, style)
+
+
+def dict2text(info):
+ assert "sn" in info and info["sn"] in range(__id_max)
+ assert "style" in info and info["style"] in range(__style_max)
+ assert "node" in info and info["node"] in nodes
+ return "%02d##%s#%d" % (info["sn"], info["node"], info["style"])
+
+
+def text2dict(candy):
+ tmp = candy.replace("##","#").split("#")
+ result = {
+ "sn": int(tmp[0]),
+ "node": tmp[1],
+ "style": int(tmp[2])
+ }
+ assert result["sn"] in range(__id_max)
+ assert result["style"] in range(__style_max)
+ assert result["node"] in nodes
+ return result
+
+
+def text2tuple(candy):
+ tmp = candy.replace("##","#").split("#")
+
+ sn = int(tmp[0])
+ node = tmp[1]
+ style = int(tmp[2])
+
+ assert sn in range(__id_max)
+ assert style in range(__style_max)
+ assert node in nodes
+ return sn, node, style
diff --git a/vstf/vstf/common/cfgparser.py b/vstf/vstf/common/cfgparser.py
index 3d50a1b1..9de5a2cd 100755
--- a/vstf/vstf/common/cfgparser.py
+++ b/vstf/vstf/common/cfgparser.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-5
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: c00225995
-"""
import os
from oslo.config import cfg
diff --git a/vstf/vstf/common/check.py b/vstf/vstf/common/check.py
index 9b2f3d04..2ceddc04 100755
--- a/vstf/vstf/common/check.py
+++ b/vstf/vstf/common/check.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-11-5
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
import vstf.common.constants as cst
diff --git a/vstf/vstf/common/cliutil.py b/vstf/vstf/common/cliutil.py
index 91ff7f18..541bba7b 100755
--- a/vstf/vstf/common/cliutil.py
+++ b/vstf/vstf/common/cliutil.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
def arg(*args, **kwargs):
"""Decorator for CLI args.
diff --git a/vstf/vstf/common/cmds.py b/vstf/vstf/common/cmds.py
index c30f2be6..2952be2c 100755
--- a/vstf/vstf/common/cmds.py
+++ b/vstf/vstf/common/cmds.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 commands
import logging
diff --git a/vstf/vstf/common/constants.py b/vstf/vstf/common/constants.py
index 1cace390..e054043e 100755
--- a/vstf/vstf/common/constants.py
+++ b/vstf/vstf/common/constants.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
slave_project_path = "/opt/esp-atf"
VSTFCPATH = "/opt/vstf"
sockaddr = VSTFCPATH + "/vstf.socket"
@@ -23,7 +32,7 @@ OPERATIONS = ["start", "stop", "restart"]
ACTIONS = ["send", "receive"]
PROTOCOLS = ["tcp_lat", "udp_lat", "tcp_bw", "udp_bw"]
TPROTOCOLS = ["tcp", "udp"]
-PROFILES = ["rdp", "fastlink", "l2switch"]
+PROVIDERS = ["rdp", "fastlink", "l2switch", None]
TTYPES = ["throughput", "latency", "frameloss"]
SCENARIOS = ["Ti", "Tn", "Tnv", "Tu"]
SOCKET_BUF = 102400
@@ -33,7 +42,8 @@ PKTLOSS_ROUND = 2
RATEP_ROUND = 3
TIME_ROUND = 3
TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
-TIME_STR = "%Y%m%d_%H%M%S"
+TIME_FORMAT2 = "%Y/%m/%d %H:%M:%S"
+TIME_FORMAT3 = "%Y%m%d_%H%M%S"
REPORT_DEFAULTS = "/tmp"
CASE_ACTOR_MAP = {
diff --git a/vstf/vstf/common/daemon.py b/vstf/vstf/common/daemon.py
index 8a298614..1085d36c 100755
--- a/vstf/vstf/common/daemon.py
+++ b/vstf/vstf/common/daemon.py
@@ -1,4 +1,12 @@
-#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2015 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 sys, os, time, atexit
import logging
from signal import SIGTERM
diff --git a/vstf/vstf/common/decorator.py b/vstf/vstf/common/decorator.py
index cafbb3ff..98d539f1 100755
--- a/vstf/vstf/common/decorator.py
+++ b/vstf/vstf/common/decorator.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-09
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
_DEFAULTS = "vstf check key defaults".encode()
diff --git a/vstf/vstf/common/excepts.py b/vstf/vstf/common/excepts.py
index dc781b9e..833eefa4 100755
--- a/vstf/vstf/common/excepts.py
+++ b/vstf/vstf/common/excepts.py
@@ -1,3 +1,13 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+
class ChannelDie(Exception):
"""rabbitmq's channel connect failed"""
pass
diff --git a/vstf/vstf/common/input.py b/vstf/vstf/common/input.py
index 9e2f9333..4f1532e6 100755
--- a/vstf/vstf/common/input.py
+++ b/vstf/vstf/common/input.py
@@ -1,7 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# date: 2015-09-09
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
__author__ = 'wly'
__version__ = '0.1'
diff --git a/vstf/vstf/common/log.py b/vstf/vstf/common/log.py
index b34a8a92..415b003a 100755
--- a/vstf/vstf/common/log.py
+++ b/vstf/vstf/common/log.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/common/message.py b/vstf/vstf/common/message.py
index 926091fb..d496990d 100755
--- a/vstf/vstf/common/message.py
+++ b/vstf/vstf/common/message.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 uuid
import logging
diff --git a/vstf/vstf/common/perfmark.py b/vstf/vstf/common/perfmark.py
index f03ee532..5edfe3a4 100755
--- a/vstf/vstf/common/perfmark.py
+++ b/vstf/vstf/common/perfmark.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
pktSize = 'AvgFrameSize'
offLoad = 'OfferedLoad'
percentLoss = 'PercentLoss'
diff --git a/vstf/vstf/common/pyhtml.py b/vstf/vstf/common/pyhtml.py
index c2a26208..f3adee8d 100755
--- a/vstf/vstf/common/pyhtml.py
+++ b/vstf/vstf/common/pyhtml.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
from sys import stdout, modules
@@ -30,11 +34,15 @@ html5_tags = {'article', 'aside', 'audio', 'bdi', 'canvas', 'command', 'datalist
nl = '\n'
tags = html4_tags | disused_tags | html5_tags
-__all__ = [x.title() for x in tags] + ['PyHtml']
+__all__ = [x.title() for x in tags] + ['PyHtml', 'space']
self_close = {'input', 'img', 'link', 'br'}
+def space(n):
+ return ' ' * n
+
+
class Tag(list):
tag_name = ''
diff --git a/vstf/vstf/common/rsync.py b/vstf/vstf/common/rsync.py
index b566136f..2209dfd3 100755
--- a/vstf/vstf/common/rsync.py
+++ b/vstf/vstf/common/rsync.py
@@ -1,378 +1,385 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-# Python conterpart of rsync written by Vivian De Smedt
-# Send any comment or bug report to vivian@vdesmedt.com.
-# I would like to thanks William Tan for its support in tuning rsync.py to support unicode path.
-# I would like to thanks Luc Saffre for its bug reports and fixes.
-#from __future__ import nested_scopes
+# from __future__ import nested_scopes
import os, os.path, shutil, glob, re, sys, getopt, stat, string
-
try:
- import win32file
+ import win32file
except:
- win32file = None
+ win32file = None
+
class Cookie:
- def __init__(self):
- self.sink_root = ""
- self.target_root = ""
- self.quiet = 0
- self.recursive = 0
- self.relative = 0
- self.dry_run = 0
- self.time = 0
- self.update = 0
- self.cvs_ignore = 0
- self.ignore_time = 0
- self.delete = 0
- self.delete_excluded = 0
- self.delete_from_source = 0
- self.size_only = 0
- self.modify_window = 2
- self.existing = 0
- self.filters = []
- self.case_sensitivity = 0
- if os.name == "nt":
- self.case_sensitivity = re.I
+ def __init__(self):
+ self.sink_root = ""
+ self.target_root = ""
+ self.quiet = 0
+ self.recursive = 0
+ self.relative = 0
+ self.dry_run = 0
+ self.time = 0
+ self.update = 0
+ self.cvs_ignore = 0
+ self.ignore_time = 0
+ self.delete = 0
+ self.delete_excluded = 0
+ self.delete_from_source = 0
+ self.size_only = 0
+ self.modify_window = 2
+ self.existing = 0
+ self.filters = []
+ self.case_sensitivity = 0
+ if os.name == "nt":
+ self.case_sensitivity = re.I
+
def visit(cookie, dirname, names):
- """Copy files names from sink_root + (dirname - sink_root) to target_root + (dirname - sink_root)"""
- if os.path.split(cookie.sink_root)[1]: # Should be tested with (C:\Cvs -> C:\)! (C:\Archives\MyDatas\UltraEdit -> C:\Archives\MyDatas) (Cvs -> "")! (Archives\MyDatas\UltraEdit -> Archives\MyDatas) (\Cvs -> \)! (\Archives\MyDatas\UltraEdit -> Archives\MyDatas)
- dirname = dirname[len(cookie.sink_root) + 1:]
- else:
- dirname = dirname[len(cookie.sink_root):]
- target_dir = os.path.join(cookie.target_root, dirname)
- if not os.path.isdir(target_dir):
- makeDir(cookie, target_dir)
- sink_dir = os.path.join(cookie.sink_root, dirname)
-
- filters = []
- if cookie.cvs_ignore:
- ignore = os.path.join(sink_dir, ".cvsignore")
- if os.path.isfile(ignore):
- filters = convertPatterns(ignore, "-")
- filters = filters + cookie.filters
-
- names_excluded = []
- if filters:
- # filter sink files (names):
- name_index = 0
- while name_index < len(names):
- name = names[name_index]
- path = os.path.join(dirname, name)
- path = convertPath(path)
- if os.path.isdir(os.path.join(sink_dir, name)):
- path = path + "/"
- for filter in filters:
- if re.search(filter[1], path, cookie.case_sensitivity):
- if filter[0] == '-':
- sink = os.path.join(sink_dir, name)
- if cookie.delete_from_source:
- if os.path.isfile(sink):
- removeFile(cookie, sink)
- elif os.path.isdir(sink):
- removeDir(cookie, sink)
- else:
- logError("Sink %s is neither a file nor a folder (skip removal)" % sink)
- names_excluded += [names[name_index]]
- del(names[name_index])
- name_index = name_index - 1
- break
- elif filter[0] == '+':
- break
- name_index = name_index + 1
-
- if cookie.delete and os.path.isdir(target_dir):
- # Delete files and folder in target not present in filtered sink.
- for name in os.listdir(target_dir):
- if not cookie.delete_excluded and name in names_excluded:
- continue
- if not name in names:
- target = os.path.join(target_dir, name)
- if os.path.isfile(target):
- removeFile(cookie, target)
- elif os.path.isdir(target):
- removeDir(cookie, target)
- else:
- pass
-
- for name in names:
- # Copy files and folder from sink to target.
- sink = os.path.join(sink_dir, name)
- #print sink
- target = os.path.join(target_dir, name)
- if os.path.exists(target):
- # When target already exit:
- if os.path.isfile(sink):
- if os.path.isfile(target):
- # file-file
- if shouldUpdate(cookie, sink, target):
- updateFile(cookie, sink, target)
- elif os.path.isdir(target):
- # file-folder
- removeDir(cookie, target)
- copyFile(cookie, sink, target)
- else:
- # file-???
- logError("Target %s is neither a file nor folder (skip update)" % sink)
-
- elif os.path.isdir(sink):
- if os.path.isfile(target):
- # folder-file
- removeFile(cookie, target)
- makeDir(cookie, target)
- else:
- # ???-xxx
- logError("Sink %s is neither a file nor a folder (skip update)" % sink)
-
- elif not cookie.existing:
- # When target dont exist:
- if os.path.isfile(sink):
- # file
- copyFile(cookie, sink, target)
- elif os.path.isdir(sink):
- # folder
- makeDir(cookie, target)
- else:
- logError("Sink %s is neither a file nor a folder (skip update)" % sink)
+ """Copy files names from sink_root + (dirname - sink_root) to target_root + (dirname - sink_root)"""
+ if os.path.split(cookie.sink_root)[
+ 1]: # Should be tested with (C:\Cvs -> C:\)! (C:\Archives\MyDatas\UltraEdit -> C:\Archives\MyDatas) (Cvs -> "")! (Archives\MyDatas\UltraEdit -> Archives\MyDatas) (\Cvs -> \)! (\Archives\MyDatas\UltraEdit -> Archives\MyDatas)
+ dirname = dirname[len(cookie.sink_root) + 1:]
+ else:
+ dirname = dirname[len(cookie.sink_root):]
+ target_dir = os.path.join(cookie.target_root, dirname)
+ if not os.path.isdir(target_dir):
+ makeDir(cookie, target_dir)
+ sink_dir = os.path.join(cookie.sink_root, dirname)
+
+ filters = []
+ if cookie.cvs_ignore:
+ ignore = os.path.join(sink_dir, ".cvsignore")
+ if os.path.isfile(ignore):
+ filters = convertPatterns(ignore, "-")
+ filters = filters + cookie.filters
+
+ names_excluded = []
+ if filters:
+ # filter sink files (names):
+ name_index = 0
+ while name_index < len(names):
+ name = names[name_index]
+ path = os.path.join(dirname, name)
+ path = convertPath(path)
+ if os.path.isdir(os.path.join(sink_dir, name)):
+ path = path + "/"
+ for filter in filters:
+ if re.search(filter[1], path, cookie.case_sensitivity):
+ if filter[0] == '-':
+ sink = os.path.join(sink_dir, name)
+ if cookie.delete_from_source:
+ if os.path.isfile(sink):
+ removeFile(cookie, sink)
+ elif os.path.isdir(sink):
+ removeDir(cookie, sink)
+ else:
+ logError("Sink %s is neither a file nor a folder (skip removal)" % sink)
+ names_excluded += [names[name_index]]
+ del (names[name_index])
+ name_index = name_index - 1
+ break
+ elif filter[0] == '+':
+ break
+ name_index = name_index + 1
+
+ if cookie.delete and os.path.isdir(target_dir):
+ # Delete files and folder in target not present in filtered sink.
+ for name in os.listdir(target_dir):
+ if not cookie.delete_excluded and name in names_excluded:
+ continue
+ if not name in names:
+ target = os.path.join(target_dir, name)
+ if os.path.isfile(target):
+ removeFile(cookie, target)
+ elif os.path.isdir(target):
+ removeDir(cookie, target)
+ else:
+ pass
+
+ for name in names:
+ # Copy files and folder from sink to target.
+ sink = os.path.join(sink_dir, name)
+ # print sink
+ target = os.path.join(target_dir, name)
+ if os.path.exists(target):
+ # When target already exit:
+ if os.path.isfile(sink):
+ if os.path.isfile(target):
+ # file-file
+ if shouldUpdate(cookie, sink, target):
+ updateFile(cookie, sink, target)
+ elif os.path.isdir(target):
+ # file-folder
+ removeDir(cookie, target)
+ copyFile(cookie, sink, target)
+ else:
+ # file-???
+ logError("Target %s is neither a file nor folder (skip update)" % sink)
+
+ elif os.path.isdir(sink):
+ if os.path.isfile(target):
+ # folder-file
+ removeFile(cookie, target)
+ makeDir(cookie, target)
+ else:
+ # ???-xxx
+ logError("Sink %s is neither a file nor a folder (skip update)" % sink)
+
+ elif not cookie.existing:
+ # When target dont exist:
+ if os.path.isfile(sink):
+ # file
+ copyFile(cookie, sink, target)
+ elif os.path.isdir(sink):
+ # folder
+ makeDir(cookie, target)
+ else:
+ logError("Sink %s is neither a file nor a folder (skip update)" % sink)
def log(cookie, message):
- if not cookie.quiet:
- try:
- print message
- except UnicodeEncodeError:
- print message.encode("utf8")
+ if not cookie.quiet:
+ try:
+ print message
+ except UnicodeEncodeError:
+ print message.encode("utf8")
def logError(message):
- try:
- sys.stderr.write(message + "\n")
- except UnicodeEncodeError:
- sys.stderr.write(message.encode("utf8") + "\n")
+ try:
+ sys.stderr.write(message + "\n")
+ except UnicodeEncodeError:
+ sys.stderr.write(message.encode("utf8") + "\n")
def shouldUpdate(cookie, sink, target):
- try:
- sink_st = os.stat(sink)
- sink_sz = sink_st.st_size
- sink_mt = sink_st.st_mtime
- except:
- logError("Fail to retrieve information about sink %s (skip update)" % sink)
- return 0
+ try:
+ sink_st = os.stat(sink)
+ sink_sz = sink_st.st_size
+ sink_mt = sink_st.st_mtime
+ except:
+ logError("Fail to retrieve information about sink %s (skip update)" % sink)
+ return 0
- try:
- target_st = os.stat(target)
- target_sz = target_st.st_size
- target_mt = target_st.st_mtime
- except:
- logError("Fail to retrieve information about target %s (skip update)" % target)
- return 0
+ try:
+ target_st = os.stat(target)
+ target_sz = target_st.st_size
+ target_mt = target_st.st_mtime
+ except:
+ logError("Fail to retrieve information about target %s (skip update)" % target)
+ return 0
- if cookie.update:
- return target_mt < sink_mt - cookie.modify_window
+ if cookie.update:
+ return target_mt < sink_mt - cookie.modify_window
- if cookie.ignore_time:
- return 1
+ if cookie.ignore_time:
+ return 1
- if target_sz != sink_sz:
- return 1
+ if target_sz != sink_sz:
+ return 1
- if cookie.size_only:
- return 0
+ if cookie.size_only:
+ return 0
- return abs(target_mt - sink_mt) > cookie.modify_window
+ return abs(target_mt - sink_mt) > cookie.modify_window
def copyFile(cookie, sink, target):
- log(cookie, "copy: %s to: %s" % (sink, target))
- if not cookie.dry_run:
- try:
- shutil.copyfile(sink, target)
- except:
- logError("Fail to copy %s" % sink)
+ log(cookie, "copy: %s to: %s" % (sink, target))
+ if not cookie.dry_run:
+ try:
+ shutil.copyfile(sink, target)
+ except:
+ logError("Fail to copy %s" % sink)
- if cookie.time:
- try:
- s = os.stat(sink)
- os.utime(target, (s.st_atime, s.st_mtime));
- except:
- logError("Fail to copy timestamp of %s" % sink)
+ if cookie.time:
+ try:
+ s = os.stat(sink)
+ os.utime(target, (s.st_atime, s.st_mtime));
+ except:
+ logError("Fail to copy timestamp of %s" % sink)
def updateFile(cookie, sink, target):
- log(cookie, "update: %s to: %s" % (sink, target))
- if not cookie.dry_run:
- # Read only and hidden and system files can not be overridden.
- try:
- try:
- if win32file:
- filemode = win32file.GetFileAttributesW(target)
- win32file.SetFileAttributesW(target, filemode & ~win32file.FILE_ATTRIBUTE_READONLY & ~win32file.FILE_ATTRIBUTE_HIDDEN & ~win32file.FILE_ATTRIBUTE_SYSTEM)
- else:
- os.chmod(target, stat.S_IWUSR)
- except:
- #logError("Fail to allow override of %s" % target)
- pass
-
- shutil.copyfile(sink, target)
- if cookie.time:
- try:
- s = os.stat(sink)
- os.utime(target, (s.st_atime, s.st_mtime));
- except:
- logError("Fail to copy timestamp of %s" % sink) # The utime api of the 2.3 version of python is not unicode compliant.
- except:
- logError("Fail to override %s" % sink)
-
- if win32file:
- win32file.SetFileAttributesW(target, filemode)
+ log(cookie, "update: %s to: %s" % (sink, target))
+ if not cookie.dry_run:
+ # Read only and hidden and system files can not be overridden.
+ try:
+ try:
+ if win32file:
+ filemode = win32file.GetFileAttributesW(target)
+ win32file.SetFileAttributesW(target,
+ filemode & ~win32file.FILE_ATTRIBUTE_READONLY & ~win32file.FILE_ATTRIBUTE_HIDDEN & ~win32file.FILE_ATTRIBUTE_SYSTEM)
+ else:
+ os.chmod(target, stat.S_IWUSR)
+ except:
+ # logError("Fail to allow override of %s" % target)
+ pass
+
+ shutil.copyfile(sink, target)
+ if cookie.time:
+ try:
+ s = os.stat(sink)
+ os.utime(target, (s.st_atime, s.st_mtime));
+ except:
+ logError(
+ "Fail to copy timestamp of %s" % sink) # The utime api of the 2.3 version of python is not unicode compliant.
+ except:
+ logError("Fail to override %s" % sink)
+
+ if win32file:
+ win32file.SetFileAttributesW(target, filemode)
def prepareRemoveFile(path):
- if win32file:
- filemode = win32file.GetFileAttributesW(path)
- win32file.SetFileAttributesW(path, filemode & ~win32file.FILE_ATTRIBUTE_READONLY & ~win32file.FILE_ATTRIBUTE_HIDDEN & ~win32file.FILE_ATTRIBUTE_SYSTEM)
- else:
- os.chmod(path, stat.S_IWUSR)
+ if win32file:
+ filemode = win32file.GetFileAttributesW(path)
+ win32file.SetFileAttributesW(path,
+ filemode & ~win32file.FILE_ATTRIBUTE_READONLY & ~win32file.FILE_ATTRIBUTE_HIDDEN & ~win32file.FILE_ATTRIBUTE_SYSTEM)
+ else:
+ os.chmod(path, stat.S_IWUSR)
def removeFile(cookie, target):
- # Read only files could not be deleted.
- log(cookie, "remove: %s" % target)
- if not cookie.dry_run:
- try:
- try:
- prepareRemoveFile(target)
- except:
- #logError("Fail to allow removal of %s" % target)
- pass
-
- os.remove(target)
- except:
- logError("Fail to remove %s" % target)
+ # Read only files could not be deleted.
+ log(cookie, "remove: %s" % target)
+ if not cookie.dry_run:
+ try:
+ try:
+ prepareRemoveFile(target)
+ except:
+ # logError("Fail to allow removal of %s" % target)
+ pass
+ os.remove(target)
+ except:
+ logError("Fail to remove %s" % target)
def makeDir(cookie, target):
- log(cookie, "make dir: %s" % target)
- if not cookie.dry_run:
- try:
- os.makedirs(target)
- except:
- logError("Fail to make dir %s" % target)
+ log(cookie, "make dir: %s" % target)
+ if not cookie.dry_run:
+ try:
+ os.makedirs(target)
+ except:
+ logError("Fail to make dir %s" % target)
def visitForPrepareRemoveDir(arg, dirname, names):
- for name in names:
- path = os.path.join(dirname, name)
- prepareRemoveFile(path)
+ for name in names:
+ path = os.path.join(dirname, name)
+ prepareRemoveFile(path)
def prepareRemoveDir(path):
- prepareRemoveFile(path)
- os.path.walk(path, visitForPrepareRemoveDir, None)
+ prepareRemoveFile(path)
+ os.path.walk(path, visitForPrepareRemoveDir, None)
def OnRemoveDirError(func, path, excinfo):
- logError("Fail to remove %s" % path)
+ logError("Fail to remove %s" % path)
def removeDir(cookie, target):
- # Read only directory could not be deleted.
- log(cookie, "remove dir: %s" % target)
- if not cookie.dry_run:
- prepareRemoveDir(target)
- try:
- shutil.rmtree(target, False, OnRemoveDirError)
- except:
- logError("Fail to remove dir %s" % target)
+ # Read only directory could not be deleted.
+ log(cookie, "remove dir: %s" % target)
+ if not cookie.dry_run:
+ prepareRemoveDir(target)
+ try:
+ shutil.rmtree(target, False, OnRemoveDirError)
+ except:
+ logError("Fail to remove dir %s" % target)
def convertPath(path):
- # Convert windows, mac path to unix version.
- separator = os.path.normpath("/")
- if separator != "/":
- path = re.sub(re.escape(separator), "/", path)
+ # Convert windows, mac path to unix version.
+ separator = os.path.normpath("/")
+ if separator != "/":
+ path = re.sub(re.escape(separator), "/", path)
- # Help file, folder pattern to express that it should match the all file or folder name.
- path = "/" + path
- return path
+ # Help file, folder pattern to express that it should match the all file or folder name.
+ path = "/" + path
+ return path
def convertPattern(pattern, sign):
- """Convert a rsync pattern that match against a path to a filter that match against a converted path."""
-
- # Check for include vs exclude patterns.
- if pattern[:2] == "+ ":
- pattern = pattern[2:]
- sign = "+"
- elif pattern[:2] == "- ":
- pattern = pattern[2:]
- sign = "-"
-
- # Express windows, mac patterns in unix patterns (rsync.py extension).
- separator = os.path.normpath("/")
- if separator != "/":
- pattern = re.sub(re.escape(separator), "/", pattern)
-
- # If pattern contains '/' it should match from the start.
- temp = pattern
- if pattern[0] == "/":
- pattern = pattern[1:]
- if temp[-1] == "/":
- temp = temp[:-1]
-
- # Convert pattern rules: ** * ? to regexp rules.
- pattern = re.escape(pattern)
- pattern = string.replace(pattern, "\\?", ".")
- pattern = string.replace(pattern, "\\*\\*", ".*")
- pattern = string.replace(pattern, "\\*", "[^/]*")
- pattern = string.replace(pattern, "\\*", ".*")
-
- if "/" in temp:
- # If pattern contains '/' it should match from the start.
- pattern = "^\\/" + pattern
- else:
- # Else the pattern should match the all file or folder name.
- pattern = "\\/" + pattern
-
- if pattern[-2:] != "\\/" and pattern[-2:] != ".*":
- # File patterns should match also folders.
- pattern = pattern + "\\/?"
-
- # Pattern should match till the end.
- pattern = pattern + "$"
- return (sign, pattern)
+ """Convert a rsync pattern that match against a path to a filter that match against a converted path."""
+
+ # Check for include vs exclude patterns.
+ if pattern[:2] == "+ ":
+ pattern = pattern[2:]
+ sign = "+"
+ elif pattern[:2] == "- ":
+ pattern = pattern[2:]
+ sign = "-"
+
+ # Express windows, mac patterns in unix patterns (rsync.py extension).
+ separator = os.path.normpath("/")
+ if separator != "/":
+ pattern = re.sub(re.escape(separator), "/", pattern)
+
+ # If pattern contains '/' it should match from the start.
+ temp = pattern
+ if pattern[0] == "/":
+ pattern = pattern[1:]
+ if temp[-1] == "/":
+ temp = temp[:-1]
+
+ # Convert pattern rules: ** * ? to regexp rules.
+ pattern = re.escape(pattern)
+ pattern = string.replace(pattern, "\\?", ".")
+ pattern = string.replace(pattern, "\\*\\*", ".*")
+ pattern = string.replace(pattern, "\\*", "[^/]*")
+ pattern = string.replace(pattern, "\\*", ".*")
+
+ if "/" in temp:
+ # If pattern contains '/' it should match from the start.
+ pattern = "^\\/" + pattern
+ else:
+ # Else the pattern should match the all file or folder name.
+ pattern = "\\/" + pattern
+
+ if pattern[-2:] != "\\/" and pattern[-2:] != ".*":
+ # File patterns should match also folders.
+ pattern = pattern + "\\/?"
+
+ # Pattern should match till the end.
+ pattern = pattern + "$"
+ return (sign, pattern)
def convertPatterns(path, sign):
- """Read the files for pattern and return a vector of filters"""
- filters = []
- f = open(path, "r")
- while 1:
- pattern = f.readline()
- if not pattern:
- break
- if pattern[-1] == "\n":
- pattern = pattern[:-1]
-
- if re.match("[\t ]*$", pattern):
- continue
- if pattern[0] == "#":
- continue
- filters = filters + [convertPattern(pattern, sign)]
- f.close()
- return filters
+ """Read the files for pattern and return a vector of filters"""
+ filters = []
+ f = open(path, "r")
+ while 1:
+ pattern = f.readline()
+ if not pattern:
+ break
+ if pattern[-1] == "\n":
+ pattern = pattern[:-1]
+
+ if re.match("[\t ]*$", pattern):
+ continue
+ if pattern[0] == "#":
+ continue
+ filters = filters + [convertPattern(pattern, sign)]
+ f.close()
+ return filters
def printUsage():
- """Print the help string that should printed by rsync.py -h"""
- print "usage: rsync.py [options] source target"
- print """
+ """Print the help string that should printed by rsync.py -h"""
+ print "usage: rsync.py [options] source target"
+ print """
-q, --quiet decrease verbosity
-r, --recursive recurse into directories
-R, --relative use relative path names
@@ -401,118 +408,124 @@ Send an email to vivian@vdesmedt.com for comments and bug reports."""
def printVersion():
- print "rsync.py version 2.0.1"
+ print "rsync.py version 2.0.1"
def main(args):
- cookie = Cookie()
-
- opts, args = getopt.getopt(args, "qrRntuCIh", ["quiet", "recursive", "relative", "dry-run", "time", "update", "cvs-ignore", "ignore-times", "help", "delete", "delete-excluded", "delete-from-source", "existing", "size-only", "modify-window=", "exclude=", "exclude-from=", "include=", "include-from=", "version"])
- for o, v in opts:
- if o in ["-q", "--quiet"]:
- cookie.quiet = 1
- if o in ["-r", "--recursive"]:
- cookie.recursive = 1
- if o in ["-R", "--relative"]:
- cookie.relative = 1
- elif o in ["-n", "--dry-run"]:
- cookie.dry_run = 1
- elif o in ["-t", "--times", "--time"]: # --time is there to guaranty backward compatibility with previous buggy version.
- cookie.time = 1
- elif o in ["-u", "--update"]:
- cookie.update = 1
- elif o in ["-C", "--cvs-ignore"]:
- cookie.cvs_ignore = 1
- elif o in ["-I", "--ignore-time"]:
- cookie.ignore_time = 1
- elif o == "--delete":
- cookie.delete = 1
- elif o == "--delete-excluded":
- cookie.delete = 1
- cookie.delete_excluded = 1
- elif o == "--delete-from-source":
- cookie.delete_from_source = 1
- elif o == "--size-only":
- cookie.size_only = 1
- elif o == "--modify-window":
- cookie.modify_window = int(v)
- elif o == "--existing":
- cookie.existing = 1
- elif o == "--exclude":
- cookie.filters = cookie.filters + [convertPattern(v, "-")]
- elif o == "--exclude-from":
- cookie.filters = cookie.filters + convertPatterns(v, "-")
- elif o == "--include":
- cookie.filters = cookie.filters + [convertPattern(v, "+")]
- elif o == "--include-from":
- cookie.filters = cookie.filters + convertPatterns(v, "+")
- elif o == "--version":
- printVersion()
- return 0
- elif o in ["-h", "--help"]:
- printUsage()
- return 0
-
- if len(args) <= 1:
- printUsage()
- return 1
-
- #print cookie.filters
-
- target_root = args[1]
- try: # In order to allow compatibility below 2.3.
- pass
- if os.path.__dict__.has_key("supports_unicode_filenames") and os.path.supports_unicode_filenames:
- target_root = unicode(target_root, sys.getfilesystemencoding())
- finally:
- cookie.target_root = target_root
-
- sinks = glob.glob(args[0])
- if not sinks:
- return 0
-
- sink_families = {}
- for sink in sinks:
- try: # In order to allow compatibility below 2.3.
- if os.path.__dict__.has_key("supports_unicode_filenames") and os.path.supports_unicode_filenames:
- sink = unicode(sink, sys.getfilesystemencoding())
- except:
- pass
- sink_name = ""
- sink_root = sink
- sink_drive, sink_root = os.path.splitdrive(sink)
- while not sink_name:
- if sink_root == os.path.sep:
- sink_name = "."
- break
- sink_root, sink_name = os.path.split(sink_root)
- sink_root = sink_drive + sink_root
- if not sink_families.has_key(sink_root):
- sink_families[sink_root] = []
- sink_families[sink_root] = sink_families[sink_root] + [sink_name]
-
- for sink_root in sink_families.keys():
- if cookie.relative:
- cookie.sink_root = ""
- else:
- cookie.sink_root = sink_root
-
- global y # In order to allow compatibility below 2.1 (nested scope where used before).
- y = sink_root
- files = filter(lambda x: os.path.isfile(os.path.join(y, x)), sink_families[sink_root])
- if files:
- visit(cookie, sink_root, files)
-
- #global y # In order to allow compatibility below 2.1 (nested scope where used before).
- y = sink_root
- folders = filter(lambda x: os.path.isdir(os.path.join(y, x)), sink_families[sink_root])
- for folder in folders:
- folder_path = os.path.join(sink_root, folder)
- if not cookie.recursive:
- visit(cookie, folder_path, os.listdir(folder_path))
- else:
- os.path.walk(folder_path, visit, cookie)
- return 0
+ cookie = Cookie()
+
+ opts, args = getopt.getopt(args, "qrRntuCIh",
+ ["quiet", "recursive", "relative", "dry-run", "time", "update", "cvs-ignore",
+ "ignore-times", "help", "delete", "delete-excluded", "delete-from-source", "existing",
+ "size-only", "modify-window=", "exclude=", "exclude-from=", "include=", "include-from=",
+ "version"])
+ for o, v in opts:
+ if o in ["-q", "--quiet"]:
+ cookie.quiet = 1
+ if o in ["-r", "--recursive"]:
+ cookie.recursive = 1
+ if o in ["-R", "--relative"]:
+ cookie.relative = 1
+ elif o in ["-n", "--dry-run"]:
+ cookie.dry_run = 1
+ elif o in ["-t", "--times",
+ "--time"]: # --time is there to guaranty backward compatibility with previous buggy version.
+ cookie.time = 1
+ elif o in ["-u", "--update"]:
+ cookie.update = 1
+ elif o in ["-C", "--cvs-ignore"]:
+ cookie.cvs_ignore = 1
+ elif o in ["-I", "--ignore-time"]:
+ cookie.ignore_time = 1
+ elif o == "--delete":
+ cookie.delete = 1
+ elif o == "--delete-excluded":
+ cookie.delete = 1
+ cookie.delete_excluded = 1
+ elif o == "--delete-from-source":
+ cookie.delete_from_source = 1
+ elif o == "--size-only":
+ cookie.size_only = 1
+ elif o == "--modify-window":
+ cookie.modify_window = int(v)
+ elif o == "--existing":
+ cookie.existing = 1
+ elif o == "--exclude":
+ cookie.filters = cookie.filters + [convertPattern(v, "-")]
+ elif o == "--exclude-from":
+ cookie.filters = cookie.filters + convertPatterns(v, "-")
+ elif o == "--include":
+ cookie.filters = cookie.filters + [convertPattern(v, "+")]
+ elif o == "--include-from":
+ cookie.filters = cookie.filters + convertPatterns(v, "+")
+ elif o == "--version":
+ printVersion()
+ return 0
+ elif o in ["-h", "--help"]:
+ printUsage()
+ return 0
+
+ if len(args) <= 1:
+ printUsage()
+ return 1
+
+ # print cookie.filters
+
+ target_root = args[1]
+ try: # In order to allow compatibility below 2.3.
+ pass
+ if os.path.__dict__.has_key("supports_unicode_filenames") and os.path.supports_unicode_filenames:
+ target_root = unicode(target_root, sys.getfilesystemencoding())
+ finally:
+ cookie.target_root = target_root
+
+ sinks = glob.glob(args[0])
+ if not sinks:
+ return 0
+
+ sink_families = {}
+ for sink in sinks:
+ try: # In order to allow compatibility below 2.3.
+ if os.path.__dict__.has_key("supports_unicode_filenames") and os.path.supports_unicode_filenames:
+ sink = unicode(sink, sys.getfilesystemencoding())
+ except:
+ pass
+ sink_name = ""
+ sink_root = sink
+ sink_drive, sink_root = os.path.splitdrive(sink)
+ while not sink_name:
+ if sink_root == os.path.sep:
+ sink_name = "."
+ break
+ sink_root, sink_name = os.path.split(sink_root)
+ sink_root = sink_drive + sink_root
+ if not sink_families.has_key(sink_root):
+ sink_families[sink_root] = []
+ sink_families[sink_root] = sink_families[sink_root] + [sink_name]
+
+ for sink_root in sink_families.keys():
+ if cookie.relative:
+ cookie.sink_root = ""
+ else:
+ cookie.sink_root = sink_root
+
+ global y # In order to allow compatibility below 2.1 (nested scope where used before).
+ y = sink_root
+ files = filter(lambda x: os.path.isfile(os.path.join(y, x)), sink_families[sink_root])
+ if files:
+ visit(cookie, sink_root, files)
+
+ # global y # In order to allow compatibility below 2.1 (nested scope where used before).
+ y = sink_root
+ folders = filter(lambda x: os.path.isdir(os.path.join(y, x)), sink_families[sink_root])
+ for folder in folders:
+ folder_path = os.path.join(sink_root, folder)
+ if not cookie.recursive:
+ visit(cookie, folder_path, os.listdir(folder_path))
+ else:
+ os.path.walk(folder_path, visit, cookie)
+ return 0
+
if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
+ sys.exit(main(sys.argv[1:]))
diff --git a/vstf/vstf/common/saltstack.py b/vstf/vstf/common/saltstack.py
index efc953c4..030bef5d 100755
--- a/vstf/vstf/common/saltstack.py
+++ b/vstf/vstf/common/saltstack.py
@@ -1,5 +1,12 @@
-#!/usr/bin/env python
-# coding=utf-8
+##############################################################################
+# Copyright (c) 2015 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 os
import sys
import inspect
diff --git a/vstf/vstf/common/ssh.py b/vstf/vstf/common/ssh.py
index 1f7eddc3..7b85e086 100755
--- a/vstf/vstf/common/ssh.py
+++ b/vstf/vstf/common/ssh.py
@@ -1,8 +1,12 @@
-'''
-Created on 2015-7-23
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-'''
import os
import logging
from stat import S_ISDIR
diff --git a/vstf/vstf/common/test_func.py b/vstf/vstf/common/test_func.py
index 9b1d24f9..2a9a4c0d 100755
--- a/vstf/vstf/common/test_func.py
+++ b/vstf/vstf/common/test_func.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
from vstf.common import cliutil as util
diff --git a/vstf/vstf/common/unix.py b/vstf/vstf/common/unix.py
index f74944e2..97582c74 100755
--- a/vstf/vstf/common/unix.py
+++ b/vstf/vstf/common/unix.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 os
import socket
from vstf.common import constants
diff --git a/vstf/vstf/common/utils.py b/vstf/vstf/common/utils.py
index 542eaa88..f2e14096 100755
--- a/vstf/vstf/common/utils.py
+++ b/vstf/vstf/common/utils.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 re
import logging
import subprocess
@@ -13,10 +22,10 @@ LOG = logging.getLogger(__name__)
def info():
def _deco(func):
def __deco(*args, **kwargs):
- if "shell" in kwargs and not kwargs["shell"]:
- LOG.info(' '.join(args[0]))
- else:
+ if "shell" in kwargs and kwargs["shell"]:
LOG.info(args[0])
+ else:
+ LOG.info(' '.join(args[0]))
return func(*args, **kwargs)
return __deco
return _deco
diff --git a/vstf/vstf/common/vstfcli.py b/vstf/vstf/common/vstfcli.py
index 9dc99779..896bb1d6 100755
--- a/vstf/vstf/common/vstfcli.py
+++ b/vstf/vstf/common/vstfcli.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 argparse
import sys
diff --git a/vstf/vstf/controller/__init__.py b/vstf/vstf/controller/__init__.py
index 4dc8a6aa..df7d24d0 100755
--- a/vstf/vstf/controller/__init__.py
+++ b/vstf/vstf/controller/__init__.py
@@ -1,15 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/controller/api_server.py b/vstf/vstf/controller/api_server.py
index d3547011..a37bf4c1 100755
--- a/vstf/vstf/controller/api_server.py
+++ b/vstf/vstf/controller/api_server.py
@@ -1,3 +1,13 @@
+##############################################################################
+# Copyright (c) 2015 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 uuid
import time
import os
@@ -10,7 +20,6 @@ from vstf.common import unix, message, cliutil, excepts
from vstf.common.vstfcli import VstfParser
from vstf.common.log import setup_logging
from vstf.common import daemon
-from vstf.rpc_frame_work import rpc_producer
from vstf.controller.fabricant import Fabricant
from vstf.agent.env.basic.commandline import CommandLine
from vstf.controller.env_build.env_build import EnvBuildApi as Builder
@@ -25,7 +34,9 @@ from vstf.controller.settings.tool_settings import ToolSettings
from vstf.controller.settings.perf_settings import PerfSettings
from vstf.controller.sw_perf.perf_provider import PerfProvider
from vstf.controller.sw_perf.flow_producer import FlowsProducer
+from vstf.controller.settings.forwarding_settings import ForwardingSettings
import vstf.controller.reporters.reporter as rp
+import vstf.rpc_frame_work.rpc_producer as rpc
import vstf.common.constants as cst
import vstf.common.check as chk
@@ -39,12 +50,11 @@ class OpsChains(object):
and setup a thread to watch the queues of rabbitmq
"""
- super(OpsChains, self).__init__()
+ LOG.info("VSTF Manager start to listen to %s", monitor)
if not os.path.exists(cst.VSTFCPATH):
os.mkdir(cst.VSTFCPATH)
- LOG.info("VSTF Manager start to listen to %s", monitor)
- self.chanl = rpc_producer.Server(host=monitor, port=port)
+ self.chanl = rpc.Server(host=monitor, port=port)
self.dbconn = DbManage()
self.collection = EnvCollectApi(self.chanl)
@@ -146,16 +156,25 @@ class OpsChains(object):
nic_info["desc"],
json.dumps(os_info[cst.OS_INFO]))
- self.dbconn.add_extent_2task(taskid, "CETH", "driver", "version 2.0")
- self.dbconn.add_extent_2task(taskid, "EVS", "switch", "version 3.0")
+ self.dbconn.add_extent_2task(taskid, "ixgbe", "driver", "")
+ self.dbconn.add_extent_2task(taskid, "OVS", "switch", "")
return taskid
- def settings(self, mail=False, perf=False):
- LOG.info("mail:%s, perf:%s" % (mail, perf))
- if mail:
- MailSettings().input()
- if perf:
- PerfSettings().input()
+ def settings(self, head, tail):
+
+ forward_settings = ForwardingSettings()
+ head_d = {
+ "ip": head,
+ "namespace":forward_settings.settings["head"]["namespace"]
+ }
+ tail_d = {
+ "ip": tail,
+ "namespace":forward_settings.settings["tail"]["namespace"]
+ }
+ LOG.info(head_d)
+ LOG.info(tail_d)
+ forward_settings.set_head(head_d)
+ forward_settings.set_tail(tail_d)
def report(self, rpath='./', mail_off=False, taskid=-1):
report = rp.Report(self.dbconn, rpath)
@@ -165,13 +184,15 @@ class OpsChains(object):
info_str = "do report over"
return info_str
- def run_perf_cmd(self, case, rpath='./', affctl=False, build_on=False, save_on=False, report_on=False, mail_on=False):
+ def run_perf_cmd(self, case, rpath='./', affctl=False, build_on=False, save_on=False, report_on=False,
+ mail_on=False):
LOG.info(case)
LOG.info("build_on:%s report_on:%s mail_on:%s" % (build_on, report_on, mail_on))
casetag = case['case']
tool = case['tool']
protocol = case['protocol']
- profile = case['profile']
+ switch = "ovs"
+ provider = None
ttype = case['type']
sizes = case['sizes']
@@ -204,7 +225,7 @@ class OpsChains(object):
LOG.info(result)
if save_on:
taskid = self._create_task(scenario)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, profile, ttype, tool)
+ testid = self.dbconn.add_test_2task(taskid, casetag, protocol, ttype, switch, provider, tool)
LOG.info(testid)
self.dbconn.add_data_2test(testid, result)
if report_on:
@@ -239,7 +260,8 @@ class OpsChains(object):
casetag = case['case']
tool = case['tool']
protocol = case['protocol']
- profile = case['profile']
+ provider = None
+ switch = "ovs"
ttype = case['type']
sizes = case['sizes']
@@ -252,7 +274,7 @@ class OpsChains(object):
result = perf.run(tool, protocol, ttype, sizes, affctl)
LOG.info(result)
- testid = self.dbconn.add_test_2task(taskid, casetag, protocol, profile, ttype, tool)
+ testid = self.dbconn.add_test_2task(taskid, casetag, protocol, ttype, switch, provider, tool)
LOG.info(testid)
self.dbconn.add_data_2test(testid, result)
@@ -285,7 +307,7 @@ class Manager(daemon.Daemon):
self.run_flag = True
def deal_unknown_obj(self, obj):
- return "unknown response %s" % obj
+ return "unknown response %s:%s" % (self, obj)
def run(self):
signal.signal(signal.SIGTERM, self.daemon_die)
diff --git a/vstf/vstf/controller/database/__init__.py b/vstf/vstf/controller/database/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/database/__init__.py
+++ b/vstf/vstf/controller/database/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/database/constants.py b/vstf/vstf/controller/database/constants.py
index d1aef398..e5070122 100755
--- a/vstf/vstf/controller/database/constants.py
+++ b/vstf/vstf/controller/database/constants.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
SCENARIO_NAME_LEN = 16
DESC_LEN = 256
FIGURE_PATH_LEN = 128
@@ -14,6 +23,7 @@ CPU_INFO_LEN = 1024
NORMAL_VAR_LEN = 32
NORMAL_VAR_LEN1 = 64
+SWITCH_LEN = 16
PROTOCOL_LEN = 16
PROVIDER_LEN = 16
diff --git a/vstf/vstf/controller/database/dbinterface.py b/vstf/vstf/controller/database/dbinterface.py
index ae34c861..d0996c30 100755
--- a/vstf/vstf/controller/database/dbinterface.py
+++ b/vstf/vstf/controller/database/dbinterface.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-07-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__version__ = ''' '''
import os
import logging
@@ -10,7 +14,8 @@ import logging
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import and_
-from vstf.controller.database.tables import *
+import vstf.controller.database.tables as table
+from vstf.controller.database import constants as const
LOG = logging.getLogger(__name__)
@@ -38,7 +43,7 @@ class DbManage(object):
except Exception as e:
raise e
- # if the db is new , cleate all tables and init static tables
+ # if the db is new , create all tables and init static tables
if not db_exists:
self.create_tables()
self.init_tables()
@@ -47,11 +52,11 @@ class DbManage(object):
self._engine.close_all()
def create_tables(self):
- Base.metadata.create_all(self._engine)
+ table.Base.metadata.create_all(self._engine)
self._session.commit()
def drop_tables(self):
- Base.metadata.drop_all(self._engine)
+ table.Base.metadata.drop_all(self._engine)
self._session.commit()
def init_tables(self):
@@ -62,9 +67,9 @@ class DbManage(object):
def init_scenario_table(self):
items = []
for values in const.SCENARIO_INFO_LIST:
- item = TblScenarioInfo(ScenarioName=values[0],
- FigurePath=values[1],
- Description=values[2])
+ item = table.TblScenarioInfo(ScenarioName=values[0],
+ FigurePath=values[1],
+ Description=values[2])
items.append(item)
self._session.add_all(items)
@@ -72,53 +77,53 @@ class DbManage(object):
def init_casetable(self):
items = []
for values in const.CASE_INFO_LIST:
- item = TblCaseInfo(CaseTag=values[0],
- ScenarioName=values[1],
- CaseName=values[2],
- FigurePath=values[3],
- Description=values[4],
- Direction=values[5],
- Directiontag=values[6],
- Configure=values[7])
+ item = table.TblCaseInfo(CaseTag=values[0],
+ ScenarioName=values[1],
+ CaseName=values[2],
+ FigurePath=values[3],
+ Description=values[4],
+ Direction=values[5],
+ Directiontag=values[6],
+ Configure=values[7])
items.append(item)
self._session.add_all(items)
def query_caseinfo(self):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.CaseTag,
- TblCaseInfo.CaseName,
- TblCaseInfo.Direction,
- TblCaseInfo.Configure)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.CaseName,
+ table.TblCaseInfo.Direction,
+ table.TblCaseInfo.Configure)
return query.all()
def query_case(self, casetag):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.Directiontag)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.Directiontag)
return query.first()
# Single TblTaskList API
def get_last_taskid(self):
- query = self._session.query(TblTaskList.TaskID)
+ query = self._session.query(table.TblTaskList.TaskID)
if query:
return query.all()[-1][0]
else:
return 0
def query_tasklist(self):
- query = self._session.query(TblTaskList)
+ query = self._session.query(table.TblTaskList)
return query.all()
def query_taskdate(self, taskid):
- query = self._session.query(TblTaskList.Date).filter(and_(
- TblTaskList.TaskID == taskid))
+ query = self._session.query(table.TblTaskList.Date).filter(and_(
+ table.TblTaskList.TaskID == taskid))
result = ""
if query:
result += query.first()[0]
return result
def query_taskname(self, taskid):
- query = self._session.query(TblTaskList.TaskName).filter(and_(
- TblTaskList.TaskID == taskid))
+ query = self._session.query(table.TblTaskList.TaskName).filter(and_(
+ table.TblTaskList.TaskID == taskid))
result = ""
if query:
result += query.first()[0]
@@ -126,7 +131,7 @@ class DbManage(object):
def create_task(self, name, date, desc):
try:
- item = TblTaskList(name, date, desc)
+ item = table.TblTaskList(name, date, desc)
self._session.add(item)
self._session.commit()
except Exception:
@@ -137,32 +142,33 @@ class DbManage(object):
# Single TblHostInfo API
def add_host_2task(self, taskid, name, machine, cpu, men, nic, os):
"""All var except task must be string"""
- item = TblHostInfo(taskid, name, machine, cpu, men, nic, os)
+ item = table.TblHostInfo(taskid, name, machine, cpu, men, nic, os)
self._session.add(item)
self._session.commit()
def query_task_host_list(self, taskid):
- query = self._session.query(TblHostInfo.HostName,
- TblHostInfo.Server,
- TblHostInfo.CPU,
- TblHostInfo.MEM,
- TblHostInfo.NIC,
- TblHostInfo.OS).filter(
- TblHostInfo.TaskID == taskid)
+ query = self._session.query(table.TblHostInfo.HostName,
+ table.TblHostInfo.Server,
+ table.TblHostInfo.CPU,
+ table.TblHostInfo.MEM,
+ table.TblHostInfo.NIC,
+ table.TblHostInfo.OS).filter(
+ table.TblHostInfo.TaskID == taskid)
return query.all()
# Single TblTestList API
def get_last_testid(self):
- query = self._session.query(TblTestList.TestID)
+ query = self._session.query(table.TblTestList.TestID)
+ print query.all()
if query:
return query.all()[-1][0]
else:
return 0
- def add_test_2task(self, task, case, protocol, provider, typ, tool):
+ def add_test_2task(self, task, case, protocol, typ, switch, provider, tool):
try:
- item = TblTestList(task, case, protocol, provider, typ, tool)
+ item = table.TblTestList(task, case, protocol, typ, switch, provider, tool)
self._session.add(item)
self._session.commit()
except Exception:
@@ -171,12 +177,12 @@ class DbManage(object):
return self.get_last_testid()
def get_test_type(self, testid):
- query = self._session.query(TblTestList.Type).filter(
- TblTestList.TestID == testid)
+ query = self._session.query(table.TblTestList.Type).filter(
+ table.TblTestList.TestID == testid)
return query.first()
def add_extent_2task(self, task, name, content, description):
- item = TblEXTInfo(task, name, content, description)
+ item = table.TblEXTInfo(task, name, content, description)
self._session.add(item)
self._session.commit()
@@ -199,9 +205,9 @@ class DbManage(object):
"""
ptype = self.get_test_type(testid)
instance_map = {
- 'throughput': TblThroughput,
- 'frameloss': TblFrameloss,
- 'latency': TblLatency
+ 'throughput': table.TblThroughput,
+ 'frameloss': table.TblFrameloss,
+ 'latency': table.TblLatency
}
if ptype and ptype[0] not in instance_map:
@@ -228,37 +234,37 @@ class DbManage(object):
def query_tasks(self):
result = []
- ret = self._session.query(TblTaskList)
+ ret = self._session.query(table.TblTaskList)
if ret:
for tmp in ret.all():
result.append([tmp.TaskID, tmp.TaskName, tmp.Date, tmp.EXTInfo])
return result
def query_all_task_id(self):
- query = self._session.query(TblTaskList.TaskID)
+ query = self._session.query(table.TblTaskList.TaskID)
if query:
return query.all()
else:
return []
def get_caseinfo(self):
- query = self._session.query(TblCaseInfo.ScenarioName,
- TblCaseInfo.CaseTag,
- TblCaseInfo.CaseName,
- TblCaseInfo.Direction,
- TblCaseInfo.Configure)
+ query = self._session.query(table.TblCaseInfo.ScenarioName,
+ table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.CaseName,
+ table.TblCaseInfo.Direction,
+ table.TblCaseInfo.Configure)
return query.all()
def query_scenario(self, casetag):
- query = self._session.query(TblCaseInfo.ScenarioName).filter(TblCaseInfo.CaseTag == casetag)
+ query = self._session.query(table.TblCaseInfo.ScenarioName).filter(table.TblCaseInfo.CaseTag == casetag)
ret = ""
if query and query.first():
ret = query.first()[0]
return ret
def query_casefigure(self, casetag, tools):
- query = self._session.query(TblCaseInfo.FigurePath).filter(and_(
- TblCaseInfo.CaseTag == casetag))
+ query = self._session.query(table.TblCaseInfo.FigurePath).filter(and_(
+ table.TblCaseInfo.CaseTag == casetag))
result = ""
if query:
result += query.first()[0]
@@ -267,167 +273,183 @@ class DbManage(object):
return result
def query_casename(self, casetag):
- query = self._session.query(TblCaseInfo.CaseName).filter(and_(
- TblCaseInfo.CaseTag == casetag))
+ query = self._session.query(table.TblCaseInfo.CaseName).filter(and_(
+ table.TblCaseInfo.CaseTag == casetag))
result = ""
if query:
result += query.first()[0]
return result
- # Single TblScenarioInfo API
+ # Single TblTestList API
def query_caselist(self, taskid, scenario):
- query = self._session.query(TblTestList.CaseTag).filter(and_(
- TblTestList.CaseTag == TblCaseInfo.CaseTag,
- TblCaseInfo.ScenarioName == scenario,
- TblTestList.TaskID == taskid)).group_by(TblCaseInfo.CaseTag)
+ query = self._session.query(table.TblTestList.CaseTag).filter(and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.ScenarioName == scenario,
+ table.TblTestList.TaskID == taskid)).group_by(table.TblCaseInfo.CaseTag)
+ return query.all()
+
+ def query_testlist(self, taskid, scenario):
+ """
+
+ :rtype : object
+ """
+ query = self._session.query(table.TblTestList).filter(and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblCaseInfo.ScenarioName == scenario,
+ table.TblTestList.TaskID == taskid))
return query.all()
def query_casetool(self, taskid, casetag, provider, ptype):
- query = self._session.query(TblTestList.Tools).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.Type == ptype))
+ query = self._session.query(table.TblTestList.Tools).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.Type == ptype))
return query.all()
def query_casetools(self, taskid, casetag):
- query = self._session.query(TblTestList.Tools).filter(and_(
- TblTestList.CaseTag == casetag,
- TblTestList.TaskID == taskid)).group_by(TblTestList.Tools)
+ query = self._session.query(table.TblTestList.Tools).filter(and_(
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.TaskID == taskid)).group_by(table.TblTestList.Tools)
return query.all()
def query_scenariolist(self, taskid):
- query = self._session.query(TblCaseInfo.ScenarioName).filter(and_(
- TblTestList.CaseTag == TblCaseInfo.CaseTag,
- TblTestList.TaskID == taskid)).group_by(TblCaseInfo.ScenarioName)
+ query = self._session.query(table.TblCaseInfo.ScenarioName).filter(and_(
+ table.TblTestList.CaseTag == table.TblCaseInfo.CaseTag,
+ table.TblTestList.TaskID == taskid)).group_by(table.TblCaseInfo.ScenarioName)
return query.all()
def query_throughput_load(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize, TblThroughput.OfferedLoad).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.OfferedLoad).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_bandwidth(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize, TblThroughput.Bandwidth).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.Bandwidth).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_table(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize,
- TblThroughput.Bandwidth,
- TblThroughput.OfferedLoad,
- TblThroughput.CPU,
- TblThroughput.MppspGhz,
- TblThroughput.MinimumLatency,
- TblThroughput.MaximumLatency,
- TblThroughput.AverageLatency,
+ query = self._session.query(table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth,
+ table.TblThroughput.OfferedLoad,
+ table.TblThroughput.CPU,
+ table.TblThroughput.MppspGhz,
+ table.TblThroughput.MinimumLatency,
+ table.TblThroughput.MaximumLatency,
+ table.TblThroughput.AverageLatency,
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_throughput_simpletable(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize,
- TblThroughput.Bandwidth,
- TblThroughput.OfferedLoad,
- TblThroughput.CPU,
- TblThroughput.MppspGhz,
- TblThroughput.AverageLatency,
+ query = self._session.query(table.TblThroughput.AvgFrameSize,
+ table.TblThroughput.Bandwidth,
+ table.TblThroughput.OfferedLoad,
+ table.TblThroughput.CPU,
+ table.TblThroughput.MppspGhz,
+ table.TblThroughput.AverageLatency,
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
+ return query.all()
+
+ def query_testdata(self, testid, ptype):
+ obj = getattr(table, "Tbl%s" % (ptype.title()))
+ query = self._session.query(obj).filter(obj.TestID == testid)
return query.all()
def query_throughput_avg(self, taskid, casetag, provider):
ptype = 'throughput'
- query = self._session.query(TblThroughput.AvgFrameSize, TblThroughput.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblThroughput.TestID))
+ query = self._session.query(table.TblThroughput.AvgFrameSize, table.TblThroughput.AverageLatency).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_frameloss_bandwidth(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(TblFrameloss.AvgFrameSize, TblFrameloss.Bandwidth).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.Bandwidth).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_load(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(TblFrameloss.AvgFrameSize, TblFrameloss.OfferedLoad).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.OfferedLoad).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_table(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(TblFrameloss.AvgFrameSize,
- TblFrameloss.Bandwidth,
- TblFrameloss.OfferedLoad,
- TblFrameloss.CPU,
- TblFrameloss.MppspGhz,
- TblFrameloss.MinimumLatency,
- TblFrameloss.MaximumLatency,
- TblFrameloss.AverageLatency,
+ query = self._session.query(table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth,
+ table.TblFrameloss.OfferedLoad,
+ table.TblFrameloss.CPU,
+ table.TblFrameloss.MppspGhz,
+ table.TblFrameloss.MinimumLatency,
+ table.TblFrameloss.MaximumLatency,
+ table.TblFrameloss.AverageLatency
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_simpletable(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(TblFrameloss.AvgFrameSize,
- TblFrameloss.Bandwidth,
- TblFrameloss.OfferedLoad,
- TblFrameloss.CPU,
- TblFrameloss.MppspGhz,
- TblFrameloss.AverageLatency,
+ query = self._session.query(table.TblFrameloss.AvgFrameSize,
+ table.TblFrameloss.Bandwidth,
+ table.TblFrameloss.OfferedLoad,
+ table.TblFrameloss.CPU,
+ table.TblFrameloss.MppspGhz,
+ table.TblFrameloss.AverageLatency
).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_frameloss_avg(self, taskid, casetag, provider):
ptype = 'frameloss'
- query = self._session.query(TblFrameloss.AvgFrameSize, TblFrameloss.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblFrameloss.TestID))
+ query = self._session.query(table.TblFrameloss.AvgFrameSize, table.TblFrameloss.AverageLatency).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_latency_avg(self, taskid, casetag, provider):
ptype = 'latency'
- query = self._session.query(TblLatency.AvgFrameSize, TblLatency.AverageLatency).filter(and_(
- TblTestList.TaskID == taskid,
- TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider, TblTestList.Type == ptype,
- TblTestList.TestID == TblLatency.TestID))
+ query = self._session.query(table.TblLatency.AvgFrameSize, table.TblLatency.AverageLatency).filter(and_(
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider, table.TblTestList.Type == ptype,
+ table.TblTestList.TestID == table.TblLatency.TestID))
return query.all()
def query_summary_table(self, taskid, casetag, provider, ptype):
@@ -461,50 +483,51 @@ class DbManage(object):
return []
def query_throughput_provider(self, taskid, casetag, provider):
- query = self._session.query(TblThroughput).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == TblThroughput.TestID))
+ query = self._session.query(table.TblThroughput).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblThroughput.TestID))
return query.all()
def query_frameloss_provider(self, taskid, casetag, provider):
- query = self._session.query(TblFrameloss).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == TblFrameloss.TestID))
+ query = self._session.query(table.TblFrameloss).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblFrameloss.TestID))
return query.all()
def query_latency_provider(self, taskid, casetag, provider):
- query = self._session.query(TblLatency).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid,
- TblTestList.TestID == TblLatency.TestID))
+ query = self._session.query(table.TblLatency).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid,
+ table.TblTestList.TestID == table.TblLatency.TestID))
return query.all()
def query_case_type_count(self, taskid, casetag, ptype):
- query = self._session.query(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Type == ptype, TblTestList.TaskID == taskid))
+ query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_case_provider_count(self, taskid, casetag, provider):
- query = self._session.query(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid))
+ query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_case_type_provider_count(self, taskid, casetag, provider, ptype):
- query = self._session.query(TblTestList).filter(and_(TblTestList.CaseTag == casetag,
- TblTestList.Type == ptype,
- TblTestList.Provider == provider,
- TblTestList.TaskID == taskid))
+ query = self._session.query(table.TblTestList).filter(and_(table.TblTestList.CaseTag == casetag,
+ table.TblTestList.Type == ptype,
+ table.TblTestList.Provider == provider,
+ table.TblTestList.TaskID == taskid))
return query.count()
def query_exten_info(self, taskid):
- query = self._session.query(TblEXTInfo.EXTName,
- TblEXTInfo.EXTContent,
- TblEXTInfo.Description).filter(TblEXTInfo.TaskID == taskid)
+ query = self._session.query(table.TblEXTInfo.EXTName,
+ table.TblEXTInfo.EXTContent,
+ table.TblEXTInfo.Description).filter(table.TblEXTInfo.TaskID == taskid)
return query.all()
@@ -517,7 +540,7 @@ def unit_test():
dbase.add_extent_2task(taskid, "CETH", "driver", "version 2.0")
dbase.add_extent_2task(taskid, "EVS", "switch", "version 3.0")
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "rdp", "throughput", "netperf")
+ testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "throughput", "ovs", None, "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -535,7 +558,7 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "rdp", "frameloss", "netperf")
+ testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "frameloss", "ovs", None, "netperf")
data = {
'64': {
'OfferedLoad': 2,
@@ -553,7 +576,7 @@ def unit_test():
}
dbase.add_data_2test(testid, data)
- testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "rdp", "latency", "netperf")
+ testid = dbase.add_test_2task(taskid, "Tn-1", 'udp', "latency", "ovs", None, "netperf")
data = {
64: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0},
128: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0},
@@ -561,7 +584,12 @@ def unit_test():
1024: {'MaximumLatency': 0.0, 'AverageLatency': 0.0, 'MinimumLatency': 0.0, 'OfferedLoad': 0.0}
}
dbase.add_data_2test(testid, data)
+ query = dbase.query_testlist(1, "Tn")
+ for item in query:
+ print item.Protocol
+ query = dbase.query_testdata(1, "throughput")
+ print query
if __name__ == '__main__':
unit_test()
diff --git a/vstf/vstf/controller/database/tables.py b/vstf/vstf/controller/database/tables.py
index a7658f49..0438d0e9 100755
--- a/vstf/vstf/controller/database/tables.py
+++ b/vstf/vstf/controller/database/tables.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# author: wly
-# date: 2015-07-29
+# date: 2015-12-25
# see license for license details
__version__ = ''' '''
from sqlalchemy import Column, Integer, String, Float, ForeignKey
@@ -127,22 +127,24 @@ class TblTestList(Base):
TaskID = Column(Integer, ForeignKey('TblTaskList.TaskID'))
CaseTag = Column(String(const.CASE_TAG_LEN))
Protocol = Column(String(const.PROTOCOL_LEN))
- Provider = Column(String(const.PROVIDER_LEN))
Type = Column(String(const.TYPE_LEN))
+ Switch = Column(String(const.SWITCH_LEN))
+ Provider = Column(String(const.PROVIDER_LEN))
Tools = Column(String(const.TOOLS_LEN))
- def __init__(self, taskid, casetag, protocol, provider, typ, tools, **kwargs):
+ def __init__(self, taskid, casetag, protocol, typ, switch, provider, tools, **kwargs):
"""Table of test"""
self.TaskID = taskid
self.CaseTag = casetag
self.Protocol = protocol
- self.Provider = provider
self.Type = typ
+ self.Switch = switch
+ self.Provider = provider
self.Tools = tools
def __repr__(self):
- return "<User(TaskID='%d', CaseTag='%s', Protocol='%s', Provider=%s, Type='%s', Tools='%s')>" % (
- self.TaskID, self.CaseTag, self.Protocol, self.Provider, self.Type, self.Tools)
+ return "<User(TaskID='%d', CaseTag='%s', Protocol='%s', Type='%s', Switch=%s, Provider=%s, Tools='%s')>" % (
+ self.TaskID, self.CaseTag, self.Protocol, self.Type, self.Switch, self.Provider, self.Tools)
class TblThroughput(Base):
diff --git a/vstf/vstf/controller/env_build/__init__.py b/vstf/vstf/controller/env_build/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/env_build/__init__.py
+++ b/vstf/vstf/controller/env_build/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/controller/env_build/cfg_intent_parse.py b/vstf/vstf/controller/env_build/cfg_intent_parse.py
index 8c7c10b8..b536e3b8 100755
--- a/vstf/vstf/controller/env_build/cfg_intent_parse.py
+++ b/vstf/vstf/controller/env_build/cfg_intent_parse.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-13
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import json
import logging
from vstf.common.utils import randomMAC
diff --git a/vstf/vstf/controller/env_build/env_build.py b/vstf/vstf/controller/env_build/env_build.py
index 85ad5d29..1d201b77 100755
--- a/vstf/vstf/controller/env_build/env_build.py
+++ b/vstf/vstf/controller/env_build/env_build.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-8-27
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import logging
from vstf.controller.fabricant import Fabricant
diff --git a/vstf/vstf/controller/env_build/env_collect.py b/vstf/vstf/controller/env_build/env_collect.py
index 888f71c7..6e32a05d 100755
--- a/vstf/vstf/controller/env_build/env_collect.py
+++ b/vstf/vstf/controller/env_build/env_collect.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
from vstf.rpc_frame_work import rpc_producer
diff --git a/vstf/vstf/controller/fabricant.py b/vstf/vstf/controller/fabricant.py
index c67bfa19..3b1c082f 100755
--- a/vstf/vstf/controller/fabricant.py
+++ b/vstf/vstf/controller/fabricant.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
from vstf.rpc_frame_work import constant as const
import vstf.common.constants as cst
@@ -43,7 +52,9 @@ class Fabricant(object):
def __transfer_msg(self, command):
def infunc(timeout=cst.TIMEOUT, **kwargs):
msg = self.conn.make_msg(command, **kwargs)
- return self.conn.call(msg, self.target, timeout)
+ if self.target:
+ return self.conn.call(msg, self.target, timeout)
+ return None
infunc.__name__ = command
return infunc
diff --git a/vstf/vstf/controller/reporters/__init__.py b/vstf/vstf/controller/reporters/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/__init__.py
+++ b/vstf/vstf/controller/reporters/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/mail/__init__.py b/vstf/vstf/controller/reporters/mail/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/mail/__init__.py
+++ b/vstf/vstf/controller/reporters/mail/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/mail/mail.py b/vstf/vstf/controller/reporters/mail/mail.py
index 42d60b1a..2241d9ad 100755
--- a/vstf/vstf/controller/reporters/mail/mail.py
+++ b/vstf/vstf/controller/reporters/mail/mail.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 smtplib
import logging
import os
diff --git a/vstf/vstf/controller/reporters/mail/sendmail.py b/vstf/vstf/controller/reporters/mail/sendmail.py
index ecc6fe93..a4d7bb0a 100755
--- a/vstf/vstf/controller/reporters/mail/sendmail.py
+++ b/vstf/vstf/controller/reporters/mail/sendmail.py
@@ -1,9 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-07
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 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 logging
from vstf.controller.reporters.mail.mail import Mail
diff --git a/vstf/vstf/controller/reporters/report/__init__.py b/vstf/vstf/controller/reporters/report/__init__.py
index 89dcd4e2..547db686 100755
--- a/vstf/vstf/controller/reporters/report/__init__.py
+++ b/vstf/vstf/controller/reporters/report/__init__.py
@@ -1,14 +1,10 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
+
diff --git a/vstf/vstf/controller/reporters/report/candy_generator.py b/vstf/vstf/controller/reporters/report/candy_generator.py
new file mode 100755
index 00000000..ea296550
--- /dev/null
+++ b/vstf/vstf/controller/reporters/report/candy_generator.py
@@ -0,0 +1,138 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.reporters.report.data_factory import TaskData
+from vstf.controller.database.dbinterface import DbManage
+import vstf.common.candy_text as candy
+import logging
+LOG = logging.getLogger(__name__)
+
+
+class CandyGenerator(object):
+ def __init__(self, task):
+ self._task = task
+
+ def create(self, scenario):
+ context = {}
+
+ sn = 1
+ chapterid = 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_env()
+
+ sn += 1
+ chapterid += 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_scenario(scenario)
+
+ template = TemplateSettings()
+ template.set_context(context)
+ LOG.info(template.settings)
+
+ def create_all(self):
+ context = {}
+
+ sn = 1
+ chapterid = 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_env()
+
+ scenarios = self._task.common.get_scenariolist()
+ for scenario in scenarios:
+ sn += 1
+ chapterid += 1
+ name = candy.tuple2text(sn, candy.chapter, chapterid)
+ context[name] = self.create_scenario(scenario)
+
+ template = TemplateSettings()
+ template.set_context(context)
+ LOG.info(template.settings)
+
+ def create_env(self):
+ env = {
+ "01##title#1": ["System Environment"],
+ "02##table#2": self._task.common.get_systeminfo()
+ }
+ return env
+
+ def create_scenario(self, scenario):
+ scenario_chapter = {
+ "01##title#1": ["Scenario Result"]
+ }
+ scenario_data = getattr(self._task, scenario)
+ test_list = scenario_data.get_testlist()
+ sectionid = 0
+ sn = 1
+ for test in test_list:
+ sn += 1
+ sectionid += 1
+ name = candy.tuple2text(sn, candy.section, sectionid)
+ testid = test.TestID
+ case = test.CaseTag.decode()
+ ttype = test.Type.decode()
+
+ params_info = [
+ " Case: " + case,
+ " Test tool: " + test.Tools.decode(),
+ " vSwitch: " + test.Switch.decode(),
+ " Protocol: " + test.Protocol.decode(),
+ " Type: " + ttype
+ ]
+ if ttype in ["frameloss", "throughput"]:
+ draw = {
+ "style": 1,
+ "node": candy.plot,
+ "data": scenario_data.get_framerate_chartdata(case, ttype)
+ }
+ table = scenario_data.get_ratedata(testid, ttype)
+ else:
+ draw = {
+ "style": 1,
+ "node": candy.chart,
+ "data": scenario_data.get_latency_bardata(case)
+ }
+ table = scenario_data.get_latency_tabledata(case)
+ test_section = self.create_test(sectionid, params_info, table, draw)
+ scenario_chapter[name] = test_section
+
+ return scenario_chapter
+
+ def create_test(self, section, info, table, draw):
+ """
+
+ :rtype : dict
+ """
+ sn = 7
+ draw_name = candy.tuple2text(sn, draw["node"], draw["style"])
+ case_section = {
+ "01##title#2": ["Test ID: %s" % section],
+ "02##paragraph#2": ["Parameter"],
+ "03##paragraph#3": info,
+ "04##paragraph#2": ["Result"],
+ "05##table#2": table,
+ "06##space#2": 2,
+ draw_name: draw["data"]
+ }
+ return case_section
+
+
+def main():
+ from vstf.common.log import setup_logging
+ setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-candy.log", clevel=logging.INFO)
+
+ dbase = DbManage()
+ taskid = dbase.get_last_taskid()
+ task = TaskData(taskid, dbase)
+ creator = CandyGenerator(task)
+
+ creator.create("Tn")
+if __name__ == '__main__':
+ main()
+
diff --git a/vstf/vstf/controller/reporters/report/data_factory.py b/vstf/vstf/controller/reporters/report/data_factory.py
index 39c534b6..f9fc69d9 100755
--- a/vstf/vstf/controller/reporters/report/data_factory.py
+++ b/vstf/vstf/controller/reporters/report/data_factory.py
@@ -1,11 +1,14 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-07-29
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
from vstf.controller.database.dbinterface import DbManage
+import vstf.common.constants as cst
class DataProvider(object):
@@ -15,59 +18,12 @@ class DataProvider(object):
class CommonData(DataProvider):
- def get_components(self):
- result = []
- query = self._dbase.query_exten_info(self._taskid)
- print "CommonData", query
- for item in query:
- if item[2]:
- context = "%s:%s(%s)" % (item[0], item[1], item[2])
- else:
- context = "%s:%s" % (item[0], item[1])
- result.append(context)
- return result
-
- def get_software(self):
- result = [
- " Host OS: ubuntu 14.04.2",
- " Guest OS: ubuntu 12.04.4"
- ]
- return result
-
- def get_hardware(self):
- result = [
- " Server: Dell R920",
- " CPU: E7-8893/2P/3.4GHz/10-Cores/37.5M-L3C",
- " MEM: 128G",
- " NIC: Intel 82599"
- ]
- return result
-
def get_taskname(self):
return self._dbase.query_taskname(self._taskid)
- def get_gitinfo_tabledata(self):
- result = []
- return result
-
- def get_profileparameters_tabledData(self):
- result = [
- ]
- return result
-
- def get_testingoptions_tabledata(self):
- result = [
- ]
- return result
-
- def get_systeminfo_tabledata(self):
- result = [
- ]
- return result
-
def get_systeminfo(self):
systable = [
- ['host', 'Server', 'CPU', 'MEM', 'NIC', 'OS'],
+ ['Host', 'Server', 'CPU', 'MEM', 'NIC', 'OS'],
]
query = self._dbase.query_task_host_list(self._taskid)
query = map(lambda x: list(x), query)
@@ -103,14 +59,6 @@ class CommonData(DataProvider):
return True
return False
- def get_contact(self):
- result = [
- "Name: xxx",
- "ID: xxxxxxxx",
- "Email: xxxx@xxx.com"
- ]
- return result
-
def get_casename(self, case):
return self._dbase.query_casename(case)
@@ -124,23 +72,6 @@ class ScenarioData(DataProvider):
DataProvider.__init__(self, taskid, dbase)
self._scenario = scenario
- def get_covertitle(self):
- result = [
- "",
- "",
- "Elastic Virtual Switching Performance "
- "Test Report",
- "Scenario %s" % (self._scenario)
- ]
- return result
-
- def get_test(self):
- result = [
- "Scenario: %s" % (self._scenario),
- "Configuration: without VLAN",
- ]
- return result
-
def get_test_tools(self, case):
query = self._dbase.query_casetools(self._taskid, case)
result = map(lambda x: list(x), query)
@@ -157,6 +88,13 @@ class ScenarioData(DataProvider):
else:
return result
+ def get_testlist(self):
+ query = self._dbase.query_testlist(self._taskid, self._scenario)
+ result = []
+ for item in query:
+ result.append(item.__dict__)
+ return query
+
def is_provider_start(self, case, provider):
count = self._dbase.query_case_provider_count(self._taskid, case, provider)
if count:
@@ -231,12 +169,27 @@ class ScenarioData(DataProvider):
]
return table_head + table_body
+ def get_ratedata(self, testid, test_type):
+ table_head = [
+ ["FrameSize (bytes)", "Bandwidth(Mpps)", "Load (%)", "CPU Usage(%)", "Mpps/Ghz", "AvgLatency(uSec)"],
+ ]
+ query = self._dbase.query_testdata(testid, test_type)
+ table_body = []
+ for item in query:
+ table_body.append([item.AvgFrameSize, item.Bandwidth, item.OfferedLoad, item.CPU, item.MppspGhz,
+ item.AverageLatency])
+ result = []
+ if table_body:
+ result = table_head + table_body
+ return result
+
def get_tabledata(self, case, test_type, item):
type_dict = {
"FrameSize": "FrameSize (byte)",
"fastlink": "fastlink",
"l2switch": "l2switch",
"rdp": "kernel rdp",
+ None: "ovs",
"line": "line speed"
}
item_dict = {
@@ -244,11 +197,10 @@ class ScenarioData(DataProvider):
"Mpps": " ",
"Avg": " ",
}
- provider_list = ["fastlink", "rdp", "l2switch"]
table = []
line_speed = 20.0 if case in ["Tn-2v", "Tn-2"] else 10.0
- for provider in provider_list:
+ for provider in cst.PROVIDERS:
if self.is_provider_start(case, provider):
if item == 'Percent':
query = self._dbase.query_load(self._taskid, case, provider, test_type)
@@ -260,9 +212,9 @@ class ScenarioData(DataProvider):
if query:
table_head = [[type_dict["FrameSize"]] + map(lambda x: " %4d " % (x), query[0])]
if item == "Avg":
- data = map(lambda x: item_dict[item] + "%.1f" % (x) + item_dict[item], query[1])
+ data = map(lambda x: item_dict[item] + "%.1f" % x + item_dict[item], query[1])
else:
- data = map(lambda x: item_dict[item] + "%.2f" % (x) + item_dict[item], query[1])
+ data = map(lambda x: item_dict[item] + "%.2f" % x + item_dict[item], query[1])
if item == "Mpps":
line_table = map(lambda x: "%.2f" % (line_speed * 1000 / (8 * (x + 20))), query[0])
table.append([type_dict[provider]] + data)
@@ -362,7 +314,7 @@ class TaskData(object):
class HistoryData(DataProvider):
def get_data(self, task_list, case, provider, ttype, item):
"""
- @provider in ["fastlink", "rdp", "l2switch"]
+ @provider in ["fastlink", "rdp", "l2switch", ""]
@ttype in ["throughput", "frameloss", "latency"]
@item in ["avg", "ratep", "load"]
"""
@@ -415,7 +367,6 @@ class HistoryData(DataProvider):
return task_list
def get_history_info(self, case):
- providers = ["fastlink", "rdp", "l2switch"]
provider_dict = {"fastlink": "Fast Link ", "l2switch": "L2Switch ", "rdp": "Kernel RDP "}
ttype_dict = {
"throughput": "Throughput Testing ",
@@ -431,15 +382,14 @@ class HistoryData(DataProvider):
task_list = self.get_tasklist()
result = []
- ttypes = ["throughput", "frameloss", "latency"]
- for ttype in ttypes:
+ for ttype in cst.TTYPES:
content = {}
if ttype == "latency":
item = "avg"
else:
item = "ratep"
- for provider in providers:
+ for provider in cst.PROVIDERS:
table_data = self.get_data(task_list, case, provider, ttype, item)
if table_data:
data = {
@@ -451,9 +401,7 @@ class HistoryData(DataProvider):
content["data"].append(data)
if content:
result.append(content)
- print "xxxxxxxxxxxxxx"
print result
- print "xxxxxxxxxxxxxx"
return result
@@ -475,11 +423,10 @@ def unit_test():
case = "Tn-1"
- providers = ["fastlink", "rdp", "l2switch"]
ttypes = ["throughput", "frameloss"]
items = ["ratep", "load"]
- for provider in providers:
+ for provider in cst.PROVIDERS:
for ttype in ttypes:
for item in items:
print provider
diff --git a/vstf/vstf/controller/reporters/report/html/__init__.py b/vstf/vstf/controller/reporters/report/html/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/report/html/__init__.py
+++ b/vstf/vstf/controller/reporters/report/html/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/report/html/html_base.py b/vstf/vstf/controller/reporters/report/html/html_base.py
index 270ef394..36be5981 100755
--- a/vstf/vstf/controller/reporters/report/html/html_base.py
+++ b/vstf/vstf/controller/reporters/report/html/html_base.py
@@ -1,41 +1,43 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09.25
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__version__ = ''' '''
import os
-from vstf.common.pyhtml import *
+import vstf.common.pyhtml as pyhtm
class HtmlBase(object):
- def __init__(self, provider, ofile='text.html'):
- self._page = PyHtml('HtmlBase Text')
- self._ofile = ofile
+ def __init__(self, provider):
+ self._page = pyhtm.PyHtml('Html Text')
self._provider = provider
- self._chapter = 1
- def save(self):
- if self._ofile:
- os.system('rm -rf %s' % self._ofile)
- self._page.output(self._ofile)
+ def save(self, ofile):
+ if ofile:
+ os.system('rm -rf %s' % ofile)
+ self._page.output(ofile)
def as_string(self):
return self._page.as_string()
def add_table(self, data):
- self._page.add_table(data)
+ if data and zip(*data):
+ self._page.add_table(data)
def add_style(self):
- style = self._provider.get_style()
+ style = self._provider.get_style
self._page.add_style(style)
- def create(self, is_save=True):
+ def create(self, ofile='text.html'):
self.add_style()
self.create_story()
- if is_save:
- self.save()
+ self.save(ofile)
return self.as_string()
def create_story(self):
diff --git a/vstf/vstf/controller/reporters/report/html/html_text.py b/vstf/vstf/controller/reporters/report/html/html_text.py
deleted file mode 100755
index 86505b8f..00000000
--- a/vstf/vstf/controller/reporters/report/html/html_text.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-24
-# see license for license details
-__version__ = ''' '''
-
-import logging
-
-LOG = logging.getLogger(__name__)
-import vstf.common.constants as cst
-from vstf.controller.reporters.report.html.html_base import *
-
-
-class HtmlCreator(HtmlBase):
- def add_subject(self):
- title = self._provider.get_subject()
- self._page << H1(title)
-
- def add_ovs(self):
- title = "%s %s" % (self._chapter, self._provider.get_ovs_title())
- self._page << H2(title)
- data = self._provider.get_ovs_table()
- self.add_table(data)
- self._chapter += 1
-
- def add_result(self):
- title = "%s %s" % (self._chapter, self._provider.get_result_title())
- self._page << H2(title)
-
- section = 1
- for ttype in cst.TTYPES:
- data = self._provider.get_result_table(ttype)
- if data:
- title = "%s.%s %s" % (self._chapter, section, ttype.title())
- self._page << H3(title)
- self.add_table(data)
- section += 1
- self._chapter += 1
-
- def create_story(self):
- self.add_subject()
- self.add_ovs()
- self.add_result()
-
-
-def unit_test():
- from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/html-test.log", clevel=logging.INFO)
-
- from vstf.controller.settings.html_settings import HtmlSettings
- from vstf.controller.settings.data_settings import DataSettings
-
- html_settings = HtmlSettings()
- LOG.info(html_settings.settings)
- data_settings = DataSettings()
- LOG.info(data_settings.settings)
-
- from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
- provider = HtmlProvider(data_settings.settings, html_settings.settings)
- html = HtmlCreator(provider)
-
- result = html.create()
- print result
-
-
-if __name__ == '__main__':
- unit_test()
diff --git a/vstf/vstf/controller/reporters/report/html/htmlcreator.py b/vstf/vstf/controller/reporters/report/html/htmlcreator.py
index e6c75caf..1d150e28 100755
--- a/vstf/vstf/controller/reporters/report/html/htmlcreator.py
+++ b/vstf/vstf/controller/reporters/report/html/htmlcreator.py
@@ -1,117 +1,85 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-08-04
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__version__ = ''' '''
import logging
-from vstf.controller.reporters.report.data_factory import TaskData
-from vstf.controller.database.dbinterface import DbManage
-from vstf.controller.reporters.report.html.html_base import *
+import vstf.common.candy_text as candy
+from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.settings.html_settings import HtmlSettings
+from vstf.controller.reporters.report.html.html_base import HtmlBase, pyhtm
LOG = logging.getLogger(__name__)
-class HtmlvSwitchCreator(HtmlBase):
- def __init__(self, task_data, provider, ofile='creator.html'):
- HtmlBase.__init__(self, provider, ofile)
- self._task = task_data
- self._table_type = 'html'
-
+class HtmlCreator(HtmlBase):
def create_story(self):
- self.add_subject()
- self.add_gitinfo()
- self.add_envinfo()
- self.add_scenarios()
-
- def add_subject(self):
- job_name = "JOB_NAME: " + self._task.common.get_taskname()
- self._page << H2(job_name)
-
- def add_gitinfo(self):
- self._page << H2("Trigger and Repository Info")
-
- git_table = self._task.common.get_gitinfo_tabledata()
- if git_table:
- self.add_table(git_table)
-
- def add_envinfo(self):
- self._page << H2("System Environment Information")
- env_table = self._task.common.get_systeminfo()
- LOG.info(env_table)
- if env_table:
- self.add_table(env_table)
-
- def add_scenarios(self):
- scenario_list = self._task.common.get_scenariolist()
- self._page << H2("Scenario List: " + ', '.join(scenario_list))
- for scenario in scenario_list:
- self._page << H2("Scenario: " + scenario)
- data = getattr(self._task, scenario)
- self.add_scenario(data)
-
- def add_scenario(self, scenario_data):
- case_list = scenario_data.get_caselist()
- for case in case_list:
- self.add_case(scenario_data, case)
-
- def add_case(self, scenario_data, case):
- case_name = self._task.common.get_casename(case)
- title = "Case : %s (%s)" % (case, case_name)
- self._page << H2(title)
-
- provider_list = ["fastlink", "rdp", "l2switch"]
- provider_dict = {"fastlink": "Fast Link", "l2switch": "L2Switch", "rdp": "Kernel RDP"}
-
- for provider in provider_list:
- if scenario_data.is_provider_start(case, provider):
- title = " %s (%s_%s)" % (provider_dict[provider], case_name, provider)
- self._page << H3(title)
- test_types = ["throughput", "frameloss"]
- for test_type in test_types:
- if scenario_data.is_type_provider_start(case, provider, test_type):
- self.add_casedata(scenario_data, case, provider, test_type)
-
- if scenario_data.is_latency_start(case):
- self.add_latency_result(scenario_data, case)
-
- def add_casedata(self, scenario_data, case, provider, test_type):
- table_content = scenario_data.get_summary_tabledata(case, provider, test_type, self._table_type)
- if table_content:
- title = "Test type:%s" % (test_type)
- self._page << H4(title)
- self.add_table(table_content)
-
- def add_latency_result(self, scenario_data, case):
- title = "Average Latency Summary"
- table_content = scenario_data.get_latency_tabledata(case)
- if table_content:
- self._page << H2(title)
- self.add_table(table_content)
+ self.add_context()
+
+ def add_context(self):
+ context = self._provider.get_context
+ self._raw_context(context)
+
+ def _raw_context(self, context, ci=0, si=0, ui=0, level=-1):
+ _story = []
+ for key, value in sorted(context.items()):
+ LOG.info(key)
+ LOG.info(value)
+ _sn, _node, _style = candy.text2tuple(key)
+ if _node in candy.dom:
+ if _node == candy.chapter:
+ ci = _style
+ elif _node == candy.section:
+ si = _style
+ else:
+ ui = _style
+ self._raw_context(value, ci, si, ui, level + 1)
+
+ else:
+ LOG.info("node: %s %s" % (_node, candy.title))
+ if _node == candy.title:
+ assert value
+ if level in range(len(candy.dom)):
+ if level == 0:
+ value[0] = "Chapter %s %s" % (ci, value[0])
+ for title in value:
+ self._page << pyhtm.H2(title)
+ elif level == 1:
+ value[0] = "%s.%s %s" % (ci, si, value[0])
+ for title in value:
+ self._page << pyhtm.H3(title)
+ else:
+ value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0])
+ for title in value:
+ self._page << pyhtm.H3(title)
+
+ elif _node == candy.table:
+ self.add_table(value)
+ elif _node == candy.paragraph:
+ for para in value:
+ para = pyhtm.space(2) + para
+ self._page << pyhtm.P(para)
def unit_test():
from vstf.common.log import setup_logging
setup_logging(level=logging.DEBUG, log_file="/var/log/html-creator.log", clevel=logging.INFO)
- dbase = DbManage()
- taskid = dbase.get_last_taskid()
- task_data = TaskData(taskid, dbase)
-
- from vstf.controller.settings.html_settings import HtmlSettings
- from vstf.controller.reporters.report.provider.html_provider import StyleProvider
+ out_file = "vstf_report.html"
+ info = TemplateSettings()
html_settings = HtmlSettings()
- LOG.info(html_settings.settings)
-
- provider = StyleProvider(html_settings.settings)
- html = HtmlvSwitchCreator(task_data, provider)
-
- result = html.create(True)
- print result
-
+ provider = HtmlProvider(info.settings, html_settings.settings)
+ reporter = HtmlCreator(provider)
+ reporter.create(out_file)
if __name__ == '__main__':
unit_test()
diff --git a/vstf/vstf/controller/reporters/report/pdf/__init__.py b/vstf/vstf/controller/reporters/report/pdf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/reporters/report/pdf/__init__.py
+++ b/vstf/vstf/controller/reporters/report/pdf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/reporters/report/pdf/element.py b/vstf/vstf/controller/reporters/report/pdf/element.py
index 2528f2c5..78d1c59b 100755
--- a/vstf/vstf/controller/reporters/report/pdf/element.py
+++ b/vstf/vstf/controller/reporters/report/pdf/element.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-04
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__version__ = ''' '''
__doc__ = """
it contains the base element for pdf
diff --git a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
index 50b3bc65..4f7bd2a8 100755
--- a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
+++ b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
@@ -1,446 +1,129 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__version__ = ''' '''
-import os
-from vstf.controller.reporters.report.pdf.styles import TemplateStyle
from vstf.controller.reporters.report.pdf.pdftemplate import PdfVswitch
-from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, LineChartStory, \
- LinePlotStory, uTableStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory, cTableStory
-from vstf.controller.reporters.report.data_factory import CommonData, ScenarioData, HistoryData
-from vstf.controller.database.dbinterface import DbManage
-import vstf.controller
-
+from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, TableStory, \
+ LinePlotStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory
+import vstf.common.candy_text as candy
+from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider
+from vstf.controller.settings.template_settings import TemplateSettings
-class LetterOrder(object):
- def __init__(self):
- self.lettertable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- self._cur = 0
- self._len = len(self.lettertable)
-
- def get(self):
- return self.lettertable[self._cur]
-
- def pre(self):
- self._cur = (self._cur + self._len - 1) % self._len
+import os
+import logging
- def next(self):
- self._cur = (self._cur + 1) % self._len
+LOG = logging.getLogger(__name__)
-class PdfBase(object):
- def __init__(self):
- self._case = ''
- self._ofile = ''
- self._title = []
+class PdfCreator(object):
+ def __init__(self, provider):
+ self._provider = provider
self._story = []
- self._rootdir = os.path.dirname(vstf.controller.__file__) + '/'
self._pdf = None
def create_pdf(self):
- style = TemplateStyle(name='default')
- title = self._title
- logo = [self._rootdir + "res/logo.jpg"]
- header = ['']
- footer = [""]
- note = ['', '']
- output = [self._ofile]
- self._pdf = PdfFrameLoss(style, title, logo, header, footer, output, note)
+ theme = self._provider.get_theme
+ self._pdf = PdfVswitch(theme["title"],
+ theme["logo"],
+ theme["header"],
+ theme["footer"],
+ theme["note"],
+ theme["style"])
- def save_pdf(self):
- self._pdf.generate(self._story)
+ def save_pdf(self, ofile):
+ self._pdf.generate(self._story, ofile)
def add_coverpage(self):
story = Story()
story = PageBreakStory(story)
self._story += story.storylist
- def create_story(self):
- raise NotImplementedError("abstract PdfBase")
-
- def create(self):
- self.create_pdf()
- self.create_story()
- self.save_pdf()
-
-
-class PdfvSwitchCreator(PdfBase):
- def __init__(self, ofile, common_data, scenario_data, history_data):
- PdfBase.__init__(self)
- self._common = common_data
- self._result = scenario_data
- self._history = history_data
- self._ofile = ofile
- self._chapterid = 0
- self._appendixid = LetterOrder()
-
- def create_pdf(self):
- style = TemplateStyle(name='default')
- title = self._result.get_covertitle()
- logo = [self._rootdir + "res/logo.jpg"]
- header = ['']
- footer = [""]
- note = ['', '']
- output = [self._ofile]
- self._pdf = PdfVswitch(style, title, logo, header, footer, output, note)
-
- def get_chapterid(self):
- self._chapterid = self._chapterid + 1
- return self._chapterid
+ def add_contents(self):
+ if self._provider.ifcontents:
+ story = Story()
+ story = TableOfContentsStory(story)
+ self._story += story.storylist
def create_story(self):
self.add_coverpage()
- self.add_table_of_contents()
- # self.add_contact()
- # self.add_overview()
- self.add_scenario()
- # self.add_info()
- # self.add_appendix()
- self.add_historys()
-
- def add_info(self):
- self.add_systeminfo()
- self.add_gitinfo()
- self.add_profile_parameters()
- self.add_testing_options()
-
- def add_contact(self):
- story = Story()
- story = SpaceStory(story)
- title = ["", "", "", "Reporter"]
- body = self._common.get_contact()
- story = TitleStory(story, data=title, style=7)
- story = ParagraphStory(story, data=body)
- self._story += story.storylist
-
- def add_table_of_contents(self):
- story = Story()
- story = TableOfContentsStory(story)
- self._story += story.storylist
-
- def add_overview(self):
- story = Story()
- story = PageBreakStory(story)
-
- chapterid = self.get_chapterid()
- title = ["%d.Overview" % (chapterid)]
- body = [""]
- story = TitleStory(story, data=title, style=1)
- story = ParagraphStory(story, data=body)
-
- sectionid = 1
- title = ["%d.%d Components under Test" % (chapterid, sectionid)]
- body = self._common.get_components()
- story = TitleStory(story, data=title, style=2)
- story = ParagraphStory(story, data=body)
-
- sectionid = sectionid + 1
- title = ["%d.%d Test" % (chapterid, sectionid)]
- body = self._result.get_test()
- story = TitleStory(story, data=title, style=2)
- story = ParagraphStory(story, data=body)
-
- sectionid = sectionid + 1
- title = ["%d.%d Configuration" % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
-
- title = ["Software"]
- body = self._common.get_software()
- story = TitleStory(story, data=title, style=6)
- story = ParagraphStory(story, data=body)
-
- title = ["Hardware"]
- body = self._common.get_hardware()
- story = TitleStory(story, data=title, style=6)
- story = ParagraphStory(story, data=body)
- self._story += story.storylist
-
- def add_scenario(self):
- case_list = self._result.get_caselist()
- for case in case_list:
- self.add_case(case)
-
- def add_case(self, case):
- story = Story()
- chapterid = self.get_chapterid()
-
- title = ["%d. Case : %s (%s)" % (chapterid, case, self._common.get_casename(case))]
-
- tools = self._result.get_test_tools(case)
- pic = self._common.get_casefigure(case, tools)
- print pic
-
- story = TitleStory(story, data=title, style=1)
- story = SpaceStory(story)
- story = ImageStory(story, data=[self._rootdir + pic])
- story = SpaceStory(story)
-
- sectionid = 1
- story = self.add_summary(story, chapterid, sectionid, case)
- story = SpaceStory(story)
-
- if self._result.is_throughput_start(case):
- sectionid = sectionid + 1
- story = self.add_throughput_result(story, chapterid, sectionid, case)
-
- if self._result.is_frameloss_start(case):
- sectionid = sectionid + 1
- story = self.add_frameloss_result(story, chapterid, sectionid, case)
-
- if self._result.is_latency_start(case):
- sectionid = sectionid + 1
- story = self.add_latency_result(story, chapterid, sectionid, case)
-
- story = SpaceStory(story)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_summary(self, story, chapterid, sectionid, case):
- title = ["%d.%d Summary" % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- provider_list = ["fastlink", "rdp", "l2switch"]
- provider_dict = {"fastlink": "Fast Link", "l2switch": "L2Switch", "rdp": "Kernel RDP"}
- unitid = 1
- case_name = self._common.get_casename(case)
- for provider in provider_list:
- if self._result.is_provider_start(case, provider):
- title = ["%d.%d.%d %s (%s_%s)" % (
- chapterid, sectionid, unitid, provider_dict[provider], case_name, provider)]
- unitid = unitid + 1
- story = TitleStory(story, data=title, style=6)
- test_types = ["throughput", "frameloss"]
- for test_type in test_types:
- if self._result.is_type_provider_start(case, provider, test_type):
- story = self.add_summary_type(story, case, provider, test_type)
- return story
-
- def add_summary_type(self, story, case, provider, test_type):
- bar_list = [test_type, "latency"]
- for item in bar_list:
- bar_data = self._result.get_bardata(case, provider, item)
- story = SpaceStory(story)
- story = BarChartStory(story, data=bar_data)
-
- table_content = self._result.get_summary_tabledata(case, provider, test_type)
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=3)
- story = SpaceStory(story)
- return story
+ self.add_contents()
+ self.add_context()
- def add_throughput_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Throughput " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "throughput"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LinePlotStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_frameloss_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Frame Loss Rate " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- test_type = "frameloss"
- unit = 'RX Frame Rate'
- chart_data = self._result.get_frameloss_chartdata(case, test_type)
- table_data = self._result.get_frameloss_tabledata(case, test_type)
- title = [unit + ' (%)']
- story = TitleStory(story, data=title, style=6)
- # story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
-
- unit = 'Frame Loss Rate'
- title = [unit + ' (Mpps)']
-
- chart_data = self._result.get_framerate_chartdata(case, test_type)
- table_data = self._result.get_framerate_tabledata(case, test_type)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- story = LineChartStory(story, data=chart_data)
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_latency_result(self, story, chapterid, sectionid, case):
- title = ["%d.%d Latency " % (chapterid, sectionid)]
- story = TitleStory(story, data=title, style=2)
- unitid = 1
- title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)]
- story = TitleStory(story, data=title, style=6)
-
- unit = 'Average Latency'
- title = [unit + ' (uSec)']
- # chart_data = self._result.get_latency_chartdata(case)
- bar_data = self._result.get_latency_bardata(case)
- table_data = self._result.get_latency_tabledata(case)
- story = TitleStory(story, data=title, style=6)
- story = SpaceStory(story)
- # story = LineChartStory(story, data=chart_data)
- story = BarChartStory(story, data=bar_data)
-
- story = SpaceStory(story)
- story = uTableStory(story, data=table_data)
- story = SpaceStory(story)
- return story
-
- def add_systeminfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. System Information " % (chapterid)]
- story = PageBreakStory(story)
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_systeminfo_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=0)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_gitinfo(self):
- story = Story()
- chapterid = self.get_chapterid()
- title = ["%d. Git Repository Information " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
-
- table_content = self._common.get_gitinfo_tabledata()
- if table_content:
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=5)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_testing_options(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = SpaceStory(story)
- title = ["%d. Testing Options" % (chapterid)]
-
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_testingoptions_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=1)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_profile_parameters(self):
- story = Story()
- chapterid = self.get_chapterid()
- story = PageBreakStory(story)
- title = ["%d. " % (chapterid)]
- story = TitleStory(story, data=title, style=1)
- table_content = self._common.get_profileparameters_tabledData()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=2)
- story = SpaceStory(story)
- self._story += story.storylist
-
- def add_appendix(self):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s: vSwitching Testing Methodology</b>" % (self._appendixid.get())]
- self._appendixid.next()
- story = TitleStory(story, data=title, style=1)
- filename = "res/Traffic-types.jpg"
- story = SpaceStory(story)
- story = ImageStory(story, data=[self._rootdir + filename])
- # story = SpaceStory(story)
-
- title = ["Traffic Patterns: "]
- story = TitleStory(story, data=title, style=6)
-
- body = [
- "<b>Ti</b> - South North Traffic",
- "<b>Tu</b> - East Eest Traffic",
- "<b>Tn</b> - Physical host or VM loop back",
- "<b>Tnv</b> - Virtual Machine loop back",
- ]
- story = ParagraphStory(story, data=body)
-
- title = ["<b>Performance Testing Coverage </b> (version 0.1):"]
- story = TitleStory(story, data=title, style=6)
-
- table_content = self._common.get_introduct_tabledata()
- story = SpaceStory(story)
- story = cTableStory(story, data=table_content, style=4)
- self._story += story.storylist
-
- def add_historys(self):
- case_list = self._result.get_caselist()
- for case in case_list:
- history = self._history.get_history_info(case)
- if history:
- self.add_history(case, history)
-
- def add_history(self, case, history):
- story = Story()
- story = PageBreakStory(story)
-
- title = ["<b>Appendix %s : %s History Records</b>" % (self._appendixid.get(), case)]
- story = TitleStory(story, data=title, style=1)
-
- for i in range(len(history)):
- title = ["%s.%s %s" % (self._appendixid.get(), i, history[i]["title"])]
- story = TitleStory(story, data=title, style=2)
-
- section = history[i]["data"]
- for unit in section:
- title = [unit['title']]
- story = TitleStory(story, data=title, style=6)
- content = unit['data']
- story = uTableStory(story, data=content)
-
- self._appendixid.next()
- self._story += story.storylist
+ def create(self, ofile):
+ self.create_pdf()
+ self.create_story()
+ self.save_pdf(ofile)
+
+ def add_context(self):
+ context = self._provider.get_context
+ self._story += self._raw_context(context)
+
+ def _raw_context(self, context, ci=0, si=0, ui=0, level=-1):
+ _story = []
+ for key, value in sorted(context.items()):
+ LOG.info(key)
+ LOG.info(value)
+ _sn, _node, _style = candy.text2tuple(key)
+ if _node in candy.dom:
+ if _node == candy.chapter:
+ ci = _style
+ elif _node == candy.section:
+ si = _style
+ else:
+ ui = _style
+ _story += self._raw_context(value, ci, si, ui, level + 1)
+
+ else:
+ story = Story()
+ LOG.info("node: %s %s" % (_node, candy.title))
+ if _node == candy.title:
+ assert value
+ if level in range(len(candy.dom)):
+ if level == 0:
+ value[0] = "Chapter %s %s" % (ci, value[0])
+ story = PageBreakStory(story)
+ elif level == 1:
+ value[0] = "%s.%s %s" % (ci, si, value[0])
+ else:
+ value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0])
+ LOG.info(value)
+ story = TitleStory(story, data=value, style=_style)
+ elif _node == candy.table:
+ story = TableStory(story, data=value, style=_style)
+ elif _node == candy.figure:
+ story = ImageStory(story, data=value, style=_style)
+ elif _node == candy.paragraph:
+ story = ParagraphStory(story, data=value, style=_style)
+ elif _node == candy.plot:
+ story = LinePlotStory(story, data=value, style=_style)
+ elif _node == candy.chart:
+ story = BarChartStory(story, data=value, style=_style)
+ elif _node == candy.space:
+ assert isinstance(value, int)
+ for i in range(value):
+ story = SpaceStory(story)
+ _story += story.storylist
+ return _story
def main():
- dbase = DbManage()
- taskid = dbase.get_last_taskid()
- common_data = CommonData(taskid, dbase)
- scenario_list = common_data.get_scenariolist()
- history_data = HistoryData(taskid, dbase)
- for scenario in scenario_list:
- out_file = "vstf_report_%s.pdf" % (scenario)
- scenario_data = ScenarioData(taskid, dbase, scenario)
- reporter = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data)
- if reporter:
- reporter.create()
+ from vstf.common.log import setup_logging
+ setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-creator.log", clevel=logging.INFO)
+
+ out_file = "vstf_report.pdf"
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ reporter = PdfCreator(provider)
+ reporter.create(out_file)
if __name__ == '__main__':
main()
diff --git a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
index 819a5c57..69c65401 100755
--- a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
+++ b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
@@ -1,13 +1,21 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 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 time
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus import PageBreak
from vstf.controller.reporters.report.pdf.styles import TemplateStyle, ps_head_lv1, ps_head_lv2, ps_head_lv3
+import vstf.common.constants as cst
-class MyDocTemplate(SimpleDocTemplate):
+class BaseDocTemplate(SimpleDocTemplate):
def __init__(self, filename, **kw):
self.allowSplitting = 0
SimpleDocTemplate.__init__(self, filename, **kw)
@@ -25,17 +33,16 @@ class MyDocTemplate(SimpleDocTemplate):
self.notify('TOCEntry', (2, text, self.page - 1))
-class PdfTemplate:
- def __init__(self, style, title, logo, header, footer, output, note=None):
- self._style = style
+class PdfTemplate(object):
+ def __init__(self, title, logo, header, footer, note=[], style="default"):
+ self._style = TemplateStyle(name=style)
self._title = title
self._logo = logo[0]
- self._header = header[0]
+ #self._header = header[0]
self._footer = footer
- self._output = output[0]
self._note = note
- info = " Generated on %s " % time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())
- self._note[0] += info
+ info = " Generated on %s " % time.strftime(cst.TIME_FORMAT2, time.localtime())
+ self._note += [info]
def myFirstPage(self, canvas, doc):
raise NotImplementedError("abstract StoryDecorator")
@@ -43,9 +50,9 @@ class PdfTemplate:
def myLaterPages(self, canvas, doc):
raise NotImplementedError("abstract StoryDecorator")
- def generate(self, story):
+ def generate(self, story, output):
sizes = (self._style.page_wight, self._style.page_height)
- doc = MyDocTemplate(self._output, pagesize=sizes)
+ doc = BaseDocTemplate(output, pagesize=sizes)
# doc.build(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
doc.multiBuild(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages)
diff --git a/vstf/vstf/controller/reporters/report/pdf/story.py b/vstf/vstf/controller/reporters/report/pdf/story.py
index 3e56e185..940c20fb 100755
--- a/vstf/vstf/controller/reporters/report/pdf/story.py
+++ b/vstf/vstf/controller/reporters/report/pdf/story.py
@@ -1,5 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
__doc__ = """
Story Decorator contains ImageStory, HeaderStory, PageBreakStory,
TableStory, LinePlotStory, TitleStory, ParagraphStory
@@ -88,44 +95,32 @@ class TableOfContentsStory(StoryDecorator):
self._story.storylist.append(toc)
-class uTableStory(StoryDecorator):
- def new_story(self):
- print "utable story"
- style = ts_left
- if not self._data:
- print "data error "
- return
- self._story.storylist.append(eCommonTable(self._data, style).table)
-
-
-class TableStory(StoryDecorator):
- def new_story(self):
- print "table story"
- style = ts_default
- self._story.storylist.append(eDataTable(self._data, style).table)
-
-
class SpaceStory(StoryDecorator):
def new_story(self):
style = ps_space
self._story.storylist.append(eParagraph([" ", " "], style).para)
-class cTableStory(StoryDecorator):
+class TableStory(StoryDecorator):
def new_story(self):
print "table story"
style = ts_default
- if self._style == 0:
+ if self._style == 1:
+ self._story.storylist.append(eDataTable(self._data, style).table)
+ elif self._style ==2:
+ style = ts_left
+ self._story.storylist.append(eCommonTable(self._data, style).table)
+ elif self._style == 3:
self._story.storylist.append(eConfigTable(self._data, style).table)
- elif self._style == 1:
+ elif self._style == 4:
self._story.storylist.append(eOptionsTable(self._data, style).table)
- elif self._style == 2:
+ elif self._style == 5:
self._story.storylist.append(eProfileTable(self._data, style).table)
- elif self._style == 3:
+ elif self._style == 6:
self._story.storylist.append(eSummaryTable(self._data, style).table)
- elif self._style == 4:
+ elif self._style == 7:
self._story.storylist.append(eScenarioTable(self._data, style).table)
- elif self._style == 5:
+ elif self._style == 8:
self._story.storylist.append(eGitInfoTable(self._data, style).table)
diff --git a/vstf/vstf/controller/reporters/report/pdf/styles.py b/vstf/vstf/controller/reporters/report/pdf/styles.py
index d54ee8ab..2860c245 100755
--- a/vstf/vstf/controller/reporters/report/pdf/styles.py
+++ b/vstf/vstf/controller/reporters/report/pdf/styles.py
@@ -1,10 +1,17 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
from reportlab.lib.styles import PropertySet
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import ParagraphStyle
-from reportlab.lib.enums import TA_LEFT
+import reportlab.lib.enums as ens
class TemplateStyle(PropertySet):
@@ -108,20 +115,14 @@ class BarChartStyle(PropertySet):
"fastlink": (colors.pink, '%4.1f'),
"l2switch": (colors.lightblue, '%4.1f'),
"kernel rdp": (colors.lightgreen, '%4.1f'),
+ "ovs": (colors.purple, '%4.1f')
},
background=colors.lightgrey,
labelsfont=6,
)
-ts_left = TableStyle(
- name='left',
- table_hAlign='LEFT', # LEFT,CENTRE or RIGHT
- table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP
- table_colWidths=None,
- table_rowHeights=None
-)
-
+tes_default = TemplateStyle(name='default')
is_default = ImageStyle(name='default')
is_traffic = ImageStyle(name='traffic',
image_height=150,
@@ -129,12 +130,19 @@ is_traffic = ImageStyle(name='traffic',
image_hAlign='CENTRE')
ts_default = TableStyle(name='default')
+ts_left = TableStyle(
+ name='left',
+ table_hAlign='LEFT', # LEFT,CENTRE or RIGHT
+ table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP
+ table_colWidths=None,
+ table_rowHeights=None
+)
lps_default = LinePlotStyle(name='default')
lcs_default = LineChartStyle(name='default')
bcs_default = BarChartStyle(name='default')
ps_head_lv1 = ParagraphStyle(name='ps_head_lv1',
fontName='Courier-Bold',
- alignment=TA_LEFT, # TA_CENTRE,
+ alignment=ens.TA_CENTER, # TA_LEFT, TA_RIGHT
fontSize=13,
leading=22,
leftIndent=0)
diff --git a/vstf/vstf/controller/reporters/report/provider/__init__.py b/vstf/vstf/controller/reporters/report/provider/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/reporters/report/provider/__init__.py
+++ b/vstf/vstf/controller/reporters/report/provider/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/controller/reporters/report/provider/html_provider.py b/vstf/vstf/controller/reporters/report/provider/html_provider.py
index b0b07432..74c4c593 100755
--- a/vstf/vstf/controller/reporters/report/provider/html_provider.py
+++ b/vstf/vstf/controller/reporters/report/provider/html_provider.py
@@ -1,63 +1,45 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 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 logging
LOG = logging.getLogger(__name__)
from vstf.controller.settings.html_settings import HtmlSettings
-from vstf.controller.settings.data_settings import DataSettings
+from vstf.controller.settings.template_settings import TemplateSettings
class HtmlProvider(object):
- def __init__(self, content, style):
- self._content = content
+ def __init__(self, info, style):
+ self._info = info
self._style = style
+ @property
def get_style(self):
+ assert "style" in self._style
return self._style["style"]
- def get_subject(self):
- return self._content["subject"]
-
- def get_ovs_title(self):
- return self._content["ovs"]["title"]
-
- def get_ovs_table(self):
- return map(lambda x: list(x), self._content["ovs"]["content"].items())
-
- def get_result_title(self):
- return self._content["result"]["title"]
-
- def get_result_table(self, ttype):
- result = []
- content = self._content["result"]["content"]
- if ttype in content:
- result.append(content[ttype]["columns"])
- result.extend(content[ttype]["data"])
-
- result = map(lambda x: list(x), zip(*result))
- return result
-
-
-class StyleProvider(object):
- def __init__(self, style):
- self._style = style
-
- def get_style(self):
- return self._style["style"]
+ @property
+ def get_context(self):
+ assert "context" in self._info
+ return self._info["context"]
-def unit_test():
+def main():
from vstf.common.log import setup_logging
setup_logging(level=logging.DEBUG, log_file="/var/log/html-provder.log", clevel=logging.INFO)
html_settings = HtmlSettings()
LOG.info(html_settings.settings)
- data_settings = DataSettings()
- LOG.info(data_settings.settings)
+ info = TemplateSettings()
+ provider = HtmlProvider(info.settings, html_settings.settings)
+ LOG.info(provider.get_style)
+ LOG.info(provider.get_context)
- hprovider = HtmlProvider(data_settings.settings, html_settings.settings)
- sprovider = StyleProvider(html_settings.settings)
+if __name__ == '__main__':
+ main() \ No newline at end of file
diff --git a/vstf/vstf/controller/reporters/report/provider/pdf_provider.py b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py
new file mode 100755
index 00000000..bc9f0e96
--- /dev/null
+++ b/vstf/vstf/controller/reporters/report/provider/pdf_provider.py
@@ -0,0 +1,51 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
+
+
+__version__ = ''' '''
+import logging
+
+LOG = logging.getLogger(__name__)
+from vstf.controller.settings.template_settings import TemplateSettings
+
+
+class PdfProvider(object):
+ def __init__(self, info):
+ self._info = info
+
+ @property
+ def get_theme(self):
+ assert "theme" in self._info
+ return self._info["theme"]
+
+ @property
+ def ifcontents(self):
+ assert "contents" in self._info
+ assert "enable" in self._info["contents"]
+ return self._info["contents"]["enable"]
+
+ @property
+ def get_context(self):
+ assert "context" in self._info
+ return self._info["context"]
+
+
+def main():
+ from vstf.common.log import setup_logging
+ setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO)
+
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ LOG.info(provider.get_theme)
+ LOG.info(provider.ifcontents)
+ LOG.info(provider.get_context)
+
+if __name__ == '__main__':
+ main() \ No newline at end of file
diff --git a/vstf/vstf/controller/reporters/reporter.py b/vstf/vstf/controller/reporters/reporter.py
index 1c256c61..e77ae349 100755
--- a/vstf/vstf/controller/reporters/reporter.py
+++ b/vstf/vstf/controller/reporters/reporter.py
@@ -1,21 +1,28 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-05-29
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 os
import argparse
import logging
import time
-from vstf.controller.reporters.report.pdf.pdfcreator import PdfvSwitchCreator
-from vstf.controller.reporters.report.html.htmlcreator import HtmlvSwitchCreator
-from vstf.controller.reporters.report.data_factory import CommonData, TaskData, ScenarioData, HistoryData
+from vstf.controller.reporters.report.provider.html_provider import HtmlProvider
+from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider
+from vstf.controller.settings.template_settings import TemplateSettings
+from vstf.controller.reporters.report.data_factory import TaskData
+from vstf.controller.reporters.report.html.htmlcreator import HtmlCreator
+from vstf.controller.reporters.report.pdf.pdfcreator import PdfCreator
from vstf.controller.database.dbinterface import DbManage
from vstf.controller.settings.mail_settings import MailSettings
from vstf.controller.reporters.mail.sendmail import SendMail
from vstf.controller.settings.html_settings import HtmlSettings
-from vstf.controller.reporters.report.provider.html_provider import StyleProvider
+from vstf.controller.reporters.report.candy_generator import CandyGenerator
import vstf.common.constants as cst
@@ -31,37 +38,44 @@ class Report(object):
"""
self._dbase = dbase
self._rpath = "."
+ self._mail_settings = MailSettings()
if os.path.exists(rpath):
self._rpath = rpath
def create_pdf(self, taskid):
- common_data = CommonData(taskid, self._dbase)
- scenario_list = common_data.get_scenariolist()
- history_data = HistoryData(taskid, self._dbase)
+ task = TaskData(taskid, self._dbase)
+ scenario_list = task.common.get_scenariolist()
+ creator = CandyGenerator(task)
attach_list = []
for scenario in scenario_list:
- out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_STR)))
+ out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_FORMAT3)))
LOG.info(out_file)
- scenario_data = ScenarioData(taskid, self._dbase, scenario)
- pdf = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data)
- if pdf:
- pdf.create()
- attach_list.append(out_file)
+ creator.create(scenario)
+ info = TemplateSettings()
+ provider = PdfProvider(info.settings)
+ reporter = PdfCreator(provider)
+ reporter.create(out_file)
+ attach_list.append(out_file)
+
if attach_list:
self._mail_settings.mset_attach(attach_list)
def create_html(self, taskid):
- task_data = TaskData(taskid, self._dbase)
+ task = TaskData(taskid, self._dbase)
+
+ creator = CandyGenerator(task)
+ creator.create_all()
html_settings = HtmlSettings()
+ info = TemplateSettings()
LOG.info(html_settings.settings)
- provider = StyleProvider(html_settings.settings)
+ provider = HtmlProvider(info.settings, html_settings.settings)
out_file = os.path.join(self._rpath, "mail.html")
LOG.info(out_file)
- html = HtmlvSwitchCreator(task_data, provider, out_file)
- content = html.create()
+ html = HtmlCreator(provider)
+ content = html.create(out_file)
self._mail_settings.mset_subtype('html')
self._mail_settings.mset_content(content)
diff --git a/vstf/vstf/controller/res/__init__.py b/vstf/vstf/controller/res/__init__.py
deleted file mode 100755
index 89dcd4e2..00000000
--- a/vstf/vstf/controller/res/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
diff --git a/vstf/vstf/controller/settings/__init__.py b/vstf/vstf/controller/settings/__init__.py
index 89dcd4e2..83b8d15d 100755
--- a/vstf/vstf/controller/settings/__init__.py
+++ b/vstf/vstf/controller/settings/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
diff --git a/vstf/vstf/controller/settings/cpu_settings.py b/vstf/vstf/controller/settings/cpu_settings.py
index c69742ad..a25af4c1 100755
--- a/vstf/vstf/controller/settings/cpu_settings.py
+++ b/vstf/vstf/controller/settings/cpu_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
import pprint
diff --git a/vstf/vstf/controller/settings/data_settings.py b/vstf/vstf/controller/settings/data_settings.py
deleted file mode 100755
index d9878bf2..00000000
--- a/vstf/vstf/controller/settings/data_settings.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-
-import logging
-
-import vstf.controller.settings.settings as sets
-
-LOG = logging.getLogger(__name__)
-
-
-class DataSettings(sets.Settings):
- def __init__(self, path="/etc/vstf/reporter/",
- filename="reporters.html.data-settings",
- mode=sets.SETS_SINGLE):
- super(DataSettings, self).__init__(path, filename, mode)
-
- def _register_func(self):
- super(DataSettings, self)._register_func()
- items = {"ovs", "result"}
- fkeys = {"title", "content"}
- for item in items:
- item = item.encode()
- for key in fkeys:
- key = key.encode()
- func_name = "set_%s_%s" % (item, key)
- setattr(self, func_name, self._setting_file(func_name, self._mset[item], self._fset[item], key))
- func_name = "mset_%s_%s" % (item, key)
- setattr(self, func_name, self._setting_memory(func_name, self._mset[item], key)) \ No newline at end of file
diff --git a/vstf/vstf/controller/settings/device_settings.py b/vstf/vstf/controller/settings/device_settings.py
index 45bc9eb1..25f2c5bf 100755
--- a/vstf/vstf/controller/settings/device_settings.py
+++ b/vstf/vstf/controller/settings/device_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/settings/flows_settings.py b/vstf/vstf/controller/settings/flows_settings.py
index b2bec625..9cd1a1b7 100755
--- a/vstf/vstf/controller/settings/flows_settings.py
+++ b/vstf/vstf/controller/settings/flows_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-18
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/settings/forwarding_settings.py b/vstf/vstf/controller/settings/forwarding_settings.py
index 67ec3f85..636ddfda 100755
--- a/vstf/vstf/controller/settings/forwarding_settings.py
+++ b/vstf/vstf/controller/settings/forwarding_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/settings/html_settings.py b/vstf/vstf/controller/settings/html_settings.py
index 7e715100..ce87733e 100755
--- a/vstf/vstf/controller/settings/html_settings.py
+++ b/vstf/vstf/controller/settings/html_settings.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-25
-# see license for license details
-__version__ = ''' '''
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/settings/mail_settings.py b/vstf/vstf/controller/settings/mail_settings.py
index fd66b5c2..a2d2d6df 100755
--- a/vstf/vstf/controller/settings/mail_settings.py
+++ b/vstf/vstf/controller/settings/mail_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-06
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
import pprint
diff --git a/vstf/vstf/controller/settings/perf_settings.py b/vstf/vstf/controller/settings/perf_settings.py
index c0c8123b..610cb4ae 100755
--- a/vstf/vstf/controller/settings/perf_settings.py
+++ b/vstf/vstf/controller/settings/perf_settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-28
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 pprint
import logging
@@ -50,7 +53,7 @@ class PerfSettings(sets.Settings):
@deco.dcheck('sizes')
@deco.dcheck("type", choices=cst.TTYPES)
- @deco.dcheck("profile", choices=cst.PROFILES)
+ @deco.dcheck("profile", choices=cst.PROVIDERS)
@deco.dcheck("protocol", choices=cst.TPROTOCOLS)
@deco.dcheck("tool", choices=cst.TOOLS)
@deco.dcheck('case')
@@ -74,7 +77,7 @@ class PerfSettings(sets.Settings):
@deco.vstf_input('sizes', types=list)
@deco.vstf_input("type", types=str, choices=cst.TTYPES)
- @deco.vstf_input("profile", types=str, choices=cst.PROFILES)
+ @deco.vstf_input("profile", types=str, choices=cst.PROVIDERS)
@deco.vstf_input("protocol", types=str, choices=cst.TPROTOCOLS)
@deco.vstf_input("tool", types=str, choices=cst.TOOLS)
@deco.vstf_input('case')
diff --git a/vstf/vstf/controller/settings/settings.py b/vstf/vstf/controller/settings/settings.py
index 4730c8db..2c712bb2 100755
--- a/vstf/vstf/controller/settings/settings.py
+++ b/vstf/vstf/controller/settings/settings.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-06
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 re
diff --git a/vstf/vstf/controller/settings/settings_input.py b/vstf/vstf/controller/settings/settings_input.py
index 2c262842..59652ed5 100755
--- a/vstf/vstf/controller/settings/settings_input.py
+++ b/vstf/vstf/controller/settings/settings_input.py
@@ -1,9 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-10-16
-# see license for license details
-
+##############################################################################
+# Copyright (c) 2015 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 clize
from sigtools.modifiers import autokwoargs
diff --git a/vstf/vstf/controller/settings/template_settings.py b/vstf/vstf/controller/settings/template_settings.py
new file mode 100755
index 00000000..b677c539
--- /dev/null
+++ b/vstf/vstf/controller/settings/template_settings.py
@@ -0,0 +1,22 @@
+##############################################################################
+# Copyright (c) 2015 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 logging
+
+import vstf.controller.settings.settings as sets
+
+LOG = logging.getLogger(__name__)
+
+
+class TemplateSettings(sets.Settings):
+ def __init__(self, path="/etc/vstf/reporter/",
+ filename="reporters.template-settings",
+ mode=sets.SETS_SINGLE):
+ super(TemplateSettings, self).__init__(path, filename, mode)
diff --git a/vstf/vstf/controller/settings/tester_settings.py b/vstf/vstf/controller/settings/tester_settings.py
index fb116a8d..554c8042 100755
--- a/vstf/vstf/controller/settings/tester_settings.py
+++ b/vstf/vstf/controller/settings/tester_settings.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015/11/17
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/settings/tool_settings.py b/vstf/vstf/controller/settings/tool_settings.py
index 1d543e6a..a84bc59f 100755
--- a/vstf/vstf/controller/settings/tool_settings.py
+++ b/vstf/vstf/controller/settings/tool_settings.py
@@ -1,8 +1,12 @@
-#!/usr/bin/env python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-18
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
import pprint
diff --git a/vstf/vstf/controller/spirent/__init__.py b/vstf/vstf/controller/spirent/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/spirent/__init__.py
+++ b/vstf/vstf/controller/spirent/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/spirent/appliance.py b/vstf/vstf/controller/spirent/appliance.py
index a06bf452..d4c5be64 100755
--- a/vstf/vstf/controller/spirent/appliance.py
+++ b/vstf/vstf/controller/spirent/appliance.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-"""
- @author: l00190809
- @group: Huawei Ltd
-"""
+##############################################################################
+# Copyright (c) 2015 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 os
import logging
diff --git a/vstf/vstf/controller/spirent/common/__init__.py b/vstf/vstf/controller/spirent/common/__init__.py
index 0e98d82e..c354d1f9 100755
--- a/vstf/vstf/controller/spirent/common/__init__.py
+++ b/vstf/vstf/controller/spirent/common/__init__.py
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License. \ No newline at end of file
+# 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
+##############################################################################
diff --git a/vstf/vstf/controller/spirent/common/model.py b/vstf/vstf/controller/spirent/common/model.py
index 511eab40..a29794f4 100755
--- a/vstf/vstf/controller/spirent/common/model.py
+++ b/vstf/vstf/controller/spirent/common/model.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-"""
- @author: l00190809
- @group: Huawei Ltd
-"""
+##############################################################################
+# Copyright (c) 2015 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 re
import copy
import time
diff --git a/vstf/vstf/controller/spirent/common/result_analysis.py b/vstf/vstf/controller/spirent/common/result_analysis.py
index 162e3888..b09a846d 100755
--- a/vstf/vstf/controller/spirent/common/result_analysis.py
+++ b/vstf/vstf/controller/spirent/common/result_analysis.py
@@ -1,4 +1,12 @@
-#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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 re
diff --git a/vstf/vstf/controller/sw_perf/__init__.py b/vstf/vstf/controller/sw_perf/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/sw_perf/__init__.py
+++ b/vstf/vstf/controller/sw_perf/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/sw_perf/flow_producer.py b/vstf/vstf/controller/sw_perf/flow_producer.py
index 1de4161c..4a3b02c2 100755
--- a/vstf/vstf/controller/sw_perf/flow_producer.py
+++ b/vstf/vstf/controller/sw_perf/flow_producer.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-11-19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/sw_perf/model.py b/vstf/vstf/controller/sw_perf/model.py
index 672daade..c49df041 100755
--- a/vstf/vstf/controller/sw_perf/model.py
+++ b/vstf/vstf/controller/sw_perf/model.py
@@ -1,8 +1,11 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author:
-# date:
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
@@ -161,7 +164,11 @@ class CpuWatcher(Fabricant):
def __init__(self, dst, conn):
super(CpuWatcher, self).__init__(dst, conn)
self._pid = None
- self._data = {}
+ self._data = {
+ "cpu_num": 0,
+ "idle": 0,
+ "cpu_mhz": 0
+ }
def start(self):
print "CpuWatcher.start"
diff --git a/vstf/vstf/controller/sw_perf/perf_provider.py b/vstf/vstf/controller/sw_perf/perf_provider.py
index bd1027ad..396e6eef 100755
--- a/vstf/vstf/controller/sw_perf/perf_provider.py
+++ b/vstf/vstf/controller/sw_perf/perf_provider.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-21
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 logging
diff --git a/vstf/vstf/controller/sw_perf/performance.py b/vstf/vstf/controller/sw_perf/performance.py
index 6ca8160e..7e6467ee 100755
--- a/vstf/vstf/controller/sw_perf/performance.py
+++ b/vstf/vstf/controller/sw_perf/performance.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-09-19
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 time
import argparse
@@ -11,6 +15,7 @@ import logging
from vstf.controller.sw_perf import model
from vstf.common import perfmark as mark
import vstf.common.constants as cst
+import vstf.common.decorator as deco
from vstf.rpc_frame_work.rpc_producer import Server
from vstf.controller.settings.flows_settings import FlowsSettings
from vstf.controller.settings.tool_settings import ToolSettings
@@ -137,12 +142,12 @@ class Performance(object):
for watcher in self._watchers:
watcher.stop()
- def start_cpuwatcher(self):
- if self._cpuwatcher:
+ def start_cpuwatcher(self, enable=True):
+ if self._cpuwatcher and enable:
self._cpuwatcher.start()
- def stop_cpuwatcher(self):
- if self._cpuwatcher:
+ def stop_cpuwatcher(self, enable=True):
+ if self._cpuwatcher and enable:
self._cpuwatcher.stop()
def getlimitspeed(self, ptype, size):
@@ -167,22 +172,26 @@ class Performance(object):
self.destory(tool)
LOG.info("run_pre_affability_settings end")
+ @deco.check("ratep", defaults=0)
+ @deco.check("cpu_watch", defaults=False)
def run_bandwidth_test(self, tool, tpro, pktsize, **kwargs):
LOG.info("run_bandwidth_test ")
+ cpu_watch = kwargs.pop("cpu_watch")
self.create(tool, tpro)
self.start_receivers()
self.start_senders(pktsize, **kwargs)
time.sleep(self._provider.wait_balance(tool))
self.start_watchers()
- self.start_cpuwatcher()
+ self.start_cpuwatcher(cpu_watch)
time.sleep(self._provider.duration(tool))
self.stop_watchers()
- self.stop_cpuwatcher()
+ self.stop_cpuwatcher(cpu_watch)
self.stop_senders()
self.stop_receivers()
self.destory(tool)
LOG.info("run_bandwidth_test end")
+ @deco.check("ratep", defaults=0)
def run_latency_test(self, tool, tpro, pktsize, **kwargs):
LOG.info("run_latency_test start")
self.create(tool, tpro)
@@ -223,7 +232,7 @@ class Performance(object):
elif ttype in ['latency']:
lat_tpro = protocol + '_lat'
lat_type = ttype
- self.run_latency_test(tool, lat_tpro, size, ratep=None)
+ self.run_latency_test(tool, lat_tpro, size, ratep=0)
lat_result = self.result(tool, lat_type)
result[size] = lat_result
else:
@@ -242,8 +251,8 @@ class Performance(object):
mark.avgLatency: 0,
mark.maxLatency: 0,
mark.minLatency: 0,
- mark.rxMbps:0,
- mark.txMbps:0
+ mark.rxMbps: 0,
+ mark.txMbps: 0
}
cpu_data = self._cpuwatcher.result()
@@ -262,16 +271,22 @@ class Performance(object):
record[mark.rxMbps] += nic_data['rxmB/s']
record[mark.txMbps] += nic_data['txmB/s']
+ if record[mark.rxMbps] > record[mark.txMbps]:
+ record[mark.rxMbps], record[mark.txMbps] = record[mark.txMbps], record[mark.rxMbps]
+
+ if record[mark.rxCount] > record[mark.txCount]:
+ record[mark.rxCount], record[mark.txCount] = record[mark.txCount], record[mark.rxCount]
+
if record[mark.txCount]:
record[mark.percentLoss] = round(100 * (1 - record[mark.rxCount] / record[mark.txCount]),
- cst.PKTLOSS_ROUND)
+ cst.PKTLOSS_ROUND)
else:
record[mark.percentLoss] = 100
record[mark.bandwidth] /= 1000000.0
if cpu_mhz and record[mark.cpu]:
record[mark.mppsGhz] = round(record[mark.bandwidth] / (record[mark.cpu] * cpu_mhz / 100000),
- cst.CPU_USAGE_ROUND)
+ cst.CPU_USAGE_ROUND)
record[mark.bandwidth] = round(record[mark.bandwidth], cst.RATEP_ROUND)
@@ -349,7 +364,7 @@ def main():
)
parser.add_argument("profile",
action="store",
- choices=cst.PROFILES,
+ choices=cst.PROVIDERS,
)
parser.add_argument("type",
action="store",
diff --git a/vstf/vstf/controller/sw_perf/raw_data.py b/vstf/vstf/controller/sw_perf/raw_data.py
index dab749eb..aefb863d 100755
--- a/vstf/vstf/controller/sw_perf/raw_data.py
+++ b/vstf/vstf/controller/sw_perf/raw_data.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 subprocess
import re
import logging
diff --git a/vstf/vstf/controller/unittest/README b/vstf/vstf/controller/unittest/README
index f9414e95..61ef1a24 100755
--- a/vstf/vstf/controller/unittest/README
+++ b/vstf/vstf/controller/unittest/README
@@ -1,8 +1,4 @@
-"""
-Created on 2015-9-28
-@author: y00228926
-"""
the procedure to integrate a module unit testing into the unit testing framework:
diff --git a/vstf/vstf/controller/unittest/__init__.py b/vstf/vstf/controller/unittest/__init__.py
index 89dcd4e2..df7d24d0 100755
--- a/vstf/vstf/controller/unittest/__init__.py
+++ b/vstf/vstf/controller/unittest/__init__.py
@@ -1,14 +1,9 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/controller/unittest/configuration.py b/vstf/vstf/controller/unittest/configuration.py
index 9364bbbf..6312efa2 100755
--- a/vstf/vstf/controller/unittest/configuration.py
+++ b/vstf/vstf/controller/unittest/configuration.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-24
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
rabbit_mq_server = '192.168.188.10'
diff --git a/vstf/vstf/controller/unittest/model.py b/vstf/vstf/controller/unittest/model.py
index c4e992ce..4c38973e 100755
--- a/vstf/vstf/controller/unittest/model.py
+++ b/vstf/vstf/controller/unittest/model.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import unittest
from vstf.rpc_frame_work import rpc_producer
diff --git a/vstf/vstf/controller/unittest/test_cfg_intent_parse.py b/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
index 665732aa..a08607bb 100755
--- a/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
+++ b/vstf/vstf/controller/unittest/test_cfg_intent_parse.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-14
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import os
import unittest
diff --git a/vstf/vstf/controller/unittest/test_collect.py b/vstf/vstf/controller/unittest/test_collect.py
index f1d54a95..3e84d019 100755
--- a/vstf/vstf/controller/unittest/test_collect.py
+++ b/vstf/vstf/controller/unittest/test_collect.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import unittest
import json
diff --git a/vstf/vstf/controller/unittest/test_driver_function.py b/vstf/vstf/controller/unittest/test_driver_function.py
index 05804421..8d45c7b3 100755
--- a/vstf/vstf/controller/unittest/test_driver_function.py
+++ b/vstf/vstf/controller/unittest/test_driver_function.py
@@ -1,7 +1,12 @@
-"""
-Created on 2015-10-27
-@author: l00190809
-"""
+##############################################################################
+# Copyright (c) 2015 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 unittest
import json
diff --git a/vstf/vstf/controller/unittest/test_env_build.py b/vstf/vstf/controller/unittest/test_env_build.py
index 2d2d882b..e4529e48 100755
--- a/vstf/vstf/controller/unittest/test_env_build.py
+++ b/vstf/vstf/controller/unittest/test_env_build.py
@@ -1,8 +1,12 @@
-'''
-Created on 2015-9-28
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-'''
import unittest
import os
diff --git a/vstf/vstf/controller/unittest/test_perf.py b/vstf/vstf/controller/unittest/test_perf.py
index 5a54b826..0258ab65 100755
--- a/vstf/vstf/controller/unittest/test_perf.py
+++ b/vstf/vstf/controller/unittest/test_perf.py
@@ -1,8 +1,12 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-# author: wly
-# date: 2015-10-30
-# see license for license details
+##############################################################################
+# Copyright (c) 2015 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 unittest
import os
diff --git a/vstf/vstf/controller/unittest/test_ssh.py b/vstf/vstf/controller/unittest/test_ssh.py
index 844f8ff5..f2403551 100755
--- a/vstf/vstf/controller/unittest/test_ssh.py
+++ b/vstf/vstf/controller/unittest/test_ssh.py
@@ -1,8 +1,12 @@
-"""
-Created on 2015-10-10
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
-@author: y00228926
-"""
import unittest
from vstf.common import ssh
diff --git a/vstf/vstf/controller/vstfadm.py b/vstf/vstf/controller/vstfadm.py
index 068ab2e0..86641e7d 100755
--- a/vstf/vstf/controller/vstfadm.py
+++ b/vstf/vstf/controller/vstfadm.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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 sys
import logging
import json
@@ -105,9 +114,8 @@ def do_show_tasks(args):
@cliutil.arg("case", action="store", help="test case like Ti-1, Tn-1, Tnv-1, Tu-1, see case definition in documents")
-@cliutil.arg("tool", action="store", choices=cst.TOOLS, )
-@cliutil.arg("protocol", action="store", choices=cst.TPROTOCOLS, )
-@cliutil.arg("profile", action="store", choices=cst.PROFILES, )
+@cliutil.arg("tool", action="store", choices=cst.TOOLS)
+@cliutil.arg("protocol", action="store", choices=cst.TPROTOCOLS)
@cliutil.arg("type", action="store", choices=cst.TTYPES)
@cliutil.arg("sizes", action="store", default="64", help='test size list "64 128"')
@cliutil.arg("--affctl", action="store_true", help="when affctl is True, it will do affctl before testing")
@@ -118,7 +126,6 @@ def do_perf_test(args):
'case': args.case,
'tool': args.tool,
'protocol': args.protocol,
- 'profile': args.profile,
'type': args.type,
'sizes': map(lambda x: int(x), args.sizes.strip().split())
}
@@ -250,6 +257,13 @@ def do_affctl_list(args):
print_stdout(ret)
+@cliutil.arg("head", action="store", help="ip of head")
+@cliutil.arg("tail", action="store", help="ip of tail")
+def do_settings(args):
+ ret = call(make_msg("settings", head=args.head, tail=args.tail))
+ print_stdout(ret)
+
+
def main():
parser = VstfParser(prog="vstfadm", description="vstf administration")
parser.set_subcommand_parser(sys.modules[__name__], "functions")
diff --git a/vstf/vstf/rpc_frame_work/__init__.py b/vstf/vstf/rpc_frame_work/__init__.py
index 4dc8a6aa..547db686 100755
--- a/vstf/vstf/rpc_frame_work/__init__.py
+++ b/vstf/vstf/rpc_frame_work/__init__.py
@@ -1,15 +1,10 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.
-# All Rights Reserved.
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
-# Licensed under the Apache License, Version 2.0 (the License); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an AS IS BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# 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
+##############################################################################
+
diff --git a/vstf/vstf/rpc_frame_work/constant.py b/vstf/vstf/rpc_frame_work/constant.py
index da555dee..84d0592a 100755
--- a/vstf/vstf/rpc_frame_work/constant.py
+++ b/vstf/vstf/rpc_frame_work/constant.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+
fan_exchange = "esp_exchange"
exchange_d = "vstf_dexch"
queue_common = "vstf-"
diff --git a/vstf/vstf/rpc_frame_work/rpc_consumer.py b/vstf/vstf/rpc_frame_work/rpc_consumer.py
index f7aacfd6..fb54e5db 100755
--- a/vstf/vstf/rpc_frame_work/rpc_consumer.py
+++ b/vstf/vstf/rpc_frame_work/rpc_consumer.py
@@ -1,5 +1,12 @@
-#!/usr/bin/env python
-# coding=utf-8
+##############################################################################
+# Copyright (c) 2015 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 logging
import time
diff --git a/vstf/vstf/rpc_frame_work/rpc_producer.py b/vstf/vstf/rpc_frame_work/rpc_producer.py
index c56c9e5e..abf2a7fc 100755
--- a/vstf/vstf/rpc_frame_work/rpc_producer.py
+++ b/vstf/vstf/rpc_frame_work/rpc_producer.py
@@ -1,5 +1,12 @@
-#!/usr/bin/env python
-# coding=utf-8
+##############################################################################
+# Copyright (c) 2015 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 uuid
import json
import time