Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/network/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Network createPrivateNetwork(String networkName, String displayText, long physic
/**
* Requests an IP address for the guest NIC
*/
NicSecondaryIp allocateSecondaryGuestIP(long nicId, IpAddresses requestedIpPair) throws InsufficientAddressCapacityException;
NicSecondaryIp allocateSecondaryGuestIP(long nicId, IpAddresses requestedIpPair, String description) throws InsufficientAddressCapacityException;

boolean releaseSecondaryIpFromNic(long ipAddressId);

Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/vm/NicSecondaryIp.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface NicSecondaryIp extends ControlledEntity, Identity, InternalIden

String getIp6Address();

String getDescription();

long getNetworkId();

long getVmId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class AddIpToVmNicCmd extends BaseAsyncCreateCmd {
@Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, required = false, description = "Secondary IP Address")
private String ipAddr;

@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, required = false, description = "Description")
private String description;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -160,7 +163,7 @@ public void create() throws ResourceAllocationException {
}

try {
result = _networkService.allocateSecondaryGuestIP(getNicId(), requestedIpPair);
result = _networkService.allocateSecondaryGuestIP(getNicId(), requestedIpPair, description);
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class NicSecondaryIpResponse extends BaseResponse {
@Param(description = "The ID of the Instance")
private String vmId;

@SerializedName(ApiConstants.DESCRIPTION)
@Param(description = "description")
private String description;

@Override
public String getObjectId() {
return this.getId();
Expand Down Expand Up @@ -98,6 +102,14 @@ public void setId(String id) {
this.id = id;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public List<NicSecondaryIpResponse> getSecondaryIpsList() {
return secondaryIpsList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testCreateSuccess() throws ResourceAllocationException, ResourceUnav
NicSecondaryIp secIp = Mockito.mock(NicSecondaryIp.class);

Mockito.when(
networkService.allocateSecondaryGuestIP(ArgumentMatchers.anyLong(), ArgumentMatchers.any()))
networkService.allocateSecondaryGuestIP(ArgumentMatchers.anyLong(), ArgumentMatchers.any(), ArgumentMatchers.anyString()))
.thenReturn(secIp);

ipTonicCmd._networkService = networkService;
Expand All @@ -79,7 +79,7 @@ public void testCreateFailure() throws ResourceAllocationException, ResourceUnav
AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);

Mockito.when(
networkService.allocateSecondaryGuestIP(ArgumentMatchers.anyLong(), ArgumentMatchers.any()))
networkService.allocateSecondaryGuestIP(ArgumentMatchers.anyLong(), ArgumentMatchers.any(), ArgumentMatchers.anyString()))
.thenReturn(null);

ipTonicCmd._networkService = networkService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ public NicSecondaryIpVO(long nicId, String ipaddr, long vmId, long accountId, lo
this.networkId = networkId;
}

public NicSecondaryIpVO(long nicId, String ip4Address, String ip6Address, long vmId, long accountId, long domainId, long networkId) {
public NicSecondaryIpVO(long nicId, String ip4Address, String ip6Address, long vmId, long accountId, long domainId, long networkId, String description) {
this.nicId = nicId;
this.vmId = vmId;
this.ip4Address = ip4Address;
this.ip6Address = ip6Address;
this.accountId = accountId;
this.domainId = domainId;
this.networkId = networkId;
this.description = description;
}

protected NicSecondaryIpVO() {
Expand Down Expand Up @@ -88,6 +89,18 @@ protected NicSecondaryIpVO() {
@Column(name = "vmId")
long vmId;

@Column(name = "description")
String description;

@Override
public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

@Override
public String toString() {
return String.format("NicSecondaryIp %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ CALL `cloud`.`IDEMPOTENT_UPDATE_API_PERMISSION`('Resource Admin', 'deleteUserKey

-- Add conserve mode for VPC offerings
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vpc_offerings','conserve_mode', 'tinyint(1) unsigned NULL DEFAULT 0 COMMENT ''True if the VPC offering is IP conserve mode enabled, allowing public IP services to be used across multiple VPC tiers'' ');

-- Add description for secondary IP addresses
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.nic_secondary_ips','description', 'varchar(2048) DEFAULT NULL');
2 changes: 2 additions & 0 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4729,6 +4729,7 @@ public NicSecondaryIpResponse createSecondaryIPToNicResponse(NicSecondaryIp resu
setResponseIpAddress(result, response);
response.setNicId(nic.getUuid());
response.setNwId(network.getUuid());
response.setDescription(result.getDescription());
response.setObjectName("nicsecondaryip");
return response;
}
Expand Down Expand Up @@ -4815,6 +4816,7 @@ public NicResponse createNicResponse(Nic result) {
for (NicSecondaryIpVO ip : secondaryIps) {
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
ipRes.setId(ip.getUuid());
ipRes.setDescription(ip.getDescription());
setResponseIpAddress(ip, ipRes);
ipList.add(ipRes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
for (NicSecondaryIpVO ip : secondaryIps) {
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
ipRes.setId(ip.getUuid());
ipRes.setDescription(ip.getDescription());
ApiResponseHelper.setResponseIpAddress(ip, ipRes);
ipList.add(ipRes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public boolean configureNicSecondaryIp(NicSecondaryIp secIp, boolean isZoneSgEna
*/
@Override
@ActionEvent(eventType = EventTypes.EVENT_NIC_SECONDARY_IP_ASSIGN, eventDescription = "Assigning secondary IP to NIC", create = true)
public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses requestedIpPair) throws InsufficientAddressCapacityException {
public NicSecondaryIp allocateSecondaryGuestIP(final long nicId, IpAddresses requestedIpPair, String description) throws InsufficientAddressCapacityException {

Account caller = CallContext.current().getCallingAccount();
String ipv4Address = requestedIpPair.getIp4Address();
Expand Down Expand Up @@ -985,7 +985,7 @@ public Long doInTransaction(TransactionStatus status) {

logger.debug("Setting nic_secondary_ip table ...");
Long vmId = nicVO.getInstanceId();
NicSecondaryIpVO secondaryIpVO = new NicSecondaryIpVO(nicId, ip4AddrFinal, ip6AddrFinal, vmId, ipOwner.getId(), ipOwner.getDomainId(), networkId);
NicSecondaryIpVO secondaryIpVO = new NicSecondaryIpVO(nicId, ip4AddrFinal, ip6AddrFinal, vmId, ipOwner.getId(), ipOwner.getDomainId(), networkId, description);
_nicSecondaryIpDao.persist(secondaryIpVO);
return secondaryIpVO.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean is
boolean isOneToOneNat = ipAddress.isOneToOneNat();
Long associatedWithVmId = ipAddress.getAssociatedWithVmId();
Nic guestNic;
NicSecondaryIpVO nicSecIp = null;
wNicSecondaryIpVO nicSecIp = null;
String dstIp = null;
Network network = _networkModel.getNetwork(networkId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ public boolean isSecondaryIpSetForNic(long nicId) {
}

@Override
public NicSecondaryIp allocateSecondaryGuestIP(long nicId, IpAddresses requestedIpPair) {
public NicSecondaryIp allocateSecondaryGuestIP(long nicId, IpAddresses requestedIpPair, String description) {
// TODO Auto-generated method stub
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@
"label.new.password": "New password",
"label.new.project": "New Project",
"label.new.secondaryip.description": "Enter new secondary IP address",
"label.new.secondaryip.description.description": "Enter a new description for the secondary IP address",
"label.new.tag": "New tag",
"label.new.vm": "New Instance",
"label.new.version.available": "New version available",
Expand Down Expand Up @@ -2242,6 +2243,7 @@
"label.secondary.storage": "Secondary Storage",
"label.secondary.storage.vm": "Secondary Storage VM",
"label.secondaryips": "Secondary IPs",
"label.secondaryip.description": "Description:",
"label.secondarystoragelimit": "Secondary Storage limits (GiB)",
"label.secretkey": "Secret key",
"label.secured": "Secured",
Expand Down
2 changes: 2 additions & 0 deletions ui/public/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@
"label.new.password": "Nova senha",
"label.new.project": "Novo projeto",
"label.new.secondaryip.description": "Insira um novo endere\u00e7o IP secund\u00e1rio",
"label.new.secondaryip.description.description": "Insira uma nova descri\u00e7\u00e3o ao endere\u00e7o IP secund\u00e1rio",
"label.new.tag": "Nova etiqueta",
"label.new.vm": "Nova VM",
"label.newdiskoffering": "Nova oferta",
Expand Down Expand Up @@ -1450,6 +1451,7 @@
"label.secondary.storage": "Armazenamento secund\u00e1rio",
"label.secondary.storage.vm": "VM de armazenamento secund\u00e1rio",
"label.secondaryips": "IPs secund\u00e1rios",
"label.secondaryip.description": "Descri\u00e7\u00e3o:",
"label.secondarystoragelimit": "Limites do armazenamento secund\u00e1rio (GiB)",
"label.secretkey": "Chave secreta",
"label.secured": "Protegido",
Expand Down
9 changes: 9 additions & 0 deletions ui/src/views/network/NicsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@
:placeholder="$t('label.new.secondaryip.description')"
v-model:value="newSecondaryIp"
v-focus="editNicResource.type!=='Shared'"></a-input>
<p class="modal-form__label">{{ $t('label.secondaryip.description') }}</p>
<a-input
:placeholder="$t('label.new.secondaryip.description.description')"
v-model:value="newSecondaryIpDescription"
v-focus="editNicResource.type!=='Shared'"></a-input>
</div>

<div style="margin-top: 10px; display: flex; justify-content:flex-end;">
Expand Down Expand Up @@ -292,6 +297,7 @@ export default {
secondaryIPs: [],
selectedNicId: '',
newSecondaryIp: '',
newSecondaryIpDescription: '',
editNicResource: {},
listIps: {
loading: false,
Expand Down Expand Up @@ -366,6 +372,7 @@ export default {
this.addNetworkData.makedefault = false
this.editIpAddressValue = ''
this.newSecondaryIp = ''
this.newSecondaryIpDescription = ''
},
onChangeIPAddress (record) {
this.editNicResource = record.nic
Expand Down Expand Up @@ -549,6 +556,7 @@ export default {
if (this.newSecondaryIp) {
params.ipaddress = this.newSecondaryIp
}
params.description = this.newSecondaryIpDescription

postAPI('addIpToNic', params).then(response => {
this.$pollJob({
Expand Down Expand Up @@ -576,6 +584,7 @@ export default {
this.loadingNic = false
}).finally(() => {
this.newSecondaryIp = null
this.newSecondaryIpDescription = null
this.fetchPublicIps(this.editNetworkId)
})
},
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/network/NicsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{ record.traffictype }}
</a-descriptions-item>
<a-descriptions-item :label="$t('label.secondaryips')" v-if="record.secondaryip && record.secondaryip.length > 0 && record.type !== 'L2'">
{{ record.secondaryip.map(x => x.ipaddress).join(', ') }}
{{ record.secondaryip.map(x => x.ipaddress + ': ' + x.description ).join(', ') }}
</a-descriptions-item>
<a-descriptions-item :label="$t('label.ip6address')" v-if="record.ip6address">
{{ record.ip6address }}
Expand Down
Loading