2016-11-13 82 views
0

我使用创建现有虚拟机的图片下面的代码 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。如果没有,请告诉我们在创建虚拟机时可以使用哪些其他方法来设置特定的私有/公共密码。

回答

0

是的,这是方法,但它取决于你用来创建虚拟机的方法。你需要为门户使用是placeOrder使用相同的方法,如果您使用的是createObject方法将无法正常工作,与该方法只可以指定主音和后端网络

0

所属VLAN这是不可能的在供应过程中分配IP。您可以选择一个子网来提取IP,但您无法在订购时绑定特定的IP。