Search in sources :

Example 6 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class ProtectionSystemService method updateProtectionSystem.

/**
 * Allows the user to update credentials for a manually created protection systems.
 *
 * @param id the URN of a ViPR protection system
 * @param param The protection system details to update.
 *
 * @brief Update protection system credentials
 * @return A ProtectionSystemRestRep reference specifying the protection system
 *         data.
 *
 * @throws InternalException When an error occurs discovering the protection
 *             system.
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateProtectionSystem(@PathParam("id") URI id, ProtectionSystemUpdateRequestParam param) throws InternalException {
    ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, id);
    ArgValidator.checkEntityNotNull(system, id, isIdEmbeddedInURL(id));
    // and Compatibility Status.
    if (!system.getIpAddress().equals(param.getIpAddress())) {
        system.setMajorVersion("");
        system.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.UNKNOWN.toString());
    }
    // Update the IP, port, username, and password with the new incoming values
    system.setIpAddress(param.getIpAddress());
    system.setPortNumber(param.getPortNumber());
    system.setUsername(param.getUserName());
    system.setPassword(param.getPassword());
    // Must force a discover during an update.
    system.setLastDiscoveryRunTime(new Long(0));
    // Make necessary changes to the protection system's cluster->varray assignments
    modifyClusterVarrayAssignments(system, param.getVarrayChanges());
    // Persist the object changes
    _dbClient.persistObject(system);
    auditOp(OperationTypeEnum.UPDATE_PROTECTION_SYSTEM, true, null, system.getId().toString(), param.getIpAddress(), param.getPortNumber(), param.getUserName());
    startProtectionSystem(system);
    // execute discovery
    ProtectionController controller = getController(RPController.class, system.getSystemType());
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(ProtectionSystem.class, system.getId(), taskId));
    TaskList taskList = discoverProtectionSystems(tasks, controller);
    return taskList.getTaskList().iterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) 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) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method upgradeToMetroPointVolume.

/**
 * Upgrade a local block volume to a protected RP volume
 *
 * @param volume the existing volume being protected.
 * @param newVpool the requested virtual pool
 * @param taskId the task identifier
 * @throws InternalException
 */
private void upgradeToMetroPointVolume(Volume volume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    _log.info(String.format("Upgrade [%s] to MetroPoint", volume.getLabel()));
    Project project = _dbClient.queryObject(Project.class, volume.getProject());
    // Now that we have a handle on the current vpool, let's set the new vpool on the volume.
    // The volume will not be persisted just yet but we need to have the new vpool to
    // properly make placement decisions and to add reference to the new vpool to the
    // recommendation objects that will be created.
    URI currentVpool = volume.getVirtualPool();
    volume.setVirtualPool(newVpool.getId());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, newVpool, vpoolChangeParam, null);
    volume.setVirtualPool(currentVpool);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Get the volume's varray
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
    // Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
    VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, newVpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
    TaskList taskList = new TaskList();
    createTaskForVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL, taskList, taskId);
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    createVolumes(param, project, varray, newVpool, recommendationMap, taskList, taskId, capabilities);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolUse(com.emc.storageos.api.service.impl.placement.VpoolUse) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) 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) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 8 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method rpVPlexGroupedMigrations.

/**
 * Calls out to the VPLEX Block Service to group any volumes in RG and migrate
 * the volumes together. If there are any volumes not in RGs they are returned
 * and then added to the single migration container to be migrated later.
 *
 * @param volumesToMigrate All volumes to migrate
 * @param singleMigrations Container to keep track of single migrations
 * @param type Personality type for logging
 * @param logMigrations Log buffer
 * @param taskList List of tasks that will be returned to user
 * @param vpoolChangeParam used to determine if we should suspend on migration commit
 */
