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();
}
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);
}
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);
}
}
}
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;
}
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();
}
Aggregations