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);
}
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);
}
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;
}
Aggregations