예제 #1
0
 def test_SetUp_ENV(self):
     '''
     @summary: 创建一个数据中心
     '''
     dcapi = DataCenterAPIs()
     # 创建1个数据中心(共享类型)
     LogPrint().info("Pre-Module-Test-1: Create DataCenter '%s'." % self.dm.dc_nfs_name)
     self.assertTrue(dcapi.createDataCenter(self.dm.xml_dc_info)['status_code']==self.dm.expected_status_code_create_dc)
     capi = ClusterAPIs()
     # 创建1个集群,开启集群服务
     LogPrint().info("Pre-Module-Test-2: Create Cluster '%s' in DataCenter '%s'." % (self.dm.cluster_nfs_name, self.dm.dc_nfs_name))
     self.assertTrue(capi.createCluster(self.dm.xml_cluster_info)['status_code']==self.dm.expected_status_code_create_cluster)
   
     # 在NFS数据中心中创建两个主机,并等待主机UP。
     LogPrint().info("Pre-Module-Test-3: Create Host '%s' in Cluster '%s'." % (self.dm.host1_name, self.dm.cluster_nfs_name))
     self.assertTrue(smart_create_host(self.dm.host1_name, self.dm.xml_host1_info))
     self.assertTrue(smart_create_host(self.dm.host2_name, self.dm.xml_host2_info))
  
     # 为数据中心创建Data域。
     @BaseTestCase.drive_data(self, self.dm.xml_storage_info)
     def create_storage_domains(xml_storage_domain_info):
         sd_name = xmltodict.parse(xml_storage_domain_info)['storage_domain']['name']
         LogPrint().info("Pre-Module-Test-4: Create Data Storage '%s'." % sd_name)
         self.assertTrue(smart_create_storage_domain(sd_name, xml_storage_domain_info))
     create_storage_domains()
      
     # 将创建的的data1、data2和export、iso域附加到NFS/ISCSI数据中心里。
     LogPrint().info("Pre-Module-Test-5: Attach the data storages to data centers.")
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.iso1_name))
예제 #2
0
    def test_SetUp_ENV(self):
        '''
        @summary: 创建一个数据中心
        '''
        dcapi = DataCenterAPIs()
        # 创建1个数据中心(共享类型)
        LogPrint().info("Pre-Module-Test-1: Create DataCenter '%s'." %
                        self.dm.dc_nfs_name)
        self.assertTrue(
            dcapi.createDataCenter(self.dm.xml_dc_info)['status_code'] ==
            self.dm.expected_status_code_create_dc)
        capi = ClusterAPIs()
        # 创建1个集群,开启集群服务
        LogPrint().info(
            "Pre-Module-Test-2: Create Cluster '%s' in DataCenter '%s'." %
            (self.dm.cluster_nfs_name, self.dm.dc_nfs_name))
        self.assertTrue(
            capi.createCluster(self.dm.xml_cluster_info)['status_code'] ==
            self.dm.expected_status_code_create_cluster)

        # 在NFS数据中心中创建两个主机,并等待主机UP。
        LogPrint().info(
            "Pre-Module-Test-3: Create Host '%s' in Cluster '%s'." %
            (self.dm.host1_name, self.dm.cluster_nfs_name))
        self.assertTrue(
            smart_create_host(self.dm.host1_name, self.dm.xml_host1_info))
        self.assertTrue(
            smart_create_host(self.dm.host2_name, self.dm.xml_host2_info))

        # 为数据中心创建Data域。
        @BaseTestCase.drive_data(self, self.dm.xml_storage_info)
        def create_storage_domains(xml_storage_domain_info):
            sd_name = xmltodict.parse(
                xml_storage_domain_info)['storage_domain']['name']
            LogPrint().info("Pre-Module-Test-4: Create Data Storage '%s'." %
                            sd_name)
            self.assertTrue(
                smart_create_storage_domain(sd_name, xml_storage_domain_info))

        create_storage_domains()

        # 将创建的的data1、data2和export、iso域附加到NFS/ISCSI数据中心里。
        LogPrint().info(
            "Pre-Module-Test-5: Attach the data storages to data centers.")
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data1_nfs_name))
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data2_nfs_name))
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.export1_name))
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.iso1_name))
예제 #3
0
 def test_CreateModuleTestEnv(self):
     '''
     @summary: 创建Disk模块测试环境
     '''
     dcapi = DataCenterAPIs()
     capi = ClusterAPIs()
       
     # 创建1个数据中心(nfs类型)
     LogPrint().info("Pre-Module-Test-1: Create DataCenter '%s'." % self.dm.dc_nfs_name)
     self.assertTrue(dcapi.createDataCenter(self.dm.xml_dc_info)['status_code']==self.dm.expected_status_code_create_dc)
   
     # 创建1个集群
     LogPrint().info("Pre-Module-Test-2: Create Cluster '%s' in DataCenter '%s'." % (self.dm.cluster_nfs_name, self.dm.dc_nfs_name))
     self.assertTrue(capi.createCluster(self.dm.xml_cluster_info)['status_code']==self.dm.expected_status_code_create_cluster)
   
     # 在NFS数据中心中创建一个主机,并等待主机UP。
     LogPrint().info("Pre-Module-Test-3: Create Host '%s' in Cluster '%s'." % (self.dm.host1_name, self.dm.cluster_nfs_name))
     self.assertTrue(smart_create_host(self.dm.host1_name, self.dm.xml_host_info))
   
     # 为NFS数据中心创建Data(data1/data2)。
     @BaseTestCase.drive_data(self, self.dm.xml_storage_info)
     def create_storage_domains(xml_storage_domain_info):
         sd_name = xmltodict.parse(xml_storage_domain_info)['storage_domain']['name']
         LogPrint().info("Pre-Module-Test-4: Create Data Storage '%s'." % sd_name)
         self.assertTrue(smart_create_storage_domain(sd_name, xml_storage_domain_info))
     create_storage_domains()
       
     # 将创建的的data1附加到NFS/ISCSI数据中心里(data2/Iso/Export处于游离状态)。
     LogPrint().info("Pre-Module-Test-5: Attach the data storages to data centers.")
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
예제 #4
0
 def test_CreateModuleTestEnv(self):
     dcapi = DataCenterAPIs()
     capi = ClusterAPIs()
       
     # 创建1个数据中心(nfs类型)
     LogPrint().info("Pre-Module-Test-1: Create DataCenter '%s'." % self.dm.dc_nfs_name)
     self.assertTrue(dcapi.createDataCenter(self.dm.xml_dc_info)['status_code']==self.dm.expected_status_code_create_dc)
   
     # 创建1个集群
     LogPrint().info("Pre-Module-Test-2: Create Cluster '%s' in DataCenter '%s'." % (self.dm.cluster_nfs_name, self.dm.dc_nfs_name))
     self.assertTrue(capi.createCluster(self.dm.xml_cluster_info)['status_code']==self.dm.expected_status_code_create_cluster)
   
     # 在NFS数据中心中创建一个主机,并等待主机UP。
     LogPrint().info("Pre-Module-Test-3: Create Host '%s' in Cluster '%s'." % (self.dm.host1_name, self.dm.cluster_nfs_name))
     self.assertTrue(smart_create_host(self.dm.host1_name, self.dm.xml_host_info))
   
     # 为NFS数据中心创建Data(data1/data2/export)。
     @BaseTestCase.drive_data(self, self.dm.xml_storage_info)
     def create_storage_domains(xml_storage_domain_info):
         sd_name = xmltodict.parse(xml_storage_domain_info)['storage_domain']['name']
         LogPrint().info("Pre-Module-Test-4: Create Data Storage '%s'." % sd_name)
         self.assertTrue(smart_create_storage_domain(sd_name, xml_storage_domain_info))
     create_storage_domains()
       
     # 将创建的的data1、data2和export域附加到NFS/ISCSI数据中心里。
     LogPrint().info("Pre-Module-Test-5: Attach the data storages to data centers.")
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
     self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
     #self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
     #创建一个虚拟机
     self.vmapi = VirtualMachineAPIs()
     r = self.vmapi.createVm(self.dm.vm_info)
     if r['status_code'] == 201:
         self.vm_name = r['result']['vm']['name']
     else:
         LogPrint().error("Create vm failed.Status-code is WRONG.")
         self.assertTrue(False)
     #创建一个磁盘    
     self.diskapi = DiskAPIs()
     sd_id = StorageDomainAPIs().getStorageDomainIdByName(ModuleData.data1_nfs_name)
     r = self.diskapi.createDisk(self.dm.disk_info, sd_id)
     def is_disk_ok():
         return self.diskapi.getDiskStatus(self.disk_id)=='ok'
     if r['status_code'] == 202:
         self.disk_id = r['result']['disk']['@id']
         if wait_until(is_disk_ok, 200, 5):
             LogPrint().info("Create disk ok.")
     else:
         LogPrint().error("Create disk failed.Status-code is WRONG.")
         self.assertTrue(False)
     #将磁盘附加到虚拟机    
     self.vmdiskapi = VmDiskAPIs()
     r=self.vmdiskapi.attachDiskToVm(self.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)
