Read the proxy info from testcase, and set it to hosts when dhrystone benchmarks... 19/14419/4
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>
Fri, 20 May 2016 07:56:13 +0000 (15:56 +0800)
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>
Mon, 23 May 2016 00:37:48 +0000 (08:37 +0800)
modification:
  Write the git_proxy_pbook.yaml to set git proxy info in hosts or vms.
  Write the sys_proxy_pbook.yaml to set yum apt wget env proxy info in hosts or vms.
  Change the dhrystone.yaml to include proxy  and add the zte-pod1 /compute/dhrystone_bm.yaml.Tested and passed.Other playbooks did not include the proxy yet. I will test and push lately.

QTIP-74

Change-Id: Ia820bc32798b9f1f6f4165a111524e04c129a5df
Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
benchmarks/playbooks/dhrystone.yaml
benchmarks/playbooks/git_proxy_pbook.yaml [new file with mode: 0644]
benchmarks/playbooks/sys_proxy_pbook.yaml [new file with mode: 0644]
func/cli.py
func/driver.py
func/env_setup.py
test_cases/zte-pod1/compute/dhrystone_bm.yaml [new file with mode: 0644]

index 3ea0438..eb46ad0 100644 (file)
@@ -26,6 +26,7 @@
     - include: ./sys_info_pbook.yaml
       vars:
           network: false
+    - include: ./sys_proxy_pbook.yaml
 
     - name: Installing UnixBench dependencies if CentOS
       shell: sudo yum install git gcc  patch perl-Time-HiRes -y
@@ -35,6 +36,8 @@
       shell: sudo apt-get install git gcc  patch perl -y
       when: ansible_os_family == "Debian"
 
+    - include: ./git_proxy_pbook.yaml
+
     - name: Clone unixbench
       shell: git clone https://github.com/kdlucas/byte-unixbench.git $HOME/tempT
 
diff --git a/benchmarks/playbooks/git_proxy_pbook.yaml b/benchmarks/playbooks/git_proxy_pbook.yaml
new file mode 100644 (file)
index 0000000..6d155a7
--- /dev/null
@@ -0,0 +1,12 @@
+
+#git
+- name: set git proxy(http)
+  shell: "git config --global http.proxy {{ http_proxy }}"
+  when: http_proxy is defined
+  ignore_errors: yes
+
+- name: set git proxy(https)
+  shell: "git config --global https.proxy {{https_proxy}}"
+  when: https_proxy is defined
+  ignore_errors: yes
+
diff --git a/benchmarks/playbooks/sys_proxy_pbook.yaml b/benchmarks/playbooks/sys_proxy_pbook.yaml
new file mode 100644 (file)
index 0000000..bf4a8cc
--- /dev/null
@@ -0,0 +1,53 @@
+#env
+- name: insert shell proxy http
+  lineinfile: dest=/etc/profile.d/proxy.sh state=present create=yes owner=root group=root mode=0644 regexp="export http_proxy={{ http_proxy }}"
+              insertafter=EOF line="export http_proxy={{ http_proxy }}"
+  when: http_proxy is defined
+  ignore_errors: yes
+
+- name: insert shell proxy https
+  lineinfile: dest=/etc/profile.d/proxy.sh state=present create=yes owner=root group=root mode=0644 regexp="export https_proxy={{ https_proxy }}"
+              insertafter=EOF line="export https_proxy={{ https_proxy }}"
+  when: https_proxy is defined
+  ignore_errors: yes
+
+- name: insert no proxy
+  lineinfile: dest=/etc/profile.d/proxy.sh state=present create=yes owner=root group=root mode=0644 regexp="{{ no_proxy }}"
+              insertafter=EOF line="export no_proxy={{ no_proxy }}"
+  when: no_proxy is defined
+  ignore_errors: yes
+
+#wget
+- name: insert wget proxy(http)
+  lineinfile: dest=/etc/wgetrc state=present regexp="http_proxy={{ http_proxy }}"
+              insertafter="^#http_proxy" line="http_proxy={{ http_proxy }}"
+  when: http_proxy is defined
+  ignore_errors: yes
+
+- name: insert wget proxy(https)
+  lineinfile: dest=/etc/wgetrc state=present regexp="https_proxy={{ https_proxy }}"
+              insertafter="^#https_proxy" line="https_proxy={{ https_proxy }}"
+  when: https_proxy is defined
+  ignore_errors: yes
+
+#yum
+- name: insert yum proxy(http)
+  lineinfile: dest=/etc/yum.conf state=present regexp="proxy={{ http_proxy }}"
+               insertafter=EOF line="proxy={{ http_proxy }}"
+  when: ansible_os_family == "RedHat" and http_proxy is defined
+  ignore_errors: yes
+
+#apt
+
+- name: insert apt proxy(http)
+  lineinfile: dest=/etc/apt/apt.conf state=present create=yes regexp="Acquire::http::Proxy \"{{ http_proxy }}\";"
+              insertafter=EOF line="Acquire::http::Proxy \"{{ http_proxy }}\";"
+  when: ansible_os_family == "Debian" and http_proxy is defined
+  ignore_errors: yes
+
+- name: insert apt proxy(https)
+  lineinfile: dest=/etc/apt/apt.conf state=present create=yes regexp="Acquire::https::Proxy \"{{ https_proxy }}\";"
+              insertafter=EOF line="Acquire::https::Proxy \"{{ https_proxy }}\";"
+  when: ansible_os_family == "Debian" and https_proxy is defined
+  ignore_errors: yes
+
index a99e9d0..1f3e96f 100644 (file)
@@ -87,7 +87,7 @@ class cli():
                 obj=''
                 obj = Env_setup()
                 if os.path.isfile('./test_cases/'+args.lab.lower()+'/'+suite[0]+'/' +benchmarks[items]):