private void rpVPlexGroupedMigrations(HashMap<VirtualPool, List<Volume>> volumesToMigrate, Map<Volume, VirtualPool> singleMigrations, String type, StringBuffer logMigrations, TaskList taskList, VirtualPoolChangeParam vpoolChangeParam) {
    for (Map.Entry<VirtualPool, List<Volume>> entry : volumesToMigrate.entrySet()) {
        // List to hold volumes that are grouped by RG and migrated together
        List<Volume> volumesInRG = new ArrayList<Volume>();
        // List to hold volumes that are not grouped by RG and will be migrated as single migrations
        List<Volume> volumesNotInRG = new ArrayList<Volume>();
        VirtualPool migrateToVpool = entry.getKey();
        List<Volume> migrateVolumes = entry.getValue();
        ControllerOperationValuesWrapper operationsWrapper = new ControllerOperationValuesWrapper();
        operationsWrapper.put(ControllerOperationValuesWrapper.MIGRATION_SUSPEND_BEFORE_COMMIT, vpoolChangeParam.getMigrationSuspendBeforeCommit());
        operationsWrapper.put(ControllerOperationValuesWrapper.MIGRATION_SUSPEND_BEFORE_DELETE_SOURCE, vpoolChangeParam.getMigrationSuspendBeforeDeleteSource());
        TaskList taskList2 = vplexBlockServiceApiImpl.migrateVolumesInReplicationGroup(migrateVolumes, migrateToVpool, volumesNotInRG, volumesInRG, operationsWrapper);
        taskList.getTaskList().addAll(taskList2.getTaskList());
        for (Volume volumeInRG : volumesInRG) {
            logMigrations.append(String.format("\tRP+VPLEX migrate %s [%s](%s) to vpool [%s](%s) - GROUPED BY RG\n", type, volumeInRG.getLabel(), volumeInRG.getId(), migrateToVpool.getLabel(), migrateToVpool.getId()));
        }
        for (Volume volumeNotInRG : volumesNotInRG) {
            logMigrations.append(String.format("\tRP+VPLEX migrate %s [%s](%s) to vpool [%s](%s)\n", type, volumeNotInRG.getLabel(), volumeNotInRG.getId(), migrateToVpool.getLabel(), migrateToVpool.getId()));
            singleMigrations.put(volumeNotInRG, migrateToVpool);
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) 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) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Map(java.util.Map) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) ControllerOperationValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.ControllerOperationValuesWrapper)

Example 9 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method changeVolumeVirtualPool.

@Override
public TaskList changeVolumeVirtualPool(List<Volume> volumes, VirtualPool vpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    TaskList taskList = new TaskList();
    StringBuffer notSuppReasonBuff = new StringBuffer();
    notSuppReasonBuff.setLength(0);
    // Get the first volume for the change vpool operation
    Volume firstVolume = volumes.get(0);
    // Get the current vpool from the first volume
    VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, firstVolume.getVirtualPool());
    // Container for RP+VPLEX migrations (if there are any)
    List<RPVPlexMigration> validMigrations = new ArrayList<RPVPlexMigration>();
    if (firstVolume.checkForRp() && firstVolume.checkPersonality(Volume.PersonalityTypes.METADATA)) {
        boolean vplex = RPHelper.isVPlexVolume(firstVolume, _dbClient);
        if (vplex) {
            if (VirtualPoolChangeAnalyzer.vpoolChangeRequiresMigration(currentVpool, vpool)) {
                // Allow the VPLEX Data Migration operation for the RP+VPLEX Journal
                // to proceed via the VPLEX Block Service.
                taskList.getTaskList().addAll(vplexBlockServiceApiImpl.changeVolumeVirtualPool(volumes, vpool, vpoolChangeParam, taskId).getTaskList());
            }
        }
    } else if (firstVolume.checkForRp() && !VirtualPool.vPoolSpecifiesProtection(vpool)) {
        taskList = createTasksForVolumes(vpool, volumes, taskId);
        removeProtection(volumes, vpool, taskId);
    } else if (VirtualPoolChangeAnalyzer.isSupportedRPVPlexMigrationVirtualPoolChange(firstVolume, currentVpool, vpool, _dbClient, notSuppReasonBuff, validMigrations)) {
        taskList.getTaskList().addAll(rpVPlexDataMigration(volumes, vpool, taskId, validMigrations, vpoolChangeParam).getTaskList());
    } else {
        // until CTRL-1347 and CTRL-5609 are fixed.
        if (volumes.size() == 1) {
            taskList = createTasksForVolumes(vpool, volumes, taskId);
            changeVolumeVirtualPool(firstVolume.getStorageController(), firstVolume, vpool, vpoolChangeParam, taskId);
        } else {
            throw APIException.methodNotAllowed.notSupportedWithReason("Multiple volume change virtual pool is currently not supported for RecoverPoint. " + "Please select one volume at a time.");
        }
    }
    return taskList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) RPVPlexMigration(com.emc.storageos.api.service.impl.resource.utils.RPVPlexMigration) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 10 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class SMISProviderService method registerSMISProvider.

