JIRA: BOTTLENECKS-29 63/7363/1
authorYiting.Li <liyiting@huawei.com>
Tue, 19 Jan 2016 06:39:31 +0000 (14:39 +0800)
committerJun Li <matthew.lijun@huawei.com>
Wed, 20 Jan 2016 01:23:27 +0000 (01:23 +0000)
 add the performance test framework

 add the copyright on the code.

Change-Id: I6ec9eefe65bf07c2dd6c636d1b90b64da303952e
Signed-off-by: Yiting.Li <liyiting@huawei.com>
(cherry picked from commit 5b4f794932cb9b28ec679e6dd88e6febb2a5db7b)

158 files changed:
vstf/README.rst
vstf/__init__.py
vstf/etc/vstf/perf/sw_perf.batch-settings
vstf/etc/vstf/perf/sw_perf.device-settings
vstf/etc/vstf/reporter/reporter.pdf.story-show [deleted file]
vstf/etc/vstf/reporter/reporters.html.data-settings [deleted file]
vstf/etc/vstf/reporter/reporters.template-settings [new file with mode: 0755]
vstf/install.sh
vstf/pylint.conf [changed mode: 0644->0755]
vstf/setup.cfg
vstf/setup.py [changed mode: 0644->0755]
vstf/vstf/__init__.py
vstf/vstf/agent/__init__.py
vstf/vstf/agent/agent.py
vstf/vstf/agent/env/__init__.py
vstf/vstf/agent/env/basic/__init__.py
vstf/vstf/agent/env/basic/collect.py
vstf/vstf/agent/env/basic/commandline.py
vstf/vstf/agent/env/basic/device_manager.py
vstf/vstf/agent/env/basic/image_manager.py
vstf/vstf/agent/env/basic/source_manager.py
vstf/vstf/agent/env/basic/vm9pfs.py
vstf/vstf/agent/env/basic/vm_manager.py
vstf/vstf/agent/env/basic/vm_xml_help.py
vstf/vstf/agent/env/builder.py
vstf/vstf/agent/env/driver_plugins/__init__.py
vstf/vstf/agent/env/driver_plugins/manager.py
vstf/vstf/agent/env/driver_plugins/model.py
vstf/vstf/agent/env/driver_plugins/origin_driver.py
vstf/vstf/agent/env/fsmonitor/FSMonitor.py
vstf/vstf/agent/env/fsmonitor/__init__.py
vstf/vstf/agent/env/fsmonitor/constant.py
vstf/vstf/agent/env/fsmonitor/utils.py
vstf/vstf/agent/env/plugins/__init__.py
vstf/vstf/agent/env/plugins/libvirt_plugin.py
vstf/vstf/agent/env/plugins/model.py
vstf/vstf/agent/env/plugins/tester_env_plugin.py
vstf/vstf/agent/env/vswitch_plugins/__init__.py
vstf/vstf/agent/env/vswitch_plugins/bridge_plugin.py
vstf/vstf/agent/env/vswitch_plugins/manager.py
vstf/vstf/agent/env/vswitch_plugins/model.py
vstf/vstf/agent/env/vswitch_plugins/ovs_plugin.py
vstf/vstf/agent/equalizer/__init__.py
vstf/vstf/agent/equalizer/equalizer.py
vstf/vstf/agent/equalizer/get_info.py
vstf/vstf/agent/equalizer/optimize.py
vstf/vstf/agent/perf/__init__.py
vstf/vstf/agent/perf/affctl.py
vstf/vstf/agent/perf/ethtool.py
vstf/vstf/agent/perf/iperf.py
vstf/vstf/agent/perf/netmap.py
vstf/vstf/agent/perf/netns.py
vstf/vstf/agent/perf/netperf.py
vstf/vstf/agent/perf/pktgen.py
vstf/vstf/agent/perf/qperf.py
vstf/vstf/agent/perf/sar.py
vstf/vstf/agent/perf/utils.py
vstf/vstf/agent/perf/vnstat.py
vstf/vstf/agent/perf/vstfperf.py
vstf/vstf/agent/softagent.py
vstf/vstf/agent/spirent/__init__.py
vstf/vstf/agent/spirent/spirent.py
vstf/vstf/agent/spirentagent.py
vstf/vstf/common/__init__.py
vstf/vstf/common/candy_text.py [new file with mode: 0755]
vstf/vstf/common/cfgparser.py
vstf/vstf/common/check.py
vstf/vstf/common/cliutil.py
vstf/vstf/common/cmds.py
vstf/vstf/common/constants.py
vstf/vstf/common/daemon.py
vstf/vstf/common/decorator.py
vstf/vstf/common/excepts.py
vstf/vstf/common/input.py
vstf/vstf/common/log.py
vstf/vstf/common/message.py
vstf/vstf/common/perfmark.py
vstf/vstf/common/pyhtml.py
vstf/vstf/common/rsync.py
vstf/vstf/common/saltstack.py
vstf/vstf/common/ssh.py
vstf/vstf/common/test_func.py
vstf/vstf/common/unix.py
vstf/vstf/common/utils.py
vstf/vstf/common/vstfcli.py
vstf/vstf/controller/__init__.py
vstf/vstf/controller/api_server.py
vstf/vstf/controller/database/__init__.py
vstf/vstf/controller/database/constants.py
vstf/vstf/controller/database/dbinterface.py
vstf/vstf/controller/database/tables.py
vstf/vstf/controller/env_build/__init__.py
vstf/vstf/controller/env_build/cfg_intent_parse.py
vstf/vstf/controller/env_build/env_build.py
vstf/vstf/controller/env_build/env_collect.py
vstf/vstf/controller/fabricant.py
vstf/vstf/controller/reporters/__init__.py
vstf/vstf/controller/reporters/mail/__init__.py
vstf/vstf/controller/reporters/mail/mail.py
vstf/vstf/controller/reporters/mail/sendmail.py
vstf/vstf/controller/reporters/report/__init__.py
vstf/vstf/controller/reporters/report/candy_generator.py [new file with mode: 0755]
vstf/vstf/controller/reporters/report/data_factory.py
vstf/vstf/controller/reporters/report/html/__init__.py
vstf/vstf/controller/reporters/report/html/html_base.py
vstf/vstf/controller/reporters/report/html/html_text.py [deleted file]
vstf/vstf/controller/reporters/report/html/htmlcreator.py
vstf/vstf/controller/reporters/report/pdf/__init__.py
vstf/vstf/controller/reporters/report/pdf/element.py
vstf/vstf/controller/reporters/report/pdf/pdfcreator.py
vstf/vstf/controller/reporters/report/pdf/pdftemplate.py
vstf/vstf/controller/reporters/report/pdf/story.py
vstf/vstf/controller/reporters/report/pdf/styles.py
vstf/vstf/controller/reporters/report/provider/__init__.py
vstf/vstf/controller/reporters/report/provider/html_provider.py
vstf/vstf/controller/reporters/report/provider/pdf_provider.py [new file with mode: 0755]
vstf/vstf/controller/reporters/reporter.py
vstf/vstf/controller/res/__init__.py [deleted file]
vstf/vstf/controller/settings/__init__.py
vstf/vstf/controller/settings/cpu_settings.py
vstf/vstf/controller/settings/data_settings.py [deleted file]
vstf/vstf/controller/settings/device_settings.py
vstf/vstf/controller/settings/flows_settings.py
vstf/vstf/controller/settings/forwarding_settings.py
vstf/vstf/controller/settings/html_settings.py
vstf/vstf/controller/settings/mail_settings.py
vstf/vstf/controller/settings/perf_settings.py
vstf/vstf/controller/settings/settings.py
vstf/vstf/controller/settings/settings_input.py
vstf/vstf/controller/settings/template_settings.py [new file with mode: 0755]
vstf/vstf/controller/settings/tester_settings.py
vstf/vstf/controller/settings/tool_settings.py
vstf/vstf/controller/spirent/__init__.py
vstf/vstf/controller/spirent/appliance.py
vstf/vstf/controller/spirent/common/__init__.py
vstf/vstf/controller/spirent/common/model.py
vstf/vstf/controller/spirent/common/result_analysis.py
vstf/vstf/controller/sw_perf/__init__.py
vstf/vstf/controller/sw_perf/flow_producer.py
vstf/vstf/controller/sw_perf/model.py
vstf/vstf/controller/sw_perf/perf_provider.py
vstf/vstf/controller/sw_perf/performance.py
vstf/vstf/controller/sw_perf/raw_data.py
vstf/vstf/controller/unittest/README
vstf/vstf/controller/unittest/__init__.py
vstf/vstf/controller/unittest/configuration.py
vstf/vstf/controller/unittest/model.py
vstf/vstf/controller/unittest/test_cfg_intent_parse.py
vstf/vstf/controller/unittest/test_collect.py
vstf/vstf/controller/unittest/test_driver_function.py
vstf/vstf/controller/unittest/test_env_build.py
vstf/vstf/controller/unittest/test_perf.py
vstf/vstf/controller/unittest/test_ssh.py
vstf/vstf/controller/vstfadm.py
vstf/vstf/rpc_frame_work/__init__.py
vstf/vstf/rpc_frame_work/constant.py
vstf/vstf/rpc_frame_work/rpc_consumer.py
vstf/vstf/rpc_frame_work/rpc_producer.py

