问题
Image image = new Image();
image.setCapacity(50L);
Guest guest = new Guest();
guest.setHostname("hostname1");
guest.setDomain("softlayer.com");
guest.setStartCpus(1l);
guest.setMaxMemory(1024l);
guest.setDatacenter(new Location());
guest.getDatacenter().setName("che01");
guest.setLocalDiskFlag(false);
guest.setHourlyBillingFlag(true);
guest.setOperatingSystemReferenceCode("UBUNTU_LATEST");
Component privateComponent = new Component();
Component publicComponent = new Component();
Vlan privateVlan = new Vlan();
privateVlan.setVlanNumber(1365L);
privateVlan.setId(2117919L);
Subnet privateSubnet = new Subnet();
privateSubnet.setId(1059121L);
privateComponent.setNetworkVlan(privateVlan);
privateComponent.setPrimarySubnet(privateSubnet);
guest.setPrimaryBackendNetworkComponent(privateComponent);
Vlan publicVlan = new Vlan();
publicVlan.setId(2117917L);
publicVlan.setVlanNumber(1290L);
Subnet primarySubnetVersion4 = new Subnet();
primarySubnetVersion4.setVersion(4L);
primarySubnetVersion4.setId(1547547L);
publicVlan.setPrimarySubnet(primarySubnetVersion4);
publicComponent.setNetworkVlan(publicVlan);
publicComponent.setPrimaryIpAddress("169.38.101.156");
guest.setPrimaryNetworkComponent(publicComponent);
Guest.service(client).createObject(guest);
How to configure a static ip address while creating a virtual server instead of assigning the dynamic IP address. I used the above code but its not working for me. please suggest a best way to configure the static ip address.
回答1:
Unfortunately you won't be able to configure the ip address while creating the VSI. The provisioning process looks for an available ip address in the subnet an it is assigned to the VSI, this ip address is static so it will not change each time you turn on/off the VSI.
More info can be find in the documentation, for example in can-i-move-my-ip-address-one-server-another? says:
Each customer will receive an initial routed block of one primary IP address. Primary IP addresses are bound to each individual server and cannot be moved unless the server is cancelled and replaced by a new server on the existing VLAN.
Below are some links that you can review about subnets and ip addresses.
http://knowledgelayer.softlayer.com/faq/can-i-move-my-ip-address-one-server-another
http://knowledgelayer.softlayer.com/faq/how-are-server-ip-addresses-assigned-softlayer-network
http://knowledgelayer.softlayer.com/faq/can-i-pick-my-servers-private-ip
http://knowledgelayer.softlayer.com/learning/virtual-machine-network-setup
http://knowledgelayer.softlayer.com/learning/utilizing-subnets-and-ips
http://knowledgelayer.softlayer.com/faq/how-do-i-use-public-network
来源:https://stackoverflow.com/questions/47308281/static-ip-address-allocation-for-public-virtual-server