Search in sources :

Example 51 with VirtualArray

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

the class VirtualArrayService method createNetwork.

/**
 * Create a network and assign it to the virtual array.
 *
 * @param param Network parameters
 * @param id the URN of a ViPR VirtualArray
 * @see NetworkService#createNetwork(NetworkCreate)
 * @deprecated used {@link NetworkService#createNetwork(NetworkCreate)}
 * @brief Create Network
 * @return Network details
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/networks")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public NetworkRestRep createNetwork(@PathParam("id") URI id, NetworkCreate param) {
    _log.debug("createNetwork: started for varray {}", id);
    // check VirtualArray
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
    if (param.getVarrays() != null && !param.getVarrays().isEmpty()) {
        throw APIException.badRequests.invalidParameterForVarrayNetwork(id.toString());
    }
    // set the varray in the param
    param.setVarrays(Collections.singletonList(id));
    // delegate to network service the actual work
    return _networkService.createNetwork(param);
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) 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)

Example 52 with VirtualArray

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

the class VirtualArrayService method queryFilteredBulkResourceReps.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected VirtualArrayBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    if (isSystemOrRestrictedSystemAdmin()) {
        return queryBulkResourceReps(ids);
    }
    if (!ids.iterator().hasNext()) {
        return new VirtualArrayBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
    Iterator<VirtualArray> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual arrays from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote array", ex);
        }
    }
    BulkList.ResourceFilter filter = new BulkList.VirtualArrayACLFilter(getUserFromContext(), _permissionsHelper);
    return new VirtualArrayBulkRep(BulkList.wrapping(dbIterator, MapVirtualArray.getInstance(), filter));
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualArrayBulkRep(com.emc.storageos.model.varray.VirtualArrayBulkRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 53 with VirtualArray

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

the class VirtualPoolService method populateCommonVirtualPoolCreateParams.

/**
 * This method is used to set the common VirtualPool create params in
 * VirtualPool model.
 *
 * @param vpool : VirtualPool object to populate params.
 * @param param : VirtualPoolCreate params.
 * @throws DatabaseException
 */
protected void populateCommonVirtualPoolCreateParams(VirtualPool vpool, VirtualPoolCommonParam param) throws DatabaseException {
    // ArgValidator.checkFieldNotEmpty(param.getName(), VPOOL_NAME);
    if (StringUtils.isNotEmpty(param.getName())) {
        vpool.setLabel(param.getName());
    }
    if (StringUtils.isNotEmpty(param.getDescription())) {
        vpool.setDescription(param.getDescription());
    }
    ArgValidator.checkFieldNotEmpty(param.getProvisionType(), VPOOL_PROVISIONING_TYPE);
    ArgValidator.checkFieldValueFromEnum(param.getProvisionType(), VPOOL_PROVISIONING_TYPE, EnumSet.of(ProvisioningType.Thick, ProvisioningType.Thin));
    vpool.setId(URIUtil.createId(VirtualPool.class));
    if (null != param.getProvisionType()) {
        vpool.setSupportedProvisioningType(param.getProvisionType());
    }
    vpool.setMaxNativeSnapshots(0);
    vpool.setProtocols(new StringSet());
    // Validate the protocols for not null and non-empty values
    ArgValidator.checkFieldNotEmpty(param.getProtocols(), VPOOL_PROTOCOLS);
    // Validate the protocols for type of VirtualPool.
    validateVirtualPoolProtocol(vpool.getType(), param.getProtocols());
    vpool.getProtocols().addAll(param.getProtocols());
    // validate and set neighborhoods
    if (param.getVarrays() != null) {
        vpool.setVirtualArrays(new StringSet());
        for (String neighborhood : param.getVarrays()) {
            URI neighborhoodURI = URI.create(neighborhood);
            ArgValidator.checkUri(neighborhoodURI);
            VirtualArray varray = _dbClient.queryObject(VirtualArray.class, neighborhoodURI);
            ArgValidator.checkEntity(varray, neighborhoodURI, isIdEmbeddedInURL(neighborhoodURI));
            vpool.getVirtualArrays().add(neighborhood);
        }
    }
    // Set the useMatchedPools flag.
    vpool.setUseMatchedPools(param.getUseMatchedPools());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 54 with VirtualArray

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

the class VirtualPoolService method getCapacityForVirtualPoolAndVirtualArray.

/**
 * Returns capacity metrics for a given pair of VirtualPool and Neighborhood. The
 * method returns set of metrics for capacity available for storage
 * provisioning: - usable_gb : total storage capacity - free_gb : free
 * storage capacity - used_gb : used storage capacity - subscribed_gb :
 * subscribed storage capacity (may be larger than usable capacity) -
 * percent_used : percent of usable capacity which is used -
 * percent_subscribed : percent of usable capacity which is subscribed (may
 * be more than 100) Subscribed and percent subscribed is returned only for
 * block vpool.
 *
 * @param vpool
 * @param vArrayId
 * @return CapacityResponse instance
 */
protected CapacityResponse getCapacityForVirtualPoolAndVirtualArray(VirtualPool vpool, URI vArrayId) {
    VirtualArray varray = _permissionsHelper.getObjectById(vArrayId, VirtualArray.class);
    ArgValidator.checkEntity(varray, vArrayId, isIdEmbeddedInURL(vArrayId));
    // Check permissions: check that varray is accessible to user's
    // tenant
    final StorageOSUser user = getUserFromContext();
    final URI tenant = URI.create(user.getTenantId());
    if (!(_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR) || _permissionsHelper.tenantHasUsageACL(tenant, varray))) {
        throw APIException.forbidden.insufficientPermissionsForUser(user.getName());
    }
    return CapacityUtils.getCapacityForVirtualPoolAndVirtualArray(vpool, vArrayId, _dbClient, _coordinator);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) URI(java.net.URI)

