2016-08-02 50 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

感謝。它工作正常。 –