Search in sources :

Example 36 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileService method prepareEmptyFileSystem.

/**
 * Allocate, initialize and persist state of the fileSystem being created.
 *
 * @param param
 * @param project
 * @param neighborhood
 * @param vpool
 * @param placement
 * @param token
 * @return
 */
private FileShare prepareEmptyFileSystem(FileSystemParam param, Project project, TenantOrg tenantOrg, VirtualArray varray, VirtualPool vpool, DataObject.Flag[] flags, String task) {
    _log.debug("prepareEmptyFileSystem start...");
    StoragePool pool = null;
    FileShare fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    fs.setLabel(param.getLabel());
    // No need to generate any name -- Since the requirement is to use the customizing label we should use the same.
    // Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
    String convertedName = param.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
    _log.info("Original name {} and converted name {}", param.getLabel(), convertedName);
    fs.setName(convertedName);
    Long fsSize = SizeUtil.translateSize(param.getSize());
    fs.setCapacity(fsSize);
    fs.setNotificationLimit(Long.valueOf(param.getNotificationLimit()));
    fs.setSoftLimit(Long.valueOf(param.getSoftLimit()));
    fs.setSoftGracePeriod(param.getSoftGrace());
    fs.setVirtualPool(param.getVpool());
    if (project != null) {
        fs.setProject(new NamedURI(project.getId(), fs.getLabel()));
    }
    fs.setTenant(new NamedURI(tenantOrg.getId(), param.getLabel()));
    fs.setVirtualArray(varray.getId());
    // When a VPool supports "thin" provisioning
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        fs.setThinlyProvisioned(Boolean.TRUE);
    }
    fs.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.CREATE_FILE_SYSTEM);
    fs.getOpStatus().createTaskStatus(task, op);
    if (flags != null) {
        fs.addInternalFlags(flags);
    }
    _dbClient.createObject(fs);
    return fs;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare)

Example 37 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class ExportGroupService method initTaskStatus.

/**
 * Convenience method for initializing a task object with a status
 *
 * @param exportGroup export group
 * @param task task ID
 * @param status status to initialize with
 * @param opType operation type
 * @return operation object
 */
private Operation initTaskStatus(ExportGroup exportGroup, String task, Operation.Status status, ResourceOperationTypeEnum opType) {
    if (exportGroup.getOpStatus() == null) {
        exportGroup.setOpStatus(new OpStatusMap());
    }
    Operation op = new Operation();
    op.setResourceType(opType);
    if (status == Operation.Status.ready) {
        op.ready();
    }
    _dbClient.createTaskOpStatus(ExportGroup.class, exportGroup.getId(), task, op);
    return op;
}
Also used : OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation)

Example 38 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileMirrorServiceApiImpl method prepareEmptyFileSystem.

/**
 * Create fileSystem
 *
 * @param newFileLabel
 * @param fileshareSize
 * @param project
 * @param fileMirrorRecommendation
 * @param tenantOrg
 * @param varray
 * @param sourceVpool
 * @param targetVpool
 * @param flags
 * @param taskId
 * @return
 */
private FileShare prepareEmptyFileSystem(String newFileLabel, Long fileshareSize, Project project, FileMirrorRecommendation fileMirrorRecommendation, TenantOrg tenantOrg, VirtualArray varray, VirtualPool sourceVpool, VirtualPool targetVpool, DataObject.Flag[] flags, String taskId) {
    _log.debug("prepareEmptyFileSystem start...");
    FileShare fs = new FileShare();
    fs.setId(URIUtil.createId(FileShare.class));
    newFileLabel = validateAndGetFileShareLabel(newFileLabel, project);
    fs.setLabel(newFileLabel);
    // No need to generate any name -- Since the requirement is to use the customizing label we should use the same.
    // Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
    String convertedName = newFileLabel.replaceAll("[^\\dA-Za-z\\_]", "");
    _log.info("Original name {} and converted name {}", newFileLabel, convertedName);
    fs.setName(convertedName);
    fs.setCapacity(fileshareSize);
    // set tenant
    fs.setTenant(new NamedURI(tenantOrg.getId(), newFileLabel));
    // set vpool
    VirtualPool vpool = sourceVpool;
    if (targetVpool != null) {
        vpool = targetVpool;
    }
    fs.setVirtualPool(vpool.getId());
    // set varray
    fs.setVirtualArray(varray.getId());
    // set project
    if (project != null) {
        fs.setProject(new NamedURI(project.getId(), fs.getLabel()));
    }
    // set prov type
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        fs.setThinlyProvisioned(Boolean.TRUE);
    }
    // set internal flags
    if (flags != null) {
        fs.addInternalFlags(flags);
    }
    fs.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.CREATE_FILE_SYSTEM);
    fs.getOpStatus().createTaskStatus(taskId, op);
    _dbClient.createObject(fs);
    return fs;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 39 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FilePolicyService method createAssignFilePolicyTask.

private TaskResourceRep createAssignFilePolicyTask(FilePolicy filepolicy, String taskId) {
    filepolicy.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.ASSIGN_FILE_POLICY);
    filepolicy.getOpStatus().createTaskStatus(taskId, op);
    _dbClient.updateObject(filepolicy);
    return toTask(filepolicy, taskId);
}
Also used : OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation)

Example 40 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileQuotaDirectoryService method updateQuotaDirectory.

