Search in sources :

Example 1 with PropertyInfoRestRep

use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.

the class ConfigService method getResetProps.

/**
 * Get reset properties based on properties specified in request,
 * current target property and metadata
 * This method iterates the target property set.
 * If a property is also in metadata
 * either it is contained keysToReset if not null or keysToReset is null (meaning,
 * reset all)
 * compare its value with default, if different, put it in resetProps
 *
 * @param keysToReset property set to delete in request
 * @param targetProps target properties
 * @param metadata metadata
 * @return reset property set with value set as defaults
 */
private PropertyInfoRestRep getResetProps(final PropertyList keysToReset, final Map<String, String> targetProps, final Map<String, PropertyMetadata> metadata) {
    // validate if properties exist in metadata
    if (keysToReset != null && keysToReset.getPropertyList() != null) {
        for (String key : keysToReset.getPropertyList()) {
            if (!targetProps.containsKey(key) || !metadata.containsKey(key)) {
                throw APIException.badRequests.propertyIsNotValid(key);
            }
        }
    }
    PropertyInfoRestRep resetProps = new PropertyInfoRestRep();
    for (Map.Entry<String, String> entry : targetProps.entrySet()) {
        final String key = entry.getKey();
        final String value = entry.getValue();
        if (metadata.containsKey(key)) {
            // property exist both in target and metadata
            if (keysToReset == null || keysToReset.getPropertyList() == null || keysToReset.getPropertyList().contains(key)) {
                // property also shows in request list and current value is not equal to default
                final String defaultValue = metadata.get(key).getDefaultValue();
                if (defaultValue != null && !value.equals(defaultValue)) {
                    // property has a default value and current value is not equal to default,
                    // reset it to default
                    resetProps.addProperty(key, defaultValue);
                }
            }
        }
    }
    // validate the changed property against it's metadata to ensure property
    // integrity.
    validateAndUpdateProperties(resetProps.getAllProperties(), true);
    return resetProps;
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 2 with PropertyInfoRestRep

use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.

the class ConfigService method configureConnectEmcFtpsParams.

/**
 * Configure ConnectEMC FTPS transport related properties
 *
 * @brief Configure ConnectEMC FTPS properties
 * @prereq Cluster state should be STABLE
 * @return ConnectEMC FTPS related properties
 */
@POST
@Path("connectemc/ftps/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response configureConnectEmcFtpsParams(ConnectEmcFtps ftpsParams) throws Exception {
    PropertyInfoUpdate ext = ConfigService.ConfigureConnectEmc.configureFtps(ftpsParams);
    PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
    PropertyInfoRestRep updateProps = getUpdateProps(ext, targetPropInfo.getAllProperties());
    return updatePropertiesCommon(updateProps, null);
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with PropertyInfoRestRep

use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.

the class ConfigService method incrementCertificateVersion.

/**
 * Update system configuration properties
 *
 * @brief Update system properties
 * @prereq Cluster state should be STABLE
 * @return Cluster information
 */
@PUT
@Path("internal/certificate-version")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response incrementCertificateVersion() throws Exception {
    PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
    String versionStr = targetPropInfo.getProperty(CERTIFICATE_VERSION);
    Integer version = new Integer(versionStr);
    PropertyInfoUpdate setProperty = new PropertyInfoUpdate();
    setProperty.addProperty(CERTIFICATE_VERSION, (++version).toString());
    _log.info("setProperties(): {}", setProperty);
    PropertyInfoRestRep updateProps = getUpdateProps(setProperty, targetPropInfo.getAllProperties());
    return updatePropertiesCommon(updateProps, null);
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 4 with PropertyInfoRestRep

use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.

the class ConfigService method getVisiblePropertiesISOCommon.

// Keep this library for now.
private Response getVisiblePropertiesISOCommon() throws Exception {
    _log.info("getVisiblePropertiesISO(): going to fetch ISO information");
    PropertyInfoRestRep propertyInfo = new PropertyInfoRestRep(getTargetPropsCommon().getProperties());
    if (propertyInfo.getAllProperties() == null || propertyInfo.getAllProperties().size() == 0) {
        _log.error("getVisiblePropertiesISO(): No properties found");
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Properties");
    }
    InputStream isoStream = new ByteArrayInputStream(CreateISO.getBytes(getPropertiesOvf(), getMutatedProps()));
    return Response.ok(isoStream).header("content-disposition", "attachment; filename = config.iso").build();
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Example 5 with PropertyInfoRestRep

use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.

the class ConfigService method configureConnectEmcEmailParams.

/**
 * Configure ConnectEMC SMTP/Email transport related properties
 *
 * @brief Configure ConnectEMC SMTP/Email properties
 * @prereq Cluster state should be STABLE
 * @return Properties related to ConnectEMC Email
 */
@POST
@Path("connectemc/email/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response configureConnectEmcEmailParams(ConnectEmcEmail emailParams) throws Exception {
    PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
    PropertyInfoUpdate ext = ConfigService.ConfigureConnectEmc.configureEmail(emailParams);
    PropertyInfoRestRep updateProps = getUpdateProps(ext, targetPropInfo.getAllProperties());
    return updatePropertiesCommon(updateProps, null);
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)19 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 Map (java.util.Map)5 HashMap (java.util.HashMap)4 TreeMap (java.util.TreeMap)4 PropertyInfoUpdate (com.emc.storageos.model.property.PropertyInfoUpdate)3 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)3 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)2 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)2 SysClientFactory (com.emc.storageos.systemservices.impl.client.SysClientFactory)2 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)1 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)1 StorageDriversInfo (com.emc.storageos.coordinator.client.model.StorageDriversInfo)1 VdcConfigVersion (com.emc.storageos.coordinator.client.model.VdcConfigVersion)1