Search in sources :

Example 91 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method addJournalCapacity.

/**
 * Add additional journal volume(s) to an existing recoverpoint
 * consistency group copy
 *
 * @param param - journal volume(s) creation parameters
 * @param project - the project
 * @param journalVarray - the virtual array for the journal(s)
 * @param journalVpool - the virtual pool for the journal(s)
 * @param consistencyGroup - the recoverpoint consistency group
 * @param capabilities - parameters for the journal volume(s)
 * @param task - the task identifier
 * @return TaskList
 */
public TaskList addJournalCapacity(VolumeCreate param, Project project, VirtualArray journalVarray, VirtualPool journalVpool, BlockConsistencyGroup consistencyGroup, VirtualPoolCapabilityValuesWrapper capabilities, String task) {
    ProtectionSystem protectionSystem = getBlockScheduler().getCgProtectionSystem(consistencyGroup.getId());
    if (protectionSystem != null) {
        _log.info("Narrowing down placement to use protection system {}, which is currently used by RecoverPoint consistency group {}.", protectionSystem.getLabel(), consistencyGroup);
    } else {
        throw APIException.badRequests.noProtectionSystemAssociatedWithTheCG(consistencyGroup.getId().toString());
    }
    // copy name to add the journal volume to
    String copyName = param.getName();
    // rp cluster internal site name of the copy
    String internalSiteName = null;
    // adding journal to a source copy
    boolean isSource = false;
    // adding journal to a target copy
    boolean isTarget = false;
    // adding journal to a metropoint standby copy
    boolean isMPStandby = copyName.contains("Standby");
    // get the list of source and target volumes; for metropoint, source volumes include both sides of the source
    // metro volume
    List<Volume> sourceVolumes = RPHelper.getCgSourceVolumes(consistencyGroup.getId(), _dbClient);
    if (sourceVolumes.isEmpty()) {
        throw APIException.badRequests.noSourceVolumesInCG(consistencyGroup.getLabel());
    }
    // only need one source volume to set up parameters for the operation
    Volume firstSrc = sourceVolumes.get(0);
    StringSet sourceInternalSiteNames = new StringSet();
    // both the active and the standby copies
    if (RPHelper.isMetroPointVolume(_dbClient, firstSrc)) {
        StringSet associatedVolumes = firstSrc.getAssociatedVolumes();
        if (associatedVolumes != null && !associatedVolumes.isEmpty()) {
            for (String associatedVolumeStr : associatedVolumes) {
                URI associatedVolumeURI = URI.create(associatedVolumeStr);
                Volume associatedVolume = _dbClient.queryObject(Volume.class, associatedVolumeURI);
                sourceInternalSiteNames.add(associatedVolume.getInternalSiteName());
                if (NullColumnValueGetter.isNotNullValue(associatedVolume.getRpCopyName())) {
                    if (associatedVolume.getRpCopyName().equals(copyName)) {
                        isSource = !isMPStandby;
                        internalSiteName = associatedVolume.getInternalSiteName();
                    }
                }
            }
        }
    // determine the internal site name for a source copy
    } else {
        sourceInternalSiteNames.add(firstSrc.getInternalSiteName());
        if (NullColumnValueGetter.isNotNullValue(firstSrc.getRpCopyName())) {
            if (firstSrc.getRpCopyName().equals(copyName)) {
                isSource = true;
                internalSiteName = firstSrc.getInternalSiteName();
            }
        }
    }
    // determine the internal site name for a target copy
    for (String targetURIString : firstSrc.getRpTargets()) {
        Volume tgtVolume = _dbClient.queryObject(Volume.class, URI.create(targetURIString));
        if (NullColumnValueGetter.isNotNullValue(tgtVolume.getRpCopyName()) && tgtVolume.getRpCopyName().equals(copyName)) {
            isTarget = true;
            internalSiteName = tgtVolume.getInternalSiteName();
        }
    }
    if (internalSiteName == null) {
        throw APIException.badRequests.unableToFindTheSpecifiedCopy(copyName);
    }
    // if we're adding volumes to a target, we need to know if it's local or remote
    String targetType = RPHelper.LOCAL;
    int copyType = RecoverPointCGCopyType.PRODUCTION.getCopyNumber();
    if (isTarget) {
        if (sourceInternalSiteNames.contains(internalSiteName)) {
            copyType = RecoverPointCGCopyType.LOCAL.getCopyNumber();
            targetType = RPHelper.LOCAL;
        } else {
            copyType = RecoverPointCGCopyType.REMOTE.getCopyNumber();
            targetType = RPHelper.REMOTE;
        }
    }
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RP_COPY_TYPE, copyType);
    RPProtectionRecommendation rpProtectionRecommendation = new RPProtectionRecommendation();
    rpProtectionRecommendation.setProtectionDevice(protectionSystem.getId());
    RPRecommendation journalRecommendation = getBlockScheduler().buildJournalRecommendation(rpProtectionRecommendation, internalSiteName, new Long(capabilities.getSize()).toString(), journalVarray, journalVpool, protectionSystem, capabilities, capabilities.getResourceCount(), null, false);
    if (journalRecommendation == null) {
        throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
    }
    String copyTypeString = RPHelper.SOURCE;
    if (isSource) {
        rpProtectionRecommendation.setSourceJournalRecommendation(journalRecommendation);
    }
    if (isMPStandby) {
        rpProtectionRecommendation.setStandbyJournalRecommendation(journalRecommendation);
        copyTypeString = "standby " + RPHelper.SOURCE;
    }
    if (isTarget) {
        List<RPRecommendation> journalRecommendations = Lists.newArrayList();
        journalRecommendations.add(journalRecommendation);
        rpProtectionRecommendation.setTargetJournalRecommendations(journalRecommendations);
        copyTypeString = targetType + " " + RPHelper.TARGET;
    }
    List<Recommendation> recommendations = Lists.newArrayList();
    recommendations.add(rpProtectionRecommendation);
    // need to set the journal copy name to something unique
    param.setName(copyName + "_" + task);
    _log.info("Request to add journal capacity to {} copy {}", copyTypeString, copyName);
    _log.info("Copy {} is protected by RP Site {}", copyName, internalSiteName);
    TaskList taskList = new TaskList();
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    return this.createVolumes(param, project, journalVarray, journalVpool, recommendationMap, taskList, task, capabilities);
}
Also used : VpoolUse(com.emc.storageos.api.service.impl.placement.VpoolUse) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) Volume(com.emc.storageos.db.client.model.Volume) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) StringSet(com.emc.storageos.db.client.model.StringSet) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List)

