Ejemplo n.º 1
0
 def test_Scene(self):
     '''
     @summary: 测试场景描述
     '''
     #step3:为虚拟机创建子模板
     self.assertTrue(
         smart_create_template(self.dm.temp_name, self.dm.xml_zi_temp_info1,
                               self.dm.version_name1))
     #step4:使用步骤2模板的最新版本创建虚拟机
     self.assertTrue(
         smart_create_vm(self.dm.vm_name_new, self.dm.xml_vm_info_temp))
     #step5:为虚拟机增加一个网络接口
     self.assertTrue(
         smart_create_vmnic(self.dm.vm_name, self.dm.nic_info,
                            self.dm.nic_name))
     #step6:为虚拟机创建一个新的子模板
     self.assertTrue(
         smart_create_template(self.dm.temp_name, self.dm.xml_zi_temp_info2,
                               self.dm.version_name2))
     #step7:检查虚拟机信息应该包含网络接口
     if VmNicAPIs().isVmNicExist(self.dm.vm_name_new, self.dm.nic_name):
         LogPrint().info("PASS:ITC1004_scene4.")
         self.assertTrue(True)
     else:
         LogPrint().error("FAIL:ITC1004_scene4.")
         self.assertTrue(False)
Ejemplo n.º 2
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.diskapi = DiskAPIs()
     #创建一个虚拟机
     LogPrint().info("Pre-Test-1: Create vm %s for TC."% self.dm.vm_name)
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.vm_info)) 
          
     #创建一块磁盘
     '''
     @note: 创建磁盘时,磁盘的sharable属性必须为false,因为共享磁盘不作为模板的一部份
     '''
     LogPrint().info("Pre-Test-2: Create a disk for TC.")
     r= smart_create_disk(self.dm.disk_info, self.dm.disk_name)
     self.assertTrue(r[0])
     self.disk_id = r[1]   
     #将该磁盘附加到虚拟机
     LogPrint().info("Pre-Test-3: Attach disk %s to vm %s for TC."% (self.dm.disk_name
                                                              ,self.dm.vm_name))
     self.vmdiskapi = VmDiskAPIs()
     r=self.vmdiskapi.attachDiskToVm(self.dm.vm_name, self.disk_id)
     if r['status_code'] == 200:
         LogPrint().info("Attach Disk to vm success.")
     else:
         LogPrint().error("Attach Disk to vm fail.Status-code is wrong.")
         self.assertTrue(False)
     #启动虚拟机
     LogPrint().info("Pre-Test-4: Start vm for TC.")
     self.assertTrue(smart_start_vm(self.dm.vm_name))
     #激活磁盘
     LogPrint().info("Pre-Test-5: Active vmdisk for TC.")
     self.assertTrue(smart_active_vmdisk(self.dm.vm_name,self.disk_id))
Ejemplo n.º 3
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))
Ejemplo n.º 4
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     #创建一个虚拟机
     LogPrint().info("Pre-Test-1: Create vm %s for TC."% self.dm.vm_name)
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.vm_info))    
     #创建一块磁盘
     '''
     @note: 创建磁盘时,磁盘的sharable属性必须为false,因为共享磁盘不作为模板的一部份
     '''
     LogPrint().info("Pre-Test-2: Create a disk for TC.")
     r= smart_create_disk(self.dm.disk_info, self.dm.disk_name)
     self.assertTrue(r[0])
     self.disk_id = r[1]    
     #将该磁盘附加到虚拟机上
     LogPrint().info("Pre-Test-3: Attach disk %s to vm %s for TC."% (self.dm.disk_name
                                                              ,self.dm.vm_name))
     self.vmdiskapi = VmDiskAPIs()
     r=self.vmdiskapi.attachDiskToVm(self.dm.vm_name, self.disk_id)
     if r['status_code'] == 200:
         LogPrint().info("Attach Disk to vm success.")
     else:
         LogPrint().error("Attach Disk to vm fail.Status-code is wrong.")
         self.assertTrue(False)    
     #该虚拟机创建模板   
     LogPrint().info("Pre-Test-4: Create template for vm %s for TC."% self.dm.vm_name)
     self.tempapi = TemplatesAPIs()
     self.vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name)
     r = self.tempapi.createTemplate(self.dm.temp_info, self.vm_id)
     def is_temp_ok():
         return self.tempapi.getTemplateInfo(temp_name=self.dm.temp_name)['result']['template']['status']['state']=='ok'
     if r['status_code'] == 202:
         if wait_until(is_temp_ok, 600, 10):
             LogPrint().info("Create Template ok.")
         else:
             LogPrint().error("Create Template overtime")
             self.assertTrue(False)
     else:
         LogPrint().error("Create Template failed.Status-code is wrong.")
         self.assertTrue(False)
     #获得模板关联的磁盘id
     r = TemplateDisksAPIs().getTemplateDiskInfo(self.dm.temp_name, self.dm.disk_name) 
     if r['status_code'] == 200:
         self.disk_id_temp = r['result']['disk']['@id']
     else:
         self.assertTrue(False)
Ejemplo n.º 5
0
 def test_Scene(self):
     '''
     @summary: 测试场景描述
     '''
     #step3:为虚拟机创建子模板
     self.assertTrue(smart_create_template(self.dm.temp_name, self.dm.xml_zi_temp_info1, self.dm.version_name1))
     #step4:使用步骤2模板的最新版本创建虚拟机
     self.assertTrue(smart_create_vm(self.dm.vm_name_new, self.dm.xml_vm_info_temp))
     #step5:为虚拟机增加一个网络接口
     self.assertTrue(smart_create_vmnic(self.dm.vm_name,self.dm.nic_info,self.dm.nic_name))
     #step6:为虚拟机创建一个新的子模板
     self.assertTrue(smart_create_template(self.dm.temp_name, self.dm.xml_zi_temp_info2, self.dm.version_name2))
     #step7:检查虚拟机信息应该包含网络接口
     if VmNicAPIs().isVmNicExist(self.dm.vm_name_new, self.dm.nic_name):
         LogPrint().info("PASS:ITC1004_scene4.")
         self.assertTrue(True)
     else:
         LogPrint().error("FAIL:ITC1004_scene4.")
         self.assertTrue(False)
Ejemplo n.º 6
0
 def test(self):
     #step1:创建一个虚拟机
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.xml_vm_info))
     #step2:为虚拟机创建模板
     vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name)
     TemplatesAPIs().createTemplate(self.dm.xml_temp_info, vm_id)
Ejemplo n.º 7
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))
Ejemplo n.º 8
0
 def test(self):
     #step1:创建一个虚拟机
     self.assertTrue(smart_create_vm(self.dm.vm_name, self.dm.xml_vm_info)) 
     #step2:为虚拟机创建模板
     vm_id = VirtualMachineAPIs().getVmIdByName(self.dm.vm_name) 
     TemplatesAPIs().createTemplate(self.dm.xml_temp_info, vm_id)