Search in sources :

Example 11 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class VMsTree method getDiskNode.

private TreeItem getDiskNode(ArrayList<Disk> disks) {
    if (disks.isEmpty()) {
        return null;
    }
    VerticalPanel vPanel = new VerticalPanel();
    // $NON-NLS-1$
    vPanel.setWidth("100%");
    for (Disk disk : disks) {
        HorizontalPanel panel = new HorizontalPanel();
        ImageResource image = resources.diskImage();
        String name = disk.getDiskAlias();
        // $NON-NLS-1$
        addItemToPanel(panel, new Image(image), "25px");
        // $NON-NLS-1$
        addTextBoxToPanel(panel, new StringValueLabel(), name, "");
        // $NON-NLS-1$ //$NON-NLS-2$
        addTextBoxToPanel(panel, new StringValueLabel(), "", "80px");
        // $NON-NLS-1$ //$NON-NLS-2$
        addTextBoxToPanel(panel, new StringValueLabel(), "", "160px");
        boolean isDiskImage = disk.getDiskStorageType() == DiskStorageType.IMAGE;
        Double actualSize = isDiskImage ? ((DiskImage) disk).getActualDiskWithSnapshotsSize() : (long) ((LunDisk) disk).getLun().getDeviceSize();
        Long virtualSize = isDiskImage ? disk.getSize() : (long) (((LunDisk) disk).getLun().getDeviceSize() * Math.pow(1024, 3));
        // $NON-NLS-1$
        addValueLabelToPanel(panel, new DiskSizeLabel<Long>(SizeConverter.SizeUnit.BYTES), virtualSize, "110px");
        // $NON-NLS-1$
        addValueLabelToPanel(panel, new DiskSizeLabel<Double>(SizeConverter.SizeUnit.GiB), actualSize, "110px");
        addValueLabelToPanel(panel, new FullDateTimeLabel(), disk.getDiskStorageType() == DiskStorageType.IMAGE ? ((DiskImage) disk).getCreationDate() : null, // $NON-NLS-1$
        "140px");
        panel.setSpacing(1);
        // $NON-NLS-1$
        panel.setWidth("100%");
        vPanel.add(panel);
    }
    TreeItem treeItem = new TreeItem(vPanel);
    treeItem.setUserObject(disks.get(0).getId());
    return treeItem;
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) Image(com.google.gwt.user.client.ui.Image) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) StringValueLabel(org.ovirt.engine.ui.common.widget.label.StringValueLabel) FullDateTimeLabel(org.ovirt.engine.ui.webadmin.widget.label.FullDateTimeLabel) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ImageResource(com.google.gwt.resources.client.ImageResource) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 12 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class RunVmCommandBase method connectLunDisks.

