2016-08-02 45 views
0

我正在使用Softlayer Java Client实现Autoscale。添加刻度组时,可以选择网络选项(请参阅附件中的png) 如何在选择框中获取网络选项?你能提供我样品或API吗? Auto scale networkAuthScale网络选择

回答

0

下面的代码将列出所有的VLAN,然后你需要过滤数据。您会注意到以下对象Mask mask[primaryRouter[datacenter[groups]], networkSpace]“networkSpace”指定该VLAN是Public还是Private,因此使用过滤器来获取所有专用VLAN。 掩码primaryRouter[datacenter[groups]将返回可用VLAN的数据中心,因此根据所选区域或数据中心,您需要过滤数据以显示该区域或数据中心可用的VLAN。

您可以使用此方法来获得数据中心和他们的群体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()); 
     } 

    } 

} 

问候

+0

感谢。它工作正常。 –