Skip to content

Commit 9f29b39

Browse files
committed
allow users to add description to private gateway and static routes
1 parent ee39104 commit 9f29b39

File tree

15 files changed

+85
-19
lines changed

15 files changed

+85
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ IpAddress associateIPToNetwork(long ipId, long networkId) throws InsufficientAdd
215215
* @throws ConcurrentOperationException
216216
* @throws ResourceAllocationException
217217
*/
218-
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String broadcastUri, String startIp, String endIP, String gateway,
219-
String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck, Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException,
218+
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String broadcastUri, String startIp, String endIP, String gateway, String netmask, String description,
219+
long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck, Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException,
220220
InsufficientCapacityException;
221221

222222
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class StaticRouteProfile implements StaticRoute {
2929
String vlanTag;
3030
String gateway;
3131
String netmask;
32+
String description;
3233
String ipAddress;
3334

3435
public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) {
@@ -43,6 +44,7 @@ public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) {
4344
vlanTag = gateway.getBroadcastUri();
4445
this.gateway = gateway.getGateway();
4546
netmask = gateway.getNetmask();
47+
description = gateway.getDescription();
4648
ipAddress = gateway.getIp4Address();
4749
}
4850

@@ -102,6 +104,10 @@ public String getNetmask() {
102104
return netmask;
103105
}
104106

107+
public String getDescription() {
108+
return description;
109+
}
110+
105111
@Override
106112
public Class<?> getEntityType() {
107113
return StaticRoute.class;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd implements UserC
6161
@Parameter(name = ApiConstants.GATEWAY, type = CommandType.STRING, required = true, description = "the gateway of the Private gateway")
6262
private String gateway;
6363

64+
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, required = false, description = "the description of the Private Gateway")
65+
private String description;
66+
6467
@Parameter(name = ApiConstants.NETMASK, type = CommandType.STRING, required = true, description = "the netmask of the Private gateway")
6568
private String netmask;
6669

@@ -102,6 +105,10 @@ public String getGateway() {
102105
return gateway;
103106
}
104107

108+
public String getDescription() {
109+
return description;
110+
}
111+
105112
public String getNetmask() {
106113
return netmask;
107114
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm
5858
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "list gateways by state")
5959
private String state;
6060

61+
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the Private Gateway")
62+
private String description;
63+
6164
/////////////////////////////////////////////////////
6265
/////////////////// Accessors ///////////////////////
6366
/////////////////////////////////////////////////////
@@ -82,6 +85,10 @@ public String getState() {
8285
return state;
8386
}
8487

88+
public String getDescription() {
89+
return description;
90+
}
91+
8592
/////////////////////////////////////////////////////
8693
/////////////// API Implementation///////////////////
8794
/////////////////////////////////////////////////////

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public class PrivateGatewayResponse extends BaseResponseWithAssociatedNetwork im
4141
@Param(description = "the private gateway's netmask")
4242
private String netmask;
4343

44+
@SerializedName(ApiConstants.DESCRIPTION)
45+
@Param(description = "the private gateway's description")
46+
private String description;
47+
4448
@SerializedName(ApiConstants.IP_ADDRESS)
4549
@Param(description = "the private gateway's ip address")
4650
private String address;
@@ -122,6 +126,10 @@ public void setNetmask(String netmask) {
122126
this.netmask = netmask;
123127
}
124128

129+
public void setDescription(String description) {
130+
this.description = description;
131+
}
132+
125133
public void setZoneId(String zoneId) {
126134
this.zoneId = zoneId;
127135
}

