예제 #1
0
 def test_11_delete_subnet(self):
     print("================Begin Test Delete Subnet================")
     listVpcResp = cli.vpcStub.ListVpc(c.ListVpcRequest(header=c.Header(regionId='gz'), start=0, limit=10))
     self.assertEqual(listVpcResp.error.errno, 0)
     self.assertTrue(len(listVpcResp.data) > 0)
     for vpc in listVpcResp.data:  # 选中刚才创建的VPC
         if vpc.name == 'testChangeVpcName':
             vpcToCheckDelete = vpc.vpcUuid
             break
     self.assertIsNotNone(vpcToCheckDelete)
     listSubnetResp = cli.vpcStub.ListSubnet(c.ListSubnetRequest(header=c.Header(regionId='gz'), start=0, limit=10,
                                                                 condition=c.ListSubnetCondition(
                                                                     vpcUuid=vpcToCheckDelete)))
     self.assertEqual(listSubnetResp.error.errno, 0)
     self.assertTrue(len(listSubnetResp.data) > 0)
     deleteSubnetReq = c.DeleteSubnetRequest(header=c.Header(regionId='gz'),vpcUuid=vpcToCheckDelete)
     subnetToDelete = deleteSubnetReq.subnet.add()
     subnetToDelete.subnetUuid=listSubnetResp.data[0].subnetUuid
     deleteSubnetResp = cli.vpcStub.DeleteSubnet(deleteSubnetReq)
     print(deleteSubnetResp)
     self.assertEqual(deleteSubnetResp.error.errno, 0)
     print("deleteSubnet, jobUuid:", deleteSubnetResp.data[0].jobUuid)
     success = cli.wait_for_job_result('gz', deleteSubnetResp.data[0].jobUuid)  # 轮询等待结果
     print("deleteSubnet, success:", success)
     self.assertTrue(success)
