Search in sources :

Example 26 with StorageServerConnections

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

the class SanStorageModelBase method createTargetModelList.

private ArrayList<SanTargetModel> createTargetModelList(LUNs a) {
    ArrayList<SanTargetModel> targetModelList = new ArrayList<>();
    if (a.getLunConnections() != null) {
        for (StorageServerConnections b : a.getLunConnections()) {
            SanTargetModel model = new SanTargetModel();
            model.setAddress(b.getConnection());
            model.setPort(b.getPort());
            model.setPortal(b.getPortal());
            model.setName(b.getIqn());
            model.setIsSelected(true);
            model.setIsLoggedIn(true);
            model.setLuns(new ObservableCollection<>());
            model.getLoginCommand().setIsExecutionAllowed(false);
            targetModelList.add(model);
        }
    }
    return targetModelList;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList)

Example 27 with StorageServerConnections

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

the class SanStorageModelBase method discoverTargets.

private void discoverTargets() {
    if (!validateDiscoverTargetFields()) {
        return;
    }
    VDS host = getContainer().getHost().getSelectedItem();
    StorageServerConnections tempVar = new StorageServerConnections();
    tempVar.setConnection(getAddress().getEntity().trim());
    tempVar.setPort(getPort().getEntity().trim());
    tempVar.setStorageType(StorageType.ISCSI);
    // $NON-NLS-1$
    tempVar.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : "");
    // $NON-NLS-1$
    tempVar.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : "");
    DiscoverSendTargetsQueryParameters parameters = new DiscoverSendTargetsQueryParameters(host.getId(), tempVar);
    setMessage(null);
    final SanStorageModelBase model = this;
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        Object result = returnValue.getReturnValue();
        model.postDiscoverTargetsInternal(result != null ? (ArrayList<StorageServerConnections>) result : new ArrayList<>());
    }, true);
    Frontend.getInstance().runQuery(QueryType.DiscoverSendTargets, parameters, asyncQuery);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) DiscoverSendTargetsQueryParameters(org.ovirt.engine.core.common.queries.DiscoverSendTargetsQueryParameters)

Example 28 with StorageServerConnections

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

the class HSMGetStorageDomainInfoVDSCommand method buildStorageStaticFromStruct.

private static Pair<StorageDomainStatic, Guid> buildStorageStaticFromStruct(Map<String, Object> struct) {
    Pair<StorageDomainStatic, Guid> returnValue = new Pair<>();
    StorageDomainStatic sdStatic = new StorageDomainStatic();
    if (struct.containsKey("name")) {
        sdStatic.setStorageName(struct.get("name").toString());
    }
    if (struct.containsKey("type")) {
        sdStatic.setStorageType(EnumUtils.valueOf(StorageType.class, struct.get("type").toString(), true));
    }
    if (struct.containsKey("class")) {
        String domainType = struct.get("class").toString();
        if ("backup".equalsIgnoreCase(domainType)) {
            sdStatic.setStorageDomainType(StorageDomainType.ImportExport);
        } else {
            sdStatic.setStorageDomainType(EnumUtils.valueOf(StorageDomainType.class, domainType, true));
        }
    }
    if (struct.containsKey("version")) {
        sdStatic.setStorageFormat(StorageFormatType.forValue(struct.get("version").toString()));
    }
    if (sdStatic.getStorageType() != StorageType.UNKNOWN) {
        if (sdStatic.getStorageType().isFileDomain() && struct.containsKey("remotePath")) {
            String path = struct.get("remotePath").toString();
            List<StorageServerConnections> connections = DbFacade.getInstance().getStorageServerConnectionDao().getAllForStorage(path);
            if (connections.isEmpty()) {
                sdStatic.setConnection(new StorageServerConnections());
                sdStatic.getConnection().setConnection(path);
                sdStatic.getConnection().setStorageType(sdStatic.getStorageType());
            } else {
                sdStatic.setStorage(connections.get(0).getId());
                sdStatic.setConnection(connections.get(0));
            }
        } else if (sdStatic.getStorageType() != StorageType.NFS) {
            if (struct.containsKey("vguuid")) {
                sdStatic.setStorage(struct.get("vguuid").toString());
            }
            if (struct.containsKey("metadataDevice")) {
                sdStatic.setFirstMetadataDevice(Objects.toString(struct.get("metadataDevice")));
            }
            if (struct.containsKey("vgMetadataDevice")) {
                sdStatic.setVgMetadataDevice(Objects.toString(struct.get("vgMetadataDevice")));
            }
        }
    }
    if (struct.containsKey("state")) {
        sdStatic.setSanState(EnumUtils.valueOf(SANState.class, struct.get("state").toString().toUpperCase(), false));
    }
    returnValue.setFirst(sdStatic);
    Object[] poolUUIDs = (Object[]) struct.get("pool");
    if (poolUUIDs.length != 0) {
        returnValue.setSecond(Guid.createGuidFromString(poolUUIDs[0].toString()));
    }
    return returnValue;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) SANState(org.ovirt.engine.core.common.businessentities.SANState) Guid(org.ovirt.engine.core.compat.Guid) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 29 with StorageServerConnections

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

the class ConnectStorageServerVDSCommand method buildStructFromConnectionListObject.

@SuppressWarnings("unchecked")
protected Map<String, String>[] buildStructFromConnectionListObject() {
    final Map<String, String>[] result = new HashMap[getParameters().getConnectionList().size()];
    int i = 0;
    for (StorageServerConnections connection : getParameters().getConnectionList()) {
        result[i] = storageConnectionHelper.createStructFromConnection(connection, getParameters().getVdsId());
        i++;
    }
    return result;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 30 with StorageServerConnections

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

the class DiscoverSendTargetsVDSCommand method parseTargets.

private List<StorageServerConnections> parseTargets(List<String> iqnList) {
    List<StorageServerConnections> connections = new ArrayList<>(iqnList.size());
    for (String iqn : iqnList) {
        StorageServerConnections con = StorageServerConnections.copyOf(getParameters().getConnection());
        con.setIqn(iqn);
        connections.add(con);
    }
    return connections;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList)

Aggregations

StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)181 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)43 Guid (org.ovirt.engine.core.compat.Guid)39 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)33 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)32 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)19 List (java.util.List)18 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)14 HashSet (java.util.HashSet)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 Set (java.util.Set)10 StorageConnection (org.ovirt.engine.api.model.StorageConnection)10 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)10 QueryType (org.ovirt.engine.core.common.queries.QueryType)10