protected boolean connectLunDisks(Guid hostId) {
    if (getVm().getDiskMap().isEmpty()) {
        vmHandler.updateDisksFromDb(getVm());
    }
    List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getVm().getDiskMap().values());
    Map<StorageType, List<StorageServerConnections>> connectionsByType = lunDisks.stream().flatMap(d -> storageServerConnectionDao.getAllForLun(d.getLun().getLUNId()).stream()).distinct().collect(groupingBy(StorageServerConnections::getStorageType, toList()));
    return connectionsByType.entrySet().stream().map(entry -> runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(hostId, getStoragePoolId(), entry.getKey(), entry.getValue()))).noneMatch(vdsReturnValue -> !vdsReturnValue.getSucceeded());
}
Also used : CinderBroker(org.ovirt.engine.core.bll.storage.disk.cinder.CinderBroker) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) ProviderDao(org.ovirt.engine.core.dao.provider.ProviderDao) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LoggerFactory(org.slf4j.LoggerFactory) Provider(org.ovirt.engine.core.common.businessentities.Provider) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) Map(java.util.Map) JobRepository(org.ovirt.engine.core.bll.job.JobRepository) VdsRefreshRate(org.ovirt.engine.core.common.config.ConfigValues.VdsRefreshRate) ThreadPoolUtil(org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) RunVmDelayer(org.ovirt.engine.core.bll.scheduling.RunVmDelayer) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) BlockingQueue(java.util.concurrent.BlockingQueue) List(java.util.List) SchedulingManager(org.ovirt.engine.core.bll.scheduling.SchedulingManager) VnicProfileDao(org.ovirt.engine.core.dao.network.VnicProfileDao) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) Job(org.ovirt.engine.core.common.job.Job) Guid(org.ovirt.engine.core.compat.Guid) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) NetworkDeviceHelper(org.ovirt.engine.core.bll.network.host.NetworkDeviceHelper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) NetworkHelper(org.ovirt.engine.core.bll.network.cluster.NetworkHelper) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy) StorageServerConnectionDao(org.ovirt.engine.core.dao.StorageServerConnectionDao) Network(org.ovirt.engine.core.common.businessentities.network.Network) IVdsAsyncCommand(org.ovirt.engine.core.common.businessentities.IVdsAsyncCommand) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Pair(org.ovirt.engine.core.common.utils.Pair) HostMonitoring(org.ovirt.engine.core.vdsbroker.monitoring.HostMonitoring) Config(org.ovirt.engine.core.common.config.Config) ProviderProxyFactory(org.ovirt.engine.core.bll.provider.ProviderProxyFactory) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) Logger(org.slf4j.Logger) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) VfScheduler(org.ovirt.engine.core.bll.network.host.VfScheduler) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) TimeUnit(java.util.concurrent.TimeUnit) VdsMonitor(org.ovirt.engine.core.vdsbroker.VdsMonitor) Collectors.toList(java.util.stream.Collectors.toList) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) ONLY_PLUGGED(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_PLUGGED) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 13 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class RemoveDiskCommandTest method testPreImportedHostedEngineLunDiskRemove.

@Test
public void testPreImportedHostedEngineLunDiskRemove() {
    disk = new LunDisk();
    setupDisk();
    disk.setDiskAlias(StorageConstants.HOSTED_ENGINE_LUN_DISK_ALIAS);
    doReturn(disk).when(cmd).getDisk();
    ValidateTestUtils.runAndAssertValidateSuccess(cmd);
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 14 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class RemoveDiskCommandTest method testImportedHostedEngineLunDiskRemove.

@Test
public void testImportedHostedEngineLunDiskRemove() {
    vm.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    vm.setStatus(VMStatus.Up);
    disk = new LunDisk();
    setupDisk();
    disk.setDiskAlias(StorageConstants.HOSTED_ENGINE_LUN_DISK_ALIAS);
    doReturn(disk).when(cmd).getDisk();
    ValidateTestUtils.runAndAssertValidateSuccess(cmd);
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 15 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class DisksFilterTest method testFilterNonImageDisks.

@Test
public void testFilterNonImageDisks() {
    Disk lunDisk = createDisk(DiskStorageType.LUN, false, false, false, false);
    Disk imageDisk = createDisk(DiskStorageType.IMAGE, false, false, true, false);
    Disk cinderDisk = createDisk(DiskStorageType.CINDER, false, false, true, false);
    List<Disk> disksList = Arrays.asList(lunDisk, imageDisk, cinderDisk);
    List<DiskImage> filteredList = DisksFilter.filterImageDisks(disksList);
    assertEquals(1, filteredList.size());
    assertThat(filteredList, containsInAnyOrder(imageDisk));
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Aggregations

LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)62 Test (org.junit.Test)29 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)21 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)16 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)13 VM (org.ovirt.engine.core.common.businessentities.VM)10 ArrayList (java.util.ArrayList)9 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 Guid (org.ovirt.engine.core.compat.Guid)7 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)6 HashMap (java.util.HashMap)5 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)5 HashSet (java.util.HashSet)3 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)3 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)3 ImageResource (com.google.gwt.resources.client.ImageResource)2 List (java.util.List)2