Ejemplo n.º 1
0
 def test_DeleteDisk_AttachtoDownVm(self):
     '''
     @summary: 删除附加到运行虚拟机的磁盘
     @note: 操作成功,验证返回状态码,验证磁盘是否存在
     ''' 
     diskapi = DiskAPIs()
     self.flag = True
     LogPrint().info("Test: Delete disk %s attached to down vm %s."% (self.dm.disk_name, self.dm.vm_name))
     r = diskapi.deleteDisk(self.disk_id)
     if r['status_code'] == self.dm.expected_status_code:
         if not diskapi.isExist(self.disk_id):
             LogPrint().info("PASS: Delete Disk attached to down vm SUCCESS." )
         else:
             LogPrint().error("FAIL: Disk is still exist. " )
             self.flag = False
     else:
         LogPrint().error("FAIL: Returned status code is %s. "% r['status_code'])
         self.flag = False
     self.assertTrue(self.flag) 
Ejemplo n.º 2
0
 def test_DeleteDisk(self):
     '''
     @summary: 测试执行步骤
     @note: 删除一个独立的磁盘,即没有附加在虚拟机和模板上
     @note: 操作成功,验证返回状态码,验证磁盘是否存在
     ''' 
     disk_api =  DiskAPIs()
     self.flag = True
     LogPrint().info("Test: Delete disk %s."% self.disk_id)
     r = disk_api.deleteDisk(self.disk_id)
     if r['status_code'] == self.dm.expected_status_code:
         if not disk_api.isExist(self.disk_id):
             LogPrint().info("PASS: Delete Disk SUCCESS." )
         else:
             LogPrint().error("FAIL: Disk is still exist. " )
             self.flag = False
     else:
         LogPrint().error("FAIL: Returned status code is %s. "% r['status_code'])
         self.flag = False
     self.assertTrue(self.flag)
Ejemplo n.º 3
0
class ITC080403_DeleteDisk_AttachtoRunVm(BaseTestCase):
    '''
    @summary: ITC-08磁盘管理-04删除磁盘-03磁盘附加到运行的虚拟机上
    '''
    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))
         
    def test_DeleteDisk_AttachtoRunVm(self): 
        '''
        @summary: 删除附加到运行虚拟机的磁盘
        @note: 操作失败,验证返回状态码和报错信息
        '''
        self.flag = True
        LogPrint().info("Test: Delete disk %s attached to running vm %s."% (self.dm.disk_name, self.dm.vm_name))
        r = self.diskapi.deleteDisk(self.disk_id)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r['result']):
                LogPrint().info("PASS: The returned status code and messages are CORRECT.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
            self.flag = False
        self.assertTrue(self.flag)
         
    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))