예제 #5
0
 def setUp(self):
     """
     @summary: 测试用例执行前的环境初始化(前提)
     """
     # 初始化测试数据
     self.dm = super(self.__class__, self).setUp()
     # 前提1:首先创建一个集群
     self.assertTrue(smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
     # 前提2:创建一个主机
     self.assertTrue(smart_create_host(self.dm.host_name, self.dm.host_info))
예제 #6
0
 def setUp(self):
     """
     @summary: 测试用例执行前的环境初始化(前提)
     """
     # 调用父类方法,获取该用例所对应的测试数据模块
     self.dm = super(self.__class__, self).setUp()
     # 前提1:创建一个集群
     LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." % self.dm.cluster_name)
     self.assertTrue(smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
     # 前提2:创建一个主机
     LogPrint().info("Pre-Test-2: Create host '%s' for this TC." % self.dm.host_name)
     self.assertTrue(smart_create_host(self.dm.host_name, self.dm.host_info))
예제 #7
0
 def setUp(self):
     '''
     @summary: 测试用例执行前的环境初始化(前提)
     '''
     # 初始化测试数据
     self.dm = super(self.__class__, self).setUp()
     # 前提1:首先创建一个集群
     self.assertTrue(
         smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
     # 前提2:创建一个主机
     self.assertTrue(smart_create_host(self.dm.host_name,
                                       self.dm.host_info))
예제 #8
0
 def setUp(self):
     '''
     @summary: 测试用例执行前的环境初始化(前提)
     '''
     # 调用父类方法,获取该用例所对应的测试数据模块
     self.dm = super(self.__class__, self).setUp()
     # 前提1:创建一个集群
     LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." %
                     self.dm.cluster_name)
     self.assertTrue(
         smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
     # 前提2:创建一个主机
     LogPrint().info("Pre-Test-2: Create host '%s' for this TC." %
                     self.dm.host_name)
     self.assertTrue(smart_create_host(self.dm.host_name,
                                       self.dm.host_info))
예제 #9
0
    def test_CreateModuleTestEnv(self):
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()

        # 创建1个数据中心(nfs类型)
        LogPrint().info("Pre-Module-Test-1: Create DataCenter '%s'." %
                        self.dm.dc_nfs_name)
        self.assertTrue(
            dcapi.createDataCenter(self.dm.xml_dc_info)['status_code'] ==
            self.dm.expected_status_code_create_dc)

        # 创建1个集群
        LogPrint().info(
            "Pre-Module-Test-2: Create Cluster '%s' in DataCenter '%s'." %
            (self.dm.cluster_nfs_name, self.dm.dc_nfs_name))
        self.assertTrue(
            capi.createCluster(self.dm.xml_cluster_info)['status_code'] ==
            self.dm.expected_status_code_create_cluster)

        # 在NFS数据中心中创建一个主机,并等待主机UP。
        LogPrint().info(
            "Pre-Module-Test-3: Create Host '%s' in Cluster '%s'." %
            (self.dm.host1_name, self.dm.cluster_nfs_name))
        self.assertTrue(
            smart_create_host(self.dm.host1_name, self.dm.xml_host_info))

        # 为NFS数据中心创建Data(data1/data2/export)。
        @BaseTestCase.drive_data(self, self.dm.xml_storage_info)
        def create_storage_domains(xml_storage_domain_info):
            sd_name = xmltodict.parse(
                xml_storage_domain_info)['storage_domain']['name']
            LogPrint().info("Pre-Module-Test-4: Create Data Storage '%s'." %
                            sd_name)
            self.assertTrue(
                smart_create_storage_domain(sd_name, xml_storage_domain_info))

        create_storage_domains()

        # 将创建的的data1、data2和export域附加到NFS/ISCSI数据中心里。
        LogPrint().info(
            "Pre-Module-Test-5: Attach the data storages to data centers.")
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data1_nfs_name))
        self.assertTrue(
            smart_attach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data2_nfs_name))
        #self.assertTrue(smart_attach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        #创建一个虚拟机
        self.vmapi = VirtualMachineAPIs()
        r = self.vmapi.createVm(self.dm.vm_info)
        if r['status_code'] == 201:
            self.vm_name = r['result']['vm']['name']
        else:
            LogPrint().error("Create vm failed.Status-code is WRONG.")
            self.assertTrue(False)
        #创建一个磁盘
        self.diskapi = DiskAPIs()
        sd_id = StorageDomainAPIs().getStorageDomainIdByName(
            ModuleData.data1_nfs_name)
        r = self.diskapi.createDisk(self.dm.disk_info, sd_id)

        def is_disk_ok():
            return self.diskapi.getDiskStatus(self.disk_id) == 'ok'

        if r['status_code'] == 202:
            self.disk_id = r['result']['disk']['@id']
            if wait_until(is_disk_ok, 200, 5):
                LogPrint().info("Create disk ok.")
        else:
            LogPrint().error("Create disk failed.Status-code is WRONG.")
            self.assertTrue(False)
        #将磁盘附加到虚拟机
        self.vmdiskapi = VmDiskAPIs()
        r = self.vmdiskapi.attachDiskToVm(self.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)