mirror of https://github.com/apache/cloudstack.git
IPv6: Add support for IPv6 on DeployVMCmd
Conflicts: api/src/com/cloud/api/commands/DeployVMCmd.java api/src/com/cloud/network/Network.java server/src/com/cloud/network/NetworkManagerImpl.java
This commit is contained in:
parent
e89d9e6272
commit
44d0cd6621
|
|
@ -44,6 +44,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network.IpAddresses;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
|
|
@ -123,12 +124,17 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name=ApiConstants.SECURITY_GROUP_NAMES, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of security groups names that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter")
|
||||
private List<String> securityGroupNameList;
|
||||
|
||||
@Parameter(name = ApiConstants.IP_NETWORK_LIST, type = CommandType.MAP, description = "ip to network mapping. Can't be specified with networkIds parameter. Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].networkid=204 - requests to use ip 10.10.10.11 in network id=204")
|
||||
@Parameter(name = ApiConstants.IP_NETWORK_LIST, type = CommandType.MAP,
|
||||
description = "ip to network mapping. Can't be specified with networkIds parameter." +
|
||||
" Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].ipv6=fc00:1234:5678::abcd&iptonetworklist[0].networkid=uuid - requests to use ip 10.10.10.11 in network id=uuid")
|
||||
private Map ipToNetworkList;
|
||||
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the ip address for default vm's network")
|
||||
private String ipAddress;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.IP6_ADDRESS, type=CommandType.STRING, description="the ipv6 address for default vm's network")
|
||||
private String ip6Address;
|
||||
|
||||
@Parameter(name=ApiConstants.KEYBOARD, type=CommandType.STRING, description="an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us")
|
||||
private String keyboard;
|
||||
|
||||
|
|
@ -222,7 +228,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
public List<Long> getNetworkIds() {
|
||||
if (ipToNetworkList != null) {
|
||||
if (networkIds != null || ipAddress != null) {
|
||||
if (networkIds != null || ipAddress != null || ip6Address != null) {
|
||||
throw new InvalidParameterValueException("ipToNetworkMap can't be specified along with networkIds or ipAddress");
|
||||
} else {
|
||||
List<Long> networks = new ArrayList<Long>();
|
||||
|
|
@ -248,21 +254,23 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
public boolean getStartVm() {
|
||||
return startVm == null ? true : startVm;
|
||||
}
|
||||
|
||||
private Map<Long, String> getIpToNetworkMap() {
|
||||
if ((networkIds != null || ipAddress != null) && ipToNetworkList != null) {
|
||||
|
||||
private Map<Long, IpAddresses> getIpToNetworkMap() {
|
||||
if ((networkIds != null || ipAddress != null || ip6Address != null) && ipToNetworkList != null) {
|
||||
throw new InvalidParameterValueException("NetworkIds and ipAddress can't be specified along with ipToNetworkMap parameter");
|
||||
}
|
||||
LinkedHashMap<Long, String> ipToNetworkMap = null;
|
||||
LinkedHashMap<Long, IpAddresses> ipToNetworkMap = null;
|
||||
if (ipToNetworkList != null && !ipToNetworkList.isEmpty()) {
|
||||
ipToNetworkMap = new LinkedHashMap<Long, String>();
|
||||
ipToNetworkMap = new LinkedHashMap<Long, IpAddresses>();
|
||||
Collection ipsCollection = ipToNetworkList.values();
|
||||
Iterator iter = ipsCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> ips = (HashMap<String, String>) iter.next();
|
||||
Long networkId = Long.valueOf(_responseGenerator.getIdentiyId("networks", ips.get("networkid")));
|
||||
String requestedIp = (String) ips.get("ip");
|
||||
ipToNetworkMap.put(networkId, requestedIp);
|
||||
String requestedIpv6 = (String) ips.get("ipv6");
|
||||
IpAddresses addrs = new IpAddresses(requestedIp, requestedIpv6);
|
||||
ipToNetworkMap.put(networkId, addrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -396,23 +404,24 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||
if (getHypervisor() == HypervisorType.BareMetal) {
|
||||
vm = _bareMetalVmService.createVirtualMachine(this);
|
||||
} else {
|
||||
IpAddresses addrs = new IpAddresses(ipAddress, ip6Address);
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
if (getNetworkIds() != null) {
|
||||
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
|
||||
} else {
|
||||
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
|
||||
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
|
||||
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
|
||||
}
|
||||
} else {
|
||||
if (zone.isSecurityGroupEnabled()) {
|
||||
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
|
||||
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
|
||||
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
|
||||
} else {
|
||||
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
|
||||
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
|
||||
}
|
||||
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
|
||||
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
|
||||
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, keyboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,6 +256,32 @@ public interface Network extends ControlledEntity {
|
|||
*/
|
||||
long getId();
|
||||
|
||||
public class IpAddresses {
|
||||
private String ip4Address;
|
||||
private String ip6Address;
|
||||
|
||||
public IpAddresses(String ip4Address, String ip6Address) {
|
||||
this.setIp4Address(ip4Address);
|
||||
this.setIp6Address(ip6Address);
|
||||
}
|
||||
|
||||
public String getIp4Address() {
|
||||
return ip4Address;
|
||||
}
|
||||
|
||||
public void setIp4Address(String ip4Address) {
|
||||
this.ip4Address = ip4Address;
|
||||
}
|
||||
|
||||
public String getIp6Address() {
|
||||
return ip6Address;
|
||||
}
|
||||
|
||||
public void setIp6Address(String ip6Address) {
|
||||
this.ip6Address = ip6Address;
|
||||
}
|
||||
}
|
||||
|
||||
String getName();
|
||||
|
||||
Mode getMode();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import com.cloud.exception.StorageUnavailableException;
|
|||
import com.cloud.exception.VirtualMachineMigrationException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network.IpAddresses;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Volume;
|
||||
|
|
@ -199,7 +200,7 @@ public interface UserVmService {
|
|||
* @throws InsufficientResourcesException
|
||||
*/
|
||||
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName,
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, String keyboard)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
|
||||
|
||||
/**
|
||||
|
|
@ -246,7 +247,7 @@ public interface UserVmService {
|
|||
* - name of the ssh key pair used to login to the virtual machine
|
||||
* @param requestedIps
|
||||
* TODO
|
||||
* @param defaultIp
|
||||
* @param defaultIps
|
||||
* TODO
|
||||
* @param accountName
|
||||
* - an optional account for the virtual machine. Must be used with domainId
|
||||
|
|
@ -264,8 +265,8 @@ public interface UserVmService {
|
|||
* @throws InsufficientResourcesException
|
||||
*/
|
||||
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList,
|
||||
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps,
|
||||
String defaultIp, String keyboard)
|
||||
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
|
||||
IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
|
||||
|
||||
/**
|
||||
|
|
@ -310,8 +311,7 @@ public interface UserVmService {
|
|||
* - name of the ssh key pair used to login to the virtual machine
|
||||
* @param requestedIps
|
||||
* TODO
|
||||
* @param defaultIp
|
||||
* TODO
|
||||
* @param defaultIps TODO
|
||||
* @param accountName
|
||||
* - an optional account for the virtual machine. Must be used with domainId
|
||||
* @param domainId
|
||||
|
|
@ -328,7 +328,7 @@ public interface UserVmService {
|
|||
* @throws InsufficientResourcesException
|
||||
*/
|
||||
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -317,6 +317,6 @@ public interface NetworkManager {
|
|||
|
||||
|
||||
PublicIpv6Address assignPublicIp6Address(long dcId, Long podId, Account owner,
|
||||
VlanType type, Long networkId, String requestedIp, boolean isSystem)
|
||||
VlanType type, Long networkId, String requestedIp6, boolean isSystem)
|
||||
throws InsufficientAddressCapacityException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,26 +296,38 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PublicIpv6Address assignPublicIp6Address(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, boolean isSystem) throws InsufficientAddressCapacityException {
|
||||
public PublicIpv6Address assignPublicIp6Address(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp6, boolean isSystem) throws InsufficientAddressCapacityException {
|
||||
Vlan vlan = _networkModel.getVlanForNetwork(networkId);
|
||||
if (vlan == null) {
|
||||
s_logger.debug("Cannot find related vlan or too many vlan attached to network " + networkId);
|
||||
return null;
|
||||
}
|
||||
String ip = null;
|
||||
int count = 0;
|
||||
while (ip == null || count >= 10) {
|
||||
ip = NetUtils.getIp6FromRange(vlan.getIp6Range());
|
||||
//Check for duplicate IP
|
||||
if (_ipv6Dao.findByDcIdAndIp(dcId, ip) == null) {
|
||||
break;
|
||||
} else {
|
||||
ip = null;
|
||||
}
|
||||
count ++;
|
||||
//TODO should check before this point
|
||||
if (!NetUtils.isIp6InRange(requestedIp6, vlan.getIp6Range())) {
|
||||
throw new CloudRuntimeException("Requested IPv6 is not in the predefined range!");
|
||||
}
|
||||
if (ip == null) {
|
||||
throw new CloudRuntimeException("Fail to get unique ipv6 address after 10 times trying!");
|
||||
String ip = null;
|
||||
if (requestedIp6 == null) {
|
||||
int count = 0;
|
||||
while (ip == null || count >= 10) {
|
||||
ip = NetUtils.getIp6FromRange(vlan.getIp6Range());
|
||||
//Check for duplicate IP
|
||||
if (_ipv6Dao.findByDcIdAndIp(dcId, ip) == null) {
|
||||
break;
|
||||
} else {
|
||||
ip = null;
|
||||
}
|
||||
count ++;
|
||||
}
|
||||
if (ip == null) {
|
||||
throw new CloudRuntimeException("Fail to get unique ipv6 address after 10 times trying!");
|
||||
}
|
||||
} else {
|
||||
ip = requestedIp6;
|
||||
//TODO should check before this point
|
||||
if (_ipv6Dao.findByDcIdAndIp(dcId, ip) != null) {
|
||||
throw new CloudRuntimeException("The requested IP is already taken!");
|
||||
}
|
||||
}
|
||||
DataCenterVO dc = _dcDao.findById(dcId);
|
||||
Long mac = dc.getMacAddress();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
|
||||
import com.cloud.network.*;
|
||||
import com.cloud.network.Network.IpAddresses;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
@ -1986,7 +1987,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
@Override
|
||||
public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner,
|
||||
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
|
||||
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
|
@ -2029,13 +2030,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId,
|
||||
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
|
||||
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIps, keyboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
|
||||
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData,
|
||||
String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
|
||||
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
|
||||
ResourceAllocationException {
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
|
@ -2134,12 +2135,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId,
|
||||
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
|
||||
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIps, keyboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
|
||||
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
|
@ -2220,12 +2221,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
}
|
||||
|
||||
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, null, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
|
||||
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, null, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIps, keyboard);
|
||||
}
|
||||
|
||||
@DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true)
|
||||
protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId,
|
||||
Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, String> requestedIps, String defaultNetworkIp, String keyboard) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
|
||||
Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
|
||||
|
|
@ -2235,7 +2237,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
long accountId = owner.getId();
|
||||
|
||||
assert !(requestedIps != null && defaultNetworkIp != null) : "requestedIp list and defaultNetworkIp should never be specified together";
|
||||
assert !(requestedIps != null && (defaultIps.getIp4Address() != null || defaultIps.getIp6Address() != null)) : "requestedIp list and defaultNetworkIp should never be specified together";
|
||||
|
||||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zone.getId());
|
||||
|
|
@ -2359,18 +2361,22 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
throw new InvalidParameterValueException("Network id=" + network.getId() + " doesn't belong to zone " + zone.getId());
|
||||
}
|
||||
|
||||
String requestedIp = null;
|
||||
IpAddresses requestedIpPair = null;
|
||||
if (requestedIps != null && !requestedIps.isEmpty()) {
|
||||
requestedIp = requestedIps.get(network.getId());
|
||||
requestedIpPair = requestedIps.get(network.getId());
|
||||
}
|
||||
|
||||
NicProfile profile = new NicProfile(requestedIp, null);
|
||||
|
||||
if (requestedIpPair == null) {
|
||||
requestedIpPair = new IpAddresses(null, null);
|
||||
}
|
||||
|
||||
NicProfile profile = new NicProfile(requestedIpPair.getIp4Address(), requestedIpPair.getIp6Address());
|
||||
|
||||
if (defaultNetworkNumber == 0) {
|
||||
defaultNetworkNumber++;
|
||||
// if user requested specific ip for default network, add it
|
||||
if (defaultNetworkIp != null) {
|
||||
profile = new NicProfile(defaultNetworkIp, null);
|
||||
if (defaultIps.getIp4Address() != null || defaultIps.getIp4Address() != null) {
|
||||
profile = new NicProfile(defaultIps.getIp4Address(), defaultIps.getIp6Address());
|
||||
}
|
||||
|
||||
profile.setDefaultNic(true);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import com.cloud.exception.VirtualMachineMigrationException;
|
|||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.IpAddresses;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.server.Criteria;
|
||||
|
|
@ -349,8 +350,8 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
|
|||
|
||||
@Override
|
||||
public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner,
|
||||
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps,
|
||||
String defaultIp, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
|
||||
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps,
|
||||
IpAddresses defaultIp, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
|
||||
ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -359,7 +360,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
|
|||
@Override
|
||||
public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
|
||||
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData,
|
||||
String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException,
|
||||
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException,
|
||||
StorageUnavailableException, ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -367,7 +368,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
|
|||
|
||||
@Override
|
||||
public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp,
|
||||
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps,
|
||||
String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1217,4 +1217,20 @@ public class NetUtils {
|
|||
}
|
||||
return endLow - startLow + 1;
|
||||
}
|
||||
|
||||
public static boolean isIp6InRange(String ip6, String ip6Range) {
|
||||
String[] ips = ip6Range.split("-");
|
||||
String startIp = ips[0];
|
||||
String endIp = null;
|
||||
if (ips.length > 1) {
|
||||
endIp = ips[1];
|
||||
}
|
||||
IPv6Address start = IPv6Address.fromString(startIp);
|
||||
IPv6Address end = IPv6Address.fromString(endIp);
|
||||
IPv6Address ip = IPv6Address.fromString(ip6);
|
||||
if (start.compareTo(ip) <= 0 && end.compareTo(ip) >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue