use of com.cloud.agent.api.StoragePoolInfo in project cloudstack by apache.
the class CitrixResourceBase method initializeLocalSR.
protected StartupStorageCommand initializeLocalSR(final Connection conn) {
final SR lvmsr = getLocalLVMSR(conn);
if (lvmsr != null) {
try {
_host.setLocalSRuuid(lvmsr.getUuid(conn));
final String lvmuuid = lvmsr.getUuid(conn);
final long cap = lvmsr.getPhysicalSize(conn);
if (cap > 0) {
final long avail = cap - lvmsr.getPhysicalUtilisation(conn);
lvmsr.setNameLabel(conn, lvmuuid);
final String name = "Cloud Stack Local LVM Storage Pool for " + _host.getUuid();
lvmsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, _host.getUuid());
final String address = host.getAddress(conn);
final StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
final StartupStorageCommand cmd = new StartupStorageCommand();
cmd.setPoolInfo(pInfo);
cmd.setGuid(_host.getUuid());
cmd.setDataCenter(Long.toString(_dcId));
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local LVM info err in host:" + _host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local LVM info err in host:" + _host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
final SR extsr = getLocalEXTSR(conn);
if (extsr != null) {
try {
final String extuuid = extsr.getUuid(conn);
_host.setLocalSRuuid(extuuid);
final long cap = extsr.getPhysicalSize(conn);
if (cap > 0) {
final long avail = cap - extsr.getPhysicalUtilisation(conn);
extsr.setNameLabel(conn, extuuid);
final String name = "Cloud Stack Local EXT Storage Pool for " + _host.getUuid();
extsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, _host.getUuid());
final String address = host.getAddress(conn);
final StoragePoolInfo pInfo = new StoragePoolInfo(extuuid, address, SRType.EXT.toString(), SRType.EXT.toString(), StoragePoolType.EXT, cap, avail);
final StartupStorageCommand cmd = new StartupStorageCommand();
cmd.setPoolInfo(pInfo);
cmd.setGuid(_host.getUuid());
cmd.setDataCenter(Long.toString(_dcId));
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local EXT info err in host:" + _host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local EXT info err in host:" + _host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
return null;
}
use of com.cloud.agent.api.StoragePoolInfo in project cloudstack by apache.
the class MockStorageManagerImpl method getLocalStorage.
@Override
public StoragePoolInfo getLocalStorage(String hostGuid) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockHost host = null;
MockStoragePoolVO storagePool = null;
try {
txn.start();
host = _mockHostDao.findByGuid(hostGuid);
storagePool = _mockStoragePoolDao.findByHost(hostGuid);
txn.commit();
} catch (Exception ex) {
txn.rollback();
throw new CloudRuntimeException("Unable to find host " + hostGuid, ex);
} finally {
txn.close();
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
if (storagePool == null) {
String uuid = UUID.randomUUID().toString();
storagePool = new MockStoragePoolVO();
storagePool.setUuid(uuid);
storagePool.setMountPoint("/mnt/" + uuid);
storagePool.setCapacity(DEFAULT_HOST_STORAGE_SIZE);
storagePool.setHostGuid(hostGuid);
storagePool.setStorageType(StoragePoolType.Filesystem);
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
storagePool = _mockStoragePoolDao.persist(storagePool);
txn.commit();
} catch (Exception ex) {
txn.rollback();
throw new CloudRuntimeException("Error when saving storagePool " + storagePool, ex);
} finally {
txn.close();
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
return new StoragePoolInfo(storagePool.getUuid(), host.getPrivateIpAddress(), storagePool.getMountPoint(), storagePool.getMountPoint(), storagePool.getPoolType(), storagePool.getCapacity(), storagePool.getCapacity());
}
Aggregations