engine/schema/src/main/java/com/cloud/network/dao/NetworkVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ public class NetworkVO implements Network {
182182
@Column(name = "external_id")
183183
String externalId;
184184

185+
@Column(name = "description")
186+
String description;
187+
185188
@Transient
186189
String routerIp;
187190

@@ -704,6 +707,14 @@ public void setExternalId(String externalId) {
704707
this.externalId = externalId;
705708
}
706709

710+
public String getDescription() {
711+
return description;
712+
}
713+
714+
public void setDescription(String description) {
715+
this.description = description;
716+
}
717+
707718
public String getVlanIdAsUUID() {
708719
return vlanIdAsUUID;
709720
}

engine/schema/src/main/java/com/cloud/network/vpc/VpcGatewayVO.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ protected VpcGatewayVO() {
106106
* @param domainId TODO
107107
* @param account_id
108108
* @param sourceNat
109+
* @param description
109110
*/
110111
public VpcGatewayVO(String ip4Address, Type type, long vpcId, long zoneId, long networkId, String broadcastUri, String gateway, String netmask, long accountId,
111-
long domainId, boolean sourceNat, long networkACLId) {
112+
long domainId, boolean sourceNat, long networkACLId, String description) {
112113
this.ip4Address = ip4Address;
113114
this.type = type;
114115
this.vpcId = vpcId;
@@ -123,7 +124,7 @@ public VpcGatewayVO(String ip4Address, Type type, long vpcId, long zoneId, long
123124
state = State.Creating;
124125
this.sourceNat = sourceNat;
125126
this.networkACLId = networkACLId;
126-
127+
this.description = description;
127128
}
128129

129130
@Override
@@ -229,4 +230,13 @@ public String getName() {
229230
public void setVpcId(Long vpcId) {
230231
this.vpcId = vpcId;
231232
}
233+
234+
@Override
235+
public String getDescription() {
236+
return description;
237+
}
238+
239+
public void setDescription(String description) {
240+
this.description = description;
241+
}
232242
}

engine/schema/src/main/resources/META-INF/db/schema-480to481.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
--;
1919
-- Schema upgrade from 4.8.0 to 4.8.1;
2020
--;
21+
22+
-- Add description
23+
alter table `cloud`.`vpc_gateways` add column `description` varchar(255) default '';
24+
alter table `cloud`.`networks` add column `description` varchar(255) default '';

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,6 +3476,7 @@ public PrivateGatewayResponse createPrivateGatewayResponse(ResponseView view, Pr
34763476
populateDomain(response, result.getDomainId());
34773477
response.setState(result.getState().toString());
34783478
response.setSourceNat(result.getSourceNat());
3479+
response.setDescription(result.getDescription());
34793480

34803481
NetworkACL acl = ApiDBUtils.findByNetworkACLId(result.getNetworkACLId());
34813482
if (acl != null) {

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5600,7 +5600,7 @@ public IpAddress associateIPToNetwork(long ipId, long networkId)
56005600
@Override
56015601
@DB
56025602
public Network createPrivateNetwork(final String networkName, final String displayText, long physicalNetworkId, String broadcastUriString, final String startIp, String endIp, final String gateway,
5603-
String netmask, final long networkOwnerId, final Long vpcId, final Boolean sourceNat, final Long networkOfferingId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId)
5603+
String netmask, final String description, final long networkOwnerId, final Long vpcId, final Boolean sourceNat, final Long networkOfferingId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId)
56045604
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
56055605

56065606
final Account caller = CallContext.current().getCallingAccount();

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,7 @@ public PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) t
22292229
String ipAddress = command.getIpAddress();
22302230
String gateway = command.getGateway();
22312231
String netmask = command.getNetmask();
2232+
String description = command.getDescription();
22322233
long gatewayOwnerId = command.getEntityOwnerId();
22332234
Long networkOfferingId = command.getNetworkOfferingId();
22342235
Boolean isSourceNat = command.getIsSourceNat();
@@ -2239,13 +2240,13 @@ public PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) t
22392240
Long physicalNetworkId = ((CreatePrivateGatewayByAdminCmd)command).getPhysicalNetworkId();
22402241
String broadcastUri = ((CreatePrivateGatewayByAdminCmd)command).getBroadcastUri();
22412242
Boolean bypassVlanOverlapCheck = ((CreatePrivateGatewayByAdminCmd)command).getBypassVlanOverlapCheck();
2242-
return createVpcPrivateGateway(vpcId, physicalNetworkId, broadcastUri, ipAddress, gateway, netmask, gatewayOwnerId, networkOfferingId, isSourceNat, aclId, bypassVlanOverlapCheck, associatedNetworkId);
2243+
return createVpcPrivateGateway(vpcId, physicalNetworkId, broadcastUri, ipAddress, gateway, netmask, description, gatewayOwnerId, networkOfferingId, isSourceNat, aclId, bypassVlanOverlapCheck, associatedNetworkId);
22432244
}
2244-
return createVpcPrivateGateway(vpcId, null, null, ipAddress, gateway, netmask, gatewayOwnerId, networkOfferingId, isSourceNat, aclId, false, associatedNetworkId);
2245+
return createVpcPrivateGateway(vpcId, null, null, ipAddress, gateway, netmask, description, gatewayOwnerId, networkOfferingId, isSourceNat, aclId, false, associatedNetworkId);
22452246
}
22462247