index 0e4e83c..ae18790 100755 (executable)
@@ -1,2 +1,2 @@
-welcome to open vstf(Virtual Switch Test Framwork
+welcome to open vstf(Virtual Switch Test Framework
 )
index e69de29..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index 7926877..83c6970 100755 (executable)
@@ -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]
         }
index a91340b..e0dac25 100755 (executable)
@@ -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 (executable)
index 514a0cc..0000000
+++ /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 (executable)
index 5c4e32b..0000000
+++ /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 (executable)
index 0000000..f0e4a29
--- /dev/null
@@ -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", "", "", "", "", ""]
+                ]
+            }
+        }
+
+    }
+}
index 2aae6f5..10a46f4 100755 (executable)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 4dce398..662f75f 100755 (executable)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 7363757..bdecb37
@@ -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
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index 396b571..b574599 100755 (executable)
@@ -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):
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index bc4f1ee..126a7d5 100755 (executable)
@@ -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
index 0df037d..e4df9b2 100755 (executable)
@@ -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
index 3209d7c..8b5387f 100755 (executable)
@@ -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
index 6c7df70..c3b5c6b 100755 (executable)
@@ -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
index 4267cbd..6edd14c 100755 (executable)
@@ -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
index f3a2c2c..7364f8b 100755 (executable)
@@ -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
index e59d6c7..60a3b37 100755 (executable)
@@ -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
index d311625..6f9131e 100755 (executable)
@@ -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>
index ebd3d3d..a66a887 100755 (executable)
@@ -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
index e69de29..fc9802b 100755 (executable)
@@ -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
index 3bb3fad..6f89565 100755 (executable)
@@ -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
 
 
index 3a0b184..ddc0744 100755 (executable)
@@ -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
 
