我使用创建现有虚拟机的图片下面的代码 service.createArchiveTransaction(templateName, blockDevices, "Image of " + vm.getHostname());
非特异性分配IP地址的虚拟机
我又创建通过API使用这种图像的虚拟机。虚拟机正在创建,但是他们分配的公有和私有ips不是我想要的。那些要么是旧的ips,要么是一些新的随机ips。
我用下面的代码分配IP: `
// Set subnet ID for Dallas 9
String primaryBackendIPAddress = "10.0.20.98"; //this ip is availble for user under the chosen subnet
Component netComp1 = new Component();
Vlan vlan = new Vlan();
vlan.setId(new Long(1229225));// id of vlan associated to the subnet
Subnet ss1 = new Subnet();
IpAddress ipaddr = new IpAddress();
ipaddr.setIpAddress("10.0.253.1");
ss1.setEndPointIpAddress(ipaddr);
ss1.setId(new Long(1208349)); // setting id of the subnet
vlan.setPrimarySubnet(ss1);
netComp1.setNetworkVlan(vlan);
netComp1.setMaxSpeed(new Long(1000));
guest.setPrimaryBackendNetworkComponent(netComp1);
guest.setPrimaryBackendIpAddress(primaryBackendIPAddress);
`
我想知道,如果这种做法是正确的设置私有/公共IPS。如果没有,请告诉我们在创建虚拟机时可以使用哪些其他方法来设置特定的私有/公共密码。