use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdatePortAssociationsProcess.
/**
* This method is responsible for
* 1. Update pools to virtual arrays & system to virtual arrays in vplex case
* 2. Run implicit Pool Matcher
* 3. Run RP Connectivity Process
*
* @param ports
* @param remPorts
* @param dbClient
* @param coordinator
* @throws IOException
*/
public static void runUpdatePortAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient, CoordinatorClient coordinator, List<StoragePool> pools) {
try {
if (null == pools) {
pools = new ArrayList<StoragePool>();
}
if (null == ports) {
ports = new ArrayList<StoragePort>();
}
if (null != remPorts) {
ports.addAll(remPorts);
}
// for better reading, added a method to group Ports by Network
Map<NetworkLite, List<StoragePort>> portsByNetwork = groupPortsByNetwork(ports, dbClient);
if (!portsByNetwork.isEmpty()) {
updatePortAssociations(ports, portsByNetwork, dbClient);
// if any ports are associated with network, then add pools to existing list and run matching pools
Set<URI> poolUris = getStoragePoolIds(pools);
List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(dbClient, ports, remPorts);
for (StoragePool pool : modifiedPools) {
if (!poolUris.contains(pool.getId())) {
pools.add(pool);
}
}
}
StringBuffer errorMessage = new StringBuffer();
// Match the VPools to the StoragePools
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(pools, dbClient, coordinator, errorMessage);
// get all the system that were affected and update their virtual
// arrays
HashSet<URI> systemsToProcess = StoragePoolAssociationHelper.getStorageSytemsFromPorts(ports, remPorts);
// Now that pools have changed varrays, we need to update RP systems
ConnectivityUtil.updateRpSystemsConnectivity(systemsToProcess, dbClient);
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method queryRegisteredResource.
/**
* Gets the storage pool with the passed id from the database.
*
* @param id the URN of a ViPR storage pool.
*
* @return A reference to the registered StoragePool.
*
* @throws BadRequestException When the storage pool is not registered.
*/
protected StoragePool queryRegisteredResource(URI id) {
ArgValidator.checkUri(id);
StoragePool pool = _dbClient.queryObject(StoragePool.class, id);
ArgValidator.checkEntityNotNull(pool, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.REGISTERED.toString().equalsIgnoreCase(pool.getRegistrationStatus())) {
throw APIException.badRequests.resourceNotRegistered(StoragePool.class.getSimpleName(), id);
}
return pool;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method queryBulkResourceReps.
@Override
public StoragePoolBulkRep queryBulkResourceReps(List<URI> ids) {
Iterator<StoragePool> _dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
return new StoragePoolBulkRep(BulkList.wrapping(_dbIterator, new Function<StoragePool, StoragePoolRestRep>() {
@Override
public StoragePoolRestRep apply(StoragePool storagePool) {
StoragePoolRestRep restRep = toStoragePoolRep(storagePool, _dbClient, _coordinator);
restRep.setNumResources(getNumResources(storagePool, _dbClient));
return restRep;
}
}));
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePortService method updateStoragePort.
/**
* Updates Network for the storage port with the passed
* id and/or updates the virtual arrays to which the storage
* port is assigned.
* <p>
* A port's network is used to determine to which initiators the port can be exported. It also determines the port's virtual arrays when
* the port is not explicitly assigned to virtual arrays ( see {@link StoragePort#getAssignedVirtualArrays()}). In this case the port's
* virtual arrays are the same as its networks virtual arrays (see {@link StoragePort#getConnectedVirtualArrays()}). Implicit virtual
* arrays cannot be removed, they can only be overridden by an explicit assignment or automatically unassigned when the network is
* unassigned from a virtual array. A port's effective virtual array assignment is {@link StoragePort#getTaggedVirtualArrays()}).
* <p>
* A port can be explicitly assigned to virtual arrays and this overrides the implicit assignment resulting from the network
* association. If the explicit assignment is removed, the implicit assignment becomes effective again.
* <p>
* Managing ports virtual array assignments requires planning. In general, networks need not to be assigned to virtual arrays unless
* implicit assignments of ports are desired.
*
* @param id the URN of a ViPR storage port.
* @param storagePortUpdates Specifies the updates to be made to the storage
* port
*
* @brief Update storage port network and/or virtual array assignments.
* @return A StoragePortRestRep specifying the updated storage port info.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StoragePortRestRep updateStoragePort(@PathParam("id") URI id, StoragePortUpdate storagePortUpdates) {
// Get the storage port with the passed id.
ArgValidator.checkFieldUriType(id, StoragePort.class, "id");
StoragePort storagePort = queryResource(id);
_log.info("Update called for storage port {}", id);
// If the port is a VPLEX, then before any changes are
// made for the port, get the storage pools for the systems
// connected to the VPLEX. These pools and the vpools they
// match may be impacted by the change to the VPLEX storage
// port. We must get these ports now before any changes are
// persisted for the port as the connected systems may
// change and we would not get all potentially impacted pools.
List<StoragePool> modifiedPools = null;
URI systemURI = storagePort.getStorageDevice();
StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
if (DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType())) {
modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, Arrays.asList(storagePort), null, true);
}
// Get the old network as part of storage port.
URI oldNetworkId = storagePort.getNetwork();
// Update the storage port network assignment.
URI newNetworkId = storagePortUpdates.getNetwork();
_log.info("Checking for updates to storage port network.");
boolean networkUpdated = updateStoragePortNetwork(storagePort, newNetworkId);
if (networkUpdated) {
_log.info("Storage port network has been modified.");
// No need to update pool connectivity because the call to network service handles that
// Get the updated reference.
storagePort = queryResource(id);
}
// Update the storage port virtual array assignments.
_log.info("Checking for updates to storage port virtual array assignments.");
boolean virtualArraysUpdated = updateStoragePortVirtualArrays(storagePort, storagePortUpdates.getVarrayChanges());
/**
* This is applicable only for Cinder Storage System's port
* as currently there is no API to discover it from Cinder.
* So, it requires user to update the value for provisioning operations.
*/
boolean portNetworkIdUpdated = updatePortNetworkId(storagePort, storagePortUpdates.getPortNetworkId());
// associations when a storage port is modified.
if (DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType())) {
List<StoragePool> pools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, Arrays.asList(storagePort), null, true);
if ((modifiedPools == null) || (modifiedPools.isEmpty())) {
modifiedPools = pools;
} else {
List<StoragePool> poolsToAdd = new ArrayList<StoragePool>();
for (StoragePool pool : pools) {
URI poolURI = pool.getId();
boolean poolFound = false;
for (StoragePool modifiedPool : modifiedPools) {
if (poolURI.equals(modifiedPool.getId())) {
poolFound = true;
break;
}
}
if (!poolFound) {
poolsToAdd.add(pool);
}
}
modifiedPools.addAll(poolsToAdd);
}
}
if (networkUpdated || portNetworkIdUpdated) {
_log.info("Storage port was moved to other network.");
// this method runs standard procedure for poolmatcher, rp connectivity
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(Collections.singleton(storagePort), null, _dbClient, _coordinator, modifiedPools);
} else if (virtualArraysUpdated) {
_log.info("Storage port virtual arrays have been modified.");
// this method runs optimized procedure for poolmatcher, rp connectivity
StoragePortAssociationHelper.runUpdatePortAssociationsProcessForVArrayChange(storagePort, _dbClient, _coordinator, modifiedPools, storagePortUpdates.getVarrayChanges());
}
// Update the virtual nas virtual arrays with network virtual arrays!!!
if (DiscoveredDataObject.Type.vnxfile.name().equals(system.getSystemType()) || DiscoveredDataObject.Type.isilon.name().equals(system.getSystemType())) {
Network newNetwork = null;
boolean removePort = false;
if (networkUpdated) {
if (!NullColumnValueGetter.isNullURI(newNetworkId)) {
_log.info("New network {} specified for vNAS storage port ", newNetworkId);
// Validate the new network exists and is active.
newNetwork = _dbClient.queryObject(Network.class, newNetworkId);
} else if (!NullColumnValueGetter.isNullURI(oldNetworkId)) {
_log.info("Removing network {} from vNAS storage port ", oldNetworkId);
// Validate the new network exists and is active.
newNetwork = _dbClient.queryObject(Network.class, oldNetworkId);
removePort = true;
}
// Update the virtual nas virtual array assignments.
_log.info("Checking for updates to virtual nas virtual array assignments.");
boolean vNasVirtualArraysUpdated = updatevNasVirtualArrays(storagePort, newNetwork, storagePortUpdates.getVarrayChanges(), removePort);
}
}
// event.
if (networkUpdated || virtualArraysUpdated || portNetworkIdUpdated) {
// Create the audit log entry.
auditOp(OperationTypeEnum.UPDATE_STORAGE_PORT, true, null, storagePort.getLabel(), id.toString());
// Record the storage port update event.
recordStoragePortEvent(OperationTypeEnum.STORAGE_PORT_UPDATE, STORAGEPORT_UPDATED_DESCRIPTION, storagePort.getId());
}
return MapStoragePort.getInstance(_dbClient).toStoragePortRestRep(storagePort);
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageSystemService method registerStorageSystem.
/**
* Allows the user register the storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
*
* @brief Register 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}/register")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StorageSystemRestRep registerStorageSystem(@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 not already registered, register it now.
if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(storageSystem.getRegistrationStatus())) {
storageSystem.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_dbClient.updateObject(storageSystem);
startStorageSystem(storageSystem);
auditOp(OperationTypeEnum.REGISTER_STORAGE_SYSTEM, true, null, storageSystem.getId().toString(), id.toString());
}
// Register all Pools.
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(id), storagePoolURIs);
Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
List<StoragePool> registeredPools = new ArrayList<StoragePool>();
while (storagePoolIter.hasNext()) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, storagePoolIter.next());
if (pool.getInactive() || DiscoveredDataObject.RegistrationStatus.REGISTERED.toString().equals(pool.getRegistrationStatus())) {
continue;
}
registerStoragePool(pool);
registeredPools.add(pool);
}
// Register 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.REGISTERED.toString().equals(port.getRegistrationStatus())) {
continue;
}
registerStoragePort(port);
}
StringBuffer errorMessage = new StringBuffer();
// Pool registration also update its varray relationship, so, we should also update vpool to pool relation.
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(registeredPools, _dbClient, _coordinator, errorMessage);
return map(storageSystem);
}
Aggregations