Search in sources :

Example 6 with DataCenterIpAddressVO

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);
}
Also used : DataCenterIpAddressVO(com.cloud.dc.DataCenterIpAddressVO)

Example 7 with DataCenterIpAddressVO

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) DataCenterIpAddressVO(com.cloud.dc.DataCenterIpAddressVO) Date(java.util.Date) DB(com.cloud.utils.db.DB)

Example 8 with DataCenterIpAddressVO

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;
}
Also used : DataCenterIpAddressVO(com.cloud.dc.DataCenterIpAddressVO) Date(java.util.Date)

Example 9 with DataCenterIpAddressVO

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);
}
Also used : DataCenterIpAddressVO(com.cloud.dc.DataCenterIpAddressVO)

Aggregations

DataCenterIpAddressVO (com.cloud.dc.DataCenterIpAddressVO)9 DB (com.cloud.utils.db.DB)3 Date (java.util.Date)3 ExternalLoadBalancerDeviceVO (com.cloud.network.dao.ExternalLoadBalancerDeviceVO)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 CreateLoadBalancerApplianceCommand (com.cloud.agent.api.routing.CreateLoadBalancerApplianceCommand)1 DestroyLoadBalancerApplianceCommand (com.cloud.agent.api.routing.DestroyLoadBalancerApplianceCommand)1 Pod (com.cloud.dc.Pod)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 NetScalerPodVO (com.cloud.network.NetScalerPodVO)1 PublicIp (com.cloud.network.addr.PublicIp)1 NetworkExternalLoadBalancerVO (com.cloud.network.dao.NetworkExternalLoadBalancerVO)1 CreateLoadBalancerApplianceAnswer (com.cloud.network.resource.CreateLoadBalancerApplianceAnswer)1 DestroyLoadBalancerApplianceAnswer (com.cloud.network.resource.DestroyLoadBalancerApplianceAnswer)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 UnableDeleteHostException (com.cloud.resource.UnableDeleteHostException)1 Pair (com.cloud.utils.Pair)1