Search in sources :

Example 6 with StoragePoolInfo

use of com.cloud.agent.api.StoragePoolInfo in project cloudstack by apache.

the class LocalStoragePoolListener method processConnect.

@Override
@DB
public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
    if (!(cmd instanceof StartupStorageCommand)) {
        return;
    }
    StartupStorageCommand ssCmd = (StartupStorageCommand) cmd;
    if (ssCmd.getResourceType() != Storage.StorageResourceType.STORAGE_POOL) {
        return;
    }
    StoragePoolInfo pInfo = ssCmd.getPoolInfo();
    if (pInfo == null) {
        return;
    }
    this._storageMgr.createLocalStorage(host, pInfo);
}
Also used : StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo) DB(com.cloud.utils.db.DB)

Example 7 with StoragePoolInfo

use of com.cloud.agent.api.StoragePoolInfo in project CloudStack-archive by CloudStack-extras.

the class MockStorageManagerImpl method getLocalStorage.

@Override
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
    MockHost host = _mockHostDao.findByGuid(hostGuid);
    if (storageSize == null) {
        storageSize = DEFAULT_HOST_STORAGE_SIZE;
    }
    MockStoragePoolVO storagePool = _mockStoragePoolDao.findByHost(hostGuid);
    if (storagePool == null) {
        String uuid = UUID.randomUUID().toString();
        storagePool = new MockStoragePoolVO();
        storagePool.setUuid(uuid);
        storagePool.setMountPoint("/mnt/" + uuid + File.separator);
        storagePool.setCapacity(storageSize);
        storagePool.setHostGuid(hostGuid);
        storagePool.setStorageType(StoragePoolType.Filesystem);
        storagePool = _mockStoragePoolDao.persist(storagePool);
    }
    return new StoragePoolInfo(storagePool.getUuid(), host.getPrivateIpAddress(), storagePool.getMountPoint(), storagePool.getMountPoint(), storagePool.getPoolType(), storagePool.getCapacity(), 0);
}
Also used : MockHost(com.cloud.simulator.MockHost) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO)

Example 8 with StoragePoolInfo

use of com.cloud.agent.api.StoragePoolInfo in project CloudStack-archive by CloudStack-extras.

the class FakeComputingResource method initialize.

@Override
public StartupCommand[] initialize() {
    Map<String, VmState> changes = null;
    final List<Object> info = getHostInfo();
    final StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.KVM, RouterPrivateIpStrategy.HostLocal, changes);
    fillNetworkInformation(cmd);
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setCluster(getConfiguredProperty("cluster", "1"));
    StoragePoolInfo pi = initializeLocalStorage();
    StartupStorageCommand sscmd = new StartupStorageCommand();
    sscmd.setPoolInfo(pi);
    sscmd.setGuid(pi.getUuid());
    sscmd.setDataCenter((String) _params.get("zone"));
    sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
    return new StartupCommand[] { cmd, sscmd };
}
Also used : StartupCommand(com.cloud.agent.api.StartupCommand) VmState(com.cloud.agent.api.StartupRoutingCommand.VmState) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo) StartupRoutingCommand(com.cloud.agent.api.StartupRoutingCommand)

Example 9 with StoragePoolInfo

use of com.cloud.agent.api.StoragePoolInfo in project CloudStack-archive by CloudStack-extras.

the class AgentRoutingResource method initializeLocalSR.

private StartupStorageCommand initializeLocalSR() {
    Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
    StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
    StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo);
    cmd.setPoolInfo(poolInfo);
    cmd.setGuid(agentHost.getGuid());
    cmd.setResourceType(StorageResourceType.STORAGE_POOL);
    return cmd;
}
Also used : TemplateInfo(com.cloud.storage.template.TemplateInfo) HashMap(java.util.HashMap) StartupStorageCommand(com.cloud.agent.api.StartupStorageCommand) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo)

Example 10 with StoragePoolInfo

use of com.cloud.agent.api.StoragePoolInfo in project cloudstack by apache.

the class MockStorageManagerImpl method getLocalStorage.

@Override
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
    TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    MockHost host = null;
    try {
        txn.start();
        host = _mockHostDao.findByGuid(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 (storageSize == null) {
        storageSize = DEFAULT_HOST_STORAGE_SIZE;
    }
    txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    MockStoragePoolVO storagePool = null;
    try {
        txn.start();
        storagePool = _mockStoragePoolDao.findByHost(hostGuid);
        txn.commit();
    } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when finding storagePool " + storagePool, 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(storageSize);
        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(), 0);
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) MockHost(com.cloud.simulator.MockHost) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolInfo(com.cloud.agent.api.StoragePoolInfo) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

StoragePoolInfo (com.cloud.agent.api.StoragePoolInfo)12 StartupStorageCommand (com.cloud.agent.api.StartupStorageCommand)8 MockHost (com.cloud.simulator.MockHost)4 MockStoragePoolVO (com.cloud.simulator.MockStoragePoolVO)4 StartupCommand (com.cloud.agent.api.StartupCommand)3 StartupRoutingCommand (com.cloud.agent.api.StartupRoutingCommand)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 ConfigurationException (javax.naming.ConfigurationException)3 VmState (com.cloud.agent.api.StartupRoutingCommand.VmState)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 URISyntaxException (java.net.URISyntaxException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HashMap (java.util.HashMap)2 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 DatastoreMO (com.cloud.hypervisor.vmware.mo.DatastoreMO)1 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)1 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)1 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 TemplateInfo (com.cloud.storage.template.TemplateInfo)1