Search in sources :

Example 76 with TaskList

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

the class AbstractBlockServiceApiImpl method createTasksForVolumes.

/**
 * Create a task list for the volumes sent in using the operation CHANGE_BLOCK_VOLUME_VPOOL.
 *
 * @param vPool
 *            virtual pool
 * @param volumes
 *            volumes
 * @param taskId
 *            task ID
 * @return a task list
 */
protected TaskList createTasksForVolumes(VirtualPool vPool, List<Volume> volumes, String taskId) {
    TaskList taskList = new TaskList();
    if (volumes == null) {
        s_logger.info("No volumes were presented to create task objects.  This is a fatal error");
        if (vPool != null && vPool.getLabel() != null) {
            throw APIException.badRequests.noVolumesForTaskObjects(vPool.getLabel(), taskId);
        }
        throw APIException.badRequests.noVolumesForTaskObjects("None Specified", taskId);
    }
    for (Volume volume : volumes) {
        // Associated resources are any resources that are indirectly affected by this
        // volume's virtual pool change. The user should be notified if there are any.
        List<? extends DataObject> associatedResources = getTaskAssociatedResources(volume, vPool);
        List<URI> associatedResourcesURIs = new ArrayList<URI>();
        if (associatedResources != null && !associatedResources.isEmpty()) {
            for (DataObject obj : associatedResources) {
                associatedResourcesURIs.add(obj.getId());
            }
        }
        // New operation
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL);
        op.setDescription("Change vpool operation");
        if (!associatedResourcesURIs.isEmpty()) {
            op.setAssociatedResourcesField(Joiner.on(',').join(associatedResourcesURIs));
        }
        op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, op);
        TaskResourceRep volumeTask = null;
        if (associatedResources != null) {
            // We need the task to reflect that there are associated resources affected by this operation.
            volumeTask = TaskMapper.toTask(volume, associatedResources, taskId, op);
        } else {
            volumeTask = TaskMapper.toTask(volume, taskId, op);
        }
        taskList.getTaskList().add(volumeTask);
    }
    return taskList;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 77 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 78 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 79 with TaskList

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

the class SMISProviderService method scanSMISProviders.

/**
 * Scan all SMI-S providers.
 * <p>
 * The method is deprecated. Use /vdc/storage-providers/scan instead.
 *
 * @brief Scan SMI-S providers
 * @return TasList of all created asynchronous tasks
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
@Path("/scan")
public TaskList scanSMISProviders() {
    TaskList taskList = new TaskList();
    List<StorageProvider> providerList = CustomQueryUtility.getActiveStorageProvidersByInterfaceType(_dbClient, StorageProvider.InterfaceType.smis.name());
    if (providerList == null || providerList.isEmpty()) {
        return taskList;
    }
    BlockController controller = getController(BlockController.class, "vnxblock");
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
    for (StorageProvider smisProvider : providerList) {
        String taskId = UUID.randomUUID().toString();
        tasks.add(new AsyncTask(StorageProvider.class, smisProvider.getId(), taskId));
    }
    taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList;
}
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) 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 80 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)161 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)67 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