Search in sources :

Example 1 with CreateStoragePoolCommand

use of com.cloud.legacymodel.communication.command.CreateStoragePoolCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testCreateStoragePoolCommand.

@Test
public void testCreateStoragePoolCommand() {
    final StoragePool pool = Mockito.mock(StoragePool.class);
    final CreateStoragePoolCommand command = new CreateStoragePoolCommand(true, pool);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) NfsStoragePool(com.cloud.agent.resource.kvm.ha.KvmHaBase.NfsStoragePool) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) StoragePool(com.cloud.legacymodel.storage.StoragePool) CreateStoragePoolCommand(com.cloud.legacymodel.communication.command.CreateStoragePoolCommand) Test(org.junit.Test)

Example 2 with CreateStoragePoolCommand

use of com.cloud.legacymodel.communication.command.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.LVM && 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.legacymodel.communication.answer.Answer) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) CreateStoragePoolCommand(com.cloud.legacymodel.communication.command.CreateStoragePoolCommand)

Example 3 with CreateStoragePoolCommand

use of com.cloud.legacymodel.communication.command.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(this.citrixResourceBase.getHost()).thenReturn(xsHost);
    final Answer answer = wrapper.execute(createStorageCommand, this.citrixResourceBase);
    verify(this.citrixResourceBase, times(1)).getConnection();
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) CreateStoragePoolCommand(com.cloud.legacymodel.communication.command.CreateStoragePoolCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)3 CreateStoragePoolCommand (com.cloud.legacymodel.communication.command.CreateStoragePoolCommand)3 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)2 Test (org.junit.Test)2 NfsStoragePool (com.cloud.agent.resource.kvm.ha.KvmHaBase.NfsStoragePool)1 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)1 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)1 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)1 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)1 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)1 StoragePool (com.cloud.legacymodel.storage.StoragePool)1 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1