index 850d785..bf3c15c 100755 (executable)
@@ -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
 
index 7102970..e655936 100755 (executable)
@@ -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
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index d30bb43..33b37eb 100755 (executable)
@@ -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'
index e6eb153..5bdb415 100755 (executable)
@@ -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
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index e7fefb6..27af806 100755 (executable)
@@ -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
index 5485f97..b19ceb9 100755 (executable)
@@ -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
 
index 0fd4b9a..0682aac 100755 (executable)
@@ -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
 
index e69de29..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index 252f190..21b8f82 100755 (executable)
@@ -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
 
index 00115df..785a1db 100755 (executable)
@@ -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
 
 
index a4d8b3b..5d70041 100755 (executable)
@@ -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
 
index 4604595..7ea56d4 100755 (executable)
@@ -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
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 8db35df..30e1de1 100755 (executable)
@@ -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
index 873f0ca..0c92f97 100755 (executable)
@@ -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:
index 941769a..5a09900 100755 (executable)
@@ -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
 
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index e9b9692..5b20363 100755 (executable)
@@ -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
 
index c214a56..3f4a372 100755 (executable)
@@ -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
 
index 25728b7..3105be4 100755 (executable)
@@ -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
index c61d257..88a2544 100755 (executable)
@@ -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
index d5552fa..c3b7386 100755 (executable)
@@ -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
index fab1fc1..99f1c90 100755 (executable)
@@ -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
index 58c0e6c..671e1aa 100755 (executable)
@@ -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
index 3cb9eaf..f84f9c2 100755 (executable)
@@ -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
index c4688c9..0231d5c 100755 (executable)
@@ -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
index 1fb4b92..4f7ddb6 100755 (executable)
@@ -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
index 7a47af1..b12ac1a 100755 (executable)
@@ -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
index 224380f..8be3c4e 100755 (executable)
@@ -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]
index 6f97239..6271a09 100755 (executable)
@@ -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
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index 3b073cb..904de73 100755 (executable)
@@ -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
index 04a9dc9..8951f96 100755 (executable)
@@ -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
 
 
index 89dcd4e..df7d24d 100755 (executable)
@@ -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 (executable)
index 0000000..818ae76
--- /dev/null
@@ -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
index 3d50a1b..9de5a2c 100755 (executable)
@@ -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
 