Example 55 with VirtualArray

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

the class VolumeService method getVolumeDetail.

// INTERNAL FUNCTIONS
protected VolumeDetail getVolumeDetail(Volume vol, String isV1Call, String openstackTenantId) {
    VolumeDetail detail = new VolumeDetail();
    int sizeInGB = (int) ((vol.getCapacity() + halfGB) / GB);
    detail.size = sizeInGB;
    detail.id = getCinderHelper().trimId(vol.getId().toString());
    detail.host_name = getCinderHelper().trimId(vol.getStorageController().toString());
    detail.tenant_id = openstackTenantId;
    detail.attachments = new ArrayList<Attachment>();
    if (vol.getInactive()) {
        detail.status = "deleted";
    } else {
        if (vol.getExtensions() == null) {
            vol.setExtensions(new StringMap());
        }
        if (vol.getProvisionedCapacity() == ZERO_BYTES) {
            detail.status = CinderConstants.ComponentStatus.CREATING.getStatus().toLowerCase();
        } else if (vol.getExtensions().containsKey("status") && vol.getExtensions().get("status").equals(CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase())) {
            Task taskObj = null;
            String task = vol.getExtensions().get(DELETE_TASK_ID).toString();
            taskObj = TaskUtils.findTaskForRequestId(_dbClient, vol.getId(), task);
            if (taskObj != null) {
                if (taskObj.getStatus().equals("error")) {
                    _log.info(String.format("Error Deleting volume %s, but moving volume to original state so that it will be usable:  ", detail.name));
                    vol.getExtensions().put("status", CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase());
                    vol.getExtensions().remove(DELETE_TASK_ID);
                    detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
                } else if (taskObj.getStatus().equals("pending")) {
                    detail.status = CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase();
                }
                _dbClient.updateObject(vol);
            } else {
                detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
            }
        } else if (vol.getExtensions().containsKey("status") && vol.getExtensions().get("status").equals(CinderConstants.ComponentStatus.EXTENDING.getStatus().toLowerCase())) {
            _log.info("Extending Volume {}", vol.getId().toString());
            Task taskObj = null;
            String task = vol.getExtensions().get("task_id").toString();
            taskObj = TaskUtils.findTaskForRequestId(_dbClient, vol.getId(), task);
            _log.debug("THE TASKOBJ is {}, task_id {}", taskObj.toString(), task);
            _log.debug("THE TASKOBJ STATUS is {}", taskObj.getStatus().toString());
            if (taskObj != null) {
                if (taskObj.getStatus().equals("ready")) {
                    detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
                    _log.debug(" STATUS is {}", detail.status);
                    vol.getExtensions().remove("task_id");
                    vol.getExtensions().put("status", "");
                } else if (taskObj.getStatus().equals("error")) {
                    detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
                    _log.info(String.format("Error in Extending volume %s, but moving volume to original state so that it will be usable:  ", detail.name));
                    vol.getExtensions().remove("task_id");
                    vol.getExtensions().put("status", "");
                } else {
                    detail.status = CinderConstants.ComponentStatus.EXTENDING.getStatus().toLowerCase();
                    _log.info("STATUS is {}", detail.status);
                }
            } else {
                detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
                _log.info(String.format("Error in Extending volume %s, but moving volume to original state so that it will be usable:  ", detail.name));
                vol.getExtensions().remove("task_id");
                vol.getExtensions().put("status", "");
            }
            _dbClient.updateObject(vol);
        } else if (vol.getExtensions().containsKey("status") && !vol.getExtensions().get("status").equals("")) {
            detail.status = vol.getExtensions().get("status").toString().toLowerCase();
        } else {
            detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
        }
    }
    detail.created_at = date(vol.getCreationTime().getTimeInMillis());
    URI vpoolUri = vol.getVirtualPool();
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolUri);
    if (vpool != null) {
        detail.volume_type = vpool.getLabel();
    }
    URI varrayUri = vol.getVirtualArray();
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayUri);
    if (varray != null) {
        detail.availability_zone = varray.getLabel();
    }
    if (vol.getExtensions().containsKey("bootable") && vol.getExtensions().get("bootable").equals(TRUE)) {
        detail.bootable = true;
        _log.debug("Volumes Bootable Flag is TRUE");
    } else {
        detail.bootable = false;
        _log.debug("Volumes Bootable Flag is False");
    }
    detail.setLink(DbObjectMapper.toLink(vol));
    detail.metadata = new HashMap<String, String>();
    String description = null;
    StringMap extensions = vol.getExtensions();
    if (extensions != null) {
        description = extensions.get("display_description");
    }
    if (isV1Call != null) {
        detail.display_name = vol.getLabel();
        detail.display_description = (description == null) ? "" : description;
        detail.description = null;
        detail.name = null;
    } else {
        detail.name = vol.getLabel();
        detail.description = (description == null) ? "" : description;
        detail.display_name = null;
        detail.display_description = null;
    }
    if (vol.getExtensions().containsKey("readonly") && vol.getExtensions().get("readonly").equals(TRUE)) {
        _log.debug("Volumes Readonly Flag is TRUE");
        detail.metadata.put("readonly", "true");
    } else {
        _log.debug("Volumes Readonly Flag is FALSE");
        detail.metadata.put("readonly", "false");
    }
    if (detail.status.equals("in-use")) {
        if (vol.getExtensions() != null && vol.getExtensions().containsKey("OPENSTACK_NOVA_INSTANCE_ID")) {
            detail.metadata.put("attached_mode", vol.getExtensions().get("OPENSTACK_ATTACH_MODE"));
            detail.attachments = getVolumeAttachments(vol);
        }
    }
    if (vol.getConsistencyGroup() != null) {
        detail.consistencygroup_id = CinderApiUtils.splitString(vol.getConsistencyGroup().toString(), ":", 3);
    }
    return detail;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask) Task(com.emc.storageos.db.client.model.Task) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDetail(com.emc.storageos.cinder.model.VolumeDetail) Attachment(com.emc.storageos.cinder.model.Attachment) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Aggregations

VirtualArray (com.emc.storageos.db.client.model.VirtualArray)183 URI (java.net.URI)91 ArrayList (java.util.ArrayList)91 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)84 Project (com.emc.storageos.db.client.model.Project)53 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)52 StringSet (com.emc.storageos.db.client.model.StringSet)50 Volume (com.emc.storageos.db.client.model.Volume)46 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 StoragePool (com.emc.storageos.db.client.model.StoragePool)43 HashMap (java.util.HashMap)38 StringMap (com.emc.storageos.db.client.model.StringMap)37 Recommendation (com.emc.storageos.volumecontroller.Recommendation)37 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)31 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)30 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)29 Network (com.emc.storageos.db.client.model.Network)27 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)27