Skip to content

Commit bd4bc02

Browse files
author
Sheng Yang
committed
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.
1 parent a2b2d45 commit bd4bc02

44 files changed

Lines changed: 1231 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/com/cloud/agent/api/routing/DhcpEntryCommand.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public class DhcpEntryCommand extends NetworkElementCommand {
2828
String defaultRouter;
2929
String staticRoutes;
3030
String defaultDns;
31-
31+
String vmIp6Address;
32+
String ip6Gateway;
33+
String duid;
3234

3335
protected DhcpEntryCommand() {
3436

@@ -39,14 +41,15 @@ public boolean executeInSequence() {
3941
return true;
4042
}
4143

42-
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName) {
44+
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address) {
4345
this.vmMac = vmMac;
4446
this.vmIpAddress = vmIpAddress;
4547
this.vmName = vmName;
48+
this.vmIp6Address = vmIp6Address;
4649
}
4750

48-
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String dns, String gateway) {
49-
this(vmMac, vmIpAddress, vmName);
51+
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address, String dns, String gateway, String ip6Gateway) {
52+
this(vmMac, vmIpAddress, vmName, vmIp6Address);
5053
this.dns = dns;
5154
this.gateway = gateway;
5255
}
@@ -102,4 +105,28 @@ public String getDefaultDns() {
102105
public void setDefaultDns(String defaultDns) {
103106
this.defaultDns = defaultDns;
104107
}
108+
109+
public String getIp6Gateway() {
110+
return ip6Gateway;
111+
}
112+
113+
public void setIp6Gateway(String ip6Gateway) {
114+
this.ip6Gateway = ip6Gateway;
115+
}
116+
117+
public String getDuid() {
118+
return duid;
119+
}
120+
121+
public void setDuid(String duid) {
122+
this.duid = duid;
123+
}
124+
125+
public String getVmIp6Address() {
126+
return vmIp6Address;
127+
}
128+
129+
public void setVmIp6Address(String ip6Address) {
130+
this.vmIp6Address = ip6Address;
131+
}
105132
}

api/src/com/cloud/dc/Vlan.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public enum VlanType {
4444

4545
public Long getPhysicalNetworkId();
4646

47+
public String getIp6Gateway();
48+
49+
public String getIp6Cidr();
50+
51+
public String getIp6Range();
4752
}

api/src/com/cloud/network/Network.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ private State(String description) {
264264
String getGateway();
265265

266266
String getCidr();
267-
267+
268+
String getIp6Gateway();
269+
270+
String getIp6Cidr();
271+
268272
long getDataCenterId();
269273

270274
long getNetworkOfferingId();

api/src/com/cloud/network/NetworkModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,5 @@ Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddres
249249

250250
boolean isNetworkInlineMode(Network network);
251251

252+
Vlan getVlanForNetwork(long networkId);
252253
}

