Esempio n. 1
0
 def run_workload(self, workload_path, result_path, vd_name, workload):
     '''
     This method run workloads and stores the result
     Arguments (str, str, str, str): workload_path, result_path, vd_name, workload
     Return: None
     '''
     # Config\VdBench_config\Workload
     path = 'cd ' + self.vdbench_path + '\n'
     str_ = 'vdbench -f "' + workload_path + '" -o "' + result_path + '"' + "\n"
     ssh = subprocess.Popen(["cmd"],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            universal_newlines=True,
                            bufsize=0)
     # Send ssh commands to stdin
     ssh.stdin.write(path)
     ssh.stdin.write(str_)
     out, err = ssh.communicate()
     print(out, err)
     ssh.wait()
     if 'Vdbench execution completed successfully' in out:
         if '4-4k-4-fill' not in result_path:
             msg = workload.upper() + ' workload executed sucessfully'
             LogCreate().logger_info.info(msg)
             new_path = os.path.join(result_path, "flatfile.html")
             ResultCreation().read_result(new_path, vd_name, workload,
                                          self.new_)
         else:
             msg = '4-4k-4-fill workload executed sucessfully'
             LogCreate().logger_info.info(msg)
Esempio n. 2
0
 def execute_test(self):
     '''
     This method execute workload and create all required
     configuration of SSY.
     Arguments : None
     Return: None
     '''
     vd_name, workload, flag_run = self.input_for_test()
     if flag_run == 1:
         print('************************'\
               'Test Started************************\n')
         LogCreate().logger_info.info('************************'\
                                     'Test Started************************')
         time.sleep(10)
         if vd_name.lower() != "standard":
             self.test_enable_cap_opt_at_server()
         time.sleep(15)
         self.create_diskpool(vd_name)
         time.sleep(15)
         self.stop_server()
         time.sleep(25)
         self.start_server()
         time.sleep(25)
         self.test_create_virtual_disk(vd_name)
         time.sleep(50)
         self.set_vd_properties(vd_name)
         time.sleep(5)
         self.test_serve_vd_to_host()
         time.sleep(10)
         diskindex = self.initialize_vd()
         time.sleep(5)
         print('************************'\
               'VdBench Execution Started************************\n')
         LogCreate().logger_info.info('************************'\
                                     'VdBench Execution Started************************')
         VdBenchRun().run(vd_name, workload, diskindex)
         print('Result creation completed')
         print('************************'\
               'Setup Cleanup Started************************\n')
         LogCreate().logger_info.info('************************'\
                                     'Setup Cleanup Started************************')
         self.un_server_vd()
         time.sleep(25)
         self.delete_vd()
         time.sleep(180)
         self.delete_pool()
         time.sleep(180)
         if vd_name.lower() != "standard":
             self.test_disable_cap_opt_at_server()
             time.sleep(30)
         print('************************'\
               'VdBench Execution Completed************************\n')
         LogCreate().logger_info.info('************************'\
                                     'VdBench Execution Completed************************')
Esempio n. 3
0
 def start_update_html(self, virtualdisk, workload):
     '''
     This method append all results in HTML page
     Arguments (str, str): virtualdisk, workload
     Return: None
     '''
     path_html = os.path.abspath("../../..") + '/' + 'HTML_Template' + '/'
     self.run()
     if self.glob_flag == 0:
         self.first_temp()
     print('************************'\
           'VdBench Result Creation Started************************\n')
     LogCreate().logger_info.info('************************'\
                                 'VdBench Result Creation Started************************')
     update = '<td class="u-border-1 u-border-grey-30 u-table-cell u-table-cell-'
     file1 = open(self.path, "r+")
     list_lines = file1.readlines()
     number = self.update_lines(workload, virtualdisk)
     for index, val in enumerate(list_lines):
         vsi_new = update + str(number)
         if vsi_new in val.strip():
             data = '<td class="u-border-1 u-border-grey-30'\
                 ' u-table-cell u-table-cell-' + str(number)
             data = data + '">' + self.merge_list[0] + "</td>"
             list_lines[index] = data
             self.merge_list.pop(0)
             number += 5
         if val.strip() == '<script class="u-script" type="text/javascript" '\
             'src="jquery.js" defer=""></script>':
             list_lines[index] = '<script class="u-script" type="text/javascript" '\
                 'src=""'+path_html+'jquery.js" defer=""></script>'
         if val.strip(
         ) == '<link rel="stylesheet" href="nicepage.css" media="screen">':
             list_lines[index] = '<link rel="stylesheet" '\
                 'href="'+path_html+'nicepage.css" media="screen">'
         if val.strip(
         ) == '<link rel="stylesheet" href="VdBench.css" media="screen">':
             list_lines[index] = '<link rel="stylesheet"'\
                 ' href="'+path_html+'VdBench.css" media="screen">'
         if val.strip() == '<script class="u-script" type="text/javascript" '\
             'src="nicepage.js" defer=""></script>':
             list_lines[index] = '<script class="u-script" type="text/javascript" '\
                 'src="href="'+path_html+'nicepage.js" defer=""></script>'
         if val.strip() == '<img class="u-image u-image-1" src="images/new.png" '\
             'data-image-width="539" data-image-height="136">':
             list_lines[index] = '<img class="u-image u-image-1" '\
                 'src="'+path_html+'images/new.png" '\
                     'data-image-width="539" data-image-height="136">'
     with open(self.destiny, "w") as file:
         for item in list_lines:
             file.write("%s\n" % item)
     file.close()
     msg = self.build + ' Result created succesfully'
     LogCreate().logger_info.info(msg)
Esempio n. 4
0
    def set_vd_properties(self, virtual_disk):
        '''
        This method used to set virtual disk property.
        Arguments (str): virtual disk
        Return: None
        '''
        payload = {}
        #Once the VD is created set virtual disk properties
        if virtual_disk.lower() != "standard":
            if virtual_disk.lower().strip() == "ildc":

                payload["Deduplication"] = True
                payload["Compression"] = True
            elif virtual_disk.lower() == "ild":
                payload["Deduplication"] = True
            elif virtual_disk.lower() == "ilc":
                payload["Compression"] = True
            uri = "virtualdisks/" + self.vd_id
            res = ILDC().do_enable_cap_opt_on_vd(uri,
                                                 header=None,
                                                 payload=payload)
            msg = virtual_disk + " property enable at virtual disk level"
            if str(res) == '<Response [200]>':
                print(msg)
                LogCreate().logger_info.info(msg)
            else:
                self.verification(res.json(), msg)
Esempio n. 5
0
 def input_for_test(self):
     '''
     This method pass disk and workload details to the tool.
     Arguments : None
     Return: None
     '''
     flag_run = 0
     vd_name = ''
     workload = ''
     self.file = open(r"../../../Config/Test.txt", "r+")
     data = self.file.readlines()
     self.file.close()
     if data == []:
         msg = 'There is nothing to perform plz give vdbench configuration'
         LogCreate().logger_info.info(msg)
     else:
         virtual_disk = data[0].split()
         vd_name = virtual_disk[0]
         workload = virtual_disk[1]
         flag_run = 1
         file = open(r"../../../Config/Test.txt", "w+")
         for _ in data[1:]:
             file.write(_)
         file.close()
     return vd_name, workload, flag_run
Esempio n. 6
0
 def run(self):
     '''
     This method validate disk is used by othere process.
     If its used by othere process it will raise error and
     stop execution of tool.
     Arguments : None
     Return: None
     '''
     flag = 0
     self.read_config()
     pd_ids = self.get_physical_disk_id()
     for _ in self.disk:
         ILDC().clean_diskpart(_)
         if int(_) not in pd_ids.keys():
             msg = 'Disk index ' + str(_) + ' Already used by other process'
             print(msg)
             LogCreate().logger_error.error(msg)
             flag = 1
         else:
             if _ in self.config_dict['co disk']:
                 self.co_disk.append(pd_ids[int(_)])
             else:
                 self.disk_pool_disk.append(pd_ids[int(_)])
     del self.config_dict
     return flag
Esempio n. 7
0
 def test_create_virtual_disk(self, virtual_disk):
     '''
     This method used to create Virtual disk.
     Arguments (str): virtual disk
     Return: None
     '''
     uri = "virtualdisks"
     vd_payload = {
         "Name": virtual_disk + "_VD",
         "Description": "Description of virtual disk",
         "Size": "500GB",
         "SectorSize": "512B",
         "PoolVolumeType": "0",  # 0-stripped, 1-spanned,
         "Pool": self.pool_id,
         "Type": "0",
         "Count": "1",
     }
     res = ILDC().do_create_vd(uri, header=None, payload=vd_payload)
     msg = "Virtual disk created successfully"
     if str(res) == '<Response [200]>':
         print(msg)
         LogCreate().logger_info.info(msg)
     else:
         self.verification(json.loads(res.content), msg)
     res = json.loads(res.content)
     if len(res) != 0:
         vd_id = [x["Id"] for x in res]
         self.vd_id = vd_id[0]
