use of com.cloud.legacymodel.storage.StoragePoolInfo in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResource method initializeLocalstorage.
private List<StartupLocalstorageCommand> initializeLocalstorage() {
final List<StartupLocalstorageCommand> startupLocalstorageCommandList = new ArrayList<>();
for (final AgentConfiguration.Localstorage localstorage : this.agentConfiguration.getLocalstorages()) {
if (localstorage.getType() == StoragePoolType.LVM) {
try {
logger.debug("Found local LVM storage pool: " + localstorage.getPath() + ", with uuid: " + localstorage.getUuid() + ", in the agent configuration");
final KvmStoragePool localStoragePool = this.storagePoolMgr.createStoragePool(localstorage.getUuid(), "localhost", -1, localstorage.getPath(), "", StoragePoolType.LVM);
final StoragePoolInfo storagePoolInfo = new StoragePoolInfo();
storagePoolInfo.setUuid(localstorage.getUuid());
storagePoolInfo.setHost(getName());
storagePoolInfo.setLocalPath(localstorage.getPath());
storagePoolInfo.setPoolType(StoragePoolType.LVM);
storagePoolInfo.setCapacityBytes(localStoragePool.getCapacity());
storagePoolInfo.setAvailableBytes(localStoragePool.getAvailable());
final StartupLocalstorageCommand startupLocalstorageCommand = new StartupLocalstorageCommand();
startupLocalstorageCommand.setPoolInfo(storagePoolInfo);
startupLocalstorageCommandList.add(startupLocalstorageCommand);
} catch (final CloudRuntimeException e) {
logger.debug("Unable to initialize local storage pool: " + e);
}
}
}
return startupLocalstorageCommandList;
}
use of com.cloud.legacymodel.storage.StoragePoolInfo in project cosmic by MissionCriticalCloud.
the class CitrixResourceBase method initializeLocalSR.
protected StartupStorageCommand initializeLocalSR(final Connection conn) {
final SR lvmsr = getLocalLVMSR(conn);
if (lvmsr != null) {
try {
this._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 " + this._host.getUuid();
lvmsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, this._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(this._host.getUuid());
cmd.setDataCenter(Long.toString(this._dcId));
cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local LVM info err in host:" + this._host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
final SR extsr = getLocalEXTSR(conn);
if (extsr != null) {
try {
final String extuuid = extsr.getUuid(conn);
this._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 " + this._host.getUuid();
extsr.setNameDescription(conn, name);
final Host host = Host.getByUuid(conn, this._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(this._host.getUuid());
cmd.setDataCenter(Long.toString(this._dcId));
cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd;
}
} catch (final XenAPIException e) {
final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.toString();
s_logger.warn(msg);
} catch (final XmlRpcException e) {
final String msg = "build local EXT info err in host:" + this._host.getUuid() + e.getMessage();
s_logger.warn(msg);
}
}
return null;
}
use of com.cloud.legacymodel.storage.StoragePoolInfo in project cosmic by MissionCriticalCloud.
the class LocalStoragePoolListener method processConnect.
@Override
@DB
public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
final List<StoragePoolVO> registeredStoragePoolsForHost = this._storagePoolDao.listHostScopedPoolsByStorageHost(host.getName());
final List<StoragePoolVO> liveStoragePools = new ArrayList<>();
for (final StartupCommand startupCommand : startupCommands) {
if (startupCommand instanceof StartupLocalstorageCommand) {
final StartupLocalstorageCommand ssCmd = (StartupLocalstorageCommand) startupCommand;
final StoragePoolInfo pInfo = ssCmd.getPoolInfo();
if (pInfo == null) {
return;
}
s_logger.info("Found storage pool in StartupCommand creating it now: " + pInfo.getUuid());
liveStoragePools.add((StoragePoolVO) this._storageMgr.createLocalStorage(host, pInfo));
}
}
registeredStoragePoolsForHost.removeAll(liveStoragePools);
registeredStoragePoolsForHost.forEach(storagePoolVO -> {
// Disable all storage pools not live right now!
s_logger.info("Disabling storage pool because it is not in the StartupCommand: " + storagePoolVO.getName());
storagePoolVO.setStatus(StoragePoolStatus.Disabled);
this._storagePoolDao.persist(storagePoolVO);
});
}
Aggregations