Search in sources :

Example 1 with StoragePortList

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

the class ApiTest method updateAllIsilonPorts.

/**
 * Update the discovered Isilon storage ports to set the transport zone.
 *
 * @param isilonDevice : Isilon Device.
 */
private void updateAllIsilonPorts(StorageSystemRestRep isilonDevice) {
    // Register all the discovered storage ports .
    StoragePortList portList = rZAdmin.path(String.format("/vdc/storage-systems/%s/storage-ports", isilonDevice.getId()).toString()).get(StoragePortList.class);
    List<NamedRelatedResourceRep> portURIList = portList.getPorts();
    for (RelatedResourceRep portURI : portURIList) {
        updateStoragePortTZ(isilonDevice.getId(), portURI);
    }
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) StoragePortList(com.emc.storageos.model.ports.StoragePortList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 2 with StoragePortList

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

the class VirtualArrayService method getVirtualArrayStoragePorts.

/**
 * Returns the storage ports for the VirtualArray with the passed id. When
 * the VirtualArray has been explicitly assigned to one or more storage
 * ports, this API will return the ids of those storage ports. VirtualArrays
 * can be explicitly assigned to storage ports when a storage port is
 * created or later by modifying the storage port after it has been created.
 * <p>
 * Whether or not a VirtualArray has been explicitly assigned to any storage ports the VirtualArray may still have implicit associations
 * with one or more storage port due to the VirtualArray's network connectivity. That is, a network resides in a VirtualArray and may
 * contain storage ports. This implies that these storage ports reside in the VirtualArray. If the VirtualArray has no explicit storage
 * port assignments, but does have implicit associations, the API will instead return those storage ports implicitly associated.
 * <p>
 * The API provides the ability to force the return of the list of storage ports implicitly associated with the VirtualArray using the
 * request parameter "network_connectivity". Passing this parameter with a value of "true" will return the ids of the storage ports
 * implicitly associated with the VirtualArray as described.
 *
 * @param id the URN of a ViPR VirtualArray.
 * @param useNetworkConnectivity true to use the network connectivity to
 *            get the list of storage ports implicitly connected to the
 *            VirtualArray.
 *
 * @brief List VirtualArray storage ports
 * @return The ids of the storage ports associated with the VirtualArray.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public StoragePortList getVirtualArrayStoragePorts(@PathParam("id") URI id, @QueryParam("network_connectivity") boolean useNetworkConnectivity) {
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
    // Query the database for the storage ports associated with the
    // VirtualArray. If the request is for storage ports whose
    // association with the VirtualArray is implicit through network
    // connectivity, then return only these storage ports. Otherwise,
    // the result is for storage ports explicitly assigned to the
    // VirtualArray.
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    if (useNetworkConnectivity) {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getImplicitVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
    } else {
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
    }
    // Create and return the result.
    StoragePortList storagePorts = new StoragePortList();
    for (URI uri : storagePortURIs) {
        StoragePort storagePort = _dbClient.queryObject(StoragePort.class, uri);
        if ((storagePort != null) && (RegistrationStatus.REGISTERED.toString().equals(storagePort.getRegistrationStatus())) && DiscoveryStatus.VISIBLE.toString().equals(storagePort.getDiscoveryStatus())) {
            storagePorts.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
        }
    }
    return storagePorts;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with StoragePortList

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

the class StoragePortService method getStoragePorts.

/**
 * Gets the ids and self links for all storage ports.
 *
 * @brief List storage ports
 * @return A StoragePortList reference specifying the ids and self links for
 *         the storage ports.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortList getStoragePorts() {
    StoragePortList storagePorts = new StoragePortList();
    List<URI> ids = _dbClient.queryByType(StoragePort.class, true);
    for (URI id : ids) {
        StoragePort port = _dbClient.queryObject(StoragePort.class, id);
        if ((port != null)) {
            storagePorts.getPorts().add(toNamedRelatedResource(port, port.getNativeGuid()));
        }
    }
    return storagePorts;
}
Also used : MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with StoragePortList

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

the class StorageSystemService method getAllStoragePorts.

/**
 * Get all storage ports for the registered storage system with the passed
 * id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief List storage system storage ports
 * @return A reference to a StoragePortList specifying the id and self link
 *         for each port.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortList getAllStoragePorts(@PathParam("id") URI id) {
    // Make sure the storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    {
        // Update the port metrics calculations. This makes the UI display up-to-date when ports shown.
        URIQueryResultList storagePortURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
        List<StoragePort> storagePorts = _dbClient.queryObject(StoragePort.class, storagePortURIs);
        portMetricsProcessor.computeStoragePortUsage(storagePorts, system, true);
    }
    StoragePortList portList = new StoragePortList();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
    Iterator<URI> storagePortsIter = storagePortURIs.iterator();
    while (storagePortsIter.hasNext()) {
        URI storagePortURI = storagePortsIter.next();
        StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
        if (storagePort != null && !storagePort.getInactive()) {
            portList.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
        }
    }
    return portList;
}
Also used : MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) TaskList(com.emc.storageos.model.TaskList) StorageSystemList(com.emc.storageos.model.systems.StorageSystemList) VirtualNASList(com.emc.storageos.model.vnas.VirtualNASList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedFileSystemList(com.emc.storageos.model.file.UnManagedFileSystemList) ObjectNamespaceList(com.emc.storageos.model.object.ObjectNamespaceList) RDFGroupList(com.emc.storageos.model.rdfgroup.RDFGroupList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with StoragePortList

use of com.emc.storageos.model.ports.StoragePortList 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)

Aggregations

StoragePortList (com.emc.storageos.model.ports.StoragePortList)7 URI (java.net.URI)5 StoragePort (com.emc.storageos.db.client.model.StoragePort)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)3 Path (javax.ws.rs.Path)3 MapStoragePort (com.emc.storageos.api.mapper.functions.MapStoragePort)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 StorageSystemList (com.emc.storageos.model.systems.StorageSystemList)2 ArrayList (java.util.ArrayList)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 MapNetwork (com.emc.storageos.api.mapper.functions.MapNetwork)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 Network (com.emc.storageos.db.client.model.Network)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1