Example 92 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method createSnapshot.

/**
 * Uses the appropriate controller to create the snapshots.
 *
 * @param reqVolume The volume from the snapshot request.
 * @param snapshotURIs The URIs of the prepared snapshots.
 * @param snapshotType The snapshot technology type.
 * @param createInactive true if the snapshots should be created but not
 *            activated, false otherwise.
 * @param readOnly true if the snapshot should be read only, false otherwise
 * @param taskId The unique task identifier.
 */
@Override
public void createSnapshot(Volume reqVolume, List<URI> snapshotURIs, String snapshotType, Boolean createInactive, Boolean readOnly, String taskId) {
    boolean vplex = RPHelper.isVPlexVolume(reqVolume, _dbClient);
    ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, reqVolume.getProtectionController());
    URI storageControllerURI = null;
    if (vplex) {
        Volume backendVolume = vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(reqVolume);
        storageControllerURI = backendVolume.getStorageController();
    } else {
        storageControllerURI = reqVolume.getStorageController();
    }
    if (reqVolume.getProtectionController() != null && (snapshotType.equalsIgnoreCase(BlockSnapshot.TechnologyType.RP.toString()) || reqVolume.getPersonality().equals(Volume.PersonalityTypes.TARGET.toString()))) {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageControllerURI);
        RPController controller = getController(RPController.class, protectionSystem.getSystemType());
        controller.createSnapshot(protectionSystem.getId(), storageSystem.getId(), snapshotURIs, createInactive, readOnly, taskId);
    } else {
        if (vplex) {
            super.createSnapshot(vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(reqVolume), snapshotURIs, snapshotType, createInactive, readOnly, taskId);
        } else {
            super.createSnapshot(reqVolume, snapshotURIs, snapshotType, createInactive, readOnly, taskId);
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 93 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method getStorageSystemConnectivity.

@Override
public StorageSystemConnectivityList getStorageSystemConnectivity(StorageSystem system) {
    _log.debug("getStorageSystemConnectivity START");
    // Connectivity list to return
    StorageSystemConnectivityList connectivityList = new StorageSystemConnectivityList();
    // Set used to ensure unique values are added to the connectivity list
    Set<String> existing = new HashSet<String>();
    // Get all the RPSiteArrays that contain this Storage System
    List<RPSiteArray> rpSiteArrays = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, RPSiteArray.class, AlternateIdConstraint.Factory.getConstraint(RPSiteArray.class, "storageSystem", system.getId().toString()));
    Map<URI, ProtectionSystem> protSysMap = new HashMap<URI, ProtectionSystem>();
    Map<String, StorageSystem> storageSystemBySerialNumber = new HashMap<String, StorageSystem>();
    // For each of the RPSiteArrays get the Protection System
    for (RPSiteArray rpSiteArray : rpSiteArrays) {
        if ((rpSiteArray.getRpProtectionSystem() != null)) {
            ProtectionSystem protectionSystem = protSysMap.get(rpSiteArray.getRpProtectionSystem());
            if (protectionSystem == null) {
                protectionSystem = _dbClient.queryObject(ProtectionSystem.class, rpSiteArray.getRpProtectionSystem());
                protSysMap.put(protectionSystem.getId(), protectionSystem);
            }
            // connectivity response list. Only store unique responses.
            for (String associatedStorageSystemStr : protectionSystem.getAssociatedStorageSystems()) {
                String associatedStorageSystemSerialNumber = ProtectionSystem.getAssociatedStorageSystemSerialNumber(associatedStorageSystemStr);
                StorageSystem associatedStorageSystem = storageSystemBySerialNumber.get(associatedStorageSystemSerialNumber);
                if (associatedStorageSystem == null) {
                    URI associatedStorageSystemURI = ConnectivityUtil.findStorageSystemBySerialNumber(associatedStorageSystemSerialNumber, _dbClient, StorageSystemType.BLOCK);
                    associatedStorageSystem = _dbClient.queryObject(StorageSystem.class, associatedStorageSystemURI);
                    if (associatedStorageSystem == null || associatedStorageSystem.getInactive()) {
                        continue;
                    }
                    storageSystemBySerialNumber.put(associatedStorageSystemSerialNumber, associatedStorageSystem);
                }
                if (ConnectivityUtil.isAVPlex(associatedStorageSystem)) {
                    continue;
                }
                StorageSystemConnectivityRestRep connection = new StorageSystemConnectivityRestRep();
                connection.getConnectionTypes().add(ProtectionSystem._RP);
                connection.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, rpSiteArray.getRpProtectionSystem(), protectionSystem.getLabel()));
                connection.setStorageSystem(toNamedRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, associatedStorageSystem.getId(), associatedStorageSystem.getSerialNumber()));
                // The key is a transient unique ID, since none of the actual fields guarantee uniqueness.
                // We use this to make sure we don't add the same storage system more than once for the same
                // protection system and connection type.
                String key = connection.getProtectionSystem().toString() + connection.getConnectionTypes() + connection.getStorageSystem().toString();
                if (!existing.contains(key)) {
                    existing.add(key);
                    connectivityList.getConnections().add(connection);
                }
            }
        }
    }
    _log.debug("getStorageSystemConnectivity END");
    return connectivityList;
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) StorageSystemConnectivityRestRep(com.emc.storageos.model.systems.StorageSystemConnectivityRestRep) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 94 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class ProtectionSystemService method discoverProtectionSystem.

