use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.
the class ObjectControllerImpl method addUserSecretKey.
@Override
public ObjectUserSecretKey addUserSecretKey(URI storage, String userId, String secretKey) throws InternalException {
_log.debug("ObjectControllerImpl:addUserSecretKey start");
// Synchronous call than queuing
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Controller controller = lookupDeviceController(storageSystem);
ObjectController objController = (ObjectController) controller;
return objController.addUserSecretKey(storage, userId, secretKey);
}
use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.
the class StorageSystemService method addUserSecretKey.
/**
* Create a secret key for an object storage array
*
* @param param secret key
* @param id storage system URN
* @param userId user in array
* @brief Add a secret key for a storage system user
* @return secret key details
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/object-user/{userId}/secret-keys")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ObjectUserSecretKeyAddRestRep addUserSecretKey(ObjectUserSecretKeyRequestParam param, @PathParam("id") URI id, @PathParam("userId") String userId) throws InternalException {
// Make sure storage system is registered and object storage
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
if (!StorageSystem.Type.ecs.toString().equals(system.getSystemType())) {
throw APIException.badRequests.invalidParameterURIInvalid("id", id);
}
ObjectController controller = getController(ObjectController.class, system.getSystemType());
String secretKey = null;
if (param != null && !StringUtil.isBlank(param.getSecretkey())) {
secretKey = param.getSecretkey();
}
ObjectUserSecretKey secretKeyRes = controller.addUserSecretKey(id, userId, secretKey);
// Return key details as this is synchronous call
return map(secretKeyRes, true);
}
use of com.emc.storageos.volumecontroller.ObjectController 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.volumecontroller.ObjectController in project coprhd-controller by CoprHD.
the class BucketService method syncBucketACL.
private void syncBucketACL(Bucket bucket) throws InternalException {
// Make sure that we don't have some pending
// operation against the bucket
checkForPendingTasks(Arrays.asList(bucket.getTenant().getURI()), Arrays.asList(bucket));
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
String task = UUID.randomUUID().toString();
_log.info(String.format("SYNC Bucket ACL --- Bucket id: %1$s, Task: %2$s", bucket.getId(), task));
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.SYNC_BUCKET_ACL);
op.setDescription("Sync Bucket ACL");
controller.syncBucketACL(bucket.getStorageDevice(), bucket.getId(), task);
auditOp(OperationTypeEnum.SYNC_BUCKET_ACL, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
toTask(bucket, task, op);
// Waiting till the task is ready to proceed.
boolean breakLoop = false;
boolean failedOp = true;
long startTime = System.currentTimeMillis();
String READY = "ready";
String ERROR = "error";
String message = "";
int MAX_SYNC_TIMEOUT = 8000;
while (!breakLoop) {
Task dbTask = TaskUtils.findTaskForRequestId(_dbClient, bucket.getId(), task);
if (READY.equals(dbTask.getStatus())) {
breakLoop = true;
failedOp = false;
}
if (ERROR.equals(dbTask.getStatus())) {
breakLoop = true;
message = dbTask.getMessage();
}
if ((System.currentTimeMillis() - startTime) > MAX_SYNC_TIMEOUT) {
breakLoop = true;
message = "Request Time-Out Wait untill bucket sync task is finished.";
}
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
// When we catch the InterruptException and swallow it, we essentially prevent any higher level methods/thread groups from
// noticing the interrupt. Which may cause problems.
// By calling Thread.currentThread().interrupt(), we set the interrupt flag of the thread, so higher level interrupt
// handlers will notice it and can handle it appropriately.
Thread.currentThread().interrupt();
}
}
if (failedOp) {
throw ECSException.exceptions.bucketACLUpdateFailed(bucket.getName(), "Could not get ACL from ECS {} " + message + " Please try again later.");
}
}
use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.
the class BucketService method updateBucket.
/**
* Updates Bucket values like Quota and Retention.
*
* @param id Bucket ID
* @param param Bucket update parameter
* @brief Change bucket properties
* @return Task resource representation
* @throws InternalException if update fails
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateBucket(@PathParam("id") URI id, BucketUpdateParam param) throws InternalException {
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
Integer retention = null != param.getRetention() ? Integer.valueOf(param.getRetention()) : 0;
// if no softquota is provided, use the old value
if (softQuota == 0) {
softQuota = bucket.getSoftQuota();
}
// if no hardquota is provided, use the old value
if (hardQuota == 0) {
hardQuota = bucket.getHardQuota();
}
// Hard Quota should be more than SoftQuota
verifyQuotaValues(softQuota, hardQuota, bucket.getLabel());
// if no retention is provided, use the old value
if (retention == 0) {
retention = bucket.getRetention();
}
VirtualPool cos = _dbClient.queryObject(VirtualPool.class, bucket.getVirtualPool());
// verify retention. Its validated only if Retention is configured.
if (retention != 0 && cos.getMaxRetention() != 0 && retention > cos.getMaxRetention()) {
throw APIException.badRequests.insufficientRetentionForVirtualPool(cos.getLabel(), "bucket");
}
String task = UUID.randomUUID().toString();
_log.info(String.format("BucketUpdate --- Bucket id: %1$s, Task: %2$s", id, task));
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.UPDATE_BUCKET);
op.setDescription("Bucket update");
ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
controller.updateBucket(bucket.getStorageDevice(), id, softQuota, hardQuota, retention, task);
auditOp(OperationTypeEnum.UPDATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
return toTask(bucket, task, op);
}
Aggregations