index 9b2f3d0..2ceddc0 100755 (executable)
@@ -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
index 91ff7f1..541bba7 100755 (executable)
@@ -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.
 
index c30f2be..2952be2 100755 (executable)
@@ -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
 
index 1cace39..e054043 100755 (executable)
@@ -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 = {
index 8a29861..1085d36 100755 (executable)
@@ -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
index cafbb3f..98d539f 100755 (executable)
@@ -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()
 
 
index dc781b9..833eefa 100755 (executable)
@@ -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
index 9e2f933..4f1532e 100755 (executable)
@@ -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'
index b34a8a9..415b003 100755 (executable)
@@ -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
 
 
index 926091f..d496990 100755 (executable)
@@ -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
index f03ee53..5edfe3a 100755 (executable)
@@ -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'
index c2a2620..f3adee8 100755 (executable)
@@ -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 = ''
 
index b566136..2209dfd 100755 (executable)
-#!/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:]))
index efc953c..030bef5 100755 (executable)
@@ -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
index 1f7eddc..7b85e08 100755 (executable)
@@ -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
index 9b1d24f..2a9a4c0 100755 (executable)
@@ -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
 
 
index f74944e..97582c7 100755 (executable)
@@ -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
index 542eaa8..f2e1409 100755 (executable)
@@ -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
index 9dc9977..896bb1d 100755 (executable)
@@ -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
 
index 4dc8a6a..df7d24d 100755 (executable)
@@ -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
+##############################################################################
 
index d354701..a37bf4c 100755 (executable)
@@ -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)
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index d1aef39..e507012 100755 (executable)
@@ -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
 
index ae34c86..d0996c3 100755 (executable)
@@ -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()
index a7658f4..0438d0e 100755 (executable)
@@ -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):
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index 8c7c10b..b536e3b 100755 (executable)
@@ -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
index 85ad5d2..1d201b7 100755 (executable)
@@ -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
index 888f71c..6e32a05 100755 (executable)
@@ -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
 
 
index c67bfa1..3b1c082 100755 (executable)
@@ -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
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 42d60b1..2241d9a 100755 (executable)
@@ -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
index ecc6fe9..a4d7bb0 100755 (executable)
@@ -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
index 89dcd4e..547db68 100755 (executable)
@@ -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 (executable)
index 0000000..ea29655
--- /dev/null
@@ -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()
+
index 39c534b..f9fc69d 100755 (executable)
@@ -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
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 270ef39..36be598 100755 (executable)
@@ -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 (executable)
index 86505b8..0000000
+++ /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()
index e6c75ca..1d150e2 100755 (executable)
-#!/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()
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 2528f2c..78d1c59 100755 (executable)
@@ -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
index 50b3bc6..4f7bd2a 100755 (executable)
-#!/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()
index 819a5c5..69c6540 100755 (executable)
@@ -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)
 
