use of com.cloud.dc.DataCenterIpAddressVO in project cloudstack by apache.
the class DataCenterIpAddressDaoImpl method releaseIpAddress.
@Override
public void releaseIpAddress(String ipAddress, long dcId, Long instanceId) {
if (s_logger.isDebugEnabled()) {
s_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);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setReservationId(null);
update(vo, sc);
}
use of com.cloud.dc.DataCenterIpAddressVO in project cloudstack by apache.
the class DataCenterIpAddressDaoImpl method takeIpAddress.
@Override
@DB
public DataCenterIpAddressVO takeIpAddress(long dcId, long podId, long instanceId, String reservationId) {
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("pod", podId);
sc.setParameters("taken", (Date) null);
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
DataCenterIpAddressVO vo = lockOneRandomRow(sc, true);
if (vo == null) {
txn.rollback();
return null;
}
vo.setTakenAt(new Date());
vo.setInstanceId(instanceId);
vo.setReservationId(reservationId);
update(vo.getId(), vo);
txn.commit();
return vo;
}
use of com.cloud.dc.DataCenterIpAddressVO in project cloudstack by apache.
the class DataCenterIpAddressDaoImpl method mark.
@Override
public boolean mark(long dcId, long podId, String ip) {
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("pod", podId);
sc.setParameters("ipAddress", ip);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(new Date());
return update(vo, sc) >= 1;
}
use of com.cloud.dc.DataCenterIpAddressVO in project cloudstack by apache.
the class DataCenterIpAddressDaoImpl method releaseIpAddress.
@Override
public void releaseIpAddress(long nicId, String reservationId) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Releasing ip address for reservationId=" + reservationId + ", instance=" + nicId);
}
SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create();
sc.setParameters("instance", nicId);
sc.setParameters("reservation", reservationId);
DataCenterIpAddressVO vo = createForUpdate();
vo.setTakenAt(null);
vo.setInstanceId(null);
vo.setReservationId(null);
update(vo, sc);
}
Aggregations