Search in sources :

Example 1 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainResourceTest method testRefreshLunsSize.

@Test
public void testRefreshLunsSize() throws Exception {
    List<String> lunsArray = new ArrayList();
    lunsArray.add(GUIDS[2].toString());
    setUriInfo(setUpActionExpectations(ActionType.RefreshLunsSize, ExtendSANStorageDomainParameters.class, new String[] { "LunIds" }, new Object[] { lunsArray }, true, true));
    Action action = new Action();
    LogicalUnits luns = new LogicalUnits();
    LogicalUnit lun = new LogicalUnit();
    lun.setId(GUIDS[2].toString());
    luns.getLogicalUnits().add(lun);
    action.setLogicalUnits(luns);
    verifyActionResponse(resource.refreshLuns(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ArrayList(java.util.ArrayList) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters) Test(org.junit.Test)

Example 2 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainsResourceTest method testAddIscsiStorageDomainAssumingConnection.

@Test
public void testAddIscsiStorageDomainAssumingConnection() throws Exception {
    StorageDomain model = getIscsi();
    Host host = new Host();
    host.setId(GUIDS[0].toString());
    model.setHost(host);
    for (LogicalUnit lun : model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits()) {
        lun.setAddress(null);
        lun.setTarget(null);
    }
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(QueryType.GetDeviceList, GetDeviceListQueryParameters.class, new String[] { "Id", "StorageType" }, new Object[] { GUIDS[0], org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI }, "this return value isn't used");
    List<LUNs> luns = setUpLuns();
    setUpGetEntityExpectations(QueryType.GetLunsByVgId, GetLunsByVgIdParameters.class, new String[] { "VgId" }, new Object[] { GUIDS[GUIDS.length - 1].toString() }, luns);
    setUpCreationExpectations(ActionType.AddSANStorageDomain, AddSANStorageDomainParameters.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[0], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getIscsiEntity());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof StorageDomain);
    verifyIscsi((StorageDomain) response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) StorageDomain(org.ovirt.engine.api.model.StorageDomain) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) Host(org.ovirt.engine.api.model.Host) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 3 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainsResourceTest method getIscsi.

protected StorageDomain getIscsi() {
    StorageDomain model = getModel(0);
    model.getStorage().setType(StorageType.ISCSI);
    model.getStorage().setAddress(null);
    model.getStorage().setPath(null);
    model.getStorage().setVolumeGroup(new VolumeGroup());
    model.getStorage().getVolumeGroup().setLogicalUnits(new LogicalUnits());
    model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().add(new LogicalUnit());
    model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setId(LUN);
    model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setTarget(TARGET);
    model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setAddress(ADDRESSES[0]);
    model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setPort(PORT);
    model.getStorage().setOverrideLuns(false);
    return model;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit)

Example 4 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainResourceTest method reduceLuns.

@Test
public void reduceLuns() throws Exception {
    List<String> paramsLuns = new LinkedList<>();
    paramsLuns.add(GUIDS[2].toString());
    paramsLuns.add(GUIDS[3].toString());
    setUriInfo(setUpActionExpectations(ActionType.ReduceSANStorageDomainDevices, ReduceSANStorageDomainDevicesCommandParameters.class, new String[] { "DevicesToReduce", "StorageDomainId" }, new Object[] { paramsLuns, GUIDS[0] }, true, true));
    Action action = new Action();
    LogicalUnits luns = new LogicalUnits();
    paramsLuns.forEach(s -> {
        LogicalUnit lun = new LogicalUnit();
        lun.setId(s);
        luns.getLogicalUnits().add(lun);
    });
    action.setLogicalUnits(luns);
    verifyActionResponse(resource.reduceLuns(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ReduceSANStorageDomainDevicesCommandParameters(org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 5 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainsResource method mapVolumeGroupIscsi.

protected void mapVolumeGroupIscsi(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) {
    VolumeGroup vg = model.getStorage().getVolumeGroup();
    List<LUNs> luns = getLunsByVgId(vg.getId());
    if (luns != null && !luns.isEmpty()) {
        vg.setLogicalUnits(new LogicalUnits());
        for (LUNs lun : luns) {
            List<StorageServerConnections> lunConnections = lun.getLunConnections();
            if (lunConnections != null) {
                for (StorageServerConnections cnx : lunConnections) {
                    LogicalUnit unit = map(lun);
                    unit = map(cnx, unit);
                    vg.getLogicalUnits().getLogicalUnits().add(unit);
                }
            }
        }
    }
}
Also used : LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Aggregations

LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)16 LogicalUnits (org.ovirt.engine.api.model.LogicalUnits)7 Test (org.junit.Test)4 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)4 Action (org.ovirt.engine.api.model.Action)3 VolumeGroup (org.ovirt.engine.api.model.VolumeGroup)3 ArrayList (java.util.ArrayList)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 ExtendSANStorageDomainParameters (org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)2 ReduceSANStorageDomainDevicesCommandParameters (org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)2 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Response (javax.ws.rs.core.Response)1 Disk (org.ovirt.engine.api.model.Disk)1 Host (org.ovirt.engine.api.model.Host)1 IscsiDetailss (org.ovirt.engine.api.model.IscsiDetailss)1 StorageType (org.ovirt.engine.api.model.StorageType)1