Search in sources :

Example 1 with CreateCommand

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

the class LibvirtComputingResourceTest method testCreateCommandCLVM.

@Test
public void testCreateCommandCLVM() {
    final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class);
    final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class);
    final String templateUrl = "http://template";
    final boolean executeInSequence = false;
    final CreateCommand command = new CreateCommand(diskCharacteristics, templateUrl, pool, executeInSequence);
    final KvmStoragePoolManager poolManager = Mockito.mock(KvmStoragePoolManager.class);
    final KvmStoragePool primary = Mockito.mock(KvmStoragePool.class);
    final KvmPhysicalDisk vol = Mockito.mock(KvmPhysicalDisk.class);
    final KvmPhysicalDisk baseVol = Mockito.mock(KvmPhysicalDisk.class);
    when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
    when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary);
    when(primary.getPhysicalDisk(command.getTemplateUrl())).thenReturn(baseVol);
    when(poolManager.createDiskFromTemplate(baseVol, diskCharacteristics.getPath(), diskCharacteristics.getProvisioningType(), primary, 0)).thenReturn(vol);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid());
}
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) CreateCommand(com.cloud.legacymodel.communication.command.CreateCommand) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) KvmStoragePoolManager(com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager) KvmPhysicalDisk(com.cloud.agent.resource.kvm.storage.KvmPhysicalDisk) DiskProfile(com.cloud.legacymodel.storage.DiskProfile) StorageFilerTO(com.cloud.legacymodel.to.StorageFilerTO) Test(org.junit.Test)

Example 2 with CreateCommand

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

the class LibvirtComputingResourceTest method testCreateCommandNoTemplate.

@Test
public void testCreateCommandNoTemplate() {
    final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class);
    final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class);
    final boolean executeInSequence = false;
    final CreateCommand command = new CreateCommand(diskCharacteristics, pool, executeInSequence);
    final KvmStoragePoolManager poolManager = Mockito.mock(KvmStoragePoolManager.class);
    final KvmStoragePool primary = Mockito.mock(KvmStoragePool.class);
    final KvmPhysicalDisk vol = Mockito.mock(KvmPhysicalDisk.class);
    when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
    when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary);
    when(primary.createPhysicalDisk(diskCharacteristics.getPath(), diskCharacteristics.getProvisioningType(), diskCharacteristics.getSize())).thenReturn(vol);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid());
}
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) CreateCommand(com.cloud.legacymodel.communication.command.CreateCommand) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) KvmStoragePoolManager(com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager) KvmPhysicalDisk(com.cloud.agent.resource.kvm.storage.KvmPhysicalDisk) DiskProfile(com.cloud.legacymodel.storage.DiskProfile) StorageFilerTO(com.cloud.legacymodel.to.StorageFilerTO) Test(org.junit.Test)

Example 3 with CreateCommand

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

the class LibvirtComputingResourceTest method testCreateCommand.

@Test
public void testCreateCommand() {
    final DiskProfile diskCharacteristics = Mockito.mock(DiskProfile.class);
    final StorageFilerTO pool = Mockito.mock(StorageFilerTO.class);
    final String templateUrl = "http://template";
    final boolean executeInSequence = false;
    final CreateCommand command = new CreateCommand(diskCharacteristics, templateUrl, pool, executeInSequence);
    final KvmStoragePoolManager poolManager = Mockito.mock(KvmStoragePoolManager.class);
    final KvmStoragePool primary = Mockito.mock(KvmStoragePool.class);
    final KvmPhysicalDisk vol = Mockito.mock(KvmPhysicalDisk.class);
    when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(poolManager);
    when(poolManager.getStoragePool(pool.getType(), pool.getUuid())).thenReturn(primary);
    when(primary.getType()).thenReturn(StoragePoolType.CLVM);
    when(this.libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(), primary, diskCharacteristics.getPath())).thenReturn(vol);
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
    verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
    verify(poolManager, times(1)).getStoragePool(pool.getType(), pool.getUuid());
}
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) CreateCommand(com.cloud.legacymodel.communication.command.CreateCommand) KvmStoragePool(com.cloud.agent.resource.kvm.storage.KvmStoragePool) KvmStoragePoolManager(com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager) KvmPhysicalDisk(com.cloud.agent.resource.kvm.storage.KvmPhysicalDisk) DiskProfile(com.cloud.legacymodel.storage.DiskProfile) StorageFilerTO(com.cloud.legacymodel.to.StorageFilerTO) Test(org.junit.Test)

Example 4 with CreateCommand

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

the class NotAValidCommand method testExecuteCreateCommand.

@Test
public void testExecuteCreateCommand() {
    final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
    final DiskProfile diskProfile = Mockito.mock(DiskProfile.class);
    final CreateCommand createCommand = new CreateCommand(diskProfile, "", poolVO, false);
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(createCommand, 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) CreateCommand(com.cloud.legacymodel.communication.command.CreateCommand) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) DiskProfile(com.cloud.legacymodel.storage.DiskProfile) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)4 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)4 CreateCommand (com.cloud.legacymodel.communication.command.CreateCommand)4 DiskProfile (com.cloud.legacymodel.storage.DiskProfile)4 Test (org.junit.Test)4 KvmPhysicalDisk (com.cloud.agent.resource.kvm.storage.KvmPhysicalDisk)3 KvmStoragePool (com.cloud.agent.resource.kvm.storage.KvmStoragePool)3 KvmStoragePoolManager (com.cloud.agent.resource.kvm.storage.KvmStoragePoolManager)3 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)3 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)3 StorageFilerTO (com.cloud.legacymodel.to.StorageFilerTO)3 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1