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)
def test_02_list_eip(self): print("================Begin Test List Eip================") listResp = cli.eipStub.ListEip( c.ListEipRequest(header=c.Header(regionId='gz'), start=0, limit=10)) print(listResp) self.assertEqual(listResp.error.errno, 0) self.assertTrue(len(listResp.data) > 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)
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)
def test_03_check_eip_price(self): print("================Begin Test Check Eip Price================") # 创建 checkPriceResp = cli.billStub.CheckEipPrice(c.CheckEipPriceRequest(header=c.Header(regionId='gz'), eipGoods=c.CheckEipPriceInput(count=2, payPeriod=3, bandwidth=5))) print(checkPriceResp) self.assertEqual(checkPriceResp.error.errno, 0) # 升配 listResp = cli.eipStub.ListEip(c.ListEipRequest(header=c.Header(regionId='gz'), start=0, limit=10)) # 获取一个Eip的Uuid self.assertEqual(listResp.error.errno, 0) self.assertTrue(len(listResp.data) > 0) checkChangePriceResp = cli.billStub.CheckEipPrice(c.CheckEipPriceRequest(header=c.Header(regionId='gz'), isChange=True, eipGoods=c.CheckEipPriceInput( eipUuid=listResp.data[0].eipUuid, bandwidth=10))) print(checkChangePriceResp) self.assertEqual(checkChangePriceResp.error.errno, 0)
def test_06_detach_eip_from_dc2(self): print("================Begin Test Detach Eip From Dc2================") 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.assertIsNotNone(listEipResp.data[0].dc2) detachEipFromDc2Req = c.DetachEipFromDc2Request(header=c.Header( regionId='gz')) eipToDetach = detachEipFromDc2Req.eip.add() eipToDetach.eipUuid = listEipResp.data[0].eipUuid detachEipFromDc2Resp = cli.eipStub.DetachEipFromDc2( detachEipFromDc2Req) print(detachEipFromDc2Resp) self.assertEqual(detachEipFromDc2Resp.error.errno, 0) print("detachEipFromDc2, jobUuid:", detachEipFromDc2Resp.data[0].jobUuid) success = cli.wait_for_job_result( 'gz', detachEipFromDc2Resp.data[0].jobUuid) # 轮询等待结果 print("detachEipFromDc2, success:", success) self.assertTrue(success)
def test_07_change_eip_bandwidth(self): print("================Begin Test Change Ebs Size ================") 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) changeEipBandwidthReq = c.ChangeEipBandwidthRequest(header=c.Header( regionId='gz')) eipToChangeBandwidth = changeEipBandwidthReq.eip.add() eipToChangeBandwidth.eipUuid = listEipResp.data[0].eipUuid eipToChangeBandwidth.bandwidth = 2 changeEipBandwidthResp = cli.eipStub.ChangeEipBandwidth( changeEipBandwidthReq) print(changeEipBandwidthResp) self.assertEqual(changeEipBandwidthResp.error.errno, 0) print("changeEipBandwidth, jobUuid:", changeEipBandwidthResp.data[0].jobUuid) success = cli.wait_for_job_result( 'gz', changeEipBandwidthResp.data[0].jobUuid) # 轮询等待结果 print("changeEipBandwidth, success:", success) self.assertTrue(success)
def test_01_get_charge_info_and_spec(self): print("================Begin Test Get Charge Info And Spec================") # DC2 listDc2Resp = cli.dc2Stub.ListDc2(c.ListDc2Request(header=c.Header(regionId='gz'), start=0, limit=10)) # 获取一个DC2的Uuid self.assertEqual(listDc2Resp.error.errno, 0) self.assertTrue(len(listDc2Resp.data) > 0) dc2Req = c.GetChargeInfoAndSpecRequest(header=c.Header(regionId='gz')) resource = dc2Req.resource.add() resource.resourceUuid = listDc2Resp.data[0].dc2Uuid getDc2ChargeInfoAndSpecResp = cli.billStub.GetDc2ChargeInfoAndSpec(dc2Req) self.assertEqual(getDc2ChargeInfoAndSpecResp.error.errno, 0) self.assertTrue(len(getDc2ChargeInfoAndSpecResp.data) > 0) # EIP listEipResp = cli.eipStub.ListEip(c.ListEipRequest(header=c.Header(regionId='gz'), start=0, limit=10)) # 获取一个Eip的Uuid self.assertEqual(listEipResp.error.errno, 0) self.assertTrue(len(listEipResp.data) > 0) eipReq = c.GetChargeInfoAndSpecRequest(header=c.Header(regionId='gz')) resource = eipReq.resource.add() resource.resourceUuid = listEipResp.data[0].eipUuid getEipChargeInfoAndSpecResp = cli.billStub.GetEipChargeInfoAndSpec(eipReq) self.assertEqual(getEipChargeInfoAndSpecResp.error.errno, 0) self.assertTrue(len(getEipChargeInfoAndSpecResp.data) > 0) # EBS listEbsResp = cli.ebsStub.ListEbs(c.ListEbsRequest(header=c.Header(regionId='gz'), start=0, limit=10)) # 获取一个Ebs的Uuid self.assertEqual(listEbsResp.error.errno, 0) self.assertTrue(len(listEbsResp.data) > 0) ebsReq = c.GetChargeInfoAndSpecRequest(header=c.Header(regionId='gz')) resource = ebsReq.resource.add() resource.resourceUuid = listEbsResp.data[0].ebsUuid getEbsChargeInfoAndSpecResp = cli.billStub.GetEbsChargeInfoAndSpec(ebsReq) self.assertEqual(getEbsChargeInfoAndSpecResp.error.errno, 0) self.assertTrue(len(getEbsChargeInfoAndSpecResp.data) > 0)