use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class StorageProviderService method scanStorageProviders.
/**
* Scan all Storage providers.
*
* @brief Scan Storage 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, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/scan")
public TaskList scanStorageProviders() {
TaskList taskList = new TaskList();
List<URI> providerURIList = _dbClient.queryByType(StorageProvider.class, true);
/**
* TODO needs to remove hard code device type to fetch the controller instance
*/
BlockController controller = getController(BlockController.class, "vnxblock");
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
if (providerURIList != null) {
for (URI providerURI : providerURIList) {
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageProvider.class, providerURI, taskId));
}
taskList = scheduler.scheduleAsyncTasks(tasks);
}
return taskList;
}
use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class StorageProviderService method addStorageSystem.
/**
* Allows the user to add a storage system and rescans the provider.
* After that corresponding provider should be able to be rescanned and add this system back to the list of managed systems.
*
* @param id id the URN of a ViPR Storage provider
* @param param The storage system details.
*
* @brief Add a new storage system and rescan the provider.
* @return An asynchronous task corresponding to the scan job scheduled for the provider.
*
* @throws BadRequestException When the system type is not valid or a
* storage system with the same native guid already exists.
* @throws com.emc.storageos.db.exceptions.DatabaseException When an error occurs querying the database.
* @throws ControllerException When an error occurs discovering the storage
* system.
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
@Path("/{id}/storage-systems")
public TaskResourceRep addStorageSystem(@PathParam("id") URI id, StorageSystemProviderRequestParam param) throws ControllerException {
TaskResourceRep taskRep;
URIQueryResultList list = new URIQueryResultList();
ArgValidator.checkFieldNotEmpty(param.getSystemType(), "system_type");
if (!StorageSystem.Type.isProviderStorageSystem(param.getSystemType())) {
throw APIException.badRequests.cannotAddStorageSystemTypeToStorageProvider(param.getSystemType());
}
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id);
ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id));
ArgValidator.checkFieldNotEmpty(param.getSerialNumber(), "serialNumber");
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(param.getSystemType(), param.getSerialNumber());
// check for duplicate StorageSystem.
List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid);
if (systems != null && !systems.isEmpty()) {
throw APIException.badRequests.invalidParameterProviderStorageSystemAlreadyExists("nativeGuid", nativeGuid);
}
int cleared = DecommissionedResource.removeDecommissionedFlag(_dbClient, nativeGuid, StorageSystem.class);
if (cleared == 0) {
log.info("Cleared {} decommissioned systems", cleared);
} else {
log.info("Did not find any decommissioned systems to clear. Continue to scan.");
}
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageProvider.class, provider.getId(), taskId));
BlockController controller = getController(BlockController.class, provider.getInterfaceType());
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList.getTaskList().listIterator().next();
}
use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class StorageSystemService method discoverSystem.
/**
* Allows the user to manually discover the registered storage system with
* the passed id.
*
* @param id the URN of a ViPR storage system.
* @QueryParam namespace
* StorageSystem Auto Discovery is grouped into multiple namespaces.
* Namespace is used to discover specific parts of Storage System.
*
* Possible Values :
* UNMANAGED_VOLUMES
* UNMANAGED_FIESYSTEMS
* ALL
*
* UNMANAGED_VOLUMES will discover all the Volumes which are present in the Array,
* and only supported on vmax and vnxblock.
* Using UNMANAGED_VOLUMES Namespace in other system types would result in error.
*
* UNMANAGED_FILESYSTEMS will discover all the fileystems which are present in the Array,
* and only supported on netapp.
*
* Using UNMANAGED_FILESYSTEMS Namespace in other system types would result in error.
*
* @brief Discover storage system
* @throws ControllerException When an error occurs discovering the storage
* 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 discoverSystem(@PathParam("id") URI id, @QueryParam("namespace") String namespace) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(storageSystem, id, isIdEmbeddedInURL(id), true);
String deviceType = storageSystem.getSystemType();
// 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, storageSystem)) {
throw APIException.badRequests.invalidParameterStorageSystemNamespace(namespace);
}
// Trigger unmanaged resource discovery only when system is compatible.
if ((Discovery_Namespaces.UNMANAGED_VOLUMES.name().equalsIgnoreCase(namespace) || Discovery_Namespaces.BLOCK_SNAPSHOTS.name().equalsIgnoreCase(namespace) || Discovery_Namespaces.UNMANAGED_FILESYSTEMS.name().equalsIgnoreCase(namespace)) && !CompatibilityStatus.COMPATIBLE.name().equalsIgnoreCase(storageSystem.getCompatibilityStatus())) {
throw APIException.badRequests.cannotDiscoverUnmanagedResourcesForUnsupportedSystem();
}
BlockController controller = getController(BlockController.class, deviceType);
DiscoveredObjectTaskScheduler scheduler = null;
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
if (Discovery_Namespaces.ARRAY_AFFINITY.name().equalsIgnoreCase(namespace)) {
if (!storageSystem.deviceIsType(Type.vmax) && !storageSystem.deviceIsType(Type.vnxblock) && !storageSystem.deviceIsType(Type.xtremio) && !storageSystem.deviceIsType(Type.unity)) {
throw APIException.badRequests.cannotDiscoverArrayAffinityForUnsupportedSystem(storageSystem.getSystemType());
}
scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ArrayAffinityJobExec(controller));
URI providerURI = storageSystem.getActiveProviderURI();
List<URI> systemIds = new ArrayList<URI>();
systemIds.add(id);
if (!NullColumnValueGetter.isNullURI(providerURI) && (storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.vnxblock) || storageSystem.deviceIsType(Type.xtremio))) {
List<URI> sysURIs = _dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> storageSystems = _dbClient.queryIterativeObjects(StorageSystem.class, sysURIs);
while (storageSystems.hasNext()) {
StorageSystem systemObj = storageSystems.next();
if (systemObj == null) {
_log.warn("StorageSystem is no longer in the DB. It could have been deleted or decommissioned");
continue;
}
if (providerURI.equals(systemObj.getActiveProviderURI()) && !id.equals(systemObj.getId())) {
systemIds.add(systemObj.getId());
}
}
}
tasks.add(new ArrayAffinityAsyncTask(StorageSystem.class, systemIds, null, taskId));
} else {
scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
tasks.add(new AsyncTask(StorageSystem.class, storageSystem.getId(), taskId, namespace));
}
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList.getTaskList().listIterator().next();
}
use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class StorageSystemService method createStorageSystem.
/**
* Manually create a storage system that cannot be discovered using a SMI-S provider. By
* default the storage system will be auto-registered upon its creation.
* For the Block type storage system, the method would add a new system to the SMIS provider.
* The SMIS provider field in the input parameter file is ignored for file type storage systems
* (VNX file and Isilon )
*
* @param param The storage system details.
* @prereq none
* @brief Create storage system
* @return An asynchronous task corresponding to the discovery job scheduled for the new Storage System.
*
* @throws BadRequestException When the system type is not valid or a
* storage system with the same native guid already exists.
* @throws DatabaseException When an error occurs querying the database.
* @throws ControllerException When an error occurs discovering the storage
* 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 })
public TaskResourceRep createStorageSystem(StorageSystemRequestParam param) throws Exception {
if (!isControllerServiceOnline()) {
_log.error("Controller services are not started yet");
throw APIException.serviceUnavailable.controllerServiceUnavailable();
}
ArgValidator.checkFieldNotEmpty(param.getSystemType(), "system_type");
if (!StorageSystem.Type.isDriverManagedStorageSystem(param.getSystemType())) {
ArgValidator.checkFieldValueFromSystemType(param.getSystemType(), "system_type", Arrays.asList(StorageSystem.Type.vnxfile, StorageSystem.Type.isilon, StorageSystem.Type.rp, StorageSystem.Type.netapp, StorageSystem.Type.netappc, StorageSystem.Type.vnxe, StorageSystem.Type.xtremio, StorageSystem.Type.ecs, StorageSystem.Type.unity, StorageSystem.Type.hp3par));
}
StorageSystem.Type systemType = StorageSystem.Type.valueOf(param.getSystemType());
if (systemType.equals(StorageSystem.Type.vnxfile)) {
validateVNXFileSMISProviderMandatoryDetails(param);
}
ArgValidator.checkFieldNotEmpty(param.getName(), "name");
checkForDuplicateName(param.getName(), StorageSystem.class);
if (systemType.equals(StorageSystem.Type.isilon) || systemType.equals(StorageSystem.Type.unity) || systemType.equals(StorageSystem.Type.vnxfile)) {
ArgValidator.checkFieldValidInetAddress(param.getIpAddress(), "ip_address");
} else {
ArgValidator.checkFieldValidIP(param.getIpAddress(), "ip_address");
}
ArgValidator.checkFieldNotNull(param.getPortNumber(), "port_number");
ArgValidator.checkFieldRange(param.getPortNumber(), 1, 65535, "port_number");
validateStorageSystemExists(param.getIpAddress(), param.getPortNumber());
StorageSystem system = prepareStorageSystem(param);
auditOp(OperationTypeEnum.CREATE_STORAGE_SYSTEM, true, null, param.getSerialNumber(), param.getSystemType(), param.getIpAddress(), param.getPortNumber());
startStorageSystem(system);
// Rather if else everywhere some code duplication with object and file
if (StorageSystem.Type.ecs.toString().equals(system.getSystemType())) {
ObjectController controller = getController(ObjectController.class, param.getSystemType());
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageSystem.class, system.getId(), taskId));
TaskList taskList = discoverStorageSystems(tasks, controller);
return taskList.getTaskList().listIterator().next();
} else {
FileController controller = getController(FileController.class, param.getSystemType());
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageSystem.class, system.getId(), taskId));
/**
* Creates MonitoringJob token on ZooKeeper for vnxfile/isilon device.
* Currently we are handling monitoring for vnxfile/vmax/vnxblock/isilon devices.
* We should not create MonitoringJob token for netapp/rp now.
*/
if (StorageSystem.Type.vnxfile.toString().equals(system.getSystemType()) || StorageSystem.Type.isilon.toString().equals(system.getSystemType())) {
controller.startMonitoring(new AsyncTask(StorageSystem.class, system.getId(), taskId), StorageSystem.Type.valueOf(system.getSystemType()));
}
TaskList taskList = discoverStorageSystems(tasks, controller);
return taskList.getTaskList().listIterator().next();
}
}
use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.
the class StorageSystemService method updateStorageSystem.
/**
* Allows the user to update credentials for a manually created storage systems.
* Allows the user to update only the name field for vmax and vnx block systems.
*
* @param id the URN of a ViPR storage system
* @param param The storage system details to update.
*
* @brief Update storage system credentials
* @return A StorageSystemRestRep reference specifying the storage system
* data.
*
* @throws BadRequestException When the system is not valid.
* @throws ControllerException When an error occurs discovering the storage
* 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 updateStorageSystem(@PathParam("id") URI id, StorageSystemUpdateRequestParam param) throws ControllerException {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
StorageSystem.Type systemType = StorageSystem.Type.valueOf(system.getSystemType());
if (param.getName() != null && !param.getName().isEmpty() && !param.getName().equalsIgnoreCase(system.getLabel())) {
checkForDuplicateName(param.getName(), StorageSystem.class);
system.setLabel(param.getName());
}
// If unlimited resources is set to false, then max resources should also be specified. If not specified, throw error
if (null != param.getIsUnlimitedResourcesSet()) {
if (param.getIsUnlimitedResourcesSet()) {
system.setIsResourceLimitSet(false);
} else {
if (null != param.getMaxResources()) {
system.setIsResourceLimitSet(true);
system.setMaxResources(param.getMaxResources());
} else {
throw APIException.badRequests.parameterMaxResourcesMissing();
}
}
} else if (null != param.getMaxResources()) {
system.setMaxResources(param.getMaxResources());
system.setIsResourceLimitSet(true);
}
// create Task with ready state and return it. Discovery not needed.
if (systemType.equals(StorageSystem.Type.vmax) || systemType.equals(StorageSystem.Type.vnxblock) || systemType.equals(StorageSystem.Type.hds) || systemType.equals(StorageSystem.Type.openstack) || systemType.equals(StorageSystem.Type.scaleio) || systemType.equals(StorageSystem.Type.xtremio) || systemType.equals(StorageSystem.Type.ceph)) {
// this check is to inform the user that he/she can not update fields other than name and max_resources.
if (param.getIpAddress() != null || param.getPortNumber() != null || param.getUserName() != null || param.getPassword() != null || param.getSmisProviderIP() != null || param.getSmisPortNumber() != null || param.getSmisUserName() != null || param.getSmisPassword() != null || param.getSmisUseSSL() != null) {
throw APIException.badRequests.onlyNameAndMaxResourceCanBeUpdatedForSystemWithType(systemType.name());
}
_dbClient.updateObject(system);
String taskId = UUID.randomUUID().toString();
TaskList taskList = new TaskList();
Operation op = new Operation();
op.ready("Updated Storage System name");
op.setResourceType(ResourceOperationTypeEnum.UPDATE_STORAGE_SYSTEM);
_dbClient.createTaskOpStatus(StorageSystem.class, system.getId(), taskId, op);
taskList.getTaskList().add(toTask(system, taskId, op));
return taskList.getTaskList().listIterator().next();
}
if (systemType.equals(StorageSystem.Type.vnxfile)) {
validateVNXFileSMISProviderMandatoryDetails(param);
}
String existingIPAddress = system.getIpAddress();
Integer existingPortNumber = system.getPortNumber();
// check to ensure a system does not exist with the new ip + port combo
if (((param.getIpAddress() != null && !param.getIpAddress().equals(existingIPAddress)) || (param.getPortNumber() != null && !param.getPortNumber().equals(existingPortNumber)))) {
String ipAddress = (param.getIpAddress() != null) ? param.getIpAddress() : system.getIpAddress();
Integer portNumber = (param.getPortNumber() != null) ? param.getPortNumber() : system.getPortNumber();
if (systemType.equals(StorageSystem.Type.isilon) || systemType.equals(StorageSystem.Type.unity) || systemType.equals(StorageSystem.Type.vnxfile) || systemType.equals(StorageSystem.Type.vnxe)) {
ArgValidator.checkFieldValidInetAddress(ipAddress, "ip_address");
} else {
ArgValidator.checkFieldValidIP(ipAddress, "ip_address");
}
ArgValidator.checkFieldRange(portNumber, 1, 65535, "port_number");
validateStorageSystemExists(ipAddress, portNumber);
system.setMgmtAccessPoint(ipAddress + "-" + portNumber);
}
updateStorageObj(system, param);
auditOp(OperationTypeEnum.UPDATE_STORAGE_SYSTEM, true, null, id.toString(), param.getIpAddress(), param.getPortNumber());
startStorageSystem(system);
// execute discovery
StorageController controller = getController(FileController.class, system.getSystemType());
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageSystem.class, system.getId(), taskId));
TaskList taskList = discoverStorageSystems(tasks, controller);
return taskList.getTaskList().listIterator().next();
}
Aggregations