index 3e56e18..940c20f 100755 (executable)
@@ -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)
 
 
index d54ee8a..2860c24 100755 (executable)
@@ -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)
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index b0b0743..74c4c59 100755 (executable)
@@ -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 (executable)
index 0000000..bc9f0e9
--- /dev/null
@@ -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
index 1c256c6..e77ae34 100755 (executable)
@@ -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 (executable)
index 89dcd4e..0000000
+++ /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.
index 89dcd4e..83b8d15 100755 (executable)
@@ -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
+##############################################################################
index c69742a..a25af4c 100755 (executable)
@@ -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 (executable)
index d9878bf..0000000
+++ /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
index 45bc9eb..25f2c5b 100755 (executable)
@@ -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
 
index b2bec62..9cd1a1b 100755 (executable)
@@ -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
 
index 67ec3f8..636ddfd 100755 (executable)
@@ -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
 
index 7e71510..ce87733 100755 (executable)
@@ -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
 
index fd66b5c..a2d2d6d 100755 (executable)
@@ -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
index c0c8123..610cb4a 100755 (executable)
@@ -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')
index 4730c8d..2c712bb 100755 (executable)
@@ -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
index 2c26284..59652ed 100755 (executable)
@@ -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 (executable)
index 0000000..b677c53
--- /dev/null
@@ -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)
index fb116a8..554c804 100755 (executable)
@@ -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
 
index 1d543e6..a84bc59 100755 (executable)
@@ -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
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index a06bf45..d4c5be6 100755 (executable)
@@ -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
 
index 0e98d82..c354d1f 100755 (executable)
@@ -1,14 +1,8 @@
-# Copyright Huawei Technologies Co., Ltd. 1998-2015.\r
-# All Rights Reserved.\r
+##############################################################################\r
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.\r
 #\r
-#    Licensed under the Apache License, Version 2.0 (the License); you may\r
-#    not use this file except in compliance with the License. You may obtain\r
-#    a copy of the License at\r
-#\r
-#         http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-#    Unless required by applicable law or agreed to in writing, software\r
-#    distributed under the License is distributed on an AS IS BASIS, WITHOUT\r
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
-#    License for the specific language governing permissions and limitations\r
-#    under the License.
\ No newline at end of file
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Apache License, Version 2.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+##############################################################################\r
index 511eab4..a29794f 100755 (executable)
@@ -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
index 162e388..b09a846 100755 (executable)
@@ -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
 
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 1de4161..4a3b02c 100755 (executable)
@@ -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
 
index 672daad..c49df04 100755 (executable)
@@ -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"
index bd1027a..396e6ee 100755 (executable)
@@ -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
 
index 6ca8160..7e6467e 100755 (executable)
@@ -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",
index dab749e..aefb863 100755 (executable)
@@ -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
index f9414e9..61ef1a2 100755 (executable)
@@ -1,8 +1,4 @@
-"""
-Created on 2015-9-28
 
-@author: y00228926
-"""
 
 the procedure to integrate a module unit testing into the unit testing framework:
 
index 89dcd4e..df7d24d 100755 (executable)
@@ -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
+##############################################################################
+
index 9364bbb..6312efa 100755 (executable)
@@ -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'
 
index c4e992c..4c38973 100755 (executable)
@@ -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
index 665732a..a08607b 100755 (executable)
@@ -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
 
index f1d54a9..3e84d01 100755 (executable)
@@ -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
 
index 0580442..8d45c7b 100755 (executable)
@@ -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
 
index 2d2d882..e4529e4 100755 (executable)
@@ -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
 
index 5a54b82..0258ab6 100755 (executable)
@@ -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
index 844f8ff..f240355 100755 (executable)
@@ -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
index 068ab2e..86641e7 100755 (executable)
@@ -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")
index 4dc8a6a..547db68 100755 (executable)
@@ -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
+##############################################################################
+
 
index da555de..84d0592 100755 (executable)
@@ -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-"
index f7aacfd..fb54e5d 100755 (executable)
@@ -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
 
index c56c9e5..abf2a7f 100755 (executable)
@@ -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