/**
 * Register an SMI-S provider to create storage systems of type
 * vnxblock and vmax. This call is not used to create SMI-S
 * providers for vnxfile.
 * <p>
 * The method is deprecated. Use /vdc/storage-providers instead.
 *
 * @param param SMIS-Provider parameters
 * @brief Register SMI-S provider
 * @return Newly registered SMIS-Provider details
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public TaskResourceRep registerSMISProvider(SMISProviderCreateParam param) throws ControllerException {
    String providerKey = param.getIpAddress() + "-" + param.getPortNumber();
    List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerKey);
    if (providers != null && !providers.isEmpty()) {
        throw APIException.badRequests.invalidParameterSMISProviderAlreadyRegistered(providerKey);
    }
    ArgValidator.checkFieldNotEmpty(param.getName(), "name");
    checkForDuplicateName(param.getName(), StorageProvider.class);
    ArgValidator.checkFieldNotEmpty(param.getIpAddress(), "ip_address");
    ArgValidator.checkFieldNotNull(param.getPortNumber(), "port_number");
    ArgValidator.checkFieldNotEmpty(param.getUserName(), "user_name");
    ArgValidator.checkFieldNotEmpty(param.getPassword(), "password");
    ArgValidator.checkFieldNotNull(param.getUseSSL(), "use_ssl");
    ArgValidator.checkFieldRange(param.getPortNumber(), 1, 65535, "port_number");
    StorageProvider smisProvider = new StorageProvider();
    smisProvider.setInterfaceType(StorageProvider.InterfaceType.smis.name());
    smisProvider.setId(URIUtil.createId(StorageProvider.class));
    smisProvider.setLabel(param.getName());
    smisProvider.setIPAddress(param.getIpAddress());
    smisProvider.setPortNumber(param.getPortNumber());
    smisProvider.setUserName(param.getUserName());
    smisProvider.setPassword(param.getPassword());
    smisProvider.setUseSSL(param.getUseSSL());
    smisProvider.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
    _dbClient.createObject(smisProvider);
    auditOp(OperationTypeEnum.REGISTER_SMISPROVIDER, true, null, smisProvider.getLabel(), smisProvider.getId().toString(), smisProvider.getIPAddress(), smisProvider.getPortNumber(), smisProvider.getUserName());
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(StorageProvider.class, smisProvider.getId(), taskId));
    // @TODO revisit this to avoid hard coding.
    BlockController controller = getController(BlockController.class, "vnxblock");
    /**
     * Creates MonitoringJob token for vnxblock/vmax device on zooKeeper queue
     */
    controller.startMonitoring(new AsyncTask(StorageProvider.class, smisProvider.getId(), taskId), StorageSystem.Type.vnxblock);
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().listIterator().next();
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) 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) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

TaskList (com.emc.storageos.model.TaskList)159 ArrayList (java.util.ArrayList)84 URI (java.net.URI)83 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)82 Volume (com.emc.storageos.db.client.model.Volume)66 Produces (javax.ws.rs.Produces)62 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)57 Operation (com.emc.storageos.db.client.model.Operation)55 POST (javax.ws.rs.POST)55 Path (javax.ws.rs.Path)54 Consumes (javax.ws.rs.Consumes)44 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)35 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)33 NamedURI (com.emc.storageos.db.client.model.NamedURI)28 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)27 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)27 Tasks (com.emc.vipr.client.Tasks)27 List (java.util.List)26 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)23