答案 0 :(得分:0)
下一个java脚本可用于将资产添加到SoftLayer Auto Scale:
/**
* This script creates a SoftLayer_Scale_Asset_Virtual_Guest for a
* SoftLayer_Scale_Group
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Asset_Virtual_Guest/createObject
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Scale_Asset_Virtual_Guest
*
* @license <http://sldn.softlayer.com/wiki/index.php/License>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
package SoftLayer_Java_Scripts.Examples;
import com.softlayer.api.*;
import com.softlayer.api.service.scale.asset.virtual.Guest;
import com.google.gson.Gson;
public class CreateScaleAssetVirtualGuest
{
public static void main( String[] args )
{
// Fill with your valid data here.
String user = "set me";
String apiKey = "set me";
long scaleGroupId = 112233;
long virtualGuestId = 44556677;
// Creating a client and the service that’s going to call the API method.
ApiClient client = new RestApiClient().withCredentials(user, apiKey);
Guest.Service service = Guest.service(client);
// A SoftLayer_Scale_Asset_Virtual_Guest container used to store the scale group id and
// the virtual guest id that’s going to be the new asset.
Guest assetVirtualGuestTemplate = new Guest();
assetVirtualGuestTemplate.setScaleGroupId(scaleGroupId);
assetVirtualGuestTemplate.setVirtualGuestId(virtualGuestId);
try
{
Guest assetVirtualGuest = service.createObject(assetVirtualGuestTemplate);
Gson gson = new Gson();
System.out.println(gson.toJson(assetVirtualGuest));
}
catch(Exception e)
{
System.out.println("Script failed, review the next message for further details: " + e);
}
}
}
下一个链接也可以帮助您: http://sldn.softlayer.com/reference/services/SoftLayer_Scale_Asset_Virtual_Guest/createObject http://sldn.softlayer.com/reference/datatypes/SoftLayer_Scale_Asset_Virtual_Guest