use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class StorageSystemService method deregisterStorageSystem.
/**
* Allows the user register the storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
*
* @brief Deregister storage system
* @return A StorageSystemRestRep reference specifying the data for the
* updated storage system.
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deregister")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StorageSystemRestRep deregisterStorageSystem(@PathParam("id") URI id) throws ControllerException {
// Validate the storage system.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(storageSystem, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(storageSystem.getRegistrationStatus())) {
storageSystem.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(storageSystem);
stopStorageSystem(storageSystem);
}
// Deregister all Pools.
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(id), storagePoolURIs);
Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
List<StoragePool> modifiedPools = new ArrayList<StoragePool>();
while (storagePoolIter.hasNext()) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, storagePoolIter.next());
modifiedPools.add(pool);
if (pool.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(pool.getRegistrationStatus())) {
continue;
}
// Setting status to UNREGISTERED.
pool.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(pool);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_POOL, true, null, id.toString());
}
// Deregister all Ports.
URIQueryResultList storagePortURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
Iterator<URI> storagePortIter = storagePortURIs.iterator();
while (storagePortIter.hasNext()) {
StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortIter.next());
if (port.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(port.getRegistrationStatus())) {
continue;
}
// Setting status to UNREGISTERED.
port.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(port);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_PORT, true, null, port.getLabel(), port.getId().toString());
}
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(modifiedPools, _dbClient, _coordinator, errorMessage);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_SYSTEM, true, null, storageSystem.getId().toString(), id.toString());
return map(storageSystem);
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class StorageSystemService method getAllRAGroups.
/**
* Get All RA Groups
*
* @param id
* @brief List RDF groups names in a storage system
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/rdf-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public RDFGroupList getAllRAGroups(@PathParam("id") URI id) {
// Make sure storage system is registered.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
RDFGroupList rdfGroupList = new RDFGroupList();
URIQueryResultList rdfGroupURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(id), rdfGroupURIs);
Iterator<URI> rdfGroupIter = rdfGroupURIs.iterator();
while (rdfGroupIter.hasNext()) {
URI rdfGroupURI = rdfGroupIter.next();
RemoteDirectorGroup rdfGroup = _dbClient.queryObject(RemoteDirectorGroup.class, rdfGroupURI);
if (rdfGroup != null && !rdfGroup.getInactive()) {
rdfGroupList.getRdfGroups().add(toNamedRelatedResource(rdfGroup, rdfGroup.getNativeGuid()));
}
}
return rdfGroupList;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList 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.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class StorageSystemService method getUnManagedFileSystems.
/**
* List all unmanaged file systems which are available for a storage system.Unmanaged file systems refers to file systems which are
* available within underlying storage systems , but
* still not managed in ViPR.
* As these file systems are not managed in ViPR, there will not be any ViPR specific
* details associated such as, virtual array, virtual pool, or project.
*
* @param id the URN of a ViPR storage system
*
* @prereq none
* @brief List of all unmanaged file systems available for a storage system
* @return UnManagedFileSystemList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/unmanaged/filesystems")
public UnManagedFileSystemList getUnManagedFileSystems(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
UnManagedFileSystemList unManagedFileSystemList = new UnManagedFileSystemList();
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceUnManagedFileSystemConstraint(id), result);
Iterator<UnManagedFileSystem> unmanagedFileSystemItr = _dbClient.queryIterativeObjects(UnManagedFileSystem.class, result, true);
while (unmanagedFileSystemItr.hasNext()) {
UnManagedFileSystem umfs = unmanagedFileSystemItr.next();
unManagedFileSystemList.getUnManagedFileSystem().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_FILESYSTEMS, umfs.getId()));
}
return unManagedFileSystemList;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class StorageSystemService method getAllStoragePortGroups.
/**
* Get all storage port groups for the storage system with the passed id.
*
* @param id
* the URN of a ViPR storage system.
*
* @brief List storage system storage port groups
* @return A reference to a StoragePortGroupList specifying the id and self link
* for each port group.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortGroupList getAllStoragePortGroups(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
URIQueryResultList portGroupURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDevicePortGroupConstraint(id), portGroupURIs);
StoragePortGroupList portList = new StoragePortGroupList();
Iterator<URI> portGroupIter = portGroupURIs.iterator();
while (portGroupIter.hasNext()) {
URI pgURI = portGroupIter.next();
StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, pgURI);
if (portGroup != null && !portGroup.getInactive() && !portGroup.checkInternalFlags(Flag.INTERNAL_OBJECT)) {
portList.getPortGroups().add(toNamedRelatedResource(portGroup, portGroup.getNativeGuid()));
}
}
return portList;
}
Aggregations