-                    [benchmark, roles, vm_info, benchmark_details, pip] = obj.parse('./test_cases/'
+                    [benchmark, roles, vm_info, benchmark_details, pip, proxy_info] = obj.parse('./test_cases/'
                                                                     +args.lab.lower()+'/'+suite[0]+'/'+benchmarks[items])
 
                     if len(vm_info) != 0:
@@ -101,7 +101,8 @@ class cli():
                                     obj.roles_dict.items(),
                                     self._get_fname(benchmarks[items]),
                                     benchmark_details,
-                                    obj.ip_pw_dict.items())
+                                    obj.ip_pw_dict.items(),
+                                    proxy_info)
                 else:
                     print (args.benchmark, ' is not a Template in the Directory - \
                                 Enter a Valid file name. or use qtip.py -h for list')
index 94fc143..48c09c5 100644 (file)
@@ -21,20 +21,22 @@ class Driver:
         print os.environ['PWD']
         self.dic_json = defaultdict()
 
-    def drive_bench(self, benchmark, roles, benchmark_fname, benchmark_detail = None, pip_dict = None):
-
+    def drive_bench(self, benchmark, roles, benchmark_fname, benchmark_detail = None, pip_dict = None, proxy_info = None):
         roles= sorted(roles)
         pip_dict = sorted(pip_dict)
         result_dir = 'results'
         benchmark_name = benchmark + '.yaml'
         self.dic_json['Dest_dir'] = str(result_dir)
-        self.dic_json['ip1']=''
-        self.dic_json['ip2']=''
-        self.dic_json['installer']=str(os.environ['INSTALLER_TYPE'])
-        self.dic_json['workingdir']=str(os.environ['PWD'])
-        self.dic_json['fname']=str(benchmark_fname)
-        self.dic_json['username']= str('root')
-
+        self.dic_json['ip1'] = ''
+        self.dic_json['ip2'] = ''
+        self.dic_json['installer'] = str(os.environ['INSTALLER_TYPE'])
+        self.dic_json['workingdir'] = str(os.environ['PWD'])
+        self.dic_json['fname'] = str(benchmark_fname)
+        self.dic_json['username'] = str('root')
+        
+        for key in proxy_info.keys():
+            self.dic_json[key] = proxy_info[key]
+                    
         if os.environ['INSTALLER_TYPE'] == str('joid'):
             self.dic_json['username']=str('ubuntu')
         if os.environ['INSTALLER_TYPE'] == str('apex'):
index 9fd7c10..487d7af 100644 (file)
@@ -31,6 +31,7 @@ class Env_setup():
         self.roles_dict.clear()
         self.ip_pw_dict.clear()
         self.ip_pip_list[:] = []
+        self.proxy_info = {}
         self.vm_parameters.clear()
         self.benchmark_details.clear()
         self.benchmark = ''
@@ -141,6 +142,10 @@ class Env_setup():
                 self.GetHostMachineinfo(doc['Context']['Host_Machines'])
             if doc.get('Scenario',{}).get('benchmark_details',{}):
                 self.GetBenchmarkDetails(doc.get('Scenario',{}).get('benchmark_details',{}))
+            if 'Proxy_Environment' in doc['Context'].keys(): 
+                self.proxy_info['http_proxy'] = doc['Context']['Proxy_Environment']['http_proxy']
+                self.proxy_info['https_proxy'] = doc['Context']['Proxy_Environment']['https_proxy']
+                self.proxy_info['no_proxy'] =  doc['Context']['Proxy_Environment']['no_proxy']
             for k, v in self.roles_ip_list:
                 self.roles_dict[k].append(v)
             for k, v in self.ip_pw_list:
@@ -150,7 +155,9 @@ class Env_setup():
                 self.roles_dict.items(),
                 self.vm_parameters,
                 self.benchmark_details.items(),
-                self.ip_pw_dict.items())
+                self.ip_pw_dict.items(),
+                self.proxy_info)
+               
         except KeyboardInterrupt:
             fname.close()
             print 'ConfigFile Closed: exiting!'
diff --git a/test_cases/zte-pod1/compute/dhrystone_bm.yaml b/test_cases/zte-pod1/compute/dhrystone_bm.yaml
new file mode 100644 (file)
index 0000000..2835ba8
--- /dev/null
@@ -0,0 +1,38 @@
+
+Scenario:
+  benchmark: dhrystone
+  host: machine_1, machine_2
+  server:
+
+Context:
+  Host_Machines:
+    machine_1:
+      ip: 10.20.0.24
+      pw:
+      role: host
+    machine_2:
+      ip: 10.20.0.25
+      pw:
+      role: host
+
+  Virtual_Machines:
+
+  Proxy_Environment:
+      http_proxy: http://10.20.0.1:8118
+      https_proxy: http://10.20.0.1:8118
+      no_proxy: localhost,127.0.0.1,10.20.*,192.168.*
+
+
+Test_Description:
+  Test_category: "Compute"
+  Benchmark: "dhrystone"
+  Overview: >
+        ''' This test will run the dhrystone benchmark in parallel  on machine_1 and machine_2.\n
+         if you wish to add a virtual machine add the following information under the Virtual_Machine tag
+
+        virtualmachine_1:
+          availability_zone:
+          public_network:
+          OS_image:
+          flavor:
+          role: '''