use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class StorageSystemService method deleteStoragePortGroup.
/**
* Delete a storage port group
*
* @param id
* the URN of a ViPR storage port.
*
* @brief Delete a storage port group
* @return The pending task
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups/{pgId}/deactivate")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep deleteStoragePortGroup(@PathParam("id") URI id, @PathParam("pgId") URI pgId) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
// Only support for VMAX
if (!DiscoveredDataObject.Type.vmax.name().equals(system.getSystemType())) {
APIException.badRequests.operationNotSupportedForSystemType(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP.name(), system.getSystemType());
}
ArgValidator.checkFieldUriType(pgId, StoragePortGroup.class, "portGroupId");
StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, pgId);
String task = UUID.randomUUID().toString();
Operation op = null;
if (portGroup == null || portGroup.getInactive()) {
// The port group has been deleted
op = _dbClient.createTaskOpStatus(StoragePortGroup.class, portGroup.getId(), task, ResourceOperationTypeEnum.DELETE_STORAGE_PORT_GROUP);
op.ready();
} else {
// Check if the port group is used by any export mask
URIQueryResultList queryResult = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportMasksByPortGroup(portGroup.getId().toString()), queryResult);
Iterator<URI> maskIt = queryResult.iterator();
if (maskIt.hasNext()) {
URI maskURI = maskIt.next();
// The port group is used by at least one export mask, throw error
ArgValidator.checkReference(StoragePortGroup.class, pgId, maskURI.toString());
}
op = _dbClient.createTaskOpStatus(StoragePortGroup.class, portGroup.getId(), task, ResourceOperationTypeEnum.DELETE_STORAGE_PORT_GROUP);
_dbClient.updateObject(portGroup);
BlockController controller = getController(BlockController.class, system.getSystemType());
controller.deleteStoragePortGroup(system.getId(), portGroup.getId(), task);
}
auditOp(OperationTypeEnum.DELETE_STORAGE_PORT_GROUP, true, null, portGroup.getNativeGuid(), pgId.toString());
recordStoragePoolPortEvent(OperationTypeEnum.DELETE_STORAGE_PORT_GROUP, OperationTypeEnum.DELETE_STORAGE_PORT_GROUP.getDescription(), portGroup.getId(), "StoragePortGroup");
return toTask(portGroup, task, op);
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class InitiatorService method setInitiatorAlias.
/**
* Sets the alias/initiator name for an initiator
* on the Storage System
*
* @param id the URN of a ViPR initiator
* @param aliasSetParam the parameter containing the storage system and alias attributes
* @prereq none
* @brief Set the serial number and alias on this storage system for an initiator
* @return A reference to an InitiatorRestRep representing the Initiator Alias after Set..
* @throws Exception When an error occurs setting the alias on a VMAX Storage System.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/alias")
public InitiatorAliasRestRep setInitiatorAlias(@PathParam("id") URI id, InitiatorAliasSetParam aliasSetParam) {
// Basic Checks
Initiator initiator = queryResource(id);
verifyUserPermisions(initiator);
URI systemURI = aliasSetParam.getSystemURI();
ArgValidator.checkFieldUriType(systemURI, StorageSystem.class, "id");
StorageSystem system = _permissionsHelper.getObjectById(systemURI, StorageSystem.class);
ArgValidator.checkEntity(system, systemURI, isIdEmbeddedInURL(systemURI));
String initiatorAlias = aliasSetParam.getInitiatorAlias();
ArgValidator.checkFieldNotNull(initiatorAlias, "alias");
if (!initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
ArgValidator.checkFieldLengthMaximum(initiatorAlias, ALIAS_MAX_LIMIT, "alias");
} else {
ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[0], ALIAS_MAX_LIMIT, "alias node name");
ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[1], ALIAS_MAX_LIMIT, "alias port name");
}
if (initiatorAlias.matches(ALIAS_ILLEGAL_CHARACTERS)) {
String errMsg = String.format("Supplied Alias: %s has invalid characters", initiatorAlias);
_log.error(errMsg);
throw DeviceControllerException.exceptions.couldNotPerformAliasOperation(errMsg);
}
_log.info("Setting alias- {} for initiator {} on system {}", initiatorAlias, id, systemURI);
if (system != null && StorageSystem.Type.vmax.toString().equalsIgnoreCase(system.getSystemType())) {
BlockController controller = getController(BlockController.class, system.getSystemType());
try {
// Actual Control
controller.setInitiatorAlias(systemURI, id, initiatorAlias);
} catch (Exception e) {
_log.error("Unexpected error: Setting alias failed.", e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
} else {
throw APIException.badRequests.operationNotSupportedForSystemType(ALIAS, system.getSystemType());
}
// Update the Initiator here..
if (initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
// If the Initiator Alias contains the "/" character, the user has supplied
// different node and port names.
initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
} else {
// The user has set the same node and port names.
initiatorAlias = String.format("%s%s%s", initiatorAlias, EMPTY_INITIATOR_ALIAS, initiatorAlias);
initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
}
_dbClient.updateObject(initiator);
return new InitiatorAliasRestRep(system.getSerialNumber(), initiatorAlias);
}
use of com.emc.storageos.volumecontroller.BlockController 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();
}
use of com.emc.storageos.volumecontroller.BlockController 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;
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl 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) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, reqVolume.getStorageController());
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
controller.createSnapshot(storageSystem.getId(), snapshotURIs, createInactive, readOnly, taskId);
}
Aggregations