我想在负载均衡器的serviceGroup中删除服务包含 但它会犯错!!
如何删除服务& serviceGroup使用java API?
VirtualIpAddress.Service vipService = VirtualIpAddress.service(client, virtualIpAddressId);
vipService.clearMask();
StringBuffer maskBuffer = new StringBuffer();
maskBuffer.append("mask");
maskBuffer.append("[");
maskBuffer.append("applicationDeliveryController");
maskBuffer.append(",billingItem");
maskBuffer.append(",ipAddress");
maskBuffer.append(",loadBalancerHardware[datacenterName,location]");
maskBuffer.append(",secureTransportCiphers");
maskBuffer.append(",secureTransportProtocols");
maskBuffer.append(",virtualServers[");
maskBuffer.append(" serviceGroups[");
maskBuffer.append(" routingMethod,routingType,serviceReferences,services[");
maskBuffer.append(" groupReferences,healthChecks,ipAddress]]]");
maskBuffer.append("]");
vipService.setMask(maskBuffer.toString());
VirtualIpAddress virtualIpAddress = vipService.getObject();
List<VirtualServer> virtualServerList = virtualIpAddress.getVirtualServers();
for(VirtualServer virtualServer : virtualServerList) {
List<Group> serviceGroupList = virtualServer.getServiceGroups();
for(Group group : serviceGroupList) {
List<com.softlayer.api.service.network.application.delivery.controller.loadbalancer.LoadBalancerService> serviceList = group.getServices();
for(com.softlayer.api.service.network.application.delivery.controller.loadbalancer.LoadBalancerService service : serviceList) {
LoadBalancerService.Service loadBalancerService = LoadBalancerService.service(client, service.getId());
System.out.println("loadBalancerService : " + loadBalancerService);
serviceDelFlag = loadBalancerService.deleteObject();
}
}
}
发生错误:
serviceGroupService : Service: SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer with ID 234553
com.softlayer.api.ApiException$NotFound: Unable to find object with id of '234553'.(code: SoftLayer_Exception_ObjectNotFound, status: 404)
at com.softlayer.api.ApiException.fromError(ApiException.java:14)
at com.softlayer.api.RestApiClient$ServiceProxy.logAndHandleResponse(RestApiClient.java:308)
at com.softlayer.api.RestApiClient$ServiceProxy.invokeService(RestApiClient.java:359)
at com.softlayer.api.RestApiClient$ServiceProxy.invoke(RestApiClient.java:537)
at com.sun.proxy.$Proxy15.deleteObject(Unknown Source)
at com.ibm.softlayer.network.LoadBalancingTest_v1.getLoadBalancerDetail(LoadBalancingTest_v1.java:219)
at com.ibm.softlayer.network.LoadBalancingTest_v1.viewLoadBalancerList(LoadBalancingTest_v1.java:134)
at com.ibm.softlayer.network.LoadBalancingTest_v1.getLoadBalancers(LoadBalancingTest_v1.java:125)
at com.ibm.softlayer.network.LoadBalancingTest_v1.test(LoadBalancingTest_v1.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
答案 0 :(得分:0)
对象类型SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer不存在ID 234553,这就是错误。
获取可以调用方法的对象的有效ID:http://sldn.softlayer.com/reference/services/SoftLayer_Account/getAdcLoadBalancers +用于列出虚拟服务器的对象掩码。这里是一个使用Restful的例子:
GET https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getAdcLoadBalancers?objectMask=mask[virtualServers]
确保在方法中使用正确的ID。
如果您仍然遇到Java客户端问题,请告诉我在java中为您编写示例。
此致