Skip to content

Commit 0cd6426

Browse files
Add property to change the public NIC's MAC Address of VPCs and Isolated Networks VRs
1 parent 11538df commit 0cd6426

File tree

35 files changed

+690
-97
lines changed

35 files changed

+690
-97
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,6 @@ public void setIp6Address(String ip6Address) {
510510
Integer getPrivateMtu();
511511

512512
Integer getNetworkCidrSize();
513+
514+
boolean getKeepMacAddressOnPublicNic();
513515
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ public Integer getNetworkCidrSize() {
385385
return networkCidrSize;
386386
}
387387

388+
@Override
389+
public boolean getKeepMacAddressOnPublicNic() {
390+
return true;
391+
}
392+
388393
@Override
389394
public String toString() {
390395
return String.format("NetworkProfile %s",

api/src/main/java/com/cloud/network/vpc/Vpc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,6 @@ public enum State {
107107
String getIp6Dns2();
108108

109109
boolean useRouterIpAsResolver();
110+
111+
boolean getKeepMacAddressOnPublicNic();
110112
}

api/src/main/java/com/cloud/network/vpc/VpcService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public interface VpcService {
5858
*/
5959
Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
6060
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu, Integer cidrSize,
61-
Long asNumber, List<Long> bgpPeerIds, Boolean useVrIpResolver) throws ResourceAllocationException;
61+
Long asNumber, List<Long> bgpPeerIds, Boolean useVrIpResolver, boolean keepMacAddressOnPublicNic) throws ResourceAllocationException;
6262

6363
/**
6464
* Persists VPC record in the database
@@ -104,7 +104,7 @@ Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, Strin
104104
* @throws ResourceUnavailableException if during restart some resources may not be available
105105
* @throws InsufficientCapacityException if for instance no address space, compute or storage is sufficiently available
106106
*/
107-
Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu, String sourceNatIp) throws ResourceUnavailableException, InsufficientCapacityException;
107+
Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu, String sourceNatIp, Boolean keepMacAddressOnPublicNic) throws ResourceUnavailableException, InsufficientCapacityException;
108108

109109
/**
110110
* Lists VPC(s) based on the parameters passed to the API call

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,13 @@ public class ApiConstants {
13481348
public static final String OBJECT_STORAGE_LIMIT = "objectstoragelimit";
13491349
public static final String OBJECT_STORAGE_TOTAL = "objectstoragetotal";
13501350

1351+
public static final String KEEP_MAC_ADDRESS_ON_PUBLIC_NIC = "keepmacaddressonpublicnic";
1352+
1353+
public static final String PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC =
1354+
"Indicates whether to use the same MAC address for the public NIC of VRs on the same network. If \"true\", when creating redundant routers or recreating" +
1355+
" a VR, CloudStack will use the same MAC address for the public NIC of all VRs. Otherwise, if \"false\", new public NICs will always have " +
1356+
" a new MAC address.";
1357+
13511358
public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
13521359
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
13531360
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd {
199199
@Parameter(name=ApiConstants.AS_NUMBER, type=CommandType.LONG, since = "4.20.0", description="the AS Number of the network")
200200
private Long asNumber;
201201

202+
@Parameter(name = ApiConstants.KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
203+
description = ApiConstants.PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
204+
type = CommandType.BOOLEAN, since = "4.23.0", authorized = {RoleType.Admin})
205+
private Boolean keepMacAddressOnPublicNic;
206+
202207
/////////////////////////////////////////////////////
203208
/////////////////// Accessors ///////////////////////
204209
/////////////////////////////////////////////////////
@@ -286,6 +291,10 @@ public String getSourceNatIP() {
286291
return sourceNatIP;
287292
}
288293

294+
public Boolean getKeepMacAddressOnPublicNic() {
295+
return keepMacAddressOnPublicNic;
296+
}
297+
289298
@Override
290299
public boolean isDisplay() {
291300
if(displayNetwork == null)

api/src/main/java/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd implements UserCmd {
105105
@Parameter(name = ApiConstants.SOURCE_NAT_IP, type = CommandType.STRING, description = "IPV4 address to be assigned to the public interface of the network router. This address must already be acquired for this network", since = "4.19")
106106
private String sourceNatIP;
107107

108+
@Parameter(name = ApiConstants.KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
109+
description = ApiConstants.PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
110+
type = CommandType.BOOLEAN, since = "4.23.0", authorized = {RoleType.Admin})
111+
private Boolean keepMacAddressOnPublicNic;
112+
108113
/////////////////////////////////////////////////////
109114
/////////////////// Accessors ///////////////////////
110115
/////////////////////////////////////////////////////
@@ -186,6 +191,10 @@ public String getSourceNatIP() {
186191
return sourceNatIP;
187192
}
188193

194+
public Boolean getKeepMacAddressOnPublicNic() {
195+
return keepMacAddressOnPublicNic;
196+
}
197+
189198
/////////////////////////////////////////////////////
190199
/////////////// API Implementation///////////////////
191200
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
130130
description="(optional) for NSX based VPCs: when set to true, use the VR IP as nameserver, otherwise use DNS1 and DNS2")
131131
private Boolean useVrIpResolver;
132132

133+
@Parameter(name = ApiConstants.KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
134+
description = ApiConstants.PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
135+
type = CommandType.BOOLEAN, since = "4.23.0", authorized = {RoleType.Admin})
136+
private boolean keepMacAddressOnPublicNic = true;
137+
133138
// ///////////////////////////////////////////////////
134139
// ///////////////// Accessors ///////////////////////
135140
// ///////////////////////////////////////////////////
@@ -214,6 +219,10 @@ public boolean getUseVrIpResolver() {
214219
return BooleanUtils.toBoolean(useVrIpResolver);
215220
}
216221

222+
public boolean getKeepMacAddressOnPublicNic() {
223+
return keepMacAddressOnPublicNic;
224+
}
225+
217226
/////////////////////////////////////////////////////
218227
/////////////// API Implementation///////////////////
219228
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ public class UpdateVPCCmd extends BaseAsyncCustomIdCmd implements UserCmd {
6969
since = "4.19")
7070
private String sourceNatIP;
7171

72+
@Parameter(name = ApiConstants.KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
73+
description = ApiConstants.PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC,
74+
type = CommandType.BOOLEAN, since = "4.23.0", authorized = {RoleType.Admin})
75+
private Boolean keepMacAddressOnPublicNic;
76+
77+
public Boolean getKeepMacAddressOnPublicNic() {
78+
return keepMacAddressOnPublicNic;
79+
}
80+
7281
/////////////////////////////////////////////////////
7382
/////////////////// Accessors ///////////////////////
7483
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/NetworkResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
331331
@Param(description = "The BGP peers for the network", since = "4.20.0")
332332
private Set<BgpPeerResponse> bgpPeers;
333333

334+
@SerializedName(ApiConstants.KEEP_MAC_ADDRESS_ON_PUBLIC_NIC)
335+
@Param(description = ApiConstants.PARAMETER_DESCRIPTION_KEEP_MAC_ADDRESS_ON_PUBLIC_NIC, since = "4.23.0")
336+
private Boolean keepMacAddressOnPublicNic;
337+
334338
public NetworkResponse() {}
335339

336340
public Boolean getDisplayNetwork() {
@@ -702,4 +706,8 @@ public void setIpv6Dns1(String ipv6Dns1) {
702706
public void setIpv6Dns2(String ipv6Dns2) {
703707
this.ipv6Dns2 = ipv6Dns2;
704708
}
709+
710+
public void setKeepMacAddressOnPublicNic(Boolean keepMacAddressOnPublicNic) {
711+
this.keepMacAddressOnPublicNic = keepMacAddressOnPublicNic;
712+
}
705713
}

0 commit comments

Comments
 (0)