use of com.cloud.legacymodel.communication.command.startup.StartupLocalstorageCommand 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.communication.command.startup.StartupLocalstorageCommand 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