예제 #2
0
 def test_05_attach_ebs_to_dc2(self):
     print("================Begin Test Attach Ebs To Dc2================")
     listDc2Resp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz', zoneId='gz01'),
                          start=0,
                          limit=10))  # 获取一个gz01的DC2的Uuid
     self.assertEqual(listDc2Resp.error.errno, 0)
     self.assertTrue(len(listDc2Resp.data) > 0)
     listEbsResp = cli.ebsStub.ListEbs(
         c.ListEbsRequest(header=c.Header(regionId='gz', zoneId='gz01'),
                          start=0,
                          limit=10))  # 获取一个gz01的EBS的Uuid
     self.assertEqual(listEbsResp.error.errno, 0)
     self.assertTrue(len(listEbsResp.data) > 0)
     self.assertEqual(len(listEbsResp.data[0].dc2.dc2Uuid), 0)
     attachEbsToDc2Req = c.AttachEbsRequest(header=c.Header(regionId='gz'))
     ebsToAttach = attachEbsToDc2Req.ebs.add()
     ebsToAttach.dc2Uuid = listDc2Resp.data[0].dc2Uuid
     ebsToAttach.ebsUuid = listEbsResp.data[0].ebsUuid
     attachEbsToDc2Resp = cli.ebsStub.AttachEbs(attachEbsToDc2Req)
     print(attachEbsToDc2Resp)
     self.assertEqual(attachEbsToDc2Resp.error.errno, 0)
     print("attachEbsToDc2, jobUuid:", attachEbsToDc2Resp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', attachEbsToDc2Resp.data[0].jobUuid)  # 轮询等待结果
     print("attachEbsToDc2, success:", success)
     self.assertTrue(success)
예제 #3
0
 def test_08_detach_dc2_from_sg(self):
     print("================Begin Test Detach Dc2 From Sg================")
     listSgResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0,
                         limit=10))  # 获取一个gz的Sg的Uuid
     self.assertEqual(listSgResp.error.errno, 0)
     self.assertTrue(len(listSgResp.data) > 0)
     listDc2Resp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(
             header=c.Header(regionId='gz'),
             start=0,
             limit=10,
             condition=c.ListDc2Condition(
                 sgUuid=listSgResp.data[0].sgUuid)))  # 获取在此SG下的dc2的Uuid
     detachDc2FromSgReq = c.DetachDc2FromSgRequest(header=c.Header(
         regionId='gz'))
     sgToDetach = detachDc2FromSgReq.sg.add()
     dc2ToDetach = detachDc2FromSgReq.dc2.add()
     sgToDetach.sgUuid = listSgResp.data[0].sgUuid
     dc2ToDetach.dc2Uuid = listDc2Resp.data[0].dc2Uuid
     detachDc2FromSgResp = cli.sgStub.DetachDc2FromSg(detachDc2FromSgReq)
     print(detachDc2FromSgResp)
     self.assertEqual(detachDc2FromSgResp.error.errno, 0)
     print("detachDc2FromSg, jobUuid:", detachDc2FromSgResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', detachDc2FromSgResp.data[0].jobUuid)  # 轮询等待结果
     print("detachDc2FromSg, success:", success)
     self.assertTrue(success)
예제 #4
0
 def test_07_attach_dc2_to_sg(self):
     print("================Begin Test Attach Dc2 To Sg================")
     listSgResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0,
                         limit=10))  # 获取一个gz的Sg的Uuid
     self.assertEqual(listSgResp.error.errno, 0)
     self.assertTrue(len(listSgResp.data) > 0)
     listDc2Resp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz'),
                          start=0,
                          limit=10,
                          condition=c.ListDc2Condition(
                              sgUuid=listSgResp.data[0].sgUuid,
                              sgExclude=True)))  # 获取不在SG下的dc2的Uuid
     self.assertEqual(listDc2Resp.error.errno, 0)
     self.assertTrue(len(listDc2Resp.data) > 0)
     attachDc2ToSgReq = c.AttachDc2ToSgRequest(header=c.Header(
         regionId='gz'))
     sgToBeAttached = attachDc2ToSgReq.sg.add()
     dc2ToAttach = attachDc2ToSgReq.dc2.add()
     sgToBeAttached.sgUuid = listSgResp.data[0].sgUuid
     dc2ToAttach.dc2Uuid = listDc2Resp.data[0].dc2Uuid
     attachDc2ToSgResp = cli.sgStub.AttachDc2ToSg(attachDc2ToSgReq)
     print(attachDc2ToSgResp)
     self.assertEqual(attachDc2ToSgResp.error.errno, 0)
     print("attachDc2ToSg, jobUuid:", attachDc2ToSgResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', attachDc2ToSgResp.data[0].jobUuid)  # 轮询等待结果
     print("attachDc2ToSg, success:", success)
     self.assertTrue(success)
예제 #5
0
 def test_09_delete_sg_rule(self):
     print("================Begin Test Delete Sg Rule================")
     listSgResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0,
                         limit=10))  # 获取一个gz的Sg的Uuid
     self.assertEqual(listSgResp.error.errno, 0)
     self.assertTrue(len(listSgResp.data) > 0)
     lisgSgRuleResp = cli.sgStub.ListSgRule(
         c.ListSgRuleRequest(header=c.Header(regionId='gz'),
                             start=0,
                             limit=10,
                             condition=c.ListSgRuleCondition(
                                 sgUuid=listSgResp.data[0].sgUuid)))
     self.assertEqual(lisgSgRuleResp.error.errno, 0)
     self.assertTrue(len(lisgSgRuleResp.data) > 0)
     deleteSgRuleReq = c.DeleteSgRuleRequest(header=c.Header(regionId='gz'))
     sgToDelete = deleteSgRuleReq.sgRule.add()
     sgToDelete.sgRuleUuid = lisgSgRuleResp.data[0].sgRuleUuid
     deleteSgRuleResp = cli.sgStub.DeleteSgRule(deleteSgRuleReq)
     print(deleteSgRuleResp)
     self.assertEqual(deleteSgRuleResp.error.errno, 0)
     print("deleteSgRule, jobUuid:", deleteSgRuleResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', deleteSgRuleResp.data[0].jobUuid)  # 轮询等待结果
     print("deleteSgRule, success:", success)
     self.assertTrue(success)
예제 #6
0
 def test_02_check_dc2_price(self):
     print("================Begin Test Check Dc2 Price================")
     # 创建
     checkPriceResp = cli.billStub.CheckDc2Price(c.CheckDc2PriceRequest(header=c.Header(regionId='gz'),
                                                                        dc2Goods=c.CheckDc2PriceInput(count=2,
                                                                            payPeriod=3,
                                                                            dc2Model='dc2.s1.small1.d20',
                                                                            eip=c.CheckEipPriceInput(bandwidth=5),
                                                                            ebs=c.CheckEbsPriceInput(count=2,
                                                                                                     size=50,
                                                                                                     diskType='SSD'))))
     print(checkPriceResp)
     self.assertEqual(checkPriceResp.error.errno, 0)
     # 升配
     listResp = cli.dc2Stub.ListDc2(c.ListDc2Request(header=c.Header(regionId='gz'),
                                                     start=0, limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     checkChangePriceResp = cli.billStub.CheckDc2Price(c.CheckDc2PriceRequest(header=c.Header(regionId='gz'),
                                                                              isChange=True,
                                                                              dc2Goods=c.CheckDc2PriceInput(
                                                                                  dc2Uuid=listResp.data[0].dc2Uuid,
                                                                                  dc2Model='dc2.s1.large4.d40')))
     print(checkChangePriceResp)
     self.assertEqual(checkChangePriceResp.error.errno, 0)
예제 #7
0
 def test_11_reinstall_dc2_system(self):
     print(
         "================Begin Test Reinstall Dc2 System================")
     # 获取镜像并选择
     imgResp = cli.dc2Stub.ListImage(
         c.ListImageRequest(header=c.Header(regionId='gz')))
     self.assertEqual(imgResp.error.errno, 0)
     for img in imgResp.data:
         if img.osFamily == 'CentOS' and img.osVersion == '7.4':
             targetImgUuid = img.imgUuid
             break
     self.assertNotEqual(len(targetImgUuid), 0)
     listResp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     reinstallDc2SystemRequest = c.ReinstallDc2SystemRequest(
         header=c.Header(regionId='gz'))
     dc2ToReinstallSystem = reinstallDc2SystemRequest.dc2.add()
     dc2ToReinstallSystem.dc2Uuid = listResp.data[0].dc2Uuid
     dc2ToReinstallSystem.imgUuid = targetImgUuid
     dc2ToReinstallSystem.password = str_to_hex("newDc2Password123")
     reinstallDc2SystemResp = cli.dc2Stub.ReinstallDc2System(
         reinstallDc2SystemRequest)
     print(reinstallDc2SystemResp)
     self.assertEqual(reinstallDc2SystemResp.error.errno, 0)
     print("reinstallDc2System, jobUuid:",
           reinstallDc2SystemResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', reinstallDc2SystemResp.data[0].jobUuid)  # 轮询等待结果
     print("reinstallDc2System, success:", success)
     self.assertTrue(success)
예제 #8
0
 def test_08_change_subnet_name(self):
     print("================Begin Test Delete Snap================")
     listVpcResp = cli.vpcStub.ListVpc(c.ListVpcRequest(header=c.Header(regionId='gz'), start=0, limit=10))
     self.assertEqual(listVpcResp.error.errno, 0)
     self.assertTrue(len(listVpcResp.data) > 0)
     for vpc in listVpcResp.data:  # 选中刚才创建的VPC
         if vpc.name == 'testChangeVpcName':
             vpcToChangeUuid = vpc.vpcUuid
             break
     self.assertIsNotNone(vpcToChangeUuid)
     listSubnetResp = cli.vpcStub.ListSubnet(c.ListSubnetRequest(header=c.Header(regionId='gz'), start=0, limit=10,
                                                                 condition=c.ListSubnetCondition(
                                                                     vpcUuid=vpcToChangeUuid)))
     print(listSubnetResp)
     self.assertEqual(listSubnetResp.error.errno, 0)
     self.assertTrue(len(listSubnetResp.data) > 0)
     changeSubnetNameReq = c.ChangeSubnetNameRequest(header=c.Header(regionId='gz'),vpcUuid=vpcToChangeUuid)
     subnetToChangeName = changeSubnetNameReq.subnet.add()
     subnetToChangeName.subnetUuid = listSubnetResp.data[0].subnetUuid
     subnetToChangeName.name = 'testChangeSubnetName'
     changeSubnetNameResp = cli.vpcStub.ChangeSubnetName(changeSubnetNameReq)
     print(changeSubnetNameResp)
     self.assertEqual(changeSubnetNameResp.error.errno, 0)
     print("changeSubnetName, jobUuid:", changeSubnetNameResp.data[0].jobUuid)
     success = cli.wait_for_job_result('gz', changeSubnetNameResp.data[0].jobUuid)  # 轮询等待结果
     print("changeSubnetName, success:", success)
     self.assertTrue(success)
예제 #9
0
    def test_05_attach_eip_to_dc2(self):
        print("================Begin Test Attach Eip To Dc2================")
        listDc2Resp = cli.dc2Stub.ListDc2(
            c.ListDc2Request(header=c.Header(regionId='gz'), start=0,
                             limit=10))  # 获取一个gz的DC2的Uuid
        self.assertEqual(listDc2Resp.error.errno, 0)
        self.assertTrue(len(listDc2Resp.data) > 0)
        self.assertEqual(len(listDc2Resp.data[0].eip.eipUuid), 0)

        listEipResp = cli.eipStub.ListEip(
            c.ListEipRequest(header=c.Header(regionId='gz'), start=0,
                             limit=10))  # 获取一个gz的EIP的Uuid
        self.assertEqual(listEipResp.error.errno, 0)
        self.assertTrue(len(listEipResp.data) > 0)
        self.assertEqual(len(listEipResp.data[0].dc2.dc2Uuid), 0)
        attachEipToDc2Req = c.AttachEipToDc2Request(header=c.Header(
            regionId='gz'))
        eipToAttach = attachEipToDc2Req.eip.add()
        eipToAttach.bindingUuid = listDc2Resp.data[0].dc2Uuid
        eipToAttach.eipUuid = listEipResp.data[0].eipUuid
        attachEipToDc2Resp = cli.eipStub.AttachEipToDc2(attachEipToDc2Req)
        print(attachEipToDc2Resp)
        self.assertEqual(attachEipToDc2Resp.error.errno, 0)
        print("attachEipToDc2, jobUuid:", attachEipToDc2Resp.data[0].jobUuid)
        success = cli.wait_for_job_result(
            'gz', attachEipToDc2Resp.data[0].jobUuid)  # 轮询等待结果
        print("attachEipToDc2, success:", success)
        self.assertTrue(success)
예제 #10
0
 def test_05_list_subnet(self):
     print("================Begin Test List Subnet================")
     listVpcResp = cli.vpcStub.ListVpc(c.ListVpcRequest(header=c.Header(regionId='gz'), start=0, limit=10))
     print(listVpcResp)
     self.assertEqual(listVpcResp.error.errno, 0)
     self.assertTrue(len(listVpcResp.data) > 0)
     listSubnetResp = cli.vpcStub.ListSubnet(c.ListSubnetRequest(header=c.Header(regionId='gz'), start=0, limit=10,
                                                                 condition=c.ListSubnetCondition(vpcUuid=listVpcResp.data[0].vpcUuid)))
     print(listSubnetResp)
     self.assertEqual(listSubnetResp.error.errno, 0)
     self.assertTrue(len(listSubnetResp.data) > 0)
예제 #11
0
 def test_06_get_subnet_total_cnt(self):
     print("================Begin Test Get Subnet Total Cnt================")
     listVpcResp = cli.vpcStub.ListVpc(c.ListVpcRequest(header=c.Header(regionId='gz'), start=0, limit=10))
     print(listVpcResp)
     self.assertEqual(listVpcResp.error.errno, 0)
     self.assertTrue(len(listVpcResp.data) > 0)
     cntResp = cli.vpcStub.GetVpcTotalCnt(c.GetSubnetTotalCntRequest(header=c.Header(regionId='gz'),
                                                                     vpcUuid=listVpcResp.data[0].vpcUuid))
     print(cntResp)
     self.assertEqual(cntResp.error.errno, 0)
     self.assertTrue(cntResp.data[0].totalCnt > 0)
예제 #12
0
    def test_15_delete_ssh_key(self):
        print("================Begin Test Delete SSH Key================")
        listResp = cli.dc2Stub.ListSshKey(
            c.ListSshKeyRequest(header=c.Header(regionId='gz')))
        self.assertEqual(listResp.error.errno, 0)
        self.assertTrue(len(listResp.data) > 0)  # 获取一个sshKey

        deleteResp = cli.dc2Stub.DeleteSshKey(
            c.DeleteSshKeyRequest(header=c.Header(regionId='gz'),
                                  pubKeyUuid=listResp.data[0].pubKeyUuid))
        print(deleteResp)
        self.assertEqual(deleteResp.error.errno, 0)
예제 #13
0
 def test_05_get_dc2_by_uuid(self):
     print("================Begin Test Get Dc2 By Uuid================")
     listResp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     getDc2ByUuidResp = cli.dc2Stub.GetDc2ByUuid(
         c.GetDc2ByUuidRequest(header=c.Header(regionId='gz'),
                               dc2Uuid=listResp.data[0].dc2Uuid))
     print(getDc2ByUuidResp)
     self.assertEqual(getDc2ByUuidResp.error.errno, 0)
     self.assertTrue(len(getDc2ByUuidResp.data) > 0)
예제 #14
0
 def test_07_continue_monthly(self):
     print("================Begin Test Get Dc2 By Uuid================")
     listResp = cli.dc2Stub.ListDc2(c.ListDc2Request(header=c.Header(regionId='gz'),
                                                     start=0, limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     continueMonthlyReq = c.ContinueMonthlyRequest(header=c.Header(regionId='gz'), payPeriod=3)  # 续费3个月
     resourceToContinueMonthly = continueMonthlyReq.resource.add()    # 添加一个待操作的资源
     resourceToContinueMonthly.resourceUuid = listResp.data[0].dc2Uuid
     resourceToContinueMonthly.resourceType = 'dc2'
     continueMonthlyResp = cli.billStub.ContinueMonthly(continueMonthlyReq)
     print(continueMonthlyResp)
     self.assertEqual(continueMonthlyResp.error.errno, 0)
예제 #15
0
 def test_03_get_eip_by_uuid(self):
     print("================Begin Test Get Eip By Uuid================")
     listResp = cli.eipStub.ListEip(
         c.ListEipRequest(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个EBS的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     getEipByUuidResp = cli.eipStub.GetEipByUuid(
         c.GetEipByUuidRequest(header=c.Header(regionId='gz'),
                               eipUuid=listResp.data[0].eipUuid))
     print(getEipByUuidResp)
     self.assertEqual(getEipByUuidResp.error.errno, 0)
     self.assertTrue(len(getEipByUuidResp.data) > 0)
예제 #16
0
 def test_06_get_sg_rule_total_cnt(self):
     print(
         "================Begin Test Get Sg Rule Total Cnt================")
     listSgResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0,
                         limit=10))  # 获取一个gz的Sg的Uuid
     self.assertEqual(listSgResp.error.errno, 0)
     self.assertTrue(len(listSgResp.data) > 0)
     cntResp = cli.sgStub.GetSgRuleTotalCnt(
         c.GetSgRuleTotalCntRequest(header=c.Header(regionId='gz'),
                                    sgUuid=listSgResp.data[0].sgUuid))
     print(cntResp)
     self.assertEqual(cntResp.error.errno, 0)
     self.assertTrue(cntResp.data[0].totalCnt > 0)
예제 #17
0
 def test_05_list_sg_rule(self):
     print("================Begin Test List Sg Rule================")
     listSgResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0,
                         limit=10))  # 获取一个gz的Sg的Uuid
     self.assertEqual(listSgResp.error.errno, 0)
     self.assertTrue(len(listSgResp.data) > 0)
     lisgSgRuleResp = cli.sgStub.ListSgRule(
         c.ListSgRuleRequest(header=c.Header(regionId='gz'),
                             start=0,
                             limit=10,
                             condition=c.ListSgRuleCondition(
                                 sgUuid=listSgResp.data[0].sgUuid)))
     self.assertEqual(lisgSgRuleResp.error.errno, 0)
     self.assertTrue(len(lisgSgRuleResp.data) > 0)
예제 #18
0
 def test_08_change_expire_strategy(self):
     print("================Begin Test Start Dc2================")
     listResp = cli.dc2Stub.ListDc2(c.ListDc2Request(header=c.Header(regionId='gz'),
                                                     start=0, limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     changeExpireStrategyReq = c.ChangeExpireStrategyRequest(header=c.Header(regionId='gz'),
                                                             autoRenewCnt=2,
                                                             autoSwitch=True)  # 到期自动续费2个月,若余额不足以续费则自动转包月
     resourceToChangeStrategy = changeExpireStrategyReq.resource.add()    # 添加一个待操作的资源
     resourceToChangeStrategy.resourceUuid = listResp.data[0].dc2Uuid
     resourceToChangeStrategy.resourceType = 'dc2'
     changeExpireStrategyResp = cli.billStub.ChangeExpireStrategy(changeExpireStrategyReq)
     print(changeExpireStrategyResp)
     self.assertEqual(changeExpireStrategyResp.error.errno, 0)
예제 #19
0
 def test_02_list_sg(self):
     print("================Begin Test List Sg================")
     listResp = cli.sgStub.ListSg(
         c.ListSgRequest(header=c.Header(regionId='gz'), start=0, limit=10))
     print(listResp)
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
예제 #20
0
 def test_14_list_ssh_key(self):
     print("================Begin Test List SSH Key================")
     listResp = cli.dc2Stub.ListSshKey(
         c.ListSshKeyRequest(header=c.Header(regionId='gz')))
     print(listResp)
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
예제 #21
0
 def test_01_list_image(self):
     print("================Begin Test List Image================")
     # 获取镜像
     imgResp = cli.dc2Stub.ListImage(
         c.ListImageRequest(header=c.Header(regionId='gz')))
     print(imgResp)
     self.assertEqual(imgResp.error.errno, 0)
예제 #22
0
 def test_04_get_ebs_total_cnt(self):
     print("================Begin Test Get Ebs Total Cnt================")
     cntResp = cli.ebsStub.GetEbsTotalCnt(
         c.GetDc2TotalCntRequest(header=c.Header(regionId='gz')))
     print(cntResp)
     self.assertEqual(cntResp.error.errno, 0)
     self.assertTrue(cntResp.data[0].totalCnt > 0)
예제 #23
0
 def test_02_list_counter_data(self):
     print("================Begin Test List Counter Data================")
     # 获取曲线信息
     listCounterDataReq = c.ListCounterDataRequest(header=c.Header(
         regionId='gz'))
     counter1 = listCounterDataReq.counter.add()
     counter1.resourceType = 'dc2'
     counter1.resourceUuid = 'ec8d243a009c5c52b1fb44d358eeaf31'
     counter1.monitorTags = 'device=vda'
     counter1.metric = 'disk.write'
     counter1.startTime = 1560997040
     counter1.endTime = 1561000640
     counter2 = listCounterDataReq.counter.add()
     counter2.resourceType = 'dc2'
     counter2.resourceUuid = 'ec8d243a009c5c52b1fb44d358eeaf31'
     counter2.monitorTags = 'device=vda'
     counter2.metric = 'disk.write'
     counter2.startTime = 1560997040
     counter2.endTime = 1561000640
     counter3 = listCounterDataReq.counter.add()
     counter3.resourceType = 'eip'
     counter3.resourceUuid = '057ae1c9855c5062a4078183d497c13b'
     counter3.monitorTags = ''
     counter3.metric = 'rxbytes'
     counter3.startTime = 1560997040
     counter3.endTime = 1561000640
     counterDataResp = cli.monitorStub.ListCounterData(listCounterDataReq)
     print(counterDataResp)
     self.assertEqual(counterDataResp.error.errno, 0)
예제 #24
0
 def test_03_get_snap_total_cnt(self):
     print("================Begin Test Get Snap Total Cnt================")
     cntResp = cli.snapStub.GetSnapshotTotalCnt(
         c.GetSnapshotTotalCntRequest(header=c.Header(regionId='gz')))
     print(cntResp)
     self.assertEqual(cntResp.error.errno, 0)
     self.assertTrue(cntResp.data[0].totalCnt > 0)
예제 #25
0
    def test_02_create_dc2(self):
        print("================Begin Test Create Dc2================")
        # 获取镜像并选择
        imgResp = cli.dc2Stub.ListImage(
            c.ListImageRequest(header=c.Header(regionId='gz')))
        self.assertEqual(imgResp.error.errno, 0)
        for img in imgResp.data:
            if img.osFamily == 'CentOS' and img.osVersion == '7.5':
                targetImgUuid = img.imgUuid
                break

        self.assertNotEqual(len(targetImgUuid), 0)
        print("choose image, uuid:", targetImgUuid)
        # 获取子网并选择
        vpcResp = cli.vpcStub.ListVpc(
            c.ListVpcRequest(header=c.Header(regionId='gz'), start=0,
                             limit=10))
        self.assertEqual(vpcResp.error.errno, 0)
        subnetResp = cli.vpcStub.ListSubnet(
            c.ListSubnetRequest(header=c.Header(regionId='gz'),
                                condition=c.ListSubnetCondition(
                                    vpcUuid=vpcResp.data[0].vpcUuid),
                                start=0,
                                limit=10))
        self.assertEqual(subnetResp.error.errno, 0)
        print("choose subnet, uuid:", subnetResp.data[0].subnetUuid)
        createDc2Req = c.CreateDc2Request(
            header=c.Header(regionId='gz'),
            name='test-python-sdk',
            imgUuid=targetImgUuid,
            subnetUuid=subnetResp.data[0].subnetUuid,
            dc2Model='dc2.s1.small1.d20',
            password=str_to_hex('YourPassword123'))  # 密码进行16位编码后传输
        createDc2Req.eip.bandwidth = 5  # 同时创建EIP,设置带宽
        ebs1 = createDc2Req.ebs.add()  # 同时创建EBS,对于数组参数调用add()添加
        ebs1.diskType = 'SSD'
        ebs1.size = 30
        createDc2Resp = cli.dc2Stub.CreateDc2(createDc2Req)  # 创建DC2
        print(createDc2Resp)
        self.assertEqual(createDc2Resp.error.errno, 0)
        print("createDc2, jobUuid:", createDc2Resp.data[0].jobUuid)
        success = cli.wait_for_job_result(
            'gz', createDc2Resp.data[0].jobUuid)  # 轮询等待结果
        print("createDc2, success:", success)
        self.assertTrue(success)
예제 #26
0
 def test_08_reboot_dc2(self):
     print("================Begin Test Reboot Dc2================")
     listResp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个DC2的Uuid
     self.assertEqual(listResp.error.errno, 0)
     self.assertTrue(len(listResp.data) > 0)
     rebootDc2Request = c.RebootDc2Request(header=c.Header(regionId='gz'))
     dc2ToReboot = rebootDc2Request.dc2.add()  # 添加一个待操作的dc2
     dc2ToReboot.dc2Uuid = listResp.data[0].dc2Uuid
     rebootDc2Resp = cli.dc2Stub.RebootDc2(rebootDc2Request)
     print(rebootDc2Resp)
     self.assertEqual(rebootDc2Resp.error.errno, 0)
     print("rebootDc2, jobUuid:", rebootDc2Resp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', rebootDc2Resp.data[0].jobUuid)  # 轮询等待结果
     print("rebootDc2, success:", success)
     self.assertTrue(success)
예제 #27
0
 def test_08_delete_eip(self):
     print("================Begin Test Delete Eip================")
     listEipResp = cli.eipStub.ListEip(
         c.ListEipRequest(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个gz的EIP的Uuid
     self.assertEqual(listEipResp.error.errno, 0)
     self.assertTrue(len(listEipResp.data) > 0)
     deleteEipReq = c.DeleteEipRequest(header=c.Header(regionId='gz'))
     eipToDelete = deleteEipReq.eip.add()
     eipToDelete.eipUuid = listEipResp.data[0].eipUuid
     deleteEipResp = cli.eipStub.DeleteEip(deleteEipReq)
     print(deleteEipResp)
     self.assertEqual(deleteEipResp.error.errno, 0)
     print("deleteEip, jobUuid:", deleteEipResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', deleteEipResp.data[0].jobUuid)  # 轮询等待结果
     print("deleteEip, success:", success)
     self.assertTrue(success)
예제 #28
0
 def test_01_create_vpc(self):
     print("================Begin Test Create Vpc================")
     createVpcResp = cli.vpcStub.CreateVpc(c.CreateVpcRequest(header=c.Header(regionId='gz'),
                                                        name='testCreateVpc', cidr='172.16.0.0/12'))
     self.assertEqual(createVpcResp.error.errno, 0)
     print("createVpc, jobUuid:", createVpcResp.data[0].jobUuid)
     success = cli.wait_for_job_result('gz', createVpcResp.data[0].jobUuid)  # 轮询等待结果
     print("createVpc, success:", success)
     self.assertTrue(success)
예제 #29
0
 def test_06_delete_snap(self):
     print("================Begin Test Delete Snap================")
     listSnapResp = cli.snapStub.ListSnapshot(
         c.ListSnapshotRequest(header=c.Header(regionId='gz'),
                               start=0,
                               limit=10))  # 获取一个gz的Snap的Uuid
     self.assertEqual(listSnapResp.error.errno, 0)
     self.assertTrue(len(listSnapResp.data) > 0)
     deleteSnapReq = c.DeleteSnapshotRequest(header=c.Header(regionId='gz'))
     snapToDelete = deleteSnapReq.snap.add()
     snapToDelete.snapUuid = listSnapResp.data[0].snapUuid
     deleteSnapResp = cli.snapStub.DeleteSnapshot(deleteSnapReq)
     print(deleteSnapResp)
     self.assertEqual(deleteSnapResp.error.errno, 0)
     print("deleteSnap, jobUuid:", deleteSnapResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', deleteSnapResp.data[0].jobUuid)  # 轮询等待结果
     print("deleteSnap, success:", success)
     self.assertTrue(success)
예제 #30
0
 def test_01_create_snap(self):
     print("================Begin Test Create Snap================")
     listDc2Resp = cli.dc2Stub.ListDc2(
         c.ListDc2Request(header=c.Header(regionId='gz'), start=0,
                          limit=10))  # 获取一个gz的DC2的Uuid
     self.assertEqual(listDc2Resp.error.errno, 0)
     self.assertTrue(len(listDc2Resp.data) > 0)
     createSnapReq = c.CreateSnapshotRequest(
         header=c.Header(regionId='gz'),
         dc2Uuid=listDc2Resp.data[0].dc2Uuid,
         snapName='testSnap')  # 给DC2打快照
     createSnapResp = cli.snapStub.CreateSnapshot(createSnapReq)
     print(createSnapResp)
     self.assertEqual(createSnapResp.error.errno, 0)
     print("createSnap, jobUuid:", createSnapResp.data[0].jobUuid)
     success = cli.wait_for_job_result(
         'gz', createSnapResp.data[0].jobUuid)  # 轮询等待结果
     print("createSnap, success:", success)
     self.assertTrue(success)