/**
 * Allows the user to manually discover the registered protection system with
 * the passed id.
 *
 * @param id the URN of a ViPR protection system.
 * @QueryParam namespace
 *             ProtectionSystem Auto Discovery is grouped into multiple namespaces.
 *             Namespace is used to discover specific parts of Storage System.
 *
 *             Possible Values :
 *             UNMANAGED_CGS
 *             ALL
 *
 *             UNMANAGED_CGS will discover all the consistency groups which are present in the
 *             Protection System (RPA).
 *
 * @brief Discover protection system
 * @throws ControllerException When an error occurs discovering the protection
 *             system.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/discover")
public TaskResourceRep discoverProtectionSystem(@PathParam("id") URI id, @QueryParam("namespace") String namespace) {
    ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, id);
    ArgValidator.checkEntity(protectionSystem, id, isIdEmbeddedInURL(id), true);
    // If Namespace is empty or null set it to ALL as default
    if (namespace == null || namespace.trim().length() < 1) {
        namespace = Discovery_Namespaces.ALL.toString();
    }
    if (!validateNameSpace(namespace)) {
        throw APIException.badRequests.invalidParameterProtectionSystemNamespace(namespace);
    }
    String deviceType = protectionSystem.getSystemType();
    ProtectionController controller = getController(RPController.class, deviceType);
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(ProtectionSystem.class, protectionSystem.getId(), taskId, namespace));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().listIterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) MapProtectionSystem(com.emc.storageos.api.mapper.functions.MapProtectionSystem) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 95 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class RPCommunicationInterface method discoverCluster.

private void discoverCluster(ProtectionSystem protectionSystem) {
    URI protectionSystemURI = protectionSystem.getId();
    _log.info("discoverCluster information for protection system {} - start", protectionSystemURI);
    // Get the rp system's array mappings from the RP client
    // TODO: Other methods do their BL in here. This one seems to do all of its BL up in the bios method.
    BiosCommandResult result = discoverRPSystem(protectionSystem);
    if (result.getCommandSuccess()) {
        _log.info("discoverCluster information for protection system {} - successful", protectionSystemURI);
        ProtectionSystem system = (ProtectionSystem) result.getObjectList().get(0);
        // Look to see if it's a duplicate of another entry.
        URIQueryResultList list = new URIQueryResultList();
        // check for duplicate ProtectionSystem.
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getProtectionSystemByNativeGuidConstraint(system.getNativeGuid()), list);
        for (URI systemID : list) {
            if (!systemID.equals(system.getId())) {
                ProtectionSystem persistedSystem = _dbClient.queryObject(ProtectionSystem.class, systemID);
                if ((persistedSystem != null) && (!persistedSystem.getInactive())) {
                    // The new system violates constraints that it can not contain IP addresses of other protection systems.
                    // This is usually caught much much higher, however in the case where discover catches it, we need to
                    // mark this object for deletion.
                    // not sure if its necessary to mark it as unregistered
                    _dbClient.persistObject(system);
                    _dbClient.markForDeletion(system);
                    throw DeviceControllerExceptions.recoverpoint.duplicateProtectionSystem(system.getLabel(), system.getId());
                }
            }
        }
        // Persist the fields that you got during discovery
        _dbClient.persistObject(system);
    }
    _log.info("discoverCluster information for protection system {} - complete", protectionSystemURI);
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)120 URI (java.net.URI)57 ArrayList (java.util.ArrayList)52 NamedURI (com.emc.storageos.db.client.model.NamedURI)44 Volume (com.emc.storageos.db.client.model.Volume)44 HashMap (java.util.HashMap)32 StringSet (com.emc.storageos.db.client.model.StringSet)30 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)28 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)25 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)25 ControllerException (com.emc.storageos.volumecontroller.ControllerException)25 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)25 URISyntaxException (java.net.URISyntaxException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)24 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)24 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)24 WorkflowException (com.emc.storageos.workflow.WorkflowException)24 Test (org.junit.Test)24 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)23 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)23