Search in sources :

Example 6 with StorageNetworkIpAddressVO

use of com.cloud.dc.StorageNetworkIpAddressVO in project cosmic by MissionCriticalCloud.

the class StorageNetworkIpAddressDaoImpl method releaseIpAddress.

@Override
public void releaseIpAddress(final String ip) {
    final SearchCriteria<StorageNetworkIpAddressVO> sc = ipSearch.create();
    sc.setParameters("ipAddress", ip);
    final StorageNetworkIpAddressVO vo = createForUpdate();
    vo.setTakenAt(null);
    update(vo, sc);
}
Also used : StorageNetworkIpAddressVO(com.cloud.dc.StorageNetworkIpAddressVO)

Example 7 with StorageNetworkIpAddressVO

use of com.cloud.dc.StorageNetworkIpAddressVO in project cosmic by MissionCriticalCloud.

the class StorageNetworkGuru method reserve.

@Override
public void reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
    if (!_sNwMgr.isStorageIpRangeAvailable(dest.getZone().getId())) {
        super.reserve(nic, network, vm, dest, context);
        return;
    }
    final Pod pod = dest.getPod();
    final Integer vlan;
    final StorageNetworkIpAddressVO ip = _sNwMgr.acquireIpAddress(pod.getId());
    if (ip == null) {
        throw new InsufficientAddressCapacityException("Unable to get a storage network ip address", Pod.class, pod.getId());
    }
    vlan = ip.getVlan();
    nic.setIPv4Address(ip.getIpAddress());
    nic.setMacAddress(NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ip.getMac())));
    nic.setFormat(AddressFormat.Ip4);
    nic.setIPv4Netmask(ip.getNetmask());
    nic.setBroadcastType(BroadcastDomainType.Storage);
    nic.setIPv4Gateway(ip.getGateway());
    if (vlan != null) {
        nic.setBroadcastUri(BroadcastDomainType.Storage.toUri(vlan));
    } else {
        nic.setBroadcastUri(null);
    }
    nic.setIsolationUri(null);
    s_logger.debug("Allocated a storage nic " + nic + " for " + vm);
}
Also used : Pod(com.cloud.dc.Pod) StorageNetworkIpAddressVO(com.cloud.dc.StorageNetworkIpAddressVO) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException)

Example 8 with StorageNetworkIpAddressVO

use of com.cloud.dc.StorageNetworkIpAddressVO in project cloudstack by apache.

the class StorageNetworkManagerImpl method acquireIpAddress.

@Override
public StorageNetworkIpAddressVO acquireIpAddress(long podId) {
    List<StorageNetworkIpRangeVO> ranges = _sNwIpRangeDao.listByPodId(podId);
    for (StorageNetworkIpRangeVO r : ranges) {
        try {
            Long rangeId = r.getId();
            r = _sNwIpRangeDao.acquireInLockTable(rangeId);
            if (r == null) {
                String msg = "Unable to acquire lock on storage network ip range id=" + rangeId + ", delete failed";
                s_logger.warn(msg);
                throw new CloudRuntimeException(msg);
            }
            StorageNetworkIpAddressVO ip = _sNwIpDao.takeIpAddress(r.getId());
            if (ip != null) {
                return ip;
            }
        } finally {
            if (r != null) {
                _sNwIpRangeDao.releaseFromLockTable(r.getId());
            }
        }
    }
    return null;
}
Also used : StorageNetworkIpRangeVO(com.cloud.dc.StorageNetworkIpRangeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StorageNetworkIpAddressVO(com.cloud.dc.StorageNetworkIpAddressVO)

Aggregations

StorageNetworkIpAddressVO (com.cloud.dc.StorageNetworkIpAddressVO)8 Pod (com.cloud.dc.Pod)2 StorageNetworkIpRangeVO (com.cloud.dc.StorageNetworkIpRangeVO)2 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)2 DB (com.cloud.utils.db.DB)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 Date (java.util.Date)2