Exemplo n.º 1
0
    def test_Scene(self):
        '''
        @summary: 测试场景描述
        '''
        volumeapi = GlusterVolumeAPIs()
        #创建一个distributed_replicate类型的卷disrep,Replica Count=2,brick=4
        LogPrint().info("Create volume disrep")
        r = volumeapi.createGlusterVolume(self.dm.cluster_name, self.dm.xml_volume_disrep)
        if r['status_code'] == self.dm.expected_status_code_create_volume:
            LogPrint().info("PASS:Create volume disrep success.")
            self.flag = True
        else:
            LogPrint().error("FAIL:Status_code is WRONG.")
            self.flag = False
        self.assertTrue(self.flag)
           
        LogPrint().info("Start volume disrep")
        r = volumeapi.startGlusterVolume(self.dm.cluster_name, "disrep")
        if r['status_code'] == self.dm.expected_status_code_start_volume:
            def is_volume_up():
                return volumeapi.getClusterVolumeStatus(self.dm.cluster_name, "disrep") == "up"
            if wait_until(is_volume_up, 600, 5):
                LogPrint().info("PASS:Start volume disrep success.")
                self.flag = True
            else:
                LogPrint().error("FAIL:Start volume failed.Status is not UP.")
                self.flag = False
        else:
            LogPrint().error("FAIL:Status_code is WRONG.")
            self.flag = False
        self.assertTrue(self.flag)
#       
#     #利用该卷创建一个glusterfs类型的存储域
        sdapi = StorageDomainAPIs()
        LogPrint().info("Create glusterfs storagedomain '%s'."%self.dm.sd_name)
        r = sdapi.createStorageDomain(self.dm.xml_sd_info)
        if r['status_code'] == self.dm.expected_status_code_create_sd:
            LogPrint().info("PASS:Create glusterfs storagedomain '%s' SUCCESS."%self.dm.sd_name)
            self.flag=True
        else:
            LogPrint().info("FAIL:Create glusterfs storagedomain '%s' FAIL."%self.dm.sd_name)
            self.flag=False
        self.assertTrue(self.flag)
#     #将存储域附加到数据中心
        LogPrint().info("Attach glusterfs storagedomain '%s'to DC '%s'."%(self.dm.sd_name, self.dm.dc_name))
        self.assertTrue(smart_attach_storage_domain(self.dm.dc_name, self.dm.sd_name))
#     #创建虚拟机,为虚拟机添加磁盘,启动虚拟机
        LogPrint().info("Create a VM '%s'."%self.dm.vm_name)
        self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.xml_vm_info))
        LogPrint().info("ADD DISK '%s' for VM '%s'."%(self.dm.disk_alias,self.dm.vm_name))
        self.assertTrue(smart_create_vmdisk(self.dm.vm_name, self.dm.xml_disk_info, self.dm.disk_alias)[0])
        LogPrint().info("Start VM '%s'."%(self.dm.vm_name))
        self.assertTrue(smart_start_vm(self.dm.vm_name))
#         #关闭虚拟机,创建模板,创建子模板
        LogPrint().info("Stop VM '%s'."%(self.dm.vm_name))
        self.assertTrue(smart_stop_vm(self.dm.vm_name))
        self.assertTrue(smart_create_template(self.dm.base_temp_name, self.dm.temp_info))
        self.assertTrue(smart_create_template(self.dm.base_temp_name, self.dm.zi_temp_info, self.dm.temp_name))
Exemplo n.º 2
0
    def test_Scene(self):
        '''
        @summary: 测试场景描述
        '''
        volumeapi = GlusterVolumeAPIs()
        #创建一个distributed_replicate类型的卷disrep,Replica Count=2,brick=4
        LogPrint().info("Create volume disrep")
        r = volumeapi.createGlusterVolume(self.dm.cluster_name,
                                          self.dm.xml_volume_disrep)
        if r['status_code'] == self.dm.expected_status_code_create_volume:
            LogPrint().info("PASS:Create volume disrep success.")
            self.flag = True
        else:
            LogPrint().error("FAIL:Status_code is WRONG.")
            self.flag = False
        self.assertTrue(self.flag)

        LogPrint().info("Start volume disrep")
        r = volumeapi.startGlusterVolume(self.dm.cluster_name, "disrep")
        if r['status_code'] == self.dm.expected_status_code_start_volume:

            def is_volume_up():
                return volumeapi.getClusterVolumeStatus(
                    self.dm.cluster_name, "disrep") == "up"

            if wait_until(is_volume_up, 600, 5):
                LogPrint().info("PASS:Start volume disrep success.")
                self.flag = True
            else:
                LogPrint().error("FAIL:Start volume failed.Status is not UP.")
                self.flag = False
        else:
            LogPrint().error("FAIL:Status_code is WRONG.")
            self.flag = False
        self.assertTrue(self.flag)
        #
        #     #利用该卷创建一个glusterfs类型的存储域
        sdapi = StorageDomainAPIs()
        LogPrint().info("Create glusterfs storagedomain '%s'." %
                        self.dm.sd_name)
        r = sdapi.createStorageDomain(self.dm.xml_sd_info)
        if r['status_code'] == self.dm.expected_status_code_create_sd:
            LogPrint().info(
                "PASS:Create glusterfs storagedomain '%s' SUCCESS." %
                self.dm.sd_name)
            self.flag = True
        else:
            LogPrint().info("FAIL:Create glusterfs storagedomain '%s' FAIL." %
                            self.dm.sd_name)
            self.flag = False
        self.assertTrue(self.flag)
        #     #将存储域附加到数据中心
        LogPrint().info("Attach glusterfs storagedomain '%s'to DC '%s'." %
                        (self.dm.sd_name, self.dm.dc_name))
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_name, self.dm.sd_name))
        #     #创建虚拟机,为虚拟机添加磁盘,启动虚拟机
        LogPrint().info("Create a VM '%s'." % self.dm.vm_name)
        self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.xml_vm_info))
        LogPrint().info("ADD DISK '%s' for VM '%s'." %
                        (self.dm.disk_alias, self.dm.vm_name))
        self.assertTrue(
            smart_create_vmdisk(self.dm.vm_name, self.dm.xml_disk_info,
                                self.dm.disk_alias)[0])
        LogPrint().info("Start VM '%s'." % (self.dm.vm_name))
        self.assertTrue(smart_start_vm(self.dm.vm_name))
        #         #关闭虚拟机,创建模板,创建子模板
        LogPrint().info("Stop VM '%s'." % (self.dm.vm_name))
        self.assertTrue(smart_stop_vm(self.dm.vm_name))
        self.assertTrue(
            smart_create_template(self.dm.base_temp_name, self.dm.temp_info))
        self.assertTrue(
            smart_create_template(self.dm.base_temp_name, self.dm.zi_temp_info,
                                  self.dm.temp_name))
Exemplo n.º 3
0
 def tearDown(self):
     self.flag = True
     LogPrint().info("Post-Test-1: Stop vm %s."%self.dm.vm_name)
     self.assertTrue(smart_stop_vm(self.dm.vm_name))
     LogPrint().info("Post-Test-2: Delete vm %s."%self.dm.vm_name)
     self.assertTrue(smart_del_vm(self.dm.vm_name))