0
votes

I want to delete service include in serviceGroup of load balancer but it make error !!

How to delete service & serviceGroup using 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();
                }
            }
        } 

occurring error:

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)
1

1 Answers

0
votes

Well the ID 234553 does not exist for the object type SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer, that is the error.

to get the valid IDs for the object you can call the method: http://sldn.softlayer.com/reference/services/SoftLayer_Account/getAdcLoadBalancers + an object mask to list the virtual server. here an example using Restful:

GET https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getAdcLoadBalancers?objectMask=mask[virtualServers]

with this method you will delete service groups http://sldn.softlayer.com/reference/services/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualServer/dele

with this method you will delete services: http://sldn.softlayer.com/reference/services/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_Service/deleteObje

Just make sure you are using the correct IDs in the methods.

If you are still having issues with the Java client let me know to write an example in java for you.

Regards