api/src/com/cloud/network/NetworkProfile.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class NetworkProfile implements Network {
3939
private TrafficType trafficType;
4040
private String gateway;
4141
private String cidr;
42+
private String ip6Gateway;
43+
private String ip6Cidr;
4244
private long networkOfferingId;
4345
private long related;
4446
private String displayText;
@@ -64,6 +66,8 @@ public NetworkProfile(Network network) {
6466
this.trafficType = network.getTrafficType();
6567
this.gateway = network.getGateway();
6668
this.cidr = network.getCidr();
69+
this.ip6Gateway = network.getIp6Gateway();
70+
this.ip6Cidr = network.getIp6Cidr();
6771
this.networkOfferingId = network.getNetworkOfferingId();
6872
this.related = network.getRelated();
6973
this.displayText = network.getDisplayText();
@@ -226,4 +230,14 @@ public Long getVpcId() {
226230
return vpcId;
227231
}
228232

233+
@Override
234+
public String getIp6Gateway() {
235+
return ip6Gateway;
236+
}
237+
238+
@Override
239+
public String getIp6Cidr() {
240+
return ip6Cidr;
241+
}
242+
229243
}

api/src/com/cloud/vm/Nic.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,10 @@ public enum ReservationStrategy {
144144
VirtualMachine.Type getVmType();
145145

146146
AddressFormat getAddressFormat();
147+
148+
String getIp6Gateway();
149+
150+
String getIp6Cidr();
151+
152+
String getIp6Address();
147153
}

api/src/com/cloud/vm/NicProfile.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class NicProfile implements InternalIdentity {
3737
TrafficType trafficType;
3838
String ip4Address;
3939
String ip6Address;
40+
String ip6Gateway;
41+
String ip6Cidr;
4042
String macAddress;
4143
URI isolationUri;
4244
String netmask;
@@ -50,7 +52,8 @@ public class NicProfile implements InternalIdentity {
5052
Integer networkRate;
5153
boolean isSecurityGroupEnabled;
5254
String name;
53-
String requestedIp;
55+
String requestedIpv4;
56+
String requestedIpv6;
5457

5558
public String getDns1() {
5659
return dns1;
@@ -218,7 +221,7 @@ public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri,
218221
this.trafficType = network.getTrafficType();
219222
this.ip4Address = nic.getIp4Address();
220223
this.format = nic.getAddressFormat();
221-
this.ip6Address = null;
224+
this.ip6Address = nic.getIp6Address();
222225
this.macAddress = nic.getMacAddress();
223226
this.reservationId = nic.getReservationId();
224227
this.strategy = nic.getReservationStrategy();
@@ -230,6 +233,8 @@ public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri,
230233
this.isSecurityGroupEnabled = isSecurityGroupEnabled;
231234
this.vmId = nic.getInstanceId();
232235
this.name = name;
236+
this.ip6Cidr = nic.getIp6Cidr();
237+
this.ip6Gateway = nic.getIp6Gateway();
233238

234239
if (networkRate != null) {
235240
this.networkRate = networkRate;
@@ -245,8 +250,9 @@ public NicProfile(ReservationStrategy strategy, String ip4Address, String macAdd
245250
this.strategy = strategy;
246251
}
247252

248-
public NicProfile(String requestedIp) {
249-
this.requestedIp = requestedIp;
253+
public NicProfile(String requestedIpv4, String requestedIpv6) {
254+
this.requestedIpv4 = requestedIpv4;
255+
this.requestedIpv6 = requestedIpv6;
250256
}
251257

252258
public NicProfile() {
@@ -272,8 +278,8 @@ public void setSecurityGroupEnabled(boolean enabled) {
272278
this.isSecurityGroupEnabled = enabled;
273279
}
274280

275-
public String getRequestedIp() {
276-
return requestedIp;
281+
public String getRequestedIpv4() {
282+
return requestedIpv4;
277283
}
278284

279285
public void deallocate() {
@@ -301,4 +307,28 @@ public String toString() {
301307
append(reservationId).append("-").append(ip4Address).append("-").append(broadcastUri).toString();
302308
}
303309

310+
public String getIp6Gateway() {
311+
return ip6Gateway;
312+
}
313+
314+
public void setIp6Gateway(String ip6Gateway) {
315+
this.ip6Gateway = ip6Gateway;
316+
}
317+
318+
public String getIp6Cidr() {
319+
return ip6Cidr;
320+
}
321+
322+
public void setIp6Cidr(String ip6Cidr) {
323+
this.ip6Cidr = ip6Cidr;
324+
}
325+
326+
public String getRequestedIpv6() {
327+
return requestedIpv6;
328+
}
329+
330+
public void setRequestedIpv6(String requestedIpv6) {
331+
this.requestedIpv6 = requestedIpv6;
332+
}
333+
304334
}

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class ApiConstants {
3838
public static final String DOMAIN_SUFFIX = "domainsuffix";
3939
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
4040
public static final String CIDR = "cidr";
41+
public static final String IP6CIDR = "ip6cidr";
4142
public static final String CIDR_LIST = "cidrlist";
4243
public static final String CLEANUP = "cleanup";
4344
public static final String CLUSTER_ID = "clusterid";
@@ -64,6 +65,7 @@ public class ApiConstants {
6465
public static final String EMAIL = "email";
6566
public static final String END_DATE = "enddate";
6667
public static final String END_IP = "endip";
68+
public static final String END_IPV6 = "endipv6";
6769
public static final String END_PORT = "endport";
6870
public static final String ENTRY_TIME = "entrytime";
6971
public static final String FETCH_LATEST = "fetchlatest";
@@ -73,6 +75,7 @@ public class ApiConstants {
7375
public static final String FORMAT = "format";
7476
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
7577
public static final String GATEWAY = "gateway";
78+
public static final String IP6GATEWAY = "ip6gateway";
7679
public static final String GROUP = "group";
7780
public static final String GROUP_ID = "groupid";
7881
public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
@@ -181,6 +184,7 @@ public class ApiConstants {
181184
public static final String SOURCE_ZONE_ID = "sourcezoneid";
182185
public static final String START_DATE = "startdate";
183186
public static final String START_IP = "startip";
187+
public static final String START_IPV6 = "startipv6";
184188
public static final String START_PORT = "startport";
185189
public static final String STATE = "state";
186190
public static final String STATUS = "status";
@@ -427,6 +431,7 @@ public class ApiConstants {
427431
public static final String CONDITION_IDS = "conditionids";
428432
public static final String COUNTERPARAM_LIST = "counterparam";
429433
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
434+
public static final String DUAL_STACK = "dualstack";
430435

431436
public enum HostDetails {
432437
all, capacity, events, stats, min;

api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,22 @@ public class CreateNetworkCmd extends BaseCmd {
113113
description="the VPC network belongs to")
114114
private Long vpcId;
115115

116+
@Parameter(name=ApiConstants.START_IPV6, type=CommandType.STRING, description="the beginning IPv6 address in the IPv6 network range")
117+
private String startIpv6;
116118

119+
@Parameter(name=ApiConstants.END_IPV6, type=CommandType.STRING, description="the ending IPv6 address in the IPv6 network range")
120+
private String endIpv6;
121+
122+
@Parameter(name=ApiConstants.IP6GATEWAY, type=CommandType.STRING, description="the gateway of the IPv6 network. Required " +
123+
"for Shared networks and Isolated networks when it belongs to VPC")
124+
private String ip6Gateway;
125+
126+
@Parameter(name=ApiConstants.IP6CIDR, type=CommandType.STRING, description="the CIDR of IPv6 network, must be at least /64")
127+
private String ip6Cidr;
128+
129+
@Parameter(name=ApiConstants.DUAL_STACK, type=CommandType.BOOLEAN, description="The network is dual-stack(IPv6 and IPv4) or not")
130+
private Boolean dualStack;
131+
117132
/////////////////////////////////////////////////////
118133
/////////////////// Accessors ///////////////////////
119134
/////////////////////////////////////////////////////
@@ -207,7 +222,50 @@ public Long getPhysicalNetworkId() {
207222
}
208223
}
209224

210-
/////////////////////////////////////////////////////
225+
public String getStartIpv6() {
226+
return startIpv6;
227+
}
228+
229+
public void setStartIpv6(String startIpv6) {
230+
this.startIpv6 = startIpv6;
231+
}
232+
233+
public String getEndIpv6() {
234+
return endIpv6;
235+
}
236+
237+
public void setEndIpv6(String endIpv6) {
238+
this.endIpv6 = endIpv6;
239+
}
240+
241+
public String getIp6Gateway() {
242+
return ip6Gateway;
243+
}
244+
245+
public void setIp6Gateway(String ip6Gateway) {
246+
this.ip6Gateway = ip6Gateway;
247+
}
248+
249+
public String getIp6Cidr() {
250+
return ip6Cidr;
251+
}
252+
253+
public void setIp6Cidr(String ip6Cidr) {
254+
this.ip6Cidr = ip6Cidr;
255+
}
256+
257+
public Boolean isDualStack() {
258+
if (dualStack == null) {
259+
return false;
260+
}
261+
return dualStack;
262+
}
263+
264+
public void setDualStack(Boolean dualStack) {
265+
this.dualStack = dualStack;
266+
}
267+
268+
/////////////////////////////////////////////////////
211269
/////////////// API Implementation///////////////////
212270
/////////////////////////////////////////////////////
213271
@Override

client/tomcatconf/components.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ under the License.
271271
<dao name="Site2SiteCustomerGatewayDao" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" singleton="false"/>
272272
<dao name="Site2SiteVpnGatewayDao" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" singleton="false"/>
273273
<dao name="Site2SiteVpnConnectionDao" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" singleton="false"/>
274+
<dao name="PublicIpv6AddressDao" class="com.cloud.network.dao.PublicIpv6AddressDaoImpl" singleton="false"/>
274275
</configuration-server>
275276

276277
<awsapi-ec2server class="com.cloud.bridge.service.EC2MainServlet">

0 commit comments

Comments
 (0)