Search in sources :

Example 11 with StoragePortRestRep

use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.

the class VirtualArrays method updateStoragePorts.

/**
 * Updates the given storage ports with the virtual array assignment changes.
 *
 * @param ids
 *            the storage port IDs.
 * @param changes
 *            the virtual array changes.
 */
private static void updateStoragePorts(List<URI> ids, VirtualArrayAssignmentChanges changes) {
    if (ids.isEmpty()) {
        return;
    }
    List<StoragePortRestRep> storagePorts = StoragePortUtils.getStoragePorts(ids);
    for (StoragePortRestRep storagePort : storagePorts) {
        StoragePortUpdate update = new StoragePortUpdate();
        update.setVarrayChanges(changes);
        StoragePortUtils.update(storagePort.getId(), update);
    }
}
Also used : StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) StoragePortUpdate(com.emc.storageos.model.ports.StoragePortUpdate)

Example 12 with StoragePortRestRep

use of com.emc.storageos.model.ports.StoragePortRestRep 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 13 with StoragePortRestRep

use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method buildPathOptions.

/* helper for building the list of asset option for affected and removed paths */
private List<AssetOption> buildPathOptions(AssetOptionsContext ctx, List<InitiatorPortMapRestRep> list, String message) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (InitiatorPortMapRestRep ipm : list) {
        InitiatorRestRep initiator = ipm.getInitiator();
        List<NamedRelatedResourceRep> ports = ipm.getStoragePorts();
        String portList = new String(" ");
        List<URI> portURIs = new ArrayList<URI>();
        for (NamedRelatedResourceRep port : ports) {
            StoragePortRestRep p = client.storagePorts().get(port.getId());
            portList += p.getPortName() + " ";
            portURIs.add(port.getId());
        }
        Map<URI, List<URI>> key = new HashMap<URI, List<URI>>();
        key.put(initiator.getId(), portURIs);
        String label = getMessage(message, initiator.getHostName(), initiator.getName(), portList);
        String keyString = EMPTY_STRING;
        try {
            keyString = CatalogSerializationUtils.serializeToString(key);
        } catch (Exception ex) {
        }
        options.add(new AssetOption(keyString, label));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) URI(java.net.URI) InitiatorPortMapRestRep(com.emc.storageos.model.block.export.InitiatorPortMapRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList)

Example 14 with StoragePortRestRep

use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.

the class VirtualArrayProvider method getVirtualArrayForStorageSystem.

protected List<AssetOption> getVirtualArrayForStorageSystem(AssetOptionsContext context, URI storageSystem) {
    ViPRCoreClient client = api(context);
    Set<String> virtualArrayIds = Sets.newHashSet();
    for (StoragePortRestRep storagePortRestRep : client.storagePorts().getByStorageSystem(storageSystem)) {
        virtualArrayIds.addAll(storagePortRestRep.getAssignedVirtualArrays());
        virtualArrayIds.addAll(storagePortRestRep.getConnectedVirtualArrays());
    }
    List<VirtualArrayRestRep> virtualArrays = client.varrays().getByIds(ResourceUtils.uris(virtualArrayIds));
    filterByContextTenant(virtualArrays, client.varrays().getByTenant(context.getTenant()));
    return createBaseResourceOptions(virtualArrays);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep)

Example 15 with StoragePortRestRep

use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.

the class VirtualArrays method addVarrayStorageSystem.

/**
 * Adds all ports of the given storage systems to a virtual array.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param ids
 *            the storage system IDs.
 */
private static void addVarrayStorageSystem(String virtualArrayId, String id) {
    List<URI> storagePorts = Lists.newArrayList();
    URI storageSystemId = uri(id);
    List<StoragePortRestRep> ports = StoragePortUtils.getStoragePortsByStorageSystem(storageSystemId);
    storagePorts.addAll(ResourceUtils.ids(ports));
    if (!storagePorts.isEmpty()) {
        VirtualArrayRestRep virtualArray = getVirtualArray(virtualArrayId);
        updateStoragePorts(storagePorts, addVirtualArray(virtualArray));
    }
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) URI(java.net.URI)

Aggregations

StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)22 URI (java.net.URI)8 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)7 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)5 NetworkRestRep (com.emc.storageos.model.varray.NetworkRestRep)4 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)4 StoragePortInfo (models.datatable.StoragePortDataTable.StoragePortInfo)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 InitiatorRestRep (com.emc.storageos.model.host.InitiatorRestRep)2 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)2 StoragePortList (com.emc.storageos.model.ports.StoragePortList)2 StoragePortUpdate (com.emc.storageos.model.ports.StoragePortUpdate)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 FlashException (controllers.util.FlashException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 EndpointInfo (models.datatable.NetworkEndpointDataTable.EndpointInfo)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 SnapshotList (com.emc.storageos.model.SnapshotList)1