use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method getTargetPropsCommon.
/**
* Get target properties
*
* @param maskSecretsProperties whether secrets properties should be masked out
* @return target properties
*/
private PropertyInfoRestRep getTargetPropsCommon(boolean maskSecretsProperties) {
PropertyInfoExt targetPropInfo = new PropertyInfoExt();
try {
targetPropInfo.setProperties(mergeProps(getPropertiesDefaults(), getMutatedProps(maskSecretsProperties)));
targetPropInfo.getProperties().putAll(getPropertiesOvf());
} catch (Exception e) {
throw APIException.internalServerErrors.getObjectFromError("target property", "coordinator", e);
}
return new PropertyInfoRestRep(targetPropInfo.getAllProperties());
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method getProperties.
/**
* Get system configuration properties
*
* @brief Get system properties
* @prereq none
* @param category - type of properties to return: all, config, ovf, mutated, secrets (require SecurityAdmin role)
* or obsolete
* @return Properties Information if success. Error response, if error./**
*/
@GET
@Path("properties/")
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public PropertyInfoRestRep getProperties(@DefaultValue("all") @QueryParam("category") String category) throws Exception {
switch(PropCategory.valueOf(category.toUpperCase())) {
case ALL:
return getTargetPropsCommon();
case CONFIG:
return new PropertyInfoRestRep(getConfigProperties());
case OVF:
return new PropertyInfoRestRep(getPropertiesOvf());
case REDEPLOY:
Map<String, String> props = getPropertiesOvf();
props.remove(MODE);
props.remove(NODE_ID);
Map<String, String> clusterInfo = new HashMap();
Set<Map.Entry<String, String>> ovfProps = props.entrySet();
for (Map.Entry<String, String> ovfProp : ovfProps) {
String parameter = propertyToParameters.get(ovfProp.getKey());
if (parameter == null) {
continue;
}
clusterInfo.put(parameter, ovfProp.getValue());
}
// Add ipsec key
clusterInfo.put(IPSEC_KEY, ipsecConfig.getPreSharedKey());
// Add version info
RepositoryInfo info = _coordinator.getTargetInfo(RepositoryInfo.class);
clusterInfo.put(VERSION, info.getCurrentVersion().toString());
_log.info("clusterInfo={}", clusterInfo);
return new PropertyInfoRestRep(clusterInfo);
case MUTATED:
return new PropertyInfoRestRep(getMutatedProps());
case SECRETS:
StorageOSUser user = getUserFromContext();
if (!user.getRoles().contains(Role.SECURITY_ADMIN.toString())) {
throw APIException.forbidden.onlySecurityAdminsCanGetSecrets();
}
return getTargetPropsCommon(false);
case OBSOLETE:
return new PropertyInfoRestRep(getObsoleteProperties());
default:
throw APIException.badRequests.invalidParameter("category", category);
}
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method setProperties.
/**
* Update system configuration properties
*
* @brief Update system properties
* @param setProperty Property's key value pair.
* @prereq Cluster state should be STABLE
* @return Cluster information
*/
@PUT
@Path("properties/")
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response setProperties(PropertyInfoUpdate setProperty) throws Exception {
PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
_log.info("setProperties(): {}", setProperty);
PropertyInfoRestRep updateProps = getUpdateProps(setProperty, targetPropInfo.getAllProperties());
return updatePropertiesCommon(updateProps, null);
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method resetProps.
/**
* Reset configuration properties to their default values. Properties with
* no default values will remain unchanged
*
* @brief Reset system properties
* @param propertyList property list
* @prereq Cluster state should be STABLE
* @return Cluster information
*/
@POST
@Path("properties/reset/")
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response resetProps(PropertyList propertyList, @QueryParam("removeObsolete") String forceRemove) throws Exception {
// get metadata
Map<String, PropertyMetadata> metadata = PropertiesMetadata.getGlobalMetadata();
// get target property set
PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
// get reset property set
PropertyInfoRestRep resetProps = getResetProps(propertyList, targetPropInfo.getAllProperties(), metadata);
// get obsolete property set
List<String> obsoleteProps = isSet(forceRemove) ? getObsoleteProps(targetPropInfo.getAllProperties(), metadata) : null;
// update properties with default value
return updatePropertiesCommon(resetProps, obsoleteProps);
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method getUpdateProps.
/**
* Get update property set, which values are different from target
*
* @param propsToUpdate property set to update in request
* @param targetProps target properties
* @return update property set
*/
private PropertyInfoRestRep getUpdateProps(final PropertyInfoUpdate propsToUpdate, final Map<String, String> targetProps) {
// validate the changed property against it's metadata to ensure property
// integrity.
validateAndUpdateProperties(propsToUpdate.getAllProperties(), false);
PropertyInfoRestRep updateProps = new PropertyInfoRestRep();
for (Map.Entry<String, String> entry : propsToUpdate.getAllProperties().entrySet()) {
final String key = entry.getKey();
final String value = entry.getValue();
if (targetProps.containsKey(key) && !targetProps.get(key).equals(value)) {
updateProps.addProperty(key, value);
} else if (!targetProps.containsKey(key)) {
updateProps.addProperty(key, value);
}
}
return updateProps;
}
Aggregations