在为自动缩放选项设置计算实例时,有公共和专用网络上行链路。当我设置网络组件时,我只设置速度。如何设置私人&公共网络和速度?
// Network Components
Component networkComponent = new Component();
networkComponent.setMaxSpeed(speed);
virtualGuestMemberTemplate.getNetworkComponents().add(networkComponent);
答案 0 :(得分:0)
您可以使用networkComponent.setPrivateNetworkOnlyFlag(true);
仅使用专用网络上行链路。将其设置为false允许Public&私人网络上行链接。
此外,您可以使用此脚本检查可用的速度值。
package SoftLayer_Java_Scripts.Examples;
import java.util.List;
import com.softlayer.api.*;
import com.softlayer.api.service.virtual.Guest;
import com.softlayer.api.service.virtual.guest.network.Component;
import com.softlayer.api.service.container.virtual.guest.Configuration;
import com.softlayer.api.service.container.virtual.guest.configuration.Option;
public class GetNetworkComponentsTemplates {
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 ) {
Guest.Service virtualGuestService = Guest.service(client);
try
{
Configuration config = virtualGuestService.getCreateObjectOptions();
List<Option> options = config.getNetworkComponents();
for(Option option : options) {
String description = option.getItemPrice().getItem().getDescription();
List<Component> networkComponents = option.getTemplate().getNetworkComponents();
long maxSpeed = 0L;
for(Component network : networkComponents) {
maxSpeed = network.getMaxSpeed();
}
System.out.println("*** Network Component ***");
System.out.println("Description: " + description);
System.out.println("Max Speed: " + maxSpeed + "\n");
}
}
catch(Exception e)
{
System.out.println("Script failed, review the next message for further details: " + e);
}
}
}
答案 1 :(得分:0)
我应该更清楚地看到我以前的答案,我正在添加用于创建Scale组的脚本,其中包含设置a所需的修改 虚拟访客网络组件。
我希望这对你有所帮助。
package SoftLayer_Java_Scripts.Examples;
import com.google.gson.Gson;
import com.softlayer.api.*;
import com.softlayer.api.service.Location;
import com.softlayer.api.service.scale.Group;
import com.softlayer.api.service.virtual.Guest;
import com.softlayer.api.service.virtual.guest.network.Component;
public class CreateScaleGroup {
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) {
Group.Service scaleGroupService = Group.service(client);
Location location = new Location();
location.setName("hkg02");
// Standard Virtual Guest configuration.
Guest guest = new Guest();
guest.setDomain("softlayer.com");
guest.setHostname("hostnametest");
guest.setPostInstallScriptUri("https://www.softlayer.com/script");
guest.setStartCpus(new Long (1));
guest.setDatacenter(location);
guest.setHourlyBillingFlag(true);
guest.setLocalDiskFlag(false);
guest.setOperatingSystemReferenceCode("CENTOS_LATEST");
guest.setMaxMemory(new Long (1));
/*
* The configuration for SoftLayer_Virtual_Guest_Network_Component
* depends on combinations of the network component max speed
* and the virtual guest privateNetworkOnlyFlag.
*
* The available configurations are:
* 1.- Network maxSpeed ( 10) Guest privateNetworkOnlyFlag (false) for "10 Mbps Public & Private Network Uplinks"
* 2.- Network maxSpeed ( 100) Guest privateNetworkOnlyFlag (false) for "100 Mbps Public & Private Network Uplinks"
* 3.- Network maxSpeed (1000) Guest privateNetworkOnlyFlag (false) for "1 Gbps Public & Private Network Uplinks"
* 4.- Network maxSpeed ( 10) Guest privateNetworkOnlyFlag ( true) for "10 Mbps Private Network Uplink"
* 5.- Network maxSpeed ( 100) Guest privateNetworkOnlyFlag ( true) for "100 Mbps Private Network Uplink"
* 6.- Network maxSpeed (1000) Guest privateNetworkOnlyFlag ( true) for "1 Gbps Private Network Uplink"
*/
Component networkComponent = new Component();
networkComponent.setMaxSpeed(new Long(100));
guest.getNetworkComponents().add(networkComponent);
guest.setPrivateNetworkOnlyFlag(false);
// Standard scale group configuration.
Group scaleGroup = new Group();
scaleGroup.setCooldown(new Long(1800));
scaleGroup.setMaximumMemberCount(new Long(5));
scaleGroup.setMinimumMemberCount(new Long(1));
scaleGroup.setName("testVSI");
scaleGroup.setRegionalGroupId(new Long(102));
scaleGroup.setSuspendedFlag(false);
scaleGroup.setTerminationPolicyId(new Long(2));
scaleGroup.setVirtualGuestMemberTemplate(guest);
scaleGroup.setVirtualGuestMemberCount(new Long(0));
Gson gson = new Gson();
System.out.println(gson.toJson(scaleGroupService.createObject(scaleGroup)));
}
}