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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations