Search in sources :

Example 11 with CreateStoragePoolCommand

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

the class SolidFireSharedPrimaryDataStoreLifeCycle method createStoragePool.

private boolean createStoragePool(HostVO host, StoragePool storagePool) {
    long hostId = host.getId();
    HypervisorType hypervisorType = host.getHypervisorType();
    CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, storagePool);
    if (HypervisorType.VMware.equals(hypervisorType)) {
        cmd.setCreateDatastore(true);
        Map<String, String> details = new HashMap<>();
        StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.DATASTORE_NAME);
        details.put(CreateStoragePoolCommand.DATASTORE_NAME, storagePoolDetail.getValue());
        storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.IQN);
        details.put(CreateStoragePoolCommand.IQN, storagePoolDetail.getValue());
        storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_VIP);
        details.put(CreateStoragePoolCommand.STORAGE_HOST, storagePoolDetail.getValue());
        storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_PORT);
        details.put(CreateStoragePoolCommand.STORAGE_PORT, storagePoolDetail.getValue());
        cmd.setDetails(details);
    }
    Answer answer = agentMgr.easySend(hostId, cmd);
    if (answer != null && answer.getResult()) {
        return true;
    } else {
        primaryDataStoreDao.expunge(storagePool.getId());
        final String msg;
        if (answer != null) {
            msg = "Cannot create storage pool through host '" + hostId + "' due to the following: " + answer.getDetails();
        } else {
            msg = "Cannot create storage pool through host '" + hostId + "' due to CreateStoragePoolCommand returns null";
        }
        LOGGER.warn(msg);
        throw new CloudRuntimeException(msg);
    }
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Answer(com.cloud.agent.api.Answer) HashMap(java.util.HashMap) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand)

Example 12 with CreateStoragePoolCommand

use of com.cloud.agent.api.CreateStoragePoolCommand in project cosmic by MissionCriticalCloud.

the class CloudStackPrimaryDataStoreLifeCycleImpl method createStoragePool.

protected boolean createStoragePool(final long hostId, final StoragePool pool) {
    s_logger.debug("creating pool " + pool.getName() + " on  host " + hostId);
    if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem && pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 && pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB && pool.getPoolType() != StoragePoolType.Gluster) {
        s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
        return false;
    }
    final CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
    final Answer answer = agentMgr.easySend(hostId, cmd);
    if (answer != null && answer.getResult()) {
        return true;
    } else {
        primaryDataStoreDao.expunge(pool.getId());
        String msg = "";
        if (answer != null) {
            msg = "Can not create storage pool through host " + hostId + " due to " + answer.getDetails();
            s_logger.warn(msg);
        } else {
            msg = "Can not create storage pool through host " + hostId + " due to CreateStoragePoolCommand returns null";
            s_logger.warn(msg);
        }
        throw new CloudRuntimeException(msg);
    }
}
Also used : Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand)

Example 13 with CreateStoragePoolCommand

use of com.cloud.agent.api.CreateStoragePoolCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testCreateStoragePoolCommand.

@Test
public void testCreateStoragePoolCommand() {
    final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
    final XsHost xsHost = Mockito.mock(XsHost.class);
    final CreateStoragePoolCommand createStorageCommand = new CreateStoragePoolCommand(false, poolVO);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    when(citrixResourceBase.getHost()).thenReturn(xsHost);
    final Answer answer = wrapper.execute(createStorageCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) Answer(com.cloud.agent.api.Answer) AttachAnswer(com.cloud.storage.command.AttachAnswer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.agent.api.Answer)13 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)2 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)2 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)2 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 CleanupNetworkRulesCmd (com.cloud.agent.api.CleanupNetworkRulesCmd)2 ComputeChecksumCommand (com.cloud.agent.api.ComputeChecksumCommand)2 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)2 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)2 CreateVolumeFromSnapshotCommand (com.cloud.agent.api.CreateVolumeFromSnapshotCommand)2 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)2 GetDomRVersionCmd (com.cloud.agent.api.GetDomRVersionCmd)2 GetHostStatsCommand (com.cloud.agent.api.GetHostStatsCommand)2 GetStorageStatsCommand (com.cloud.agent.api.GetStorageStatsCommand)2