use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class StorageSystemService method getStoragePort.
/**
* Get information about the storage port with the passed id on the
* registered storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
* @param portId The id of the storage port.
*
* @brief Show storage system storage port
* @return A StoragePortRestRep reference specifying the data for the
* requested port.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports/{portId}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortRestRep getStoragePort(@PathParam("id") URI id, @PathParam("portId") URI portId) {
// Make sure the storage system is registered.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
ArgValidator.checkFieldUriType(portId, StoragePort.class, "portId");
StoragePort port = _dbClient.queryObject(StoragePort.class, portId);
ArgValidator.checkEntity(port, portId, isIdEmbeddedInURL(portId));
return MapStoragePort.getInstance(_dbClient).toStoragePortRestRep(port);
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class StorageSystemService method getStorageSystems.
/**
* Gets the id, name, and self link for all registered storage systems.
*
* @brief List storage systems
* @return A reference to a StorageSystemList.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemList getStorageSystems() {
StorageSystemList systemsList = new StorageSystemList();
List<URI> ids = _dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> iter = _dbClient.queryIterativeObjects(StorageSystem.class, ids);
while (iter.hasNext()) {
systemsList.getStorageSystems().add(toNamedRelatedResource(iter.next()));
}
return systemsList;
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class StorageSystemService method getStorageSystem.
/**
* Get information about the registered storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
*
* @brief Show storage system
* @return A reference to a StorageSystemRestRep
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemRestRep getStorageSystem(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
StorageSystemRestRep restRep = map(system);
restRep.setNumResources(getNumResources(system, _dbClient));
return restRep;
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class InitiatorService method setInitiatorAlias.
/**
* Sets the alias/initiator name for an initiator
* on the Storage System
*
* @param id the URN of a ViPR initiator
* @param aliasSetParam the parameter containing the storage system and alias attributes
* @prereq none
* @brief Set the serial number and alias on this storage system for an initiator
* @return A reference to an InitiatorRestRep representing the Initiator Alias after Set..
* @throws Exception When an error occurs setting the alias on a VMAX Storage System.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/alias")
public InitiatorAliasRestRep setInitiatorAlias(@PathParam("id") URI id, InitiatorAliasSetParam aliasSetParam) {
// Basic Checks
Initiator initiator = queryResource(id);
verifyUserPermisions(initiator);
URI systemURI = aliasSetParam.getSystemURI();
ArgValidator.checkFieldUriType(systemURI, StorageSystem.class, "id");
StorageSystem system = _permissionsHelper.getObjectById(systemURI, StorageSystem.class);
ArgValidator.checkEntity(system, systemURI, isIdEmbeddedInURL(systemURI));
String initiatorAlias = aliasSetParam.getInitiatorAlias();
ArgValidator.checkFieldNotNull(initiatorAlias, "alias");
if (!initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
ArgValidator.checkFieldLengthMaximum(initiatorAlias, ALIAS_MAX_LIMIT, "alias");
} else {
ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[0], ALIAS_MAX_LIMIT, "alias node name");
ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[1], ALIAS_MAX_LIMIT, "alias port name");
}
if (initiatorAlias.matches(ALIAS_ILLEGAL_CHARACTERS)) {
String errMsg = String.format("Supplied Alias: %s has invalid characters", initiatorAlias);
_log.error(errMsg);
throw DeviceControllerException.exceptions.couldNotPerformAliasOperation(errMsg);
}
_log.info("Setting alias- {} for initiator {} on system {}", initiatorAlias, id, systemURI);
if (system != null && StorageSystem.Type.vmax.toString().equalsIgnoreCase(system.getSystemType())) {
BlockController controller = getController(BlockController.class, system.getSystemType());
try {
// Actual Control
controller.setInitiatorAlias(systemURI, id, initiatorAlias);
} catch (Exception e) {
_log.error("Unexpected error: Setting alias failed.", e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
} else {
throw APIException.badRequests.operationNotSupportedForSystemType(ALIAS, system.getSystemType());
}
// Update the Initiator here..
if (initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
// If the Initiator Alias contains the "/" character, the user has supplied
// different node and port names.
initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
} else {
// The user has set the same node and port names.
initiatorAlias = String.format("%s%s%s", initiatorAlias, EMPTY_INITIATOR_ALIAS, initiatorAlias);
initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
}
_dbClient.updateObject(initiator);
return new InitiatorAliasRestRep(system.getSerialNumber(), initiatorAlias);
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class ProtectionSystemService method getConnectivity.
/**
* This method will assemble a connectivity table that expresses all of the storage systems
* that are connected via this protection system. We will mark which RP site each storage
* system is visible on.
*
* @param system protection system
* @return rest response
*/
private ProtectionSystemConnectivityRestRep getConnectivity(ProtectionSystem system) {
ProtectionSystemConnectivityRestRep response = new ProtectionSystemConnectivityRestRep();
// Dig through the RPSiteArray table for now and return connectivity
Map<String, Set<URI>> siteStorageSystemMap = new HashMap<String, Set<URI>>();
// Get the rp system's array mappings from the RP client
URIQueryResultList sitelist = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getRPSiteArrayProtectionSystemConstraint(system.getId().toString()), sitelist);
List<RPSiteArray> rpSiteArrays = new ArrayList<RPSiteArray>();
Iterator<URI> it = sitelist.iterator();
while (it.hasNext()) {
URI rpSiteArrayId = it.next();
RPSiteArray siteArray = _dbClient.queryObject(RPSiteArray.class, rpSiteArrayId);
if (siteArray != null) {
rpSiteArrays.add(siteArray);
}
}
for (RPSiteArray rpSiteArray : rpSiteArrays) {
_log.info("dicoverProtectionSystem(): analyzing rpsitearray: " + rpSiteArray.toString());
if (siteStorageSystemMap.get(rpSiteArray.getRpSiteName()) == null) {
siteStorageSystemMap.put(rpSiteArray.getRpSiteName(), new HashSet<URI>());
}
// Add this storage system associated with this RP Site
siteStorageSystemMap.get(rpSiteArray.getRpSiteName()).add(rpSiteArray.getStorageSystem());
}
// Translate the primitive type into a presentable type
for (String siteId : siteStorageSystemMap.keySet()) {
ProtectionSystemConnectivitySiteRestRep site = new ProtectionSystemConnectivitySiteRestRep();
site.setSiteID(siteId);
Set<URI> addedStorageSystems = new HashSet<URI>();
for (URI storageID : siteStorageSystemMap.get(siteId)) {
if (!addedStorageSystems.contains(storageID)) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageID);
site.getStorageSystems().add(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, storageSystem.getId()));
addedStorageSystems.add(storageID);
}
}
if (response.getProtectionSites() == null) {
response.setProtectionSites(new ArrayList<ProtectionSystemConnectivitySiteRestRep>());
}
response.getProtectionSites().add(site);
}
response.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, system.getId(), system.getLabel()));
return response;
}
Aggregations