22472248
private PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNetworkId, final String broadcastUri, final String ipAddress, final String gateway,
2248-
final String netmask, final long gatewayOwnerId, final Long networkOfferingIdPassed, final Boolean isSourceNat, final Long aclId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId) throws ResourceAllocationException,
2249+
final String netmask, final String description, final long gatewayOwnerId, final Long networkOfferingIdPassed, final Boolean isSourceNat, final Long aclId, final Boolean bypassVlanOverlapCheck, final Long associatedNetworkId) throws ResourceAllocationException,
22492250
ConcurrentOperationException, InsufficientCapacityException {
22502251

22512252
// Validate parameters
@@ -2286,7 +2287,7 @@ private PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNe
22862287
logger.info("creating new network for vpc " + vpc + " using broadcast uri: " + broadcastUri + " and associated network id: " + associatedNetworkId);
22872288
final String networkName = "vpc-" + vpc.getName() + "-privateNetwork";
22882289
privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkIdFinal, broadcastUri, ipAddress, null, gateway, netmask,
2289-
gatewayOwnerId, vpcId, isSourceNat, networkOfferingId, bypassVlanOverlapCheck, associatedNetworkId);
2290+
description, gatewayOwnerId, vpcId, isSourceNat, networkOfferingId, bypassVlanOverlapCheck, associatedNetworkId);
22902291
} else { // create the nic/ip as createPrivateNetwork
22912292
// doesn''t do that work for us now
22922293
logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri);
@@ -2328,7 +2329,7 @@ private PrivateGateway createVpcPrivateGateway(final long vpcId, Long physicalNe
23282329

23292330
// 2) create gateway entry
23302331
gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(), privateNtwk.getId(), privateNtwk.getBroadcastUri().toString(),
2331-
gateway, netmask, vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId);
2332+
gateway, netmask, vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId, description);
23322333
_vpcGatewayDao.persist(gatewayVO);
23332334

23342335
logger.debug("Created vpc gateway entry " + gatewayVO);

server/src/test/java/com/cloud/network/CreatePrivateNetworkTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,21 @@ public void createInvalidlyHostedPrivateNetwork() {
153153
/* Network nw; */
154154
try {
155155
/* nw = */
156-
networkService.createPrivateNetwork("bla", "fake", 1L, "vlan:1", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, true, 1L, false, null);
156+
networkService.createPrivateNetwork("bla", "fake", 1L, "vlan:1", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", "bla vlan:1", 1L, 1L, true, 1L, false, null);
157157
/* nw = */
158-
networkService.createPrivateNetwork("bla", "fake", 1L, "lswitch:3", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1L, 1L, false, 1L, false, null);
158+
networkService.createPrivateNetwork("bla", "fake", 1L, "lswitch:3", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", "bla lswitch:3", 1L, 1L, false, 1L, false, null);
159159
boolean invalid = false;
160160
boolean unsupported = false;
161161
try {
162162
/* nw = */
163-
networkService.createPrivateNetwork("bla", "fake", 1, "bla:2", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, true, 1L, false, null);
163+
networkService.createPrivateNetwork("bla", "fake", 1, "bla:2", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", "bla bla:2", 1, 1L, true, 1L, false, null);
164164
} catch (CloudRuntimeException e) {
165165
Assert.assertEquals("unexpected parameter exception", "string 'bla:2' has an unknown BroadcastDomainType.", e.getMessage());
166166
invalid = true;
167167
}
168168
try {
169169
/* nw = */
170-
networkService.createPrivateNetwork("bla", "fake", 1, "mido://4", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", 1, 1L, false, 1L, false, null);
170+
networkService.createPrivateNetwork("bla", "fake", 1, "mido://4", "10.1.1.2", null, "10.1.1.1", "255.255.255.0", "bla mido://4", 1, 1L, false, 1L, false, null);
171171
} catch (InvalidParameterValueException e) {
172172
Assert.assertEquals("unexpected parameter exception", "unsupported type of broadcastUri specified: mido://4", e.getMessage());
173173
unsupported = true;

server/src/test/java/com/cloud/vpc/MockNetworkManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ public IpAddress associateIPToNetwork(long ipId, long networkId) throws Insuffic
541541
* @see com.cloud.network.NetworkService#createPrivateNetwork(java.lang.String, java.lang.String, long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, long, java.lang.Long)
542542
*/
543543
@Override
544-
public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan, String startIp, String endIP, String gateway,
545-
String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck, Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException,
544+
public Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan, String startIp, String endIP, String gateway, String netmask, String description,
545+
long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck, Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException,
546546
InsufficientCapacityException {
547547
// TODO Auto-generated method stub
548548
return null;

ui/src/config/section/network.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ export default {
861861
icon: 'gateway-outlined',
862862
hidden: true,
863863
permission: ['listPrivateGateways'],
864-
columns: ['ipaddress', 'state', 'gateway', 'netmask', 'account', 'domain'],
865-
details: ['ipaddress', 'gateway', 'netmask', 'vlan', 'sourcenatsupported', 'aclname', 'account', 'domain', 'zone', 'associatednetwork', 'associatednetworkid'],
864+
columns: ['ipaddress', 'state', 'gateway', 'netmask', 'description', 'account', 'domain'],
865+
details: ['ipaddress', 'gateway', 'netmask', 'description', 'vlan', 'sourcenatsupported', 'aclname', 'account', 'domain', 'zone', 'associatednetwork', 'associatednetworkid'],
866866
tabs: [{
867867
name: 'details',
868868
component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue')))
@@ -879,7 +879,7 @@ export default {
879879
docHelp: 'adminguide/networking_and_traffic.html#adding-a-private-gateway-to-a-vpc',
880880
listView: true,
881881
args: (record, store) => {
882-
var fields = ['vpcid', 'physicalnetworkid', 'vlan', 'ipaddress', 'gateway', 'netmask', 'sourcenatsupported', 'aclid']
882+
var fields = ['vpcid', 'physicalnetworkid', 'vlan', 'ipaddress', 'gateway', 'netmask', 'description', 'sourcenatsupported', 'aclid']
883883
if (store.apis.createPrivateGateway.params.filter(x => x.name === 'bypassvlanoverlapcheck').length > 0) {
884884
fields.push('bypassvlanoverlapcheck')
885885
}

ui/src/views/network/VpcTab.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@
218218
v-model:value="form.gateway"
219219
></a-input>
220220
</a-form-item>
221+
<a-form-item :label="$t('label.description')" ref="description" name="description">
222+
<a-input
223+
:placeholder="placeholders.description"
224+
v-model:value="form.description"
225+
></a-input>
226+
</a-form-item>
221227
<a-form-item :label="$t('label.netmask')" ref="netmask" name="netmask">
222228
<a-input
223229
:placeholder="placeholders.netmask"
@@ -456,6 +462,10 @@ export default {
456462
title: this.$t('label.netmask'),
457463
dataIndex: 'netmask'
458464
},
465+
{
466+
title: this.$t('label.description'),
467+
dataIndex: 'description'
468+
},
459469
{
460470
title: this.$t('label.vlan'),
461471
dataIndex: 'vlan'
@@ -743,6 +753,7 @@ export default {
743753
ipaddress: data.ipaddress,
744754
gateway: data.gateway,
745755
netmask: data.netmask,
756+
description: data.description,
746757
aclid: data.acl
747758
}
748759
if (data.bypassvlanoverlapcheck) {

0 commit comments

Comments
 (0)