mirror of https://github.com/apache/cloudstack.git
IPv6: Accept IPv6 parameter for createNetworkCmd
Also ass public_ipv6_address for ipv6 address management. Extend nics and vlans for ipv6 address. Add dependency to com.googlecode.ipv6(java-ipv6). Modify dhcpcommand for ipv6.
This commit is contained in:
parent
a2b2d45e40
commit
bd4bc025d1
|
|
@ -28,7 +28,9 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||||
String defaultRouter;
|
String defaultRouter;
|
||||||
String staticRoutes;
|
String staticRoutes;
|
||||||
String defaultDns;
|
String defaultDns;
|
||||||
|
String vmIp6Address;
|
||||||
|
String ip6Gateway;
|
||||||
|
String duid;
|
||||||
|
|
||||||
protected DhcpEntryCommand() {
|
protected DhcpEntryCommand() {
|
||||||
|
|
||||||
|
|
@ -39,14 +41,15 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName) {
|
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address) {
|
||||||
this.vmMac = vmMac;
|
this.vmMac = vmMac;
|
||||||
this.vmIpAddress = vmIpAddress;
|
this.vmIpAddress = vmIpAddress;
|
||||||
this.vmName = vmName;
|
this.vmName = vmName;
|
||||||
|
this.vmIp6Address = vmIp6Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String dns, String gateway) {
|
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address, String dns, String gateway, String ip6Gateway) {
|
||||||
this(vmMac, vmIpAddress, vmName);
|
this(vmMac, vmIpAddress, vmName, vmIp6Address);
|
||||||
this.dns = dns;
|
this.dns = dns;
|
||||||
this.gateway = gateway;
|
this.gateway = gateway;
|
||||||
}
|
}
|
||||||
|
|
@ -102,4 +105,28 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
||||||
public void setDefaultDns(String defaultDns) {
|
public void setDefaultDns(String defaultDns) {
|
||||||
this.defaultDns = defaultDns;
|
this.defaultDns = defaultDns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDuid() {
|
||||||
|
return duid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuid(String duid) {
|
||||||
|
this.duid = duid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVmIp6Address() {
|
||||||
|
return vmIp6Address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVmIp6Address(String ip6Address) {
|
||||||
|
this.vmIp6Address = ip6Address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,9 @@ public interface Vlan extends InfrastructureEntity, InternalIdentity, Identity {
|
||||||
|
|
||||||
public Long getPhysicalNetworkId();
|
public Long getPhysicalNetworkId();
|
||||||
|
|
||||||
|
public String getIp6Gateway();
|
||||||
|
|
||||||
|
public String getIp6Cidr();
|
||||||
|
|
||||||
|
public String getIp6Range();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,11 @@ public interface Network extends ControlledEntity, InternalIdentity, Identity {
|
||||||
String getGateway();
|
String getGateway();
|
||||||
|
|
||||||
String getCidr();
|
String getCidr();
|
||||||
|
|
||||||
|
String getIp6Gateway();
|
||||||
|
|
||||||
|
String getIp6Cidr();
|
||||||
|
|
||||||
long getDataCenterId();
|
long getDataCenterId();
|
||||||
|
|
||||||
long getNetworkOfferingId();
|
long getNetworkOfferingId();
|
||||||
|
|
|
||||||
|
|
@ -249,4 +249,5 @@ public interface NetworkModel {
|
||||||
|
|
||||||
boolean isNetworkInlineMode(Network network);
|
boolean isNetworkInlineMode(Network network);
|
||||||
|
|
||||||
|
Vlan getVlanForNetwork(long networkId);
|
||||||
}
|
}
|
||||||
|
|
@ -39,6 +39,8 @@ public class NetworkProfile implements Network {
|
||||||
private TrafficType trafficType;
|
private TrafficType trafficType;
|
||||||
private String gateway;
|
private String gateway;
|
||||||
private String cidr;
|
private String cidr;
|
||||||
|
private String ip6Gateway;
|
||||||
|
private String ip6Cidr;
|
||||||
private long networkOfferingId;
|
private long networkOfferingId;
|
||||||
private long related;
|
private long related;
|
||||||
private String displayText;
|
private String displayText;
|
||||||
|
|
@ -64,6 +66,8 @@ public class NetworkProfile implements Network {
|
||||||
this.trafficType = network.getTrafficType();
|
this.trafficType = network.getTrafficType();
|
||||||
this.gateway = network.getGateway();
|
this.gateway = network.getGateway();
|
||||||
this.cidr = network.getCidr();
|
this.cidr = network.getCidr();
|
||||||
|
this.ip6Gateway = network.getIp6Gateway();
|
||||||
|
this.ip6Cidr = network.getIp6Cidr();
|
||||||
this.networkOfferingId = network.getNetworkOfferingId();
|
this.networkOfferingId = network.getNetworkOfferingId();
|
||||||
this.related = network.getRelated();
|
this.related = network.getRelated();
|
||||||
this.displayText = network.getDisplayText();
|
this.displayText = network.getDisplayText();
|
||||||
|
|
@ -226,4 +230,14 @@ public class NetworkProfile implements Network {
|
||||||
return vpcId;
|
return vpcId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,4 +144,10 @@ public interface Nic extends Identity, InternalIdentity {
|
||||||
VirtualMachine.Type getVmType();
|
VirtualMachine.Type getVmType();
|
||||||
|
|
||||||
AddressFormat getAddressFormat();
|
AddressFormat getAddressFormat();
|
||||||
|
|
||||||
|
String getIp6Gateway();
|
||||||
|
|
||||||
|
String getIp6Cidr();
|
||||||
|
|
||||||
|
String getIp6Address();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ public class NicProfile implements InternalIdentity {
|
||||||
TrafficType trafficType;
|
TrafficType trafficType;
|
||||||
String ip4Address;
|
String ip4Address;
|
||||||
String ip6Address;
|
String ip6Address;
|
||||||
|
String ip6Gateway;
|
||||||
|
String ip6Cidr;
|
||||||
String macAddress;
|
String macAddress;
|
||||||
URI isolationUri;
|
URI isolationUri;
|
||||||
String netmask;
|
String netmask;
|
||||||
|
|
@ -50,7 +52,8 @@ public class NicProfile implements InternalIdentity {
|
||||||
Integer networkRate;
|
Integer networkRate;
|
||||||
boolean isSecurityGroupEnabled;
|
boolean isSecurityGroupEnabled;
|
||||||
String name;
|
String name;
|
||||||
String requestedIp;
|
String requestedIpv4;
|
||||||
|
String requestedIpv6;
|
||||||
|
|
||||||
public String getDns1() {
|
public String getDns1() {
|
||||||
return dns1;
|
return dns1;
|
||||||
|
|
@ -218,7 +221,7 @@ public class NicProfile implements InternalIdentity {
|
||||||
this.trafficType = network.getTrafficType();
|
this.trafficType = network.getTrafficType();
|
||||||
this.ip4Address = nic.getIp4Address();
|
this.ip4Address = nic.getIp4Address();
|
||||||
this.format = nic.getAddressFormat();
|
this.format = nic.getAddressFormat();
|
||||||
this.ip6Address = null;
|
this.ip6Address = nic.getIp6Address();
|
||||||
this.macAddress = nic.getMacAddress();
|
this.macAddress = nic.getMacAddress();
|
||||||
this.reservationId = nic.getReservationId();
|
this.reservationId = nic.getReservationId();
|
||||||
this.strategy = nic.getReservationStrategy();
|
this.strategy = nic.getReservationStrategy();
|
||||||
|
|
@ -230,6 +233,8 @@ public class NicProfile implements InternalIdentity {
|
||||||
this.isSecurityGroupEnabled = isSecurityGroupEnabled;
|
this.isSecurityGroupEnabled = isSecurityGroupEnabled;
|
||||||
this.vmId = nic.getInstanceId();
|
this.vmId = nic.getInstanceId();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.ip6Cidr = nic.getIp6Cidr();
|
||||||
|
this.ip6Gateway = nic.getIp6Gateway();
|
||||||
|
|
||||||
if (networkRate != null) {
|
if (networkRate != null) {
|
||||||
this.networkRate = networkRate;
|
this.networkRate = networkRate;
|
||||||
|
|
@ -245,8 +250,9 @@ public class NicProfile implements InternalIdentity {
|
||||||
this.strategy = strategy;
|
this.strategy = strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicProfile(String requestedIp) {
|
public NicProfile(String requestedIpv4, String requestedIpv6) {
|
||||||
this.requestedIp = requestedIp;
|
this.requestedIpv4 = requestedIpv4;
|
||||||
|
this.requestedIpv6 = requestedIpv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicProfile() {
|
public NicProfile() {
|
||||||
|
|
@ -272,8 +278,8 @@ public class NicProfile implements InternalIdentity {
|
||||||
this.isSecurityGroupEnabled = enabled;
|
this.isSecurityGroupEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestedIp() {
|
public String getRequestedIpv4() {
|
||||||
return requestedIp;
|
return requestedIpv4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deallocate() {
|
public void deallocate() {
|
||||||
|
|
@ -301,4 +307,28 @@ public class NicProfile implements InternalIdentity {
|
||||||
append(reservationId).append("-").append(ip4Address).append("-").append(broadcastUri).toString();
|
append(reservationId).append("-").append(ip4Address).append("-").append(broadcastUri).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Cidr(String ip6Cidr) {
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestedIpv6() {
|
||||||
|
return requestedIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestedIpv6(String requestedIpv6) {
|
||||||
|
this.requestedIpv6 = requestedIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public class ApiConstants {
|
||||||
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
||||||
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
|
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
|
||||||
public static final String CIDR = "cidr";
|
public static final String CIDR = "cidr";
|
||||||
|
public static final String IP6CIDR = "ip6cidr";
|
||||||
public static final String CIDR_LIST = "cidrlist";
|
public static final String CIDR_LIST = "cidrlist";
|
||||||
public static final String CLEANUP = "cleanup";
|
public static final String CLEANUP = "cleanup";
|
||||||
public static final String CLUSTER_ID = "clusterid";
|
public static final String CLUSTER_ID = "clusterid";
|
||||||
|
|
@ -64,6 +65,7 @@ public class ApiConstants {
|
||||||
public static final String EMAIL = "email";
|
public static final String EMAIL = "email";
|
||||||
public static final String END_DATE = "enddate";
|
public static final String END_DATE = "enddate";
|
||||||
public static final String END_IP = "endip";
|
public static final String END_IP = "endip";
|
||||||
|
public static final String END_IPV6 = "endipv6";
|
||||||
public static final String END_PORT = "endport";
|
public static final String END_PORT = "endport";
|
||||||
public static final String ENTRY_TIME = "entrytime";
|
public static final String ENTRY_TIME = "entrytime";
|
||||||
public static final String FETCH_LATEST = "fetchlatest";
|
public static final String FETCH_LATEST = "fetchlatest";
|
||||||
|
|
@ -73,6 +75,7 @@ public class ApiConstants {
|
||||||
public static final String FORMAT = "format";
|
public static final String FORMAT = "format";
|
||||||
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
|
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
|
||||||
public static final String GATEWAY = "gateway";
|
public static final String GATEWAY = "gateway";
|
||||||
|
public static final String IP6GATEWAY = "ip6gateway";
|
||||||
public static final String GROUP = "group";
|
public static final String GROUP = "group";
|
||||||
public static final String GROUP_ID = "groupid";
|
public static final String GROUP_ID = "groupid";
|
||||||
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
|
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
|
||||||
|
|
@ -181,6 +184,7 @@ public class ApiConstants {
|
||||||
public static final String SOURCE_ZONE_ID = "sourcezoneid";
|
public static final String SOURCE_ZONE_ID = "sourcezoneid";
|
||||||
public static final String START_DATE = "startdate";
|
public static final String START_DATE = "startdate";
|
||||||
public static final String START_IP = "startip";
|
public static final String START_IP = "startip";
|
||||||
|
public static final String START_IPV6 = "startipv6";
|
||||||
public static final String START_PORT = "startport";
|
public static final String START_PORT = "startport";
|
||||||
public static final String STATE = "state";
|
public static final String STATE = "state";
|
||||||
public static final String STATUS = "status";
|
public static final String STATUS = "status";
|
||||||
|
|
@ -427,6 +431,7 @@ public class ApiConstants {
|
||||||
public static final String CONDITION_IDS = "conditionids";
|
public static final String CONDITION_IDS = "conditionids";
|
||||||
public static final String COUNTERPARAM_LIST = "counterparam";
|
public static final String COUNTERPARAM_LIST = "counterparam";
|
||||||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||||
|
public static final String DUAL_STACK = "dualstack";
|
||||||
|
|
||||||
public enum HostDetails {
|
public enum HostDetails {
|
||||||
all, capacity, events, stats, min;
|
all, capacity, events, stats, min;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,22 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||||
description="the VPC network belongs to")
|
description="the VPC network belongs to")
|
||||||
private Long vpcId;
|
private Long vpcId;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.START_IPV6, type=CommandType.STRING, description="the beginning IPv6 address in the IPv6 network range")
|
||||||
|
private String startIpv6;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.END_IPV6, type=CommandType.STRING, description="the ending IPv6 address in the IPv6 network range")
|
||||||
|
private String endIpv6;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.IP6GATEWAY, type=CommandType.STRING, description="the gateway of the IPv6 network. Required " +
|
||||||
|
"for Shared networks and Isolated networks when it belongs to VPC")
|
||||||
|
private String ip6Gateway;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.IP6CIDR, type=CommandType.STRING, description="the CIDR of IPv6 network, must be at least /64")
|
||||||
|
private String ip6Cidr;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.DUAL_STACK, type=CommandType.BOOLEAN, description="The network is dual-stack(IPv6 and IPv4) or not")
|
||||||
|
private Boolean dualStack;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
@ -207,7 +222,50 @@ public class CreateNetworkCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
public String getStartIpv6() {
|
||||||
|
return startIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartIpv6(String startIpv6) {
|
||||||
|
this.startIpv6 = startIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndIpv6() {
|
||||||
|
return endIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndIpv6(String endIpv6) {
|
||||||
|
this.endIpv6 = endIpv6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Cidr(String ip6Cidr) {
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isDualStack() {
|
||||||
|
if (dualStack == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return dualStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDualStack(Boolean dualStack) {
|
||||||
|
this.dualStack = dualStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,7 @@ under the License.
|
||||||
<dao name="Site2SiteCustomerGatewayDao" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" singleton="false"/>
|
<dao name="Site2SiteCustomerGatewayDao" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" singleton="false"/>
|
||||||
<dao name="Site2SiteVpnGatewayDao" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" singleton="false"/>
|
<dao name="Site2SiteVpnGatewayDao" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" singleton="false"/>
|
||||||
<dao name="Site2SiteVpnConnectionDao" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" singleton="false"/>
|
<dao name="Site2SiteVpnConnectionDao" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" singleton="false"/>
|
||||||
|
<dao name="PublicIpv6AddressDao" class="com.cloud.network.dao.PublicIpv6AddressDaoImpl" singleton="false"/>
|
||||||
</configuration-server>
|
</configuration-server>
|
||||||
|
|
||||||
<awsapi-ec2server class="com.cloud.bridge.service.EC2MainServlet">
|
<awsapi-ec2server class="com.cloud.bridge.service.EC2MainServlet">
|
||||||
|
|
|
||||||
1
pom.xml
1
pom.xml
|
|
@ -87,6 +87,7 @@
|
||||||
<cs.lang.version>2.6</cs.lang.version>
|
<cs.lang.version>2.6</cs.lang.version>
|
||||||
<cs.commons-io.version>1.4</cs.commons-io.version>
|
<cs.commons-io.version>1.4</cs.commons-io.version>
|
||||||
<cs.reflections.version>0.9.8</cs.reflections.version>
|
<cs.reflections.version>0.9.8</cs.reflections.version>
|
||||||
|
<cs.java-ipv6.version>0.8</cs.java-ipv6.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ public class ExternalDhcpManagerImpl implements ExternalDhcpManager, ResourceSta
|
||||||
if (dns == null) {
|
if (dns == null) {
|
||||||
dns = nic.getDns2();
|
dns = nic.getDns2();
|
||||||
}
|
}
|
||||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName(), dns, nic.getGateway());
|
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName(), null, dns, nic.getGateway(), null);
|
||||||
String errMsg = String.format("Set dhcp entry on external DHCP %1$s failed(ip=%2$s, mac=%3$s, vmname=%4$s)",
|
String errMsg = String.format("Set dhcp entry on external DHCP %1$s failed(ip=%2$s, mac=%3$s, vmname=%4$s)",
|
||||||
h.getPrivateIpAddress(), nic.getIp4Address(), nic.getMacAddress(), profile.getVirtualMachine().getHostName());
|
h.getPrivateIpAddress(), nic.getIp4Address(), nic.getMacAddress(), profile.getVirtualMachine().getHostName());
|
||||||
//prepareBareMetalDhcpEntry(nic, dhcpCommand);
|
//prepareBareMetalDhcpEntry(nic, dhcpCommand);
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||||
boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap,
|
boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap,
|
||||||
boolean specifyIpRanges);
|
boolean specifyIpRanges);
|
||||||
|
|
||||||
Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId, Account vlanOwner) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanGatewayv6, String vlanCidrv6) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||||
|
|
||||||
void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException;
|
void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
|
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
|
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
|
import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
|
|
||||||
import org.apache.cloudstack.api.command.admin.offering.*;
|
import org.apache.cloudstack.api.command.admin.offering.*;
|
||||||
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
|
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
|
||||||
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
|
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
|
||||||
|
|
@ -2253,7 +2252,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
|
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
|
||||||
endIP, vlanGateway, vlanNetmask, vlanId, vlanOwner);
|
endIP, vlanGateway, vlanNetmask, vlanId, vlanOwner, null, null, null, null);
|
||||||
|
|
||||||
if (associateIpRangeToAccount) {
|
if (associateIpRangeToAccount) {
|
||||||
_networkMgr.associateIpAddressListToAccount(userId, vlanOwner.getId(), zoneId, vlan.getId(), null);
|
_networkMgr.associateIpAddressListToAccount(userId, vlanOwner.getId(), zoneId, vlan.getId(), null);
|
||||||
|
|
@ -2279,11 +2278,23 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||||
@DB
|
@DB
|
||||||
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId,
|
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId,
|
||||||
String startIP, String endIP, String vlanGateway, String vlanNetmask,
|
String startIP, String endIP, String vlanGateway, String vlanNetmask,
|
||||||
String vlanId, Account vlanOwner) {
|
String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanGatewayv6, String vlanCidrv6) {
|
||||||
|
|
||||||
|
|
||||||
Network network = _networkModel.getNetwork(networkId);
|
Network network = _networkModel.getNetwork(networkId);
|
||||||
|
|
||||||
|
boolean ipv4 = false, ipv6 = false;
|
||||||
|
|
||||||
|
if (startIP != null) {
|
||||||
|
ipv4 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIPv6 != null) {
|
||||||
|
ipv6 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ipv4 && !ipv6) {
|
||||||
|
throw new InvalidParameterValueException("Please specify IPv4 or IPv6 address.");
|
||||||
|
}
|
||||||
|
|
||||||
//Validate the zone
|
//Validate the zone
|
||||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||||
if (zone == null) {
|
if (zone == null) {
|
||||||
|
|
@ -2348,90 +2359,108 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||||
throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced);
|
throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the gateway is valid
|
if (ipv4) {
|
||||||
if (!NetUtils.isValidIp(vlanGateway)) {
|
// Make sure the gateway is valid
|
||||||
throw new InvalidParameterValueException("Please specify a valid gateway");
|
if (!NetUtils.isValidIp(vlanGateway)) {
|
||||||
|
throw new InvalidParameterValueException("Please specify a valid gateway");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the netmask is valid
|
||||||
|
if (!NetUtils.isValidIp(vlanNetmask)) {
|
||||||
|
throw new InvalidParameterValueException("Please specify a valid netmask");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipv6) {
|
||||||
|
if (!NetUtils.isValidIPv6(vlanGatewayv6)) {
|
||||||
|
throw new InvalidParameterValueException("Please specify a valid IPv6 gateway");
|
||||||
|
}
|
||||||
|
if (!NetUtils.isValidIp6Cidr(vlanCidrv6)) {
|
||||||
|
throw new InvalidParameterValueException("Please specify a valid IPv6 CIDR");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the netmask is valid
|
// TODO skip all vlan check for ipv6 now
|
||||||
if (!NetUtils.isValidIp(vlanNetmask)) {
|
if (ipv4) {
|
||||||
throw new InvalidParameterValueException("Please specify a valid netmask");
|
String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask);
|
||||||
}
|
|
||||||
|
|
||||||
String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask);
|
// Check if the new VLAN's subnet conflicts with the guest network in
|
||||||
|
// the specified zone (guestCidr is null for basic zone)
|
||||||
|
String guestNetworkCidr = zone.getGuestNetworkCidr();
|
||||||
|
if (guestNetworkCidr != null) {
|
||||||
|
String[] cidrPair = guestNetworkCidr.split("\\/");
|
||||||
|
String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrPair[0], Long.parseLong(cidrPair[1]));
|
||||||
|
long guestCidrSize = Long.parseLong(cidrPair[1]);
|
||||||
|
long vlanCidrSize = NetUtils.getCidrSize(vlanNetmask);
|
||||||
|
|
||||||
// Check if the new VLAN's subnet conflicts with the guest network in
|
long cidrSizeToUse = -1;
|
||||||
// the specified zone (guestCidr is null for basic zone)
|
if (vlanCidrSize < guestCidrSize) {
|
||||||
String guestNetworkCidr = zone.getGuestNetworkCidr();
|
cidrSizeToUse = vlanCidrSize;
|
||||||
if (guestNetworkCidr != null) {
|
} else {
|
||||||
String[] cidrPair = guestNetworkCidr.split("\\/");
|
cidrSizeToUse = guestCidrSize;
|
||||||
String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrPair[0], Long.parseLong(cidrPair[1]));
|
}
|
||||||
long guestCidrSize = Long.parseLong(cidrPair[1]);
|
|
||||||
long vlanCidrSize = NetUtils.getCidrSize(vlanNetmask);
|
|
||||||
|
|
||||||
long cidrSizeToUse = -1;
|
String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse);
|
||||||
if (vlanCidrSize < guestCidrSize) {
|
|
||||||
cidrSizeToUse = vlanCidrSize;
|
|
||||||
} else {
|
|
||||||
cidrSizeToUse = guestCidrSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse);
|
if (newVlanSubnet.equals(guestSubnet)) {
|
||||||
|
throw new InvalidParameterValueException("The new IP range you have specified has the same subnet as the guest network in zone: " + zone.getName()
|
||||||
|
+ ". Please specify a different gateway/netmask.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (newVlanSubnet.equals(guestSubnet)) {
|
// Check if there are any errors with the IP range
|
||||||
throw new InvalidParameterValueException("The new IP range you have specified has the same subnet as the guest network in zone: " + zone.getName()
|
checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
|
||||||
+ ". Please specify a different gateway/netmask.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there are any errors with the IP range
|
// Throw an exception if any of the following is true:
|
||||||
checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
|
// 1. Another VLAN in the same zone has a different tag but the same
|
||||||
|
// subnet as the new VLAN. Make an exception for the
|
||||||
|
// case when both vlans are Direct.
|
||||||
|
// 2. Another VLAN in the same zone that has the same tag and subnet as
|
||||||
|
// the new VLAN has IPs that overlap with the IPs
|
||||||
|
// being added
|
||||||
|
// 3. Another VLAN in the same zone that has the same tag and subnet as
|
||||||
|
// the new VLAN has a different gateway than the
|
||||||
|
// new VLAN
|
||||||
|
// 4. If VLAN is untagged and Virtual, and there is existing UNTAGGED
|
||||||
|
// vlan with different subnet
|
||||||
|
List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
|
||||||
|
for (VlanVO vlan : vlans) {
|
||||||
|
String otherVlanGateway = vlan.getVlanGateway();
|
||||||
|
// Continue if it's IPv6
|
||||||
|
if (otherVlanGateway == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String otherVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask());
|
||||||
|
String[] otherVlanIpRange = vlan.getIpRange().split("\\-");
|
||||||
|
String otherVlanStartIP = otherVlanIpRange[0];
|
||||||
|
String otherVlanEndIP = null;
|
||||||
|
if (otherVlanIpRange.length > 1) {
|
||||||
|
otherVlanEndIP = otherVlanIpRange[1];
|
||||||
|
}
|
||||||
|
|
||||||
// Throw an exception if any of the following is true:
|
if (forVirtualNetwork && !vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet) && !allowIpRangeOverlap(vlan, forVirtualNetwork, networkId)) {
|
||||||
// 1. Another VLAN in the same zone has a different tag but the same
|
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName()
|
||||||
// subnet as the new VLAN. Make an exception for the
|
+ " has the same subnet. Please specify a different gateway/netmask.");
|
||||||
// case when both vlans are Direct.
|
}
|
||||||
// 2. Another VLAN in the same zone that has the same tag and subnet as
|
|
||||||
// the new VLAN has IPs that overlap with the IPs
|
|
||||||
// being added
|
|
||||||
// 3. Another VLAN in the same zone that has the same tag and subnet as
|
|
||||||
// the new VLAN has a different gateway than the
|
|
||||||
// new VLAN
|
|
||||||
// 4. If VLAN is untagged and Virtual, and there is existing UNTAGGED
|
|
||||||
// vlan with different subnet
|
|
||||||
List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
|
|
||||||
for (VlanVO vlan : vlans) {
|
|
||||||
String otherVlanGateway = vlan.getVlanGateway();
|
|
||||||
String otherVlanSubnet = NetUtils.getSubNet(vlan.getVlanGateway(), vlan.getVlanNetmask());
|
|
||||||
String[] otherVlanIpRange = vlan.getIpRange().split("\\-");
|
|
||||||
String otherVlanStartIP = otherVlanIpRange[0];
|
|
||||||
String otherVlanEndIP = null;
|
|
||||||
if (otherVlanIpRange.length > 1) {
|
|
||||||
otherVlanEndIP = otherVlanIpRange[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forVirtualNetwork && !vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet) && !allowIpRangeOverlap(vlan, forVirtualNetwork, networkId)) {
|
boolean vlansUntaggedAndVirtual = (vlanId.equals(Vlan.UNTAGGED) && vlanId.equals(vlan.getVlanTag()) && forVirtualNetwork && vlan.getVlanType() == VlanType.VirtualNetwork);
|
||||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName()
|
|
||||||
+ " has the same subnet. Please specify a different gateway/netmask.");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean vlansUntaggedAndVirtual = (vlanId.equals(Vlan.UNTAGGED) && vlanId.equals(vlan.getVlanTag()) && forVirtualNetwork && vlan.getVlanType() == VlanType.VirtualNetwork);
|
if (vlansUntaggedAndVirtual && !newVlanSubnet.equals(otherVlanSubnet)) {
|
||||||
|
throw new InvalidParameterValueException("The Untagged ip range with different subnet already exists in zone " + zone.getId());
|
||||||
|
}
|
||||||
|
|
||||||
if (vlansUntaggedAndVirtual && !newVlanSubnet.equals(otherVlanSubnet)) {
|
if (vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet)) {
|
||||||
throw new InvalidParameterValueException("The Untagged ip range with different subnet already exists in zone " + zone.getId());
|
if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) {
|
||||||
}
|
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag()
|
||||||
|
+ " already has IPs that overlap with the new range. Please specify a different start IP/end IP.");
|
||||||
|
}
|
||||||
|
|
||||||
if (vlanId.equals(vlan.getVlanTag()) && newVlanSubnet.equals(otherVlanSubnet)) {
|
if (!vlanGateway.equals(otherVlanGateway)) {
|
||||||
if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) {
|
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + otherVlanGateway
|
||||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag()
|
+ ". Please specify a different tag.");
|
||||||
+ " already has IPs that overlap with the new range. Please specify a different start IP/end IP.");
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!vlanGateway.equals(otherVlanGateway)) {
|
|
||||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + otherVlanGateway
|
|
||||||
+ ". Please specify a different tag.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a guest VLAN is using the same tag
|
// Check if a guest VLAN is using the same tag
|
||||||
|
|
@ -2453,21 +2482,36 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String ipRange = startIP;
|
String ipRange = null;
|
||||||
if (endIP != null) {
|
|
||||||
ipRange += "-" + endIP;
|
if (ipv4) {
|
||||||
|
ipRange = startIP;
|
||||||
|
if (endIP != null) {
|
||||||
|
ipRange += "-" + endIP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String ipv6Range = null;
|
||||||
|
if (ipv6) {
|
||||||
|
ipv6Range = startIPv6;
|
||||||
|
if (endIPv6 != null) {
|
||||||
|
ipv6Range += "-" + endIPv6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything was fine, so persist the VLAN
|
// Everything was fine, so persist the VLAN
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId);
|
VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId, vlanGatewayv6, vlanCidrv6, ipv6Range);
|
||||||
s_logger.debug("Saving vlan range " + vlan);
|
s_logger.debug("Saving vlan range " + vlan);
|
||||||
vlan = _vlanDao.persist(vlan);
|
vlan = _vlanDao.persist(vlan);
|
||||||
|
|
||||||
if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
|
// IPv6 use a used ip map, is different from ipv4, no need to save public ip range
|
||||||
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support.");
|
if (ipv4) {
|
||||||
|
if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
|
||||||
|
throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vlanOwner != null) {
|
if (vlanOwner != null) {
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ import com.cloud.network.dao.PhysicalNetworkDaoImpl;
|
||||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
|
import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
|
||||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
|
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
|
||||||
import com.cloud.network.dao.PortProfileDaoImpl;
|
import com.cloud.network.dao.PortProfileDaoImpl;
|
||||||
|
import com.cloud.network.dao.PublicIpv6AddressDaoImpl;
|
||||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||||
import com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl;
|
import com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl;
|
||||||
import com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl;
|
import com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl;
|
||||||
|
|
@ -380,6 +381,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
||||||
addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class);
|
addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class);
|
||||||
addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class);
|
addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class);
|
||||||
addDao("Site2SiteVpnConnnectionDao", Site2SiteVpnConnectionDaoImpl.class);
|
addDao("Site2SiteVpnConnnectionDao", Site2SiteVpnConnectionDaoImpl.class);
|
||||||
|
addDao("PublicIpv6AddressDao", PublicIpv6AddressDaoImpl.class);
|
||||||
|
|
||||||
addDao("UserVmJoinDao", UserVmJoinDaoImpl.class);
|
addDao("UserVmJoinDao", UserVmJoinDaoImpl.class);
|
||||||
addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class);
|
addDao("DomainRouterJoinDao", DomainRouterJoinDaoImpl.class);
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,21 @@ public class VlanVO implements Vlan {
|
||||||
@Column(name="vlan_netmask")
|
@Column(name="vlan_netmask")
|
||||||
String vlanNetmask;
|
String vlanNetmask;
|
||||||
|
|
||||||
|
@Column(name="ip6_gateway")
|
||||||
|
String ip6Gateway;
|
||||||
|
|
||||||
|
@Column(name="ip6_cidr")
|
||||||
|
String ip6Cidr;
|
||||||
|
|
||||||
@Column(name="data_center_id")
|
@Column(name="data_center_id")
|
||||||
long dataCenterId;
|
long dataCenterId;
|
||||||
|
|
||||||
@Column(name="description")
|
@Column(name="description")
|
||||||
String ipRange;
|
String ipRange;
|
||||||
|
|
||||||
|
@Column(name="ip6_range")
|
||||||
|
String ip6Range;
|
||||||
|
|
||||||
@Column(name="network_id")
|
@Column(name="network_id")
|
||||||
Long networkId;
|
Long networkId;
|
||||||
|
|
||||||
|
|
@ -67,13 +76,16 @@ public class VlanVO implements Vlan {
|
||||||
@Column(name="uuid")
|
@Column(name="uuid")
|
||||||
String uuid;
|
String uuid;
|
||||||
|
|
||||||
public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange, Long networkId, Long physicalNetworkId) {
|
public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange, Long networkId, Long physicalNetworkId, String ip6Gateway, String ip6Cidr, String ip6Range) {
|
||||||
this.vlanType = vlanType;
|
this.vlanType = vlanType;
|
||||||
this.vlanTag = vlanTag;
|
this.vlanTag = vlanTag;
|
||||||
this.vlanGateway = vlanGateway;
|
this.vlanGateway = vlanGateway;
|
||||||
this.vlanNetmask = vlanNetmask;
|
this.vlanNetmask = vlanNetmask;
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
this.dataCenterId = dataCenterId;
|
this.dataCenterId = dataCenterId;
|
||||||
this.ipRange = ipRange;
|
this.ipRange = ipRange;
|
||||||
|
this.ip6Range = ip6Range;
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.physicalNetworkId = physicalNetworkId;
|
this.physicalNetworkId = physicalNetworkId;
|
||||||
|
|
@ -149,9 +161,36 @@ public class VlanVO implements Vlan {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (toString == null) {
|
if (toString == null) {
|
||||||
toString = new StringBuilder("Vlan[").append(vlanTag).append("|").append(vlanGateway).append("|").append(vlanNetmask).
|
toString = new StringBuilder("Vlan[").append(vlanTag).append("|").append(vlanGateway).append("|").append(vlanNetmask).
|
||||||
append("|").append(ipRange).append("|").append(networkId).append("]").toString();
|
append("|").append(ip6Gateway).append("|").append(ip6Cidr).append("|").append(ipRange).append("|").
|
||||||
|
append("|").append(ip6Range).append(networkId).append("]").toString();
|
||||||
}
|
}
|
||||||
return toString;
|
return toString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Cidr(String ip6Cidr) {
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Range() {
|
||||||
|
return ip6Range;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Range(String ip6Range) {
|
||||||
|
this.ip6Range = ip6Range;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ public interface NetworkManager {
|
||||||
|
|
||||||
Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr,
|
Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr,
|
||||||
String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork,
|
String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork,
|
||||||
long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
|
long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr)
|
||||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
|
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -167,7 +167,7 @@ public interface NetworkManager {
|
||||||
|
|
||||||
void allocateDirectIp(NicProfile nic, DataCenter dc,
|
void allocateDirectIp(NicProfile nic, DataCenter dc,
|
||||||
VirtualMachineProfile<? extends VirtualMachine> vm,
|
VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||||
Network network, String requestedIp)
|
Network network, String requestedIpv4, String requestedIpv6)
|
||||||
throws InsufficientVirtualNetworkCapcityException,
|
throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException;
|
InsufficientAddressCapacityException;
|
||||||
|
|
||||||
|
|
@ -327,4 +327,8 @@ public interface NetworkManager {
|
||||||
int getRuleCountForIp(Long addressId, FirewallRule.Purpose purpose, FirewallRule.State state);
|
int getRuleCountForIp(Long addressId, FirewallRule.Purpose purpose, FirewallRule.State state);
|
||||||
|
|
||||||
LoadBalancingServiceProvider getLoadBalancingProviderForNetwork(Network network);
|
LoadBalancingServiceProvider getLoadBalancingProviderForNetwork(Network network);
|
||||||
|
|
||||||
|
PublicIpv6Address assignPublicIp6Address(long dcId, Long podId, Account owner,
|
||||||
|
VlanType type, Long networkId, String requestedIp, boolean isSystem)
|
||||||
|
throws InsufficientAddressCapacityException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ import com.cloud.network.dao.PhysicalNetworkDao;
|
||||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
||||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
|
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
|
||||||
|
import com.cloud.network.dao.PublicIpv6AddressDao;
|
||||||
import com.cloud.network.element.DhcpServiceProvider;
|
import com.cloud.network.element.DhcpServiceProvider;
|
||||||
import com.cloud.network.element.IpDeployer;
|
import com.cloud.network.element.IpDeployer;
|
||||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||||
|
|
@ -273,6 +274,8 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
NetworkACLManager _networkACLMgr;
|
NetworkACLManager _networkACLMgr;
|
||||||
@Inject
|
@Inject
|
||||||
NetworkModel _networkModel;
|
NetworkModel _networkModel;
|
||||||
|
@Inject
|
||||||
|
PublicIpv6AddressDao _ipv6Dao;
|
||||||
|
|
||||||
ScheduledExecutorService _executor;
|
ScheduledExecutorService _executor;
|
||||||
|
|
||||||
|
|
@ -294,6 +297,36 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
return fetchNewPublicIp(dcId, podId, null, owner, type, networkId, false, true, requestedIp, isSystem, null);
|
return fetchNewPublicIp(dcId, podId, null, owner, type, networkId, false, true, requestedIp, isSystem, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicIpv6Address assignPublicIp6Address(long dcId, Long podId, Account owner, VlanType type, Long networkId, String requestedIp, 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 = NetUtils.getIp6FromRange(vlan.getIp6Range());
|
||||||
|
//Check for duplicate IP
|
||||||
|
if (_ipv6Dao.findByDcIdAndIp(dcId, ip) != null) {
|
||||||
|
//TODO regenerate ip
|
||||||
|
throw new CloudRuntimeException("Fail to get unique ipv6 address");
|
||||||
|
}
|
||||||
|
DataCenterVO dc = _dcDao.findById(dcId);
|
||||||
|
Long mac = dc.getMacAddress();
|
||||||
|
Long nextMac = mac + 1;
|
||||||
|
dc.setMacAddress(nextMac);
|
||||||
|
_dcDao.update(dc.getId(), dc);
|
||||||
|
|
||||||
|
String macAddress = NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(mac));
|
||||||
|
PublicIpv6AddressVO ipVO = new PublicIpv6AddressVO(ip, dcId, macAddress, vlan.getId());
|
||||||
|
ipVO.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
|
||||||
|
ipVO.setSourceNetworkId(vlan.getNetworkId());
|
||||||
|
ipVO.setState(PublicIpv6Address.State.Allocated);
|
||||||
|
ipVO.setDomainId(owner.getDomainId());
|
||||||
|
ipVO.setAccountId(owner.getAccountId());
|
||||||
|
_ipv6Dao.persist(ipVO);
|
||||||
|
return ipVO;
|
||||||
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
public PublicIp fetchNewPublicIp(long dcId, Long podId, Long vlanDbId, Account owner, VlanType vlanUse,
|
public PublicIp fetchNewPublicIp(long dcId, Long podId, Long vlanDbId, Account owner, VlanType vlanUse,
|
||||||
Long guestNetworkId, boolean sourceNat, boolean assign, String requestedIp, boolean isSystem, Long vpcId)
|
Long guestNetworkId, boolean sourceNat, boolean assign, String requestedIp, boolean isSystem, Long vpcId)
|
||||||
|
|
@ -1334,6 +1367,11 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
vo.setState(Nic.State.Allocated);
|
vo.setState(Nic.State.Allocated);
|
||||||
|
|
||||||
|
vo.setIp6Address(profile.getIp6Address());
|
||||||
|
vo.setIp6Gateway(profile.getIp6Gateway());
|
||||||
|
vo.setIp6Cidr(profile.getIp6Cidr());
|
||||||
|
|
||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1792,7 +1830,7 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
@DB
|
@DB
|
||||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
|
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
|
||||||
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||||
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
|
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr)
|
||||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||||
|
|
||||||
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
||||||
|
|
@ -1825,9 +1863,18 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean ipv6 = false;
|
||||||
|
|
||||||
|
if (ip6Gateway != null && ip6Cidr != null) {
|
||||||
|
ipv6 = true;
|
||||||
|
}
|
||||||
// Validate zone
|
// Validate zone
|
||||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||||
|
if (ipv6) {
|
||||||
|
throw new InvalidParameterValueException("IPv6 is not supported in Basic zone");
|
||||||
|
}
|
||||||
|
|
||||||
// In Basic zone the network should have aclType=Domain, domainId=1, subdomainAccess=true
|
// In Basic zone the network should have aclType=Domain, domainId=1, subdomainAccess=true
|
||||||
if (aclType == null || aclType != ACLType.Domain) {
|
if (aclType == null || aclType != ACLType.Domain) {
|
||||||
throw new InvalidParameterValueException("Only AclType=Domain can be specified for network creation in Basic zone");
|
throw new InvalidParameterValueException("Only AclType=Domain can be specified for network creation in Basic zone");
|
||||||
|
|
@ -1870,6 +1917,9 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
|
|
||||||
} else if (zone.getNetworkType() == NetworkType.Advanced) {
|
} else if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||||
if (zone.isSecurityGroupEnabled()) {
|
if (zone.isSecurityGroupEnabled()) {
|
||||||
|
if (ipv6) {
|
||||||
|
throw new InvalidParameterValueException("IPv6 is not supported with security group!");
|
||||||
|
}
|
||||||
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
|
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
|
||||||
// enabled zone
|
// enabled zone
|
||||||
boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated
|
boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated
|
||||||
|
|
@ -1948,14 +1998,14 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x
|
// In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x
|
||||||
// limitation, remove after we introduce support for multiple ip ranges
|
// limitation, remove after we introduce support for multiple ip ranges
|
||||||
// with different Cidrs for the same Shared network
|
// with different Cidrs for the same Shared network
|
||||||
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && ntwkOff.getTrafficType() == TrafficType.Guest
|
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && ntwkOff.getTrafficType() == TrafficType.Guest
|
||||||
&& (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
|
&& (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
|
||||||
&& !_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
|
&& !_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
|
||||||
if (cidr == null && cidrRequired) {
|
if (cidr == null && ip6Cidr == null && cidrRequired) {
|
||||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" +
|
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" +
|
||||||
" type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service "
|
" type " + Network.GuestType.Shared + " and network of type " + GuestType.Isolated + " with service "
|
||||||
+ Service.SourceNat.getName() + " disabled");
|
+ Service.SourceNat.getName() + " disabled");
|
||||||
|
|
@ -1966,11 +2016,11 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask can't be specified for zone of type " + NetworkType.Basic);
|
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask can't be specified for zone of type " + NetworkType.Basic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if cidr is RFC1918 compliant if the network is Guest Isolated
|
// Check if cidr is RFC1918 compliant if the network is Guest Isolated for IPv4
|
||||||
if (cidr != null && ntwkOff.getGuestType() == Network.GuestType.Isolated && ntwkOff.getTrafficType() == TrafficType.Guest) {
|
if (cidr != null && ntwkOff.getGuestType() == Network.GuestType.Isolated && ntwkOff.getTrafficType() == TrafficType.Guest) {
|
||||||
if (!NetUtils.validateGuestCidr(cidr)) {
|
if (!NetUtils.validateGuestCidr(cidr)) {
|
||||||
throw new InvalidParameterValueException("Virtual Guest Cidr " + cidr + " is not RFC1918 compliant");
|
throw new InvalidParameterValueException("Virtual Guest Cidr " + cidr + " is not RFC1918 compliant");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
|
@ -1997,7 +2047,21 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ip6Cidr != null && ip6Gateway != null) {
|
||||||
|
userNetwork.setIp6Cidr(ip6Cidr);
|
||||||
|
userNetwork.setIp6Gateway(ip6Gateway);
|
||||||
|
if (vlanId != null) {
|
||||||
|
userNetwork.setBroadcastUri(URI.create("vlan://" + vlanId));
|
||||||
|
userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan);
|
||||||
|
if (!vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
|
||||||
|
userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan);
|
||||||
|
} else {
|
||||||
|
userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<NetworkVO> networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId,
|
List<NetworkVO> networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId,
|
||||||
aclType, subdomainAccess, vpcId);
|
aclType, subdomainAccess, vpcId);
|
||||||
|
|
||||||
|
|
@ -2559,7 +2623,7 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
|
||||||
, owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
|
, owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
|
||||||
zoneId, ACLType.Account,
|
zoneId, ACLType.Account,
|
||||||
null, null);
|
null, null, null, null);
|
||||||
if (guestNetwork == null) {
|
if (guestNetwork == null) {
|
||||||
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
|
||||||
throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " +
|
throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " +
|
||||||
|
|
@ -3303,27 +3367,56 @@ public class NetworkManagerImpl implements NetworkManager, Manager, Listener {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException,
|
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network,
|
||||||
|
String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
if (nic.getIp4Address() == null) {
|
boolean ipv4 = false, ipv6 = false;
|
||||||
PublicIp ip = assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIp, false);
|
if (network.getGateway() != null) {
|
||||||
nic.setIp4Address(ip.getAddress().toString());
|
if (nic.getIp4Address() == null) {
|
||||||
nic.setGateway(ip.getGateway());
|
ipv4 = true;
|
||||||
nic.setNetmask(ip.getNetmask());
|
PublicIp ip = assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIpv4, false);
|
||||||
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
nic.setIp4Address(ip.getAddress().toString());
|
||||||
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
nic.setGateway(ip.getGateway());
|
||||||
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
|
nic.setNetmask(ip.getNetmask());
|
||||||
nic.setFormat(AddressFormat.Ip4);
|
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||||
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||||
nic.setMacAddress(ip.getMacAddress());
|
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
|
||||||
}
|
nic.setFormat(AddressFormat.Ip4);
|
||||||
|
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||||
|
nic.setMacAddress(ip.getMacAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (network.getIp6Gateway() != null) {
|
||||||
|
if (nic.getIp6Address() == null) {
|
||||||
|
ipv6 = true;
|
||||||
|
PublicIpv6Address ip = assignPublicIp6Address(dc.getId(), null, vm.getOwner(), VlanType.DirectAttached, network.getId(), requestedIpv6, false);
|
||||||
|
Vlan vlan = _networkModel.getVlanForNetwork(network.getId());
|
||||||
|
if (vlan == null) {
|
||||||
|
s_logger.debug("Cannot find related vlan or too many vlan attached to network " + network.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nic.setIp6Address(ip.getAddress().toString());
|
||||||
|
nic.setIp6Gateway(vlan.getIp6Gateway());
|
||||||
|
nic.setIp6Cidr(vlan.getIp6Cidr());
|
||||||
|
if (ipv4) {
|
||||||
|
nic.setFormat(AddressFormat.Mixed);
|
||||||
|
} else {
|
||||||
|
nic.setIsolationUri(IsolationType.Vlan.toUri(vlan.getVlanTag()));
|
||||||
|
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||||
|
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan.getVlanTag()));
|
||||||
|
nic.setFormat(AddressFormat.Ip6);
|
||||||
|
nic.setReservationId(String.valueOf(vlan.getVlanTag()));
|
||||||
|
nic.setMacAddress(ip.getMacAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nic.setDns1(dc.getDns1());
|
nic.setDns1(dc.getDns1());
|
||||||
nic.setDns2(dc.getDns2());
|
nic.setDns2(dc.getDns2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Override
|
|
||||||
public boolean setupDns(Network network, Provider provider) {
|
public boolean setupDns(Network network, Provider provider) {
|
||||||
boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, provider );
|
boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, provider );
|
||||||
boolean dhcpProvided =_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
boolean dhcpProvided =_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
import com.cloud.configuration.ConfigurationManager;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.PodVlanMapVO;
|
import com.cloud.dc.PodVlanMapVO;
|
||||||
|
import com.cloud.dc.Vlan;
|
||||||
import com.cloud.dc.Vlan.VlanType;
|
import com.cloud.dc.Vlan.VlanType;
|
||||||
import com.cloud.dc.VlanVO;
|
import com.cloud.dc.VlanVO;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
|
|
@ -65,6 +66,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
||||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
||||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
|
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
|
||||||
|
import com.cloud.network.dao.PublicIpv6AddressDao;
|
||||||
import com.cloud.network.element.NetworkElement;
|
import com.cloud.network.element.NetworkElement;
|
||||||
import com.cloud.network.element.UserDataServiceProvider;
|
import com.cloud.network.element.UserDataServiceProvider;
|
||||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||||
|
|
@ -157,7 +159,8 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
||||||
NetworkServiceMapDao _ntwkSrvcDao;
|
NetworkServiceMapDao _ntwkSrvcDao;
|
||||||
@Inject
|
@Inject
|
||||||
PrivateIpDao _privateIpDao;
|
PrivateIpDao _privateIpDao;
|
||||||
|
@Inject
|
||||||
|
PublicIpv6AddressDao _ipv6Dao;
|
||||||
|
|
||||||
|
|
||||||
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||||
|
|
@ -510,7 +513,15 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
||||||
}
|
}
|
||||||
boolean hasFreeIps = true;
|
boolean hasFreeIps = true;
|
||||||
if (network.getGuestType() == GuestType.Shared) {
|
if (network.getGuestType() == GuestType.Shared) {
|
||||||
hasFreeIps = _ipAddressDao.countFreeIPsInNetwork(network.getId()) > 0;
|
if (network.getGateway() != null) {
|
||||||
|
hasFreeIps = _ipAddressDao.countFreeIPsInNetwork(network.getId()) > 0;
|
||||||
|
}
|
||||||
|
if (!hasFreeIps) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (network.getIp6Gateway() != null) {
|
||||||
|
hasFreeIps = isIP6AddressAvailable(network);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hasFreeIps = (getAvailableIps(network, null)).size() > 0;
|
hasFreeIps = (getAvailableIps(network, null)).size() > 0;
|
||||||
}
|
}
|
||||||
|
|
@ -518,9 +529,27 @@ public class NetworkModelImpl implements NetworkModel, Manager{
|
||||||
return hasFreeIps;
|
return hasFreeIps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Vlan getVlanForNetwork(long networkId) {
|
||||||
|
List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
|
||||||
|
if (vlans == null || vlans.size() > 1) {
|
||||||
|
s_logger.debug("Cannot find related vlan or too many vlan attached to network " + networkId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return vlans.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isIP6AddressAvailable(Network network) {
|
||||||
|
if (network.getIp6Gateway() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Vlan vlan = getVlanForNetwork(network.getId());
|
||||||
|
long existedCount = _ipv6Dao.countExistedIpsInNetwork(network.getId());
|
||||||
|
long rangeCount = NetUtils.countIp6InRange(vlan.getIp6Range());
|
||||||
|
return (existedCount < rangeCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId) {
|
public Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId) {
|
||||||
|
|
||||||
Map<Service, Map<Capability, String>> networkCapabilities = new HashMap<Service, Map<Capability, String>>();
|
Map<Service, Map<Capability, String>> networkCapabilities = new HashMap<Service, Map<Capability, String>>();
|
||||||
|
|
|
||||||
|
|
@ -615,6 +615,11 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
boolean isDomainSpecific = false;
|
boolean isDomainSpecific = false;
|
||||||
Boolean subdomainAccess = cmd.getSubdomainAccess();
|
Boolean subdomainAccess = cmd.getSubdomainAccess();
|
||||||
Long vpcId = cmd.getVpcId();
|
Long vpcId = cmd.getVpcId();
|
||||||
|
String startIPv6 = cmd.getStartIpv6();
|
||||||
|
String endIPv6 = cmd.getEndIpv6();
|
||||||
|
String ip6Gateway = cmd.getIp6Gateway();
|
||||||
|
String ip6Cidr = cmd.getIp6Cidr();
|
||||||
|
Boolean dualStack = cmd.isDualStack();
|
||||||
|
|
||||||
// Validate network offering
|
// Validate network offering
|
||||||
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
|
||||||
|
|
@ -732,36 +737,85 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
UserContext.current().setAccountId(owner.getAccountId());
|
UserContext.current().setAccountId(owner.getAccountId());
|
||||||
|
|
||||||
// VALIDATE IP INFO
|
// VALIDATE IP INFO
|
||||||
// if end ip is not specified, default it to startIp
|
if (startIPv6 != null && startIP != null && (dualStack == null || dualStack == false)) {
|
||||||
|
throw new InvalidParameterValueException("Cannot specify both IPv4 and IPv6 address without set dualStack = true!");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ipv4 = false, ipv6 = false;
|
||||||
if (startIP != null) {
|
if (startIP != null) {
|
||||||
if (!NetUtils.isValidIp(startIP)) {
|
ipv4 = true;
|
||||||
throw new InvalidParameterValueException("Invalid format for the startIp parameter");
|
|
||||||
}
|
|
||||||
if (endIP == null) {
|
|
||||||
endIP = startIP;
|
|
||||||
} else if (!NetUtils.isValidIp(endIP)) {
|
|
||||||
throw new InvalidParameterValueException("Invalid format for the endIp parameter");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (startIPv6 != null) {
|
||||||
if (startIP != null && endIP != null) {
|
ipv6 = true;
|
||||||
if (!(gateway != null && netmask != null)) {
|
|
||||||
throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String cidr = null;
|
String cidr = null;
|
||||||
if (gateway != null && netmask != null) {
|
if (ipv4) {
|
||||||
if (!NetUtils.isValidIp(gateway)) {
|
// if end ip is not specified, default it to startIp
|
||||||
throw new InvalidParameterValueException("Invalid gateway");
|
if (startIP != null) {
|
||||||
}
|
if (!NetUtils.isValidIp(startIP)) {
|
||||||
if (!NetUtils.isValidNetmask(netmask)) {
|
throw new InvalidParameterValueException("Invalid format for the startIp parameter");
|
||||||
throw new InvalidParameterValueException("Invalid netmask");
|
}
|
||||||
}
|
if (endIP == null) {
|
||||||
|
endIP = startIP;
|
||||||
|
} else if (!NetUtils.isValidIp(endIP)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid format for the endIp parameter");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
if (startIP != null && endIP != null) {
|
||||||
|
if (!(gateway != null && netmask != null)) {
|
||||||
|
throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gateway != null && netmask != null) {
|
||||||
|
if (!NetUtils.isValidIp(gateway)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid gateway");
|
||||||
|
}
|
||||||
|
if (!NetUtils.isValidNetmask(netmask)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid netmask");
|
||||||
|
}
|
||||||
|
|
||||||
|
cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipv6) {
|
||||||
|
if (!NetUtils.isValidIPv6(startIPv6)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid format for the startIPv6 parameter");
|
||||||
|
}
|
||||||
|
if (endIPv6 == null) {
|
||||||
|
endIPv6 = startIPv6;
|
||||||
|
} else if (!NetUtils.isValidIPv6(endIPv6)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid format for the endIPv6 parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ip6Gateway != null && ip6Cidr != null)) {
|
||||||
|
throw new InvalidParameterValueException("ip6Gateway and ip6Cidr should be defined when startIPv6/endIPv6 are passed in");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NetUtils.isValidIPv6(ip6Gateway)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid ip6Gateway");
|
||||||
|
}
|
||||||
|
if (!NetUtils.isValidIp6Cidr(ip6Cidr)) {
|
||||||
|
throw new InvalidParameterValueException("Invalid ip6cidr");
|
||||||
|
}
|
||||||
|
|
||||||
|
int cidrSize = NetUtils.getIp6CidrSize(ip6Cidr);
|
||||||
|
// Ipv6 cidr limit should be at least /64
|
||||||
|
if (cidrSize < 64) {
|
||||||
|
throw new InvalidParameterValueException("The cidr size of IPv6 must be bigger than 64 bits!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ipv6) {
|
||||||
|
if (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != Network.GuestType.Shared) {
|
||||||
|
throw new InvalidParameterValueException("Can only support create IPv6 network with advance shared network!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Regular user can create Guest Isolated Source Nat enabled network only
|
// Regular user can create Guest Isolated Source Nat enabled network only
|
||||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL
|
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL
|
||||||
&& (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Isolated
|
&& (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Isolated
|
||||||
|
|
@ -775,19 +829,25 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (ntwkOff.getSpecifyVlan() || vlanId != null)) {
|
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && (ntwkOff.getSpecifyVlan() || vlanId != null)) {
|
||||||
throw new InvalidParameterValueException("Regular user is not allowed to specify vlanId");
|
throw new InvalidParameterValueException("Regular user is not allowed to specify vlanId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ipv4) {
|
||||||
|
// For non-root admins check cidr limit - if it's allowed by global config value
|
||||||
|
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && cidr != null) {
|
||||||
|
|
||||||
// For non-root admins check cidr limit - if it's allowed by global config value
|
String[] cidrPair = cidr.split("\\/");
|
||||||
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && cidr != null) {
|
int cidrSize = Integer.valueOf(cidrPair[1]);
|
||||||
|
|
||||||
String[] cidrPair = cidr.split("\\/");
|
if (cidrSize < _cidrLimit) {
|
||||||
int cidrSize = Integer.valueOf(cidrPair[1]);
|
throw new InvalidParameterValueException("Cidr size can't be less than " + _cidrLimit);
|
||||||
|
}
|
||||||
if (cidrSize < _cidrLimit) {
|
}
|
||||||
throw new InvalidParameterValueException("Cidr size can't be less than " + _cidrLimit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<String> ntwkProviders = _networkMgr.finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values();
|
Collection<String> ntwkProviders = _networkMgr.finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values();
|
||||||
|
if (ipv6 && providersConfiguredForExternalNetworking(ntwkProviders)) {
|
||||||
|
throw new InvalidParameterValueException("Cannot support IPv6 on network offering with external devices!");
|
||||||
|
}
|
||||||
|
|
||||||
if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) {
|
if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) {
|
||||||
if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) &&
|
if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) &&
|
||||||
isSharedNetworkOfferingWithServices(networkOfferingId)) {
|
isSharedNetworkOfferingWithServices(networkOfferingId)) {
|
||||||
|
|
@ -798,7 +858,6 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Vlan is created in 2 cases - works in Advance zone only:
|
// Vlan is created in 2 cases - works in Advance zone only:
|
||||||
// 1) GuestType is Shared
|
// 1) GuestType is Shared
|
||||||
// 2) GuestType is Isolated, but SourceNat service is disabled
|
// 2) GuestType is Isolated, but SourceNat service is disabled
|
||||||
|
|
@ -806,6 +865,13 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
&& ((ntwkOff.getGuestType() == Network.GuestType.Shared)
|
&& ((ntwkOff.getGuestType() == Network.GuestType.Shared)
|
||||||
|| (ntwkOff.getGuestType() == GuestType.Isolated &&
|
|| (ntwkOff.getGuestType() == GuestType.Isolated &&
|
||||||
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))));
|
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))));
|
||||||
|
|
||||||
|
if (!createVlan) {
|
||||||
|
// Only support advance shared network in IPv6, which means createVlan is a must
|
||||||
|
if (ipv6) {
|
||||||
|
createVlan = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Can add vlan range only to the network which allows it
|
// Can add vlan range only to the network which allows it
|
||||||
if (createVlan && !ntwkOff.getSpecifyIpRanges()) {
|
if (createVlan && !ntwkOff.getSpecifyIpRanges()) {
|
||||||
|
|
@ -851,13 +917,13 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
throw new InvalidParameterValueException("Network offering can be used for VPC networks only");
|
throw new InvalidParameterValueException("Network offering can be used for VPC networks only");
|
||||||
}
|
}
|
||||||
network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
||||||
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) {
|
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) {
|
||||||
// Create vlan ip range
|
// Create vlan ip range
|
||||||
_configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(), network.getId(), physicalNetworkId,
|
_configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(), network.getId(), physicalNetworkId,
|
||||||
false, null, startIP, endIP, gateway, netmask, vlanId, null);
|
false, null, startIP, endIP, gateway, netmask, vlanId, null, startIPv6, endIPv6, ip6Gateway, ip6Cidr);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
@ -2813,7 +2879,7 @@ public class NetworkServiceImpl implements NetworkService, Manager {
|
||||||
if (privateNetwork == null) {
|
if (privateNetwork == null) {
|
||||||
//create Guest network
|
//create Guest network
|
||||||
privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan,
|
privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan,
|
||||||
null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null);
|
null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null, null, null);
|
||||||
s_logger.debug("Created private network " + privateNetwork);
|
s_logger.debug("Created private network " + privateNetwork);
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Private network already exists: " + privateNetwork);
|
s_logger.debug("Private network already exists: " + privateNetwork);
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,12 @@ public class NetworkVO implements Network {
|
||||||
|
|
||||||
@Column(name="specify_ip_ranges")
|
@Column(name="specify_ip_ranges")
|
||||||
boolean specifyIpRanges = false;
|
boolean specifyIpRanges = false;
|
||||||
|
|
||||||
|
@Column(name="ip6_gateway")
|
||||||
|
String ip6Gateway;
|
||||||
|
|
||||||
|
@Column(name="ip6_cidr")
|
||||||
|
String ip6Cidr;
|
||||||
|
|
||||||
public NetworkVO() {
|
public NetworkVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
|
@ -195,6 +201,8 @@ public class NetworkVO implements Network {
|
||||||
state = State.Allocated;
|
state = State.Allocated;
|
||||||
}
|
}
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
this.ip6Gateway = that.getIp6Gateway();
|
||||||
|
this.ip6Cidr = that.getIp6Cidr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -491,4 +499,20 @@ public class NetworkVO implements Network {
|
||||||
public Long getVpcId() {
|
public Long getVpcId() {
|
||||||
return vpcId;
|
return vpcId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Cidr(String ip6Cidr) {
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
package com.cloud.network;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.acl.ControlledEntity;
|
||||||
|
import org.apache.cloudstack.api.Identity;
|
||||||
|
import org.apache.cloudstack.api.InternalIdentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sheng Yang
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface PublicIpv6Address extends ControlledEntity, Identity, InternalIdentity {
|
||||||
|
enum State {
|
||||||
|
Allocating, // The IP Address is being propagated to other network elements and is not ready for use yet.
|
||||||
|
Allocated, // The IP address is in used.
|
||||||
|
Releasing, // The IP address is being released for other network elements and is not ready for allocation.
|
||||||
|
Free // The IP address is ready to be allocated.
|
||||||
|
}
|
||||||
|
|
||||||
|
long getDataCenterId();
|
||||||
|
|
||||||
|
String getAddress();
|
||||||
|
|
||||||
|
long getVlanId();
|
||||||
|
|
||||||
|
State getState();
|
||||||
|
|
||||||
|
Long getNetworkId();
|
||||||
|
|
||||||
|
Long getSourceNetworkId();
|
||||||
|
|
||||||
|
Long getPhysicalNetworkId();
|
||||||
|
|
||||||
|
void setState(PublicIpv6Address.State state);
|
||||||
|
|
||||||
|
String getMacAddress();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,189 @@
|
||||||
|
// Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
// or more contributor license agreements. See the NOTICE file
|
||||||
|
// distributed with this work for additional information
|
||||||
|
// regarding copyright ownership. The ASF licenses this file
|
||||||
|
// to you under the Apache License, Version 2.0 (the
|
||||||
|
// "License"); you may not use this file except in compliance
|
||||||
|
// with the License. You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing,
|
||||||
|
// software distributed under the License is distributed on an
|
||||||
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
// KIND, either express or implied. See the License for the
|
||||||
|
// specific language governing permissions and limitations
|
||||||
|
// under the License.
|
||||||
|
package com.cloud.network;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name=("public_ipv6_address"))
|
||||||
|
public class PublicIpv6AddressVO implements PublicIpv6Address {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
@Column(name="id")
|
||||||
|
long id;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name="ip_address")
|
||||||
|
@Enumerated(value=EnumType.STRING)
|
||||||
|
private String address = null;
|
||||||
|
|
||||||
|
@Column(name="data_center_id", updatable=false)
|
||||||
|
private long dataCenterId;
|
||||||
|
|
||||||
|
@Column(name="vlan_id")
|
||||||
|
private long vlanId;
|
||||||
|
|
||||||
|
@Column(name="state")
|
||||||
|
private State state;
|
||||||
|
|
||||||
|
@Column(name="mac_address")
|
||||||
|
private String macAddress;
|
||||||
|
|
||||||
|
@Column(name="source_network_id")
|
||||||
|
private Long sourceNetworkId;
|
||||||
|
|
||||||
|
@Column(name="network_id")
|
||||||
|
private Long networkId;
|
||||||
|
|
||||||
|
@Column(name="uuid")
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
@Column(name="physical_network_id")
|
||||||
|
private Long physicalNetworkId;
|
||||||
|
|
||||||
|
@Column(name="account_id")
|
||||||
|
private Long accountId = null;
|
||||||
|
|
||||||
|
@Column(name="domain_id")
|
||||||
|
private Long domainId = null;
|
||||||
|
|
||||||
|
@Column(name = GenericDao.CREATED_COLUMN)
|
||||||
|
Date created;
|
||||||
|
|
||||||
|
protected PublicIpv6AddressVO() {
|
||||||
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) {
|
||||||
|
this.address = address;
|
||||||
|
this.dataCenterId = dataCenterId;
|
||||||
|
this.vlanId = vlanDbId;
|
||||||
|
this.state = State.Free;
|
||||||
|
this.setMacAddress(macAddress);
|
||||||
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDomainId() {
|
||||||
|
return domainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataCenterId() {
|
||||||
|
return dataCenterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getVlanId() {
|
||||||
|
return vlanId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getNetworkId() {
|
||||||
|
return networkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getSourceNetworkId() {
|
||||||
|
return sourceNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getPhysicalNetworkId() {
|
||||||
|
return physicalNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setState(State state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMacAddress() {
|
||||||
|
return macAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMacAddress(String macAddress) {
|
||||||
|
this.macAddress = macAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceNetworkId(Long sourceNetworkId) {
|
||||||
|
this.sourceNetworkId = sourceNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNetworkId(Long networkId) {
|
||||||
|
this.networkId = networkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhysicalNetworkId(Long physicalNetworkId) {
|
||||||
|
this.physicalNetworkId = physicalNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDomainId(Long domainId) {
|
||||||
|
this.domainId = domainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(Long accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreated(Date created) {
|
||||||
|
this.created = created;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -206,4 +206,19 @@ public class PublicIp implements PublicIpAddress {
|
||||||
public void setVpcId(Long vpcId) {
|
public void setVpcId(Long vpcId) {
|
||||||
_addr.setVpcId(vpcId);
|
_addr.setVpcId(vpcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return _vlan.getIp6Gateway();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return _vlan.getIp6Cidr();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Range() {
|
||||||
|
return _vlan.getIp6Range();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.cloud.network.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.cloud.network.Network;
|
||||||
|
import com.cloud.network.PublicIpv6AddressVO;
|
||||||
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
|
public interface PublicIpv6AddressDao extends GenericDao<PublicIpv6AddressVO, Long> {
|
||||||
|
List<PublicIpv6AddressVO> listByAccount(long accountId);
|
||||||
|
|
||||||
|
List<PublicIpv6AddressVO> listByVlanId(long vlanId);
|
||||||
|
|
||||||
|
List<PublicIpv6AddressVO> listByDcId(long dcId);
|
||||||
|
|
||||||
|
List<PublicIpv6AddressVO> listByNetwork(long networkId);
|
||||||
|
|
||||||
|
public PublicIpv6AddressVO findByDcIdAndIp(long dcId, String ipAddress);
|
||||||
|
|
||||||
|
List<PublicIpv6AddressVO> listByPhysicalNetworkId(long physicalNetworkId);
|
||||||
|
|
||||||
|
long countExistedIpsInNetwork(long networkId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.cloud.network.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.ejb.Local;
|
||||||
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.network.Network;
|
||||||
|
import com.cloud.network.PublicIpv6AddressVO;
|
||||||
|
import com.cloud.utils.Pair;
|
||||||
|
import com.cloud.utils.db.Filter;
|
||||||
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
import com.cloud.utils.db.GenericSearchBuilder;
|
||||||
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
import com.cloud.utils.db.SearchCriteria.Func;
|
||||||
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
|
import com.cloud.utils.db.SearchCriteria2;
|
||||||
|
|
||||||
|
@Local(value=PublicIpv6AddressDao.class)
|
||||||
|
public class PublicIpv6AddressDaoImpl extends GenericDaoBase<PublicIpv6AddressVO, Long> implements PublicIpv6AddressDao {
|
||||||
|
private static final Logger s_logger = Logger.getLogger(IPAddressDaoImpl.class);
|
||||||
|
|
||||||
|
protected final SearchBuilder<PublicIpv6AddressVO> AllFieldsSearch;
|
||||||
|
protected GenericSearchBuilder<PublicIpv6AddressVO, Long> CountFreePublicIps;
|
||||||
|
|
||||||
|
public PublicIpv6AddressDaoImpl() {
|
||||||
|
AllFieldsSearch = createSearchBuilder();
|
||||||
|
AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("dataCenterId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getAddress(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("vlan", AllFieldsSearch.entity().getVlanId(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||||
|
AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||||
|
AllFieldsSearch.done();
|
||||||
|
|
||||||
|
CountFreePublicIps = createSearchBuilder(Long.class);
|
||||||
|
CountFreePublicIps.select(null, Func.COUNT, null);
|
||||||
|
CountFreePublicIps.and("networkId", CountFreePublicIps.entity().getSourceNetworkId(), SearchCriteria.Op.EQ);
|
||||||
|
CountFreePublicIps.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicIpv6AddressVO> listByAccount(long accountId) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("accountId", accountId);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicIpv6AddressVO> listByVlanId(long vlanId) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("vlan", vlanId);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicIpv6AddressVO> listByDcId(long dcId) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("dataCenterId", dcId);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicIpv6AddressVO> listByNetwork(long networkId) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("network", networkId);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicIpv6AddressVO findByDcIdAndIp(long dcId, String ipAddress) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("dataCenterId", dcId);
|
||||||
|
sc.setParameters("ipAddress", ipAddress);
|
||||||
|
return findOneBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PublicIpv6AddressVO> listByPhysicalNetworkId(long physicalNetworkId) {
|
||||||
|
SearchCriteria<PublicIpv6AddressVO> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long countExistedIpsInNetwork(long networkId) {
|
||||||
|
SearchCriteria<Long> sc = CountFreePublicIps.create();
|
||||||
|
sc.setParameters("networkId", networkId);
|
||||||
|
return customSearch(sc, null).get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,9 @@ import com.cloud.network.NetworkVO;
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
import com.cloud.network.Networks.Mode;
|
import com.cloud.network.Networks.Mode;
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
|
import com.cloud.network.PublicIpv6AddressVO;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
|
import com.cloud.network.dao.PublicIpv6AddressDao;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
@ -72,6 +74,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
IPAddressDao _ipAddressDao;
|
IPAddressDao _ipAddressDao;
|
||||||
@Inject
|
@Inject
|
||||||
NetworkOfferingDao _networkOfferingDao;
|
NetworkOfferingDao _networkOfferingDao;
|
||||||
|
@Inject
|
||||||
|
PublicIpv6AddressDao _ipv6Dao;
|
||||||
|
|
||||||
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
||||||
|
|
||||||
|
|
@ -120,11 +124,20 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
throw new InvalidParameterValueException("cidr and gateway must be specified together.");
|
throw new InvalidParameterValueException("cidr and gateway must be specified together.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((userSpecified.getIp6Cidr() == null && userSpecified.getIp6Gateway() != null) || (userSpecified.getIp6Cidr() != null && userSpecified.getIp6Gateway() == null)) {
|
||||||
|
throw new InvalidParameterValueException("cidrv6 and gatewayv6 must be specified together.");
|
||||||
|
}
|
||||||
|
|
||||||
if (userSpecified.getCidr() != null) {
|
if (userSpecified.getCidr() != null) {
|
||||||
config.setCidr(userSpecified.getCidr());
|
config.setCidr(userSpecified.getCidr());
|
||||||
config.setGateway(userSpecified.getGateway());
|
config.setGateway(userSpecified.getGateway());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userSpecified.getIp6Cidr() != null) {
|
||||||
|
config.setIp6Cidr(userSpecified.getIp6Cidr());
|
||||||
|
config.setIp6Gateway(userSpecified.getIp6Gateway());
|
||||||
|
}
|
||||||
|
|
||||||
if (userSpecified.getBroadcastUri() != null) {
|
if (userSpecified.getBroadcastUri() != null) {
|
||||||
config.setBroadcastUri(userSpecified.getBroadcastUri());
|
config.setBroadcastUri(userSpecified.getBroadcastUri());
|
||||||
config.setState(State.Setup);
|
config.setState(State.Setup);
|
||||||
|
|
@ -137,6 +150,9 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
|
|
||||||
boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
|
||||||
if (isSecurityGroupEnabled) {
|
if (isSecurityGroupEnabled) {
|
||||||
|
if (userSpecified.getIp6Cidr() != null) {
|
||||||
|
throw new InvalidParameterValueException("Didn't support security group with IPv6");
|
||||||
|
}
|
||||||
config.setName("SecurityGroupEnabledNetwork");
|
config.setName("SecurityGroupEnabledNetwork");
|
||||||
config.setDisplayText("SecurityGroupEnabledNetwork");
|
config.setDisplayText("SecurityGroupEnabledNetwork");
|
||||||
}
|
}
|
||||||
|
|
@ -165,13 +181,13 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
|
|
||||||
if (nic == null) {
|
if (nic == null) {
|
||||||
nic = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
nic = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
||||||
} else if (nic.getIp4Address() == null) {
|
} else if (nic.getIp4Address() == null && nic.getIp6Address() == null) {
|
||||||
nic.setStrategy(ReservationStrategy.Start);
|
nic.setStrategy(ReservationStrategy.Start);
|
||||||
} else {
|
} else {
|
||||||
nic.setStrategy(ReservationStrategy.Create);
|
nic.setStrategy(ReservationStrategy.Create);
|
||||||
}
|
}
|
||||||
|
|
||||||
_networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIp());
|
_networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIpv4(), nic.getRequestedIpv6());
|
||||||
nic.setStrategy(ReservationStrategy.Create);
|
nic.setStrategy(ReservationStrategy.Create);
|
||||||
|
|
||||||
return nic;
|
return nic;
|
||||||
|
|
@ -180,8 +196,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
@Override
|
@Override
|
||||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||||
if (nic.getIp4Address() == null) {
|
if (nic.getIp4Address() == null && nic.getIp6Address() == null) {
|
||||||
_networkMgr.allocateDirectIp(nic, dest.getDataCenter(), vm, network, null);
|
_networkMgr.allocateDirectIp(nic, dest.getDataCenter(), vm, network, null, null);
|
||||||
nic.setStrategy(ReservationStrategy.Create);
|
nic.setStrategy(ReservationStrategy.Create);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -202,14 +218,23 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
|
s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
|
if (nic.getIp4Address() != null) {
|
||||||
if (ip != null) {
|
IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
|
||||||
Transaction txn = Transaction.currentTxn();
|
if (ip != null) {
|
||||||
txn.start();
|
Transaction txn = Transaction.currentTxn();
|
||||||
_networkMgr.markIpAsUnavailable(ip.getId());
|
txn.start();
|
||||||
_ipAddressDao.unassignIpAddress(ip.getId());
|
_networkMgr.markIpAsUnavailable(ip.getId());
|
||||||
txn.commit();
|
_ipAddressDao.unassignIpAddress(ip.getId());
|
||||||
}
|
txn.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nic.getIp6Address() != null) {
|
||||||
|
PublicIpv6AddressVO ip = _ipv6Dao.findByDcIdAndIp(network.getDataCenterId(), nic.getIp6Address());
|
||||||
|
if (ip != null) {
|
||||||
|
_ipv6Dao.remove(ip.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
nic.deallocate();
|
nic.deallocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
||||||
rsStrategy = ReservationStrategy.Create;
|
rsStrategy = ReservationStrategy.Create;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nic != null && nic.getRequestedIp() != null) {
|
if (nic != null && nic.getRequestedIpv4() != null) {
|
||||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
|
|
||||||
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
|
if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIpv4() != null) {
|
||||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||||
|
|
||||||
String guestIp = null;
|
String guestIp = null;
|
||||||
if (network.getSpecifyIpRanges()) {
|
if (network.getSpecifyIpRanges()) {
|
||||||
_networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIp());
|
_networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIpv4(), null);
|
||||||
} else {
|
} else {
|
||||||
//if Vm is router vm and source nat is enabled in the network, set ip4 to the network gateway
|
//if Vm is router vm and source nat is enabled in the network, set ip4 to the network gateway
|
||||||
boolean isGateway = false;
|
boolean isGateway = false;
|
||||||
|
|
@ -371,7 +371,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
|
||||||
if (isGateway) {
|
if (isGateway) {
|
||||||
guestIp = network.getGateway();
|
guestIp = network.getGateway();
|
||||||
} else {
|
} else {
|
||||||
guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
|
guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIpv4());
|
||||||
if (guestIp == null) {
|
if (guestIp == null) {
|
||||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire Guest IP" +
|
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire Guest IP" +
|
||||||
" address for network " + network, DataCenter.class, dc.getId());
|
" address for network " + network, DataCenter.class, dc.getId());
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
assert trafficType == TrafficType.Management || trafficType == TrafficType.Storage: "Well, I can't take care of this config now can I? " + config;
|
assert trafficType == TrafficType.Management || trafficType == TrafficType.Storage: "Well, I can't take care of this config now can I? " + config;
|
||||||
|
|
||||||
if (nic != null) {
|
if (nic != null) {
|
||||||
if (nic.getRequestedIp() != null) {
|
if (nic.getRequestedIpv4() != null) {
|
||||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||||
}
|
}
|
||||||
nic.setStrategy(nic.getIp4Address() != null ? ReservationStrategy.Create : ReservationStrategy.Start);
|
nic.setStrategy(nic.getIp4Address() != null ? ReservationStrategy.Create : ReservationStrategy.Start);
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||||
|
|
||||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||||
|
|
||||||
if (nic != null && nic.getRequestedIp() != null) {
|
if (nic != null && nic.getRequestedIpv4() != null) {
|
||||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1656,7 +1656,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp);
|
NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp, null);
|
||||||
if (setupPublicNetwork) {
|
if (setupPublicNetwork) {
|
||||||
if (isRedundant) {
|
if (isRedundant) {
|
||||||
gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null));
|
gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null));
|
||||||
|
|
@ -3018,11 +3018,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDhcpEntryCommand(VirtualRouter router, UserVm vm, NicVO nic, Commands cmds) {
|
private void createDhcpEntryCommand(VirtualRouter router, UserVm vm, NicVO nic, Commands cmds) {
|
||||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
|
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName(), nic.getIp6Address());
|
||||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||||
String gatewayIp = findGatewayIp(vm.getId());
|
String gatewayIp = findGatewayIp(vm.getId());
|
||||||
boolean needGateway = true;
|
boolean needGateway = true;
|
||||||
if (!gatewayIp.equals(nic.getGateway())) {
|
if (gatewayIp != null && !gatewayIp.equals(nic.getGateway())) {
|
||||||
needGateway = false;
|
needGateway = false;
|
||||||
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
|
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
|
||||||
// Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset.
|
// Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset.
|
||||||
|
|
@ -3038,7 +3038,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
gatewayIp = "0.0.0.0";
|
gatewayIp = "0.0.0.0";
|
||||||
}
|
}
|
||||||
dhcpCommand.setDefaultRouter(gatewayIp);
|
dhcpCommand.setDefaultRouter(gatewayIp);
|
||||||
|
dhcpCommand.setIp6Gateway(nic.getIp6Gateway());
|
||||||
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
||||||
|
dhcpCommand.setDuid(NetUtils.getDuidLL(nic.getMacAddress()));
|
||||||
|
|
||||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
||||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||||
|
|
|
||||||
|
|
@ -1884,7 +1884,7 @@ public class VpcManagerImpl implements VpcManager, Manager{
|
||||||
|
|
||||||
//2) Create network
|
//2) Create network
|
||||||
Network guestNetwork = _ntwkMgr.createGuestNetwork(ntwkOffId, name, displayText, gateway, cidr, vlanId,
|
Network guestNetwork = _ntwkMgr.createGuestNetwork(ntwkOffId, name, displayText, gateway, cidr, vlanId,
|
||||||
networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, null, null);
|
||||||
|
|
||||||
return guestNetwork;
|
return guestNetwork;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,12 @@ public class NicVO implements Nic {
|
||||||
@Column(name = "default_nic")
|
@Column(name = "default_nic")
|
||||||
boolean defaultNic;
|
boolean defaultNic;
|
||||||
|
|
||||||
|
@Column(name = "ip6_gateway")
|
||||||
|
String ip6Gateway;
|
||||||
|
|
||||||
|
@Column(name = "ip6_cidr")
|
||||||
|
String ip6Cidr;
|
||||||
|
|
||||||
@Column(name = "strategy")
|
@Column(name = "strategy")
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
ReservationStrategy reservationStrategy;
|
ReservationStrategy reservationStrategy;
|
||||||
|
|
@ -156,6 +162,7 @@ public class NicVO implements Nic {
|
||||||
this.defaultNic = defaultNic;
|
this.defaultNic = defaultNic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getIp6Address() {
|
public String getIp6Address() {
|
||||||
return ip6Address;
|
return ip6Address;
|
||||||
}
|
}
|
||||||
|
|
@ -324,4 +331,22 @@ public class NicVO implements Nic {
|
||||||
public void setUuid(String uuid) {
|
public void setUuid(String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Gateway() {
|
||||||
|
return ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Gateway(String ip6Gateway) {
|
||||||
|
this.ip6Gateway = ip6Gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIp6Cidr() {
|
||||||
|
return ip6Cidr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp6Cidr(String ip6Cidr) {
|
||||||
|
this.ip6Cidr = ip6Cidr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2184,7 +2184,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||||
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||||
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
|
||||||
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null);
|
||||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||||
} else if (virtualNetworks.size() > 1) {
|
} else if (virtualNetworks.size() > 1) {
|
||||||
throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds");
|
throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds");
|
||||||
|
|
@ -2372,13 +2372,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||||
requestedIp = requestedIps.get(network.getId());
|
requestedIp = requestedIps.get(network.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
NicProfile profile = new NicProfile(requestedIp);
|
NicProfile profile = new NicProfile(requestedIp, null);
|
||||||
|
|
||||||
if (defaultNetworkNumber == 0) {
|
if (defaultNetworkNumber == 0) {
|
||||||
defaultNetworkNumber++;
|
defaultNetworkNumber++;
|
||||||
// if user requested specific ip for default network, add it
|
// if user requested specific ip for default network, add it
|
||||||
if (defaultNetworkIp != null) {
|
if (defaultNetworkIp != null) {
|
||||||
profile = new NicProfile(defaultNetworkIp);
|
profile = new NicProfile(defaultNetworkIp, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.setDefaultNic(true);
|
profile.setDefaultNic(true);
|
||||||
|
|
@ -3543,7 +3543,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||||
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
requiredOfferings.get(0).getId() + " as a part of deployVM process");
|
||||||
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
|
||||||
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
|
||||||
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null);
|
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null);
|
||||||
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
defaultNetwork = _networkDao.findById(newNetwork.getId());
|
||||||
} else if (virtualNetworks.size() > 1) {
|
} else if (virtualNetworks.size() > 1) {
|
||||||
throw new InvalidParameterValueException("More than 1 default Isolated networks are found " +
|
throw new InvalidParameterValueException("More than 1 default Isolated networks are found " +
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||||
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -660,7 +660,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm,
|
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||||
Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException,
|
Network network, String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
|
@ -818,4 +818,12 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicIpv6Address assignPublicIp6Address(long dcId, Long podId,
|
||||||
|
Account owner, VlanType type, Long networkId, String requestedIpv6,
|
||||||
|
boolean isSystem) throws InsufficientAddressCapacityException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -806,4 +806,10 @@ public class MockNetworkModelImpl implements NetworkModel, Manager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vlan getVlanForNetwork(long networkId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ public class MockConfigurationManagerImpl implements ConfigurationManager, Confi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId,
|
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId,
|
||||||
Account vlanOwner) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException {
|
Account vlanOwner, String startIPv6, String endIPv6, String vlanGatewayv6, String vlanCidrv6) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import com.cloud.network.PhysicalNetwork;
|
||||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||||
import com.cloud.network.PublicIpAddress;
|
import com.cloud.network.PublicIpAddress;
|
||||||
|
import com.cloud.network.PublicIpv6Address;
|
||||||
import com.cloud.network.addr.PublicIp;
|
import com.cloud.network.addr.PublicIp;
|
||||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||||
|
|
@ -846,7 +847,7 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
||||||
@Override
|
@Override
|
||||||
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
|
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
|
||||||
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
|
||||||
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
|
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6)
|
||||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -1011,10 +1012,9 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm,
|
public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm,
|
||||||
Network network, String requestedIp) throws InsufficientVirtualNetworkCapcityException,
|
Network network, String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException,
|
||||||
InsufficientAddressCapacityException {
|
InsufficientAddressCapacityException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1313,10 +1313,6 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.cloud.network.NetworkService#getNetwork(java.lang.String)
|
* @see com.cloud.network.NetworkService#getNetwork(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|
@ -1325,4 +1321,12 @@ public class MockNetworkManagerImpl implements NetworkManager, NetworkService, M
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicIpv6Address assignPublicIp6Address(long dcId, Long podId,
|
||||||
|
Account owner, VlanType type, Long networkId, String requestedIpv6,
|
||||||
|
boolean isSystem) throws InsufficientAddressCapacityException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,8 @@ CREATE TABLE `cloud`.`networks` (
|
||||||
`broadcast_uri` varchar(255) COMMENT 'broadcast domain specifier',
|
`broadcast_uri` varchar(255) COMMENT 'broadcast domain specifier',
|
||||||
`gateway` varchar(15) COMMENT 'gateway for this network configuration',
|
`gateway` varchar(15) COMMENT 'gateway for this network configuration',
|
||||||
`cidr` varchar(18) COMMENT 'network cidr',
|
`cidr` varchar(18) COMMENT 'network cidr',
|
||||||
|
`ip6_gateway` varchar(50) COMMENT 'IPv6 gateway for this network',
|
||||||
|
`ip6_cidr` varchar(50) COMMENT 'IPv6 cidr for this network',
|
||||||
`mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
|
`mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
|
||||||
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
|
`network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
|
||||||
`physical_network_id` bigint unsigned COMMENT 'physical network id that this configuration is based on',
|
`physical_network_id` bigint unsigned COMMENT 'physical network id that this configuration is based on',
|
||||||
|
|
@ -270,6 +272,8 @@ CREATE TABLE `cloud`.`nics` (
|
||||||
`update_time` timestamp NOT NULL COMMENT 'time the state was changed',
|
`update_time` timestamp NOT NULL COMMENT 'time the state was changed',
|
||||||
`isolation_uri` varchar(255) COMMENT 'id for isolation',
|
`isolation_uri` varchar(255) COMMENT 'id for isolation',
|
||||||
`ip6_address` char(40) COMMENT 'ip6 address',
|
`ip6_address` char(40) COMMENT 'ip6 address',
|
||||||
|
`ip6_gateway` varchar(50) COMMENT 'gateway for ip6 address',
|
||||||
|
`ip6_cidr` varchar(50) COMMENT 'cidr for ip6 address',
|
||||||
`default_nic` tinyint NOT NULL COMMENT "None",
|
`default_nic` tinyint NOT NULL COMMENT "None",
|
||||||
`vm_type` varchar(32) COMMENT 'type of vm: System or User vm',
|
`vm_type` varchar(32) COMMENT 'type of vm: System or User vm',
|
||||||
`created` datetime NOT NULL COMMENT 'date created',
|
`created` datetime NOT NULL COMMENT 'date created',
|
||||||
|
|
@ -500,7 +504,10 @@ CREATE TABLE `cloud`.`vlan` (
|
||||||
`vlan_id` varchar(255),
|
`vlan_id` varchar(255),
|
||||||
`vlan_gateway` varchar(255),
|
`vlan_gateway` varchar(255),
|
||||||
`vlan_netmask` varchar(255),
|
`vlan_netmask` varchar(255),
|
||||||
|
`ip6_gateway` varchar(255),
|
||||||
|
`ip6_cidr` varchar(255),
|
||||||
`description` varchar(255),
|
`description` varchar(255),
|
||||||
|
`ip6_range` varchar(255),
|
||||||
`vlan_type` varchar(255),
|
`vlan_type` varchar(255),
|
||||||
`data_center_id` bigint unsigned NOT NULL,
|
`data_center_id` bigint unsigned NOT NULL,
|
||||||
`network_id` bigint unsigned NOT NULL COMMENT 'id of corresponding network offering',
|
`network_id` bigint unsigned NOT NULL COMMENT 'id of corresponding network offering',
|
||||||
|
|
@ -2543,5 +2550,30 @@ INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (2,
|
||||||
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (3, UUID(), 'snmp','Linux CPU Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now());
|
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (3, UUID(), 'snmp','Linux CPU Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now());
|
||||||
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (100, UUID(), 'netscaler','Response Time - microseconds', 'RESPTIME', now());
|
INSERT INTO `cloud`.`counter` (id, uuid, source, name, value,created) VALUES (100, UUID(), 'netscaler','Response Time - microseconds', 'RESPTIME', now());
|
||||||
|
|
||||||
|
CREATE TABLE `cloud`.`public_ipv6_address` (
|
||||||
|
`id` bigint unsigned NOT NULL UNIQUE auto_increment,
|
||||||
|
`uuid` varchar(40),
|
||||||
|
`account_id` bigint unsigned NULL,
|
||||||
|
`domain_id` bigint unsigned NULL,
|
||||||
|
`ip_address` char(50) NOT NULL,
|
||||||
|
`data_center_id` bigint unsigned NOT NULL COMMENT 'zone that it belongs to',
|
||||||
|
`vlan_id` bigint unsigned NOT NULL,
|
||||||
|
`state` char(32) NOT NULL default 'Free' COMMENT 'state of the ip address',
|
||||||
|
`mac_address` varchar(40) NOT NULL COMMENT 'mac address of this ip',
|
||||||
|
`source_network_id` bigint unsigned NOT NULL COMMENT 'network id ip belongs to',
|
||||||
|
`network_id` bigint unsigned COMMENT 'network this public ip address is associated with',
|
||||||
|
`physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network id that this configuration is based on',
|
||||||
|
`created` datetime NULL COMMENT 'Date this ip was allocated to someone',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE (`ip_address`, `source_network_id`),
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__source_network_id` FOREIGN KEY (`source_network_id`) REFERENCES `networks`(`id`),
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`),
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`),
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__vlan_id` FOREIGN KEY (`vlan_id`) REFERENCES `vlan`(`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `uc_public_ipv6_address__uuid` UNIQUE (`uuid`),
|
||||||
|
CONSTRAINT `fk_public_ipv6_address__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
SET foreign_key_checks = 1;
|
SET foreign_key_checks = 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,11 @@
|
||||||
<artifactId>ejb-api</artifactId>
|
<artifactId>ejb-api</artifactId>
|
||||||
<version>${cs.ejb.version}</version>
|
<version>${cs.ejb.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.java-ipv6</groupId>
|
||||||
|
<artifactId>java-ipv6</artifactId>
|
||||||
|
<version>${cs.java-ipv6.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-configuration</groupId>
|
<groupId>commons-configuration</groupId>
|
||||||
<artifactId>commons-configuration</artifactId>
|
<artifactId>commons-configuration</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ import java.util.regex.Pattern;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.xml.DOMConfigurator;
|
import org.apache.log4j.xml.DOMConfigurator;
|
||||||
|
|
||||||
|
import com.googlecode.ipv6.IPv6Address;
|
||||||
|
import com.googlecode.ipv6.IPv6Network;
|
||||||
|
|
||||||
import com.cloud.utils.IteratorUtil;
|
import com.cloud.utils.IteratorUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
@ -1142,4 +1145,73 @@ public class NetUtils {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidIPv6(String ip) {
|
||||||
|
try {
|
||||||
|
IPv6Address address = IPv6Address.fromString(ip);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValidIp6Cidr(String ip6Cidr) {
|
||||||
|
try {
|
||||||
|
IPv6Network network = IPv6Network.fromString(ip6Cidr);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getIp6CidrSize(String ip6Cidr) {
|
||||||
|
IPv6Network network = null;
|
||||||
|
try {
|
||||||
|
network = IPv6Network.fromString(ip6Cidr);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return network.getNetmask().asPrefixLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: only able to cover lower 32 bits
|
||||||
|
public static String getIp6FromRange(String ip6Range) {
|
||||||
|
String[] ips = ip6Range.split("-");
|
||||||
|
String startIp = ips[0];
|
||||||
|
long gap = countIp6InRange(ip6Range);
|
||||||
|
IPv6Address start = IPv6Address.fromString(startIp);
|
||||||
|
// Find a random number based on lower 32 bits
|
||||||
|
int d = _rand.nextInt((int)(gap % Integer.MAX_VALUE));
|
||||||
|
// And a number based on the difference of lower 32 bits
|
||||||
|
IPv6Address ip = start.add(d);
|
||||||
|
return ip.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//RFC3315, section 9.4
|
||||||
|
public static String getDuidLL(String macAddress) {
|
||||||
|
String duid = "00:03:00:06:" + macAddress;
|
||||||
|
return duid;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: only able to cover lower 64 bits
|
||||||
|
public static long countIp6InRange(String ip6Range) {
|
||||||
|
String[] ips = ip6Range.split("-");
|
||||||
|
String startIp = ips[0];
|
||||||
|
String endIp = null;
|
||||||
|
if (ips.length > 1) {
|
||||||
|
endIp = ips[1];
|
||||||
|
}
|
||||||
|
IPv6Address start, end;
|
||||||
|
try {
|
||||||
|
start = IPv6Address.fromString(startIp);
|
||||||
|
end = IPv6Address.fromString(endIp);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
long startLow = start.getLowBits(), endLow = end.getLowBits();
|
||||||
|
if (startLow > endLow) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return endLow - startLow + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,18 @@ public class NetUtilsTest extends TestCase {
|
||||||
assertFalse(NetUtils.isValidS2SVpnPolicy(";modp1536"));
|
assertFalse(NetUtils.isValidS2SVpnPolicy(";modp1536"));
|
||||||
assertFalse(NetUtils.isValidS2SVpnPolicy(",aes;modp1536,,,"));
|
assertFalse(NetUtils.isValidS2SVpnPolicy(",aes;modp1536,,,"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIpv6() {
|
||||||
|
assertTrue(NetUtils.isValidIPv6("fc00::1"));
|
||||||
|
assertFalse(NetUtils.isValidIPv6(""));
|
||||||
|
assertFalse(NetUtils.isValidIPv6(null));
|
||||||
|
assertFalse(NetUtils.isValidIPv6("1234:5678::1/64"));
|
||||||
|
assertTrue(NetUtils.isValidIp6Cidr("1234:5678::1/64"));
|
||||||
|
assertFalse(NetUtils.isValidIp6Cidr("1234:5678::1"));
|
||||||
|
assertEquals(NetUtils.getIp6CidrSize("1234:5678::1/32"), 32);
|
||||||
|
assertEquals(NetUtils.getIp6CidrSize("1234:5678::1"), 0);
|
||||||
|
assertEquals(NetUtils.countIp6InRange("1234:5678::1-1234:5678::2"), 2);
|
||||||
|
assertEquals(NetUtils.countIp6InRange("1234:5678::2-1234:5678::0"), 0);
|
||||||
|
assertEquals(NetUtils.getIp6FromRange("1234:5678::1-1234:5678::1"), "1234:5678::1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue