Fix column from op_dc_ip_address_alloc not being referenced correctly by its ORM class (#8812)

* refactored field instanceId to nicId in DataCenterIpAddressVO and AcquirePodIpCmdResponse

* refactored ocurrences of "instanceId" in DataCenterDaoImpl and DataCenterIpAddressDaoImpl
This commit is contained in:
Felipe 2024-08-13 16:26:55 -03:00 committed by GitHub
parent b429e843cd
commit cf1428ddcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 34 deletions

View File

@ -44,7 +44,7 @@ public class AcquirePodIpCmdResponse extends BaseResponse {
@SerializedName(ApiConstants.NIC_ID)
@Param(description = "the ID of the nic")
private Long instanceId;
private Long nicId;
@SerializedName(ApiConstants.HOST_MAC)
@Param(description = "MAC address of the pod the IP")
@ -58,8 +58,8 @@ public class AcquirePodIpCmdResponse extends BaseResponse {
this.ipAddress = ipAddress;
}
public void setInstanceId(Long instanceId) {
this.instanceId = instanceId;
public void setNicId(Long nicId) {
this.nicId = nicId;
}
public void setPodId(long podId) {
@ -82,8 +82,8 @@ public class AcquirePodIpCmdResponse extends BaseResponse {
return id;
}
public Long getInstanceId() {
return instanceId;
public Long getNicId() {
return nicId;
}
public long getPodId() {

View File

@ -55,7 +55,7 @@ public class DataCenterIpAddressVO implements InternalIdentity {
String reservationId;
@Column(name = "nic_id")
private Long instanceId;
private Long nicId;
@Column(name = "mac_address")
long macAddress;
@ -88,12 +88,12 @@ public class DataCenterIpAddressVO implements InternalIdentity {
return id;
}
public Long getInstanceId() {
return instanceId;
public Long getNicId() {
return nicId;
}
public void setInstanceId(Long instanceId) {
this.instanceId = instanceId;
public void setNicId(Long nicId) {
this.nicId = nicId;
}
public long getPodId() {

View File

@ -164,8 +164,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
}
@Override
public void releasePrivateIpAddress(String ipAddress, long dcId, Long instanceId) {
_ipAllocDao.releaseIpAddress(ipAddress, dcId, instanceId);
public void releasePrivateIpAddress(String ipAddress, long dcId, Long nicId) {
_ipAllocDao.releaseIpAddress(ipAddress, dcId, nicId);
}
@Override
@ -179,8 +179,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
}
@Override
public void releaseLinkLocalIpAddress(String ipAddress, long dcId, Long instanceId) {
_linkLocalIpAllocDao.releaseIpAddress(ipAddress, dcId, instanceId);
public void releaseLinkLocalIpAddress(String ipAddress, long dcId, Long nicId) {
_linkLocalIpAllocDao.releaseIpAddress(ipAddress, dcId, nicId);
}
@Override
@ -226,9 +226,9 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
}
@Override
public PrivateAllocationData allocatePrivateIpAddress(long dcId, long podId, long instanceId, String reservationId, boolean forSystemVms) {
_ipAllocDao.releaseIpAddress(instanceId);
DataCenterIpAddressVO vo = _ipAllocDao.takeIpAddress(dcId, podId, instanceId, reservationId, forSystemVms);
public PrivateAllocationData allocatePrivateIpAddress(long dcId, long podId, long nicId, String reservationId, boolean forSystemVms) {
_ipAllocDao.releaseIpAddress(nicId);
DataCenterIpAddressVO vo = _ipAllocDao.takeIpAddress(dcId, podId, nicId, reservationId, forSystemVms);
if (vo == null) {
return null;
}
@ -242,8 +242,8 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
}
@Override
public String allocateLinkLocalIpAddress(long dcId, long podId, long instanceId, String reservationId) {
DataCenterLinkLocalIpAddressVO vo = _linkLocalIpAllocDao.takeIpAddress(dcId, podId, instanceId, reservationId);
public String allocateLinkLocalIpAddress(long dcId, long podId, long nicId, String reservationId) {
DataCenterLinkLocalIpAddressVO vo = _linkLocalIpAllocDao.takeIpAddress(dcId, podId, nicId, reservationId);
if (vo == null) {
return null;
}

View File

@ -51,7 +51,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
@Override
@DB
public DataCenterIpAddressVO takeIpAddress(long dcId, long podId, long instanceId, String reservationId, boolean forSystemVms) {
public DataCenterIpAddressVO takeIpAddress(long dcId, long podId, long nicId, String reservationId, boolean forSystemVms) {
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("pod", podId);
sc.setParameters("taken", (Date)null);
@ -71,7 +71,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
return null;
}
vo.setTakenAt(new Date());
vo.setInstanceId(instanceId);
vo.setNicId(nicId);
vo.setReservationId(reservationId);
update(vo.getId(), vo);
txn.commit();
@ -166,19 +166,19 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
}
@Override
public void releaseIpAddress(String ipAddress, long dcId, Long instanceId) {
public void releaseIpAddress(String ipAddress, long dcId, Long nicId) {
if (logger.isDebugEnabled()) {
logger.debug("Releasing ip address: " + ipAddress + " data center " + dcId);
}
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("ip", ipAddress);
sc.setParameters("dc", dcId);
sc.setParameters("instance", instanceId);
sc.setParameters("nic", nicId);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setNicId(null);
vo.setReservationId(null);
update(vo, sc);
}
@ -186,15 +186,15 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
@Override
public void releaseIpAddress(long nicId, String reservationId) {
if (logger.isDebugEnabled()) {
logger.debug("Releasing ip address for reservationId=" + reservationId + ", instance=" + nicId);
logger.debug("Releasing ip address for reservationId=" + reservationId + ", nic=" + nicId);
}
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("instance", nicId);
sc.setParameters("nic", nicId);
sc.setParameters("reservation", reservationId);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setNicId(null);
vo.setReservationId(null);
update(vo, sc);
}
@ -207,7 +207,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
DataCenterIpAddressVO vo = this.findById(id);
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setNicId(null);
vo.setReservationId(null);
persist(vo);
}
@ -215,14 +215,14 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
@Override
public void releaseIpAddress(long nicId) {
if (logger.isDebugEnabled()) {
logger.debug("Releasing ip address for instance=" + nicId);
logger.debug("Releasing ip address for nic=" + nicId);
}
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("instance", nicId);
sc.setParameters("nic", nicId);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setNicId(null);
vo.setReservationId(null);
update(vo, sc);
}
@ -305,7 +305,7 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
AllFieldsSearch.and("ip", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("instance", AllFieldsSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("nic", AllFieldsSearch.entity().getNicId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getIpAddress(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("reservation", AllFieldsSearch.entity().getReservationId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("taken", AllFieldsSearch.entity().getTakenAt(), SearchCriteria.Op.EQ);

View File

@ -1261,7 +1261,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
AcquirePodIpCmdResponse ret = new AcquirePodIpCmdResponse();
ret.setCidrAddress(pod_vo.getCidrAddress());
ret.setGateway(pod_vo.getGateway());
ret.setInstanceId(vo.getInstanceId());
ret.setNicId(vo.getNicId());
ret.setIpAddress(vo.getIpAddress());
ret.setMacAddress(vo.getMacAddress());
ret.setPodId(vo.getPodId());

View File

@ -2716,7 +2716,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
}
if (existingPrivateIPs.size() == 1) {
final DataCenterIpAddressVO vo = existingPrivateIPs.get(0);
if (vo.getInstanceId() != null) {
if (vo.getNicId() != null) {
throw new IllegalArgumentException("The private ip address of the server (" + serverPrivateIP + ") is already in use in pod: " + pod.getName() +
" and zone: " + dc.getName());
}