Esempio n. 8
0
    def __init__(self):
        self.config_file = r"../../../Config/VdBench_config/VDBench_config.ini"
        self.config_test = r"../../../Config/Test.txt"
        self.list_lines = []
        self.file = ''
        configur = ConfigParser()
        configur.read(self.config_file)
        flag = 1
        msg = ''
        if configur.get('first run', 'run') == 'False':

            today = datetime.datetime.now()
            date_time = today.strftime("%y-%m-%d_%H-%M-%S")
            self.set_config_val('first run', 'start', date_time)
            flag, msg = AutoLoggin().run()
        print(flag, msg)
        if flag == 1 and msg == '':
            flag_ = self.verification_file()
            if flag_ == 0:
                self.arguments()
            else:
                Test_ILDC().start()
                self.set_config_val('first run', 'run', 'True')
                print('System will restart in 30 sec')
                time.sleep(30)
                os.system("shutdown /r /t 1")
        else:
            print(msg)
            LogCreate().logger_error.error(msg)
Esempio n. 9
0
 def verification(self, res_json, msg):
     '''
     This method used to log INFO and ERROR to log file.
     Arguments (dict, str): res_json, msg
     Return (str): self.test_status
     '''
     try:
         if 'ErrorCode' not in res_json.keys():
             self.test_status = "Pass"
             LogCreate().logger_info.info(msg)
             print(msg)
         else:
             self.test_status = "Fail"
             print(res_json['Message'])
             LogCreate().logger_error.error(res_json['Message'])
     except:
         LogCreate().logger_error.error(res_json['Message'])
     return self.test_status
Esempio n. 10
0
 def zfs_data(self):
     '''
     This method read ZFS data.
     Arguments : None
     Return (float, float, float, float): os_mem, ddt, comp, dedup
     '''
     try:
         process = subprocess.Popen(
             'cmd.exe',
             stdin=subprocess.PIPE,
             stdout=subprocess.PIPE,
             stderr=subprocess.PIPE,
             encoding='utf8',
             universal_newlines=True,
             bufsize=0,
             creationflags=subprocess.CREATE_NEW_CONSOLE,
             shell=False)
         process.stdin.write('cd /d c:\\' + "\n")
         process.stdin.write(
             "cd \"C:/Program Files/DataCore/SANsymphony/zfs\"" + "\n")
         process.stdin.write("zpool status -D" + "\n")
         process.stdin.write("kstat spl:0:spl_misc:os_mem_alloc" + "\n")
         process.stdin.write("zpool list" + "\n")
         process.stdin.write("zfs get compressratio" + "\n")
         process.stdin.write("kstat.exe zfs:0:tunable:zfs_arc_meta_limit" +
                             "\n")
         process.stdin.write("kstat.exe zfs:0:tunable:zfs_arc_meta_limit" +
                             "\n")
         process.stdin.write("zfs get primarycache" + "\n")
         process.stdin.write("zfs get sync" + "\n")
         process.stdin.close()
         output = process.stdout.read().split('\n')
         count = 0
         for _ in output:
             if count == 1:
                 count = 0
                 if 'compressratio' in _.split():
                     comp = str(_.split()[-2].strip('x'))
                 else:
                     dedup = str(_.split()[-3].strip('x'))
             if 'dedup: DDT entries' in _:
                 ddt = (int(_.split()[3].split(',')[0])) * (int(
                     _.split()[8]))
             if 'os_mem_alloc' in _:
                 os_mem = _.split()[-1]
             if 'SIZE  ALLOC   FREE  CKPOINT' in _:
                 count = 1
             if 'PROPERTY       VALUE  SOURCE' in _:
                 count = 1
             if 'zfs_arc_meta_limit' in _:
                 self.zfs_max = _.split()[-1]
         ddt = str(round(ddt / 1048576, 2))
         os_mem = str(round(int(os_mem) / 1073741824, 2))
         return os_mem, ddt, comp, dedup
     except Exception as error:
         LogCreate().logger_error.error(error)
