Search in sources :

Example 1 with StoragePortGroupRestRepList

use of com.emc.storageos.model.portgroup.StoragePortGroupRestRepList in project coprhd-controller by CoprHD.

the class BlockProvider method getCurrentExportPortGroups.

@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathStorageSystem", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI storageSystemId, URI varrayId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemId, null, null, false);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 2 with StoragePortGroupRestRepList

use of com.emc.storageos.model.portgroup.StoragePortGroupRestRepList in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPortGroups.

@Asset("exportChangePortGroup")
@AssetDependencies({ "host", "exportPathStorageSystem", "exportPathVirtualArray", "exportCurrentPortGroup" })
public List<AssetOption> getExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI storageSystemId, URI varrayId, URI exportCurrentPortGroupId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(varrayId, null, storageSystemId, null, null, true);
        // Get a handle of the actual port group list
        List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
        // Filter out the current port group as we do not want the user to see this an a valid option
        ResourceFilter<StoragePortGroupRestRep> filterExistingPG = new DefaultResourceFilter<StoragePortGroupRestRep>() {

            @Override
            public boolean accept(StoragePortGroupRestRep pg) {
                return !pg.getId().equals(exportCurrentPortGroupId);
            }
        };
        ResourceUtils.applyFilter(portGroups, filterExistingPG);
        return createPortGroupOptions(portGroups);
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with StoragePortGroupRestRepList

use of com.emc.storageos.model.portgroup.StoragePortGroupRestRepList in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumeForComputePortGroups.

@Asset("exportVolumeForComputePortGroups")
@AssetDependencies({ "blockVirtualArray", "blockVirtualPool", "project" })
public List<AssetOption> getExportVolumeForComputePortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, null, null, vpoolId, null, true);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with StoragePortGroupRestRepList

use of com.emc.storageos.model.portgroup.StoragePortGroupRestRepList in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPathPorts.

@Asset("exportPathPorts")
@AssetDependencies({ "exportPathVirtualArray", "exportPathStorageSystem", "exportPathExport" })
public List<AssetOption> getExportPathPorts(AssetOptionsContext ctx, URI vArrayId, URI storageSystemId, URI exportId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    // Get all the PGs for the varray/storage system/EG combo then check to
    // see if there are any non-mutable PGs;
    // if there are the storage ports displayed to the user would be limited
    // to just those ones.
    StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(vArrayId, exportId, storageSystemId, null, null, false);
    // Keep a list of ports from the non-mutable PGs. This could remain
    // empty if there are no PGs or none that are non-mutable.
    List<URI> nonMutablePGPortURIs = new ArrayList<URI>();
    if (portGroupsRestRep != null) {
        // Drill down to get the PG and the storage ports
        List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
        if (!CollectionUtils.isEmpty(portGroups)) {
            for (StoragePortGroupRestRep pg : portGroups) {
                // Check to see if the PG is non-mutable
                if (!pg.getMutable()) {
                    // Keep track of these storage ports, they will be used
                    // to filter out
                    // other storage ports.
                    StoragePortList pgPortsList = pg.getStoragePorts();
                    List<NamedRelatedResourceRep> pgPorts = pgPortsList.getPorts();
                    for (NamedRelatedResourceRep pgPort : pgPorts) {
                        nonMutablePGPortURIs.add(pgPort.getId());
                    }
                }
            }
        }
    }
    List<StoragePortRestRep> ports = client.storagePorts().getByVirtualArray(vArrayId);
    for (StoragePortRestRep port : ports) {
        // Check to see if this port needs to be filtered out.
        boolean filterOutPortBasedOnPG = (!nonMutablePGPortURIs.isEmpty()) ? !nonMutablePGPortURIs.contains(port.getId()) : false;
        if (!filterOutPortBasedOnPG) {
            if (port.getPortType().equals(StoragePort.PortType.frontend.toString()) && port.getStorageDevice().getId().equals(storageSystemId) && port.getOperationalStatus().equals(StoragePort.OperationalStatus.OK.toString())) {
                if (port.getNetwork() != null) {
                    String portPercentBusy = (port.getPortPercentBusy() != null) ? String.valueOf(Math.round(port.getPortPercentBusy() * 100 / 100)) + "%" : "N/A";
                    String networkName = client.networks().get(port.getNetwork().getId()).getName();
                    String label = getMessage("exportPathAdjustment.ports", port.getPortName(), networkName, port.getPortNetworkId(), portPercentBusy);
                    options.add(new AssetOption(port.getId(), label));
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) StoragePortList(com.emc.storageos.model.ports.StoragePortList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with StoragePortGroupRestRepList

use of com.emc.storageos.model.portgroup.StoragePortGroupRestRepList in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumeForHostPortGroups.

@Asset("exportVolumeForHostPortGroups")
@AssetDependencies({ "virtualArray", "blockVirtualPool", "host", "project" })
public List<AssetOption> getExportVolumeForHostPortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI hostOrClusterId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, vArrayId, client);
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, (export != null ? export.getId() : null), null, vpoolId, null, true);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)9 Asset (com.emc.sa.asset.annotation.Asset)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 URI (java.net.URI)5 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)4 HashSet (java.util.HashSet)4 StoragePortGroupRestRep (com.emc.storageos.model.portgroup.StoragePortGroupRestRep)3 ArrayList (java.util.ArrayList)2 MapStoragePortGroup (com.emc.storageos.api.mapper.functions.MapStoragePortGroup)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 StoragePortGroupComparator (com.emc.storageos.api.service.impl.resource.utils.StoragePortGroupComparator)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 ExportMask (com.emc.storageos.db.client.model.ExportMask)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1