/**
 * Update Quota Directory for a file share
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id
 *            the URN of a ViPR Quota directory
 * @param param
 *            File system Quota directory update parameters
 * @brief Update file system quota directory
 * @return Task resource representation
 * @throws com.emc.storageos.svcs.errorhandling.resources.InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateQuotaDirectory(@PathParam("id") URI id, QuotaDirectoryUpdateParam param) throws InternalException {
    _log.info("FileService::Update Quota directory Request recieved {}", id);
    QuotaDirectory quotaDirNew = new QuotaDirectory();
    if (param.getSecurityStyle() != null) {
        ArgValidator.checkFieldValueFromEnum(param.getSecurityStyle(), "security_style", EnumSet.allOf(QuotaDirectory.SecurityStyles.class));
    }
    // Get the FileSystem object
    QuotaDirectory quotaDir = queryResource(id);
    FileShare fs = queryFileShareResource(quotaDir.getParent().getURI());
    ArgValidator.checkFieldNotNull(fs, "filesystem");
    // Set all other optional parameters too.
    quotaDirNew.setName(quotaDir.getName());
    quotaDirNew.setId(id);
    quotaDirNew.setNativeGuid(quotaDir.getNativeGuid());
    if (param.getOpLock() != null) {
        quotaDirNew.setOpLock(param.getOpLock());
    }
    if (param.getSecurityStyle() != null) {
        quotaDirNew.setSecurityStyle(param.getSecurityStyle());
    }
    if (param.getSize() != null) {
        // converts the input string in format "<value>GB" to Bytes
        Long quotaSize = SizeUtil.translateSize(param.getSize());
        if (quotaSize > 0) {
            ArgValidator.checkFieldMaximum(quotaSize, fs.getCapacity(), SizeUtil.SIZE_B, "size", true);
            quotaDirNew.setSize(quotaSize);
        }
    }
    ArgValidator.checkFieldMaximum(param.getSoftLimit(), 100, "softLimit");
    ArgValidator.checkFieldMaximum(param.getNotificationLimit(), 100, "notificationLimit");
    if (param.getSoftLimit() != 0L) {
        ArgValidator.checkFieldMinimum(param.getSoftGrace(), 1L, "softGrace");
    }
    int fsSoftLimit = -1;
    if (null != fs.getSoftLimit()) {
        fsSoftLimit = fs.getSoftLimit().intValue();
    }
    int fsNotifiLimit = -1;
    if (null != fs.getNotificationLimit()) {
        fsNotifiLimit = fs.getNotificationLimit().intValue();
    }
    int fsGraceLimit = -1;
    if (null != fs.getSoftGracePeriod()) {
        fsGraceLimit = fs.getSoftGracePeriod().intValue();
    }
    String task = UUID.randomUUID().toString();
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.UPDATE_FILE_SYSTEM_QUOTA_DIR);
    // Update the quota directory object to store in ViPR database
    quotaDir.setOpStatus(new OpStatusMap());
    quotaDir.getOpStatus().createTaskStatus(task, op);
    fs.setOpStatus(new OpStatusMap());
    fs.getOpStatus().createTaskStatus(task, op);
    _dbClient.updateObject(fs);
    _dbClient.updateObject(quotaDir);
    quotaDirNew.setSoftLimit(param.getSoftLimit() > 0 ? param.getSoftLimit() : quotaDir.getSoftLimit() > 0 ? quotaDir.getSoftLimit() : fsSoftLimit > 0 ? fsSoftLimit : 0);
    quotaDirNew.setSoftGrace(param.getSoftGrace() > 0 ? param.getSoftGrace() : quotaDir.getSoftGrace() > 0 ? quotaDir.getSoftGrace() : fsGraceLimit > 0 ? fsGraceLimit : 0);
    quotaDirNew.setNotificationLimit(param.getNotificationLimit() > 0 ? param.getNotificationLimit() : quotaDir.getNotificationLimit() > 0 ? quotaDir.getNotificationLimit() : fsNotifiLimit > 0 ? fsNotifiLimit : 0);
    // Create an object of type "FileShareQtree" to be passed into the
    // south-bound layers.
    FileShareQuotaDirectory qt = new FileShareQuotaDirectory(quotaDirNew);
    // Now get ready to make calls into the controller
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    FileController controller = getController(FileController.class, device.getSystemType());
    try {
        controller.updateQuotaDirectory(device.getId(), qt, fs.getId(), task);
    } catch (InternalException e) {
        _log.error("Error during update of Quota Directory {}", e);
        // errors
        throw e;
    }
    auditOp(OperationTypeEnum.UPDATE_FILE_SYSTEM_QUOTA_DIR, true, AuditLogManager.AUDITOP_BEGIN, quotaDirNew.getLabel(), quotaDirNew.getId().toString(), fs.getId().toString());
    fs = _dbClient.queryObject(FileShare.class, fs.getId());
    _log.debug("FileService::Quota directory Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
    return toTask(quotaDir, task, op);
}
Also used : FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) FileController(com.emc.storageos.volumecontroller.FileController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) MapQuotaDirectory(com.emc.storageos.api.mapper.functions.MapQuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) 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)

Aggregations

OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)48 Operation (com.emc.storageos.db.client.model.Operation)29 NamedURI (com.emc.storageos.db.client.model.NamedURI)28 Volume (com.emc.storageos.db.client.model.Volume)15 URI (java.net.URI)15 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 StringSet (com.emc.storageos.db.client.model.StringSet)13 FileShare (com.emc.storageos.db.client.model.FileShare)12 ArrayList (java.util.ArrayList)10 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)9 StringMap (com.emc.storageos.db.client.model.StringMap)9 HashMap (java.util.HashMap)9 StoragePool (com.emc.storageos.db.client.model.StoragePool)8 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)6 DataObject (com.emc.storageos.db.client.model.DataObject)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Consumes (javax.ws.rs.Consumes)6 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)5