Esempio n. 11
0
 def get_physical_disk_id(self):
     '''
     This method used to get all physical disk details.
     Arguments : None
     Return: None
     '''
     uri = "physicaldisks"
     pd_data = Disks().do_get_physical_disks(uri, header=None)
     pd_data = json.loads(pd_data.content)
     if len(pd_data) != 0:
         self.pd_ids = {
             x['DiskIndex']: x["Id"]
             for x in pd_data if x['Partitioned'] == False
         }
         msg = "Found %d physical disks in server group" % len(self.pd_ids)
         LogCreate().logger_info.info(msg)
     else:
         msg = "No Physical disks found"
         LogCreate().logger_error.error(msg)
     return self.pd_ids
Esempio n. 12
0
 def get_host(self):
     '''
     This method used to get host details.
     Arguments : None
     Return: None
     '''
     uri = 'hosts'
     res = ILDC().do_ssy_details(uri, header=None)
     msg = 'Get host details'
     if str(res) == '<Response [200]>':
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 13
0
 def get_server(self):
     '''
     This method used to get server details.
     Arguments : None
     Return: None
     '''
     uri = "servers"
     res = ILDC().do_ssy_details(uri, header=None)
     self.server_id = res.json()[0]['Id']
     msg = 'Get server details'
     if str(res) == '<Response [200]>':
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 14
0
 def delete_vd(self):
     '''
     This method used to delete virtual disk.
     Arguments : None
     Return: None
     '''
     uri = "virtualdisks/" + self.vd_id
     res = ILDC().do_vd_delete(uri)
     msg = "Virtual disk deleted"
     if str(res) == '<Response [200]>':
         print(msg)
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 15
0
 def delete_pool(self):
     '''
     This method used to delete diskpool.
     Arguments : None
     Return: None
     '''
     uri = "pools/" + self.pool_id
     res = ILDC().do_pool_delete(uri)
     msg = "Diskpool deleted successfully"
     if str(res) == '<Response [200]>':
         print(msg)
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 16
0
 def un_server_vd(self):
     '''
     This method used to unserve virtual disk from host.
     Arguments : None
     Return: None
     '''
     uri = "virtualdisks/" + self.vd_id
     payload_dict = {"Operation": "Unserve", "Host": self.server_id}
     res = ILDC().do_serve_vd(uri, header=None, payload=payload_dict)
     msg = "Unserve Virtual disk sucessfuly"
     if str(res) == '<Response [200]>':
         print(msg)
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 17
0
 def add_disk_to_pool(self):
     '''
     This method add disks to diskpool.
     Arguments : None
     Return: None
     '''
     uri = "pools/" + self.pool_id
     payload_dict = {
         "Operation": "AddDisks",
         "Disks": self.disk_pool_disk[1:]
     }
     res = ILDC().do_create_pool(uri, header=None, payload=payload_dict)
     msg = "Disks are added to Diskpool"
     if str(res) == '<Response [200]>':
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res.json(), msg)
Esempio n. 18
0
 def initialize_vd(self):
     '''
     This method used to initialize virtual disk.
     Arguments : None
     Return: None
     '''
     uri = "physicaldisks"
     pd_data = Disks().do_get_physical_disks(uri, header=None)
     pd_data = json.loads(pd_data.content)
     for i in range(len(pd_data)):
         for key, val in pd_data[i].items():
             if key == "VirtualDiskId" and val in self.vd_id:
                 diskindex = pd_data[i]['DiskIndex']
                 ILDC().initial_disk(diskindex)
                 msg = "Initialized Virtual disk"
                 print(msg)
                 LogCreate().logger_info.info(msg)
                 break
     return diskindex
Esempio n. 19
0
 def test_serve_vd_to_host(self):
     '''
     This method used serve virtual disk to host.
     Arguments : None
     Return: None
     '''
     uri = "virtualdisks/" + self.vd_id
     serve_payload = {
         "Operation": "Serve",
         "Host": self.server_id,
         "Redundancy": "false"
     }
     res = ILDC().do_serve_vd(uri, header=None, payload=serve_payload)
     msg = "Virtual disk server to the host"
     if str(res) == '<Response [200]>':
         print(msg)
         LogCreate().logger_info.info(msg)
     else:
         self.verification(res, msg)