Search code examples
ibm-cloud-infrastructure

AuthScale Network selection


I'm implementing Autoscale using Softlayer Java Client. When adding a scale group, network option can be selected.(please refer to the attached png) How can I get the Network options in the select box ? Can you provide me samples or APIs ? Auto scale network


Solution

  • The code below will list all the VLANS, then you need to filter the data. You will notice the following object Mask mask[primaryRouter[datacenter[groups]], networkSpace] The "networkSpace" specifies if the VLAN is Public or Private, so use a filter to get all private VLANS. The mask primaryRouter[datacenter[groups]will return the datacenter where the VLAN is available, so according the selected Region or Datacenter you need to filter the data in order to display the VLANs which are avaialbe for that region or datacenter.

    You can use this method to get the datacenters and their groups http://sldn.softlayer.com/reference/services/SoftLayer_Location/getDatacenters

    import com.softlayer.api.ApiClient;
    import com.softlayer.api.RestApiClient;
    import com.softlayer.api.service.Account;
    import com.google.gson.Gson;
    
    public class VlanScale {
    
        private static String user = "set me";
    
        private static String apiKey = "set me";
    
        private static ApiClient client = new RestApiClient().withCredentials(user, apiKey);
    
        public static void main(String[] args) {
    
            // Declare the API client
            ApiClient client = new RestApiClient().withCredentials(user, apiKey);
            Account.Service accountService = Account.service(client);
    
            accountService.setMask("mask[primaryRouter[datacenter[groups]], networkSpace]");
    
            // Send the request to get the VLANs and print the result
            try {
                Gson gson = new Gson();
                System.out.println(gson.toJson(accountService.getNetworkVlans()));
    
    
            } catch (Exception e) {
                    System.out.println("Unable to retrieve the VLANs. "
                                + e.getMessage());
            }
    
        }
    
    }
    

    Regards