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);
如何在创建虚拟服务器时配置静态IP地址,而不是分配动态IP地址。我使用上面的代码,但它不适合我。请建议配置静态IP地址的最佳方法。
答案 0 :(得分:0)
不幸的是,在创建VSI时,您无法配置IP地址。配置过程在子网中查找分配给VSI的可用IP地址,此IP地址是静态的,因此每次打开/关闭VSI时都不会更改。
可以在文档中找到更多信息,例如在can-i-move-my-ip-address-one-server-another?中说:
每个客户将收到一个主IP地址的初始路由块。主IP地址绑定到每个单独的服务器,除非服务器被取消并被现有VLAN上的新服务器替换,否则无法移动。
以下是一些可以查看子网和IP地址的链接。
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