aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/docker/backend/backend-files.xml2
-rw-r--r--src/main/docker/frontend/Dockerfile6
-rw-r--r--src/main/docker/frontend/frontend-files.xml11
-rw-r--r--src/main/docker/frontend/nginx/nginx.conf23
-rw-r--r--src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java13
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java58
-rw-r--r--src/main/java/org/onap/clamp/loop/Loop.java39
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java68
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/ExternalComponent.java6
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/ExternalComponentState.java60
-rw-r--r--src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java60
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java37
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java37
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java146
-rw-r--r--src/main/resources/META-INF/resources/swagger.html2
-rw-r--r--src/main/resources/application-noaaf.properties19
-rw-r--r--src/main/resources/application.properties2
-rw-r--r--src/main/resources/clds/aaf/ssl/clamp.key32
-rw-r--r--src/main/resources/clds/aaf/ssl/clamp.pem64
-rw-r--r--src/main/resources/clds/camel/routes/dcae-flows.xml51
-rw-r--r--src/main/resources/clds/camel/routes/loop-flows.xml166
-rw-r--r--src/main/resources/clds/camel/routes/policy-flows.xml128
-rw-r--r--src/main/resources/clds/camel/routes/utils-flows.xml19
-rw-r--r--src/main/resources/clds/json-schema/operational_policies/operational_policy.json362
24 files changed, 1114 insertions, 297 deletions
diff --git a/src/main/docker/backend/backend-files.xml b/src/main/docker/backend/backend-files.xml
index 7a9c6f53..c73c47f6 100644
--- a/src/main/docker/backend/backend-files.xml
+++ b/src/main/docker/backend/backend-files.xml
@@ -36,7 +36,7 @@
<include>${project.build.finalName}.jar</include>
</includes>
<directory>${project.build.directory}</directory>
- <outputDirectory>/</outputDirectory>
+ <outputDirectory></outputDirectory>
</fileSet>
</fileSets>
diff --git a/src/main/docker/frontend/Dockerfile b/src/main/docker/frontend/Dockerfile
index 8c755b03..8cdad308 100644
--- a/src/main/docker/frontend/Dockerfile
+++ b/src/main/docker/frontend/Dockerfile
@@ -46,7 +46,9 @@ RUN mkdir /var/log/onap
RUN chmod a+rwx /var/log/onap
COPY --from=build /app/build /usr/share/nginx/html
+COPY --from=build /app/ssl /etc/ssl
RUN rm /etc/nginx/conf.d/default.conf
-COPY onap-clamp-frontend/nginx/nginx.conf /etc/nginx/conf.d
-EXPOSE 80
+#COPY onap-clamp-frontend/nginx/nginx.conf /etc/nginx/conf.d
+COPY nginx/nginx.conf /etc/nginx/conf.d
+EXPOSE 443
CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file
diff --git a/src/main/docker/frontend/frontend-files.xml b/src/main/docker/frontend/frontend-files.xml
index 2610e828..aaf32be8 100644
--- a/src/main/docker/frontend/frontend-files.xml
+++ b/src/main/docker/frontend/frontend-files.xml
@@ -17,7 +17,7 @@
limitations under the License.
============LICENSE_END=========================================================
-->
-
+
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -35,8 +35,13 @@
<excludes>
<exclude>node_modules</exclude>
</excludes>
- <directory>${project.basedir}/ui-react</directory>
- <outputDirectory>/</outputDirectory>
+ <directory>${project.build.directory}/${ui.react.src}</directory>
+ <outputDirectory></outputDirectory>
+ </fileSet>
+ <!-- include ssl certificates files obtain from aaf p12 -->
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/clds/aaf/ssl</directory>
+ <outputDirectory>ssl</outputDirectory>
</fileSet>
</fileSets>
diff --git a/src/main/docker/frontend/nginx/nginx.conf b/src/main/docker/frontend/nginx/nginx.conf
new file mode 100644
index 00000000..5bcac5cf
--- /dev/null
+++ b/src/main/docker/frontend/nginx/nginx.conf
@@ -0,0 +1,23 @@
+server {
+
+ listen 443 default ssl;
+ ssl_protocols TLSv1.2;
+ ssl_certificate /etc/ssl/clamp.pem;
+ ssl_certificate_key /etc/ssl/clamp.key;
+ location /restservices/clds/ {
+ proxy_pass https://clamp-backend:8443;
+ }
+
+ location / {
+ root /usr/share/nginx/html;
+ index index.html index.htm;
+ try_files $uri $uri/ /index.html;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+
+ location = /50x.html {
+ root /usr/share/nginx/html;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java b/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java
index a8ff1206..9d4e7d0c 100644
--- a/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java
@@ -75,8 +75,10 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) {
try {
http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**")
- .authenticated().anyRequest().permitAll().and().logout().and().sessionManagement().maximumSessions(1)
- .and().invalidSessionUrl("/designer/timeout.html");
+ .authenticated().anyRequest().permitAll().and().logout()
+ .logoutUrl("/restservices/clds/v1/user/logout").logoutSuccessUrl("/index.html")
+ .invalidateHttpSession(true).deleteCookies("JSESSIONID").and().sessionManagement()
+ .maximumSessions(1);
} catch (Exception e) {
logger.error(SETUP_WEB_USERS_EXCEPTION_MSG, e);
@@ -105,7 +107,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
}
for (CldsUser user : usersList) {
auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword())
- .authorities(user.getPermissionsString()).and().passwordEncoder(passwordEncoder);
+ .authorities(user.getPermissionsString()).and().passwordEncoder(passwordEncoder);
}
} catch (Exception e) {
logger.error(SETUP_WEB_USERS_EXCEPTION_MSG, e);
@@ -118,8 +120,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
* CldsUser.
*
* @return The array of CldsUser
- * @throws IOException
- * In case of the file is not found
+ * @throws IOException In case of the file is not found
*/
private CldsUser[] loadUsers() throws IOException {
logger.info("Load from clds-users.properties");
@@ -134,7 +135,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
return new BCryptPasswordEncoder(cldsBcryptEncoderStrength);
} else {
throw new CldsConfigException(
- "Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
+ "Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
}
}
} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
index c228e171..454056cd 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
@@ -60,47 +60,73 @@ public class CldsDictionaryService extends SecureServiceBase {
@PostConstruct
- private final void initConstruct() {
+ private void initConstruct() {
permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance,
"update");
}
/**
- * REST Service that creates or Updates a Dictionary.
- *
+ * REST Service that creates a Dictionary.
+ *
* @param dictionaryName dictionary name
- * @param cldsDictionary clds dictionary
* @return CldsDictionary that was created in DB.
*/
+ public CldsDictionary createDictionary(String dictionaryName) {
+ CldsDictionary cldsDictionary = new CldsDictionary();
+ cldsDictionary.setDictionaryName(dictionaryName);
+ cldsDictionary.save(cldsDictionary.getDictionaryName(), cldsDao, getUserId());
+ return cldsDictionary;
+ }
+
+ /**
+ * REST Service that creates or Updates a Dictionary.
+ * Used in clds-services.xml
+ *
+ * @param cldsDictionary clds dictionary
+ * @return ResponseEntity with CldsDictionary that was created in DB.
+ */
public ResponseEntity<CldsDictionary> createOrUpdateDictionary(String dictionaryName,
- CldsDictionary cldsDictionary) {
- final Date startTime = new Date();
+ CldsDictionary cldsDictionary) {
+
+ Date startTime = new Date();
LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionary", getPrincipalName());
// TODO revisit based on new permissions
isAuthorized(permissionUpdateTosca);
+
if (cldsDictionary == null) {
- cldsDictionary = new CldsDictionary();
- cldsDictionary.setDictionaryName(dictionaryName);
+
+ cldsDictionary = createDictionary(dictionaryName);
+ } else {
+
+ if (cldsDictionary.getDictionaryName() == null) {
+ cldsDictionary.setDictionaryName(dictionaryName);
+ }
+
+ cldsDictionary.save(cldsDictionary.getDictionaryName(), cldsDao, getUserId());
}
- cldsDictionary.save(dictionaryName, cldsDao, getUserId());
- auditLogInfo("createOrUpdateDictionary", startTime);
+
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "createOrUpdateDictionary success", this.getClass().getName());
+ auditLogger.info("createOrUpdateDictionary completed");
+
return new ResponseEntity<>(cldsDictionary, HttpStatus.OK);
}
/**
* REST Service that creates or Updates a Dictionary Elements for dictionary
* in DB.
- *
+ *
* @param dictionaryName dictionary name
* @param dictionaryItem dictionary item
* @return CldsDictionaryItem A dictionary items that was created or updated
* in DB
*/
public ResponseEntity<CldsDictionaryItem> createOrUpdateDictionaryElements(String dictionaryName,
- CldsDictionaryItem dictionaryItem) {
+ CldsDictionaryItem dictionaryItem) {
final Date startTime = new Date();
- LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionaryElements", getPrincipalName());
+ LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionaryElements",
+ getPrincipalName());
// TODO revisit based on new permissions
isAuthorized(permissionUpdateTosca);
dictionaryItem.save(dictionaryName, cldsDao, getUserId());
@@ -110,7 +136,7 @@ public class CldsDictionaryService extends SecureServiceBase {
/**
* Rest Service that retrieves all CLDS dictionary in DB.
- *
+ *
* @return CldsDictionary List List of CldsDictionary available in DB
*/
public ResponseEntity<List<CldsDictionary>> getAllDictionaryNames() {
@@ -126,7 +152,7 @@ public class CldsDictionaryService extends SecureServiceBase {
/**
* Rest Service that retrieves all CLDS dictionary items in DB for a give
* dictionary name.
- *
+ *
* @param dictionaryName dictionary name
* @return CldsDictionaryItem list List of CLDS Dictionary items for a given
* dictionary name
@@ -150,4 +176,4 @@ public class CldsDictionaryService extends SecureServiceBase {
util = utilP;
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index 2393f249..37d597ee 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -23,9 +23,13 @@
package org.onap.clamp.loop;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
+import com.google.gson.JsonSyntaxException;
import com.google.gson.annotations.Expose;
+import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
@@ -59,6 +63,7 @@ import org.onap.clamp.loop.components.external.PolicyComponent;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.onap.clamp.policy.operational.OperationalPolicyRepresentationBuilder;
@Entity
@Table(name = "loops")
@@ -70,6 +75,9 @@ public class Loop implements Serializable {
*/
private static final long serialVersionUID = -286522707701388642L;
+ @Transient
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(Loop.class);
+
@Id
@Expose
@Column(nullable = false, name = "name", unique = true)
@@ -92,6 +100,11 @@ public class Loop implements Serializable {
@Expose
@Type(type = "json")
+ @Column(columnDefinition = "json", name = "operational_policy_schema")
+ private JsonObject operationalPolicySchema;
+
+ @Expose
+ @Type(type = "json")
@Column(columnDefinition = "json", name = "global_properties_json")
private JsonObject globalPropertiesJson;
@@ -131,6 +144,9 @@ public class Loop implements Serializable {
this.addComponent(new DcaeComponent());
}
+ /**
+ * Public constructor.
+ */
public Loop() {
initializeExternalComponents();
}
@@ -256,6 +272,13 @@ public class Loop implements Serializable {
void setModelPropertiesJson(JsonObject modelPropertiesJson) {
this.modelPropertiesJson = modelPropertiesJson;
+ try {
+ this.operationalPolicySchema = OperationalPolicyRepresentationBuilder
+ .generateOperationalPolicySchema(this.getModelPropertiesJson());
+ } catch (JsonSyntaxException | IOException | NullPointerException e) {
+ logger.error("Unable to generate the operational policy Schema ... ", e);
+ this.operationalPolicySchema = new JsonObject();
+ }
}
public Map<String, ExternalComponent> getComponents() {
@@ -273,20 +296,16 @@ public class Loop implements Serializable {
/**
* Generate the loop name.
*
- * @param serviceName
- * The service name
- * @param serviceVersion
- * The service version
- * @param resourceName
- * The resource name
- * @param blueprintFileName
- * The blueprint file name
+ * @param serviceName The service name
+ * @param serviceVersion The service version
+ * @param resourceName The resource name
+ * @param blueprintFileName The blueprint file name
* @return The generated loop name
*/
static String generateLoopName(String serviceName, String serviceVersion, String resourceName,
- String blueprintFilename) {
+ String blueprintFilename) {
StringBuilder buffer = new StringBuilder("LOOP_").append(serviceName).append("_v").append(serviceVersion)
- .append("_").append(resourceName).append("_").append(blueprintFilename.replaceAll(".yaml", ""));
+ .append("_").append(resourceName).append("_").append(blueprintFilename.replaceAll(".yaml", ""));
return buffer.toString().replace('.', '_').replaceAll(" ", "");
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java
index ad13ad34..41d34a22 100644
--- a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java
+++ b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java
@@ -99,10 +99,10 @@ public class LoopCsarInstaller implements CsarInstaller {
boolean alreadyInstalled = true;
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
alreadyInstalled = alreadyInstalled
- && loopRepository.existsById(Loop.generateLoopName(csar.getSdcNotification().getServiceName(),
- csar.getSdcNotification().getServiceVersion(),
- blueprint.getValue().getResourceAttached().getResourceInstanceName(),
- blueprint.getValue().getBlueprintArtifactName()));
+ && loopRepository.existsById(Loop.generateLoopName(csar.getSdcNotification().getServiceName(),
+ csar.getSdcNotification().getServiceVersion(),
+ blueprint.getValue().getResourceAttached().getResourceInstanceName(),
+ blueprint.getValue().getBlueprintArtifactName()));
}
return alreadyInstalled;
}
@@ -110,7 +110,7 @@ public class LoopCsarInstaller implements CsarInstaller {
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void installTheCsar(CsarHandler csar)
- throws SdcArtifactInstallerException, InterruptedException, PolicyModelException {
+ throws SdcArtifactInstallerException, InterruptedException, PolicyModelException {
try {
logger.info("Installing the CSAR " + csar.getFilePath());
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
@@ -126,53 +126,53 @@ public class LoopCsarInstaller implements CsarInstaller {
}
private Loop createLoopFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact)
- throws IOException, ParseException, InterruptedException {
+ throws IOException, ParseException, InterruptedException {
Loop newLoop = new Loop();
newLoop.setBlueprint(blueprintArtifact.getDcaeBlueprint());
newLoop.setName(Loop.generateLoopName(csar.getSdcNotification().getServiceName(),
- csar.getSdcNotification().getServiceVersion(),
- blueprintArtifact.getResourceAttached().getResourceInstanceName(),
- blueprintArtifact.getBlueprintArtifactName()));
+ csar.getSdcNotification().getServiceVersion(),
+ blueprintArtifact.getResourceAttached().getResourceInstanceName(),
+ blueprintArtifact.getBlueprintArtifactName()));
newLoop.setLastComputedState(LoopState.DESIGN);
List<MicroService> microServicesChain = chainGenerator
- .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint()));
+ .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint()));
if (microServicesChain.isEmpty()) {
microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint());
}
-
- newLoop
- .setMicroServicePolicies(createMicroServicePolicies(microServicesChain, csar, blueprintArtifact, newLoop));
+ newLoop.setModelPropertiesJson(createModelPropertiesJson(csar));
+ newLoop.setMicroServicePolicies(
+ createMicroServicePolicies(microServicesChain, csar, blueprintArtifact, newLoop));
newLoop.setOperationalPolicies(createOperationalPolicies(csar, blueprintArtifact, newLoop));
newLoop.setSvgRepresentation(svgFacade.getSvgImage(microServicesChain));
newLoop.setGlobalPropertiesJson(createGlobalPropertiesJson(blueprintArtifact, newLoop));
- newLoop.setModelPropertiesJson(createModelPropertiesJson(csar));
+
DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact);
newLoop.setDcaeBlueprintId(dcaeResponse.getTypeId());
return newLoop;
}
private HashSet<OperationalPolicy> createOperationalPolicies(CsarHandler csar, BlueprintArtifact blueprintArtifact,
- Loop newLoop) {
+ Loop newLoop) {
return new HashSet<>(Arrays.asList(new OperationalPolicy(Policy.generatePolicyName("OPERATIONAL",
- csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
- blueprintArtifact.getResourceAttached().getResourceInstanceName(),
- blueprintArtifact.getBlueprintArtifactName()), newLoop, new JsonObject())));
+ csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
+ blueprintArtifact.getResourceAttached().getResourceInstanceName(),
+ blueprintArtifact.getBlueprintArtifactName()), newLoop, new JsonObject())));
}
private HashSet<MicroServicePolicy> createMicroServicePolicies(List<MicroService> microServicesChain,
- CsarHandler csar, BlueprintArtifact blueprintArtifact, Loop newLoop) throws IOException {
+ CsarHandler csar, BlueprintArtifact blueprintArtifact, Loop newLoop) throws IOException {
HashSet<MicroServicePolicy> newSet = new HashSet<>();
for (MicroService microService : microServicesChain) {
MicroServicePolicy microServicePolicy = new MicroServicePolicy(
- Policy.generatePolicyName(microService.getName(), csar.getSdcNotification().getServiceName(),
- csar.getSdcNotification().getServiceVersion(),
- blueprintArtifact.getResourceAttached().getResourceInstanceName(),
- blueprintArtifact.getBlueprintArtifactName()),
- microService.getModelType(), csar.getPolicyModelYaml().orElse(""), false,
- new HashSet<>(Arrays.asList(newLoop)));
+ Policy.generatePolicyName(microService.getName(), csar.getSdcNotification().getServiceName(),
+ csar.getSdcNotification().getServiceVersion(),
+ blueprintArtifact.getResourceAttached().getResourceInstanceName(),
+ blueprintArtifact.getBlueprintArtifactName()),
+ microService.getModelType(), csar.getPolicyModelYaml().orElse(""), false,
+ new HashSet<>(Arrays.asList(newLoop)));
newSet.add(microServicePolicy);
microService.setMappedNameJpa(microServicePolicy.getName());
@@ -191,8 +191,8 @@ public class LoopCsarInstaller implements CsarInstaller {
// Loop on all Groups defined in the service (VFModule entries type:
// org.openecomp.groups.VfModule)
for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity(
- EntityQuery.newBuilder(EntityTemplateType.GROUP).build(),
- TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) {
+ EntityQuery.newBuilder(EntityTemplateType.GROUP).build(),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) {
// Get all metadata info
JsonObject allVfProps = (JsonObject) JsonUtils.GSON.toJsonTree(entity.getMetadata().getAllProperties());
vfModuleProps.add(entity.getMetadata().getAllProperties().get("vfModuleModelName"), allVfProps);
@@ -200,7 +200,7 @@ public class LoopCsarInstaller implements CsarInstaller {
// volume_group, etc ... fields under the VFmodule name
for (Entry<String, Property> additionalProp : entity.getProperties().entrySet()) {
allVfProps.add(additionalProp.getValue().getName(),
- JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue()));
+ JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue()));
}
}
return vfModuleProps;
@@ -214,7 +214,7 @@ public class LoopCsarInstaller implements CsarInstaller {
// For each type, get the metadata of each nodetemplate
for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) {
resourcesPropByType.add(nodeTemplate.getName(),
- JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties()));
+ JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties()));
}
resourcesProp.add(type.getValue(), resourcesPropByType);
}
@@ -225,7 +225,7 @@ public class LoopCsarInstaller implements CsarInstaller {
JsonObject modelProperties = new JsonObject();
// Add service details
modelProperties.add("serviceDetails", JsonUtils.GSON.fromJson(
- JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class));
+ JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class));
// Add properties details for each type, VfModule, VF, VFC, ....
JsonObject resourcesProp = createServicePropertiesByType(csar);
resourcesProp.add("VFModule", createVfModuleProperties(csar));
@@ -237,7 +237,7 @@ public class LoopCsarInstaller implements CsarInstaller {
JsonObject node = new JsonObject();
Yaml yaml = new Yaml();
Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
- .load(blueprintArtifact.getDcaeBlueprint())).get("inputs"));
+ .load(blueprintArtifact.getDcaeBlueprint())).get("inputs"));
inputsNodes.entrySet().stream().filter(e -> !e.getKey().contains("policy_id")).forEach(elem -> {
Object defaultValue = ((Map<String, Object>) elem.getValue()).get("default");
if (defaultValue != null) {
@@ -258,10 +258,10 @@ public class LoopCsarInstaller implements CsarInstaller {
* @return The DcaeInventoryResponse object containing the dcae values
*/
private DcaeInventoryResponse queryDcaeToGetServiceTypeId(BlueprintArtifact blueprintArtifact)
- throws IOException, ParseException, InterruptedException {
+ throws IOException, ParseException, InterruptedException {
return dcaeInventoryService.getDcaeInformation(blueprintArtifact.getBlueprintArtifactName(),
- blueprintArtifact.getBlueprintInvariantServiceUuid(),
- blueprintArtifact.getResourceAttached().getResourceInvariantUUID());
+ blueprintArtifact.getBlueprintInvariantServiceUuid(),
+ blueprintArtifact.getResourceAttached().getResourceInvariantUUID());
}
private void addPropertyToNode(JsonObject node, String key, Object value) {
diff --git a/src/main/java/org/onap/clamp/loop/components/external/ExternalComponent.java b/src/main/java/org/onap/clamp/loop/components/external/ExternalComponent.java
index a8aae203..2be707fe 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/ExternalComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/ExternalComponent.java
@@ -28,9 +28,7 @@ import com.google.gson.annotations.Expose;
import org.apache.camel.Exchange;
/**
- *
- * SHould be abstract but Gson can't instantiate it if it's an abstract
- *
+ * Should be abstract but Gson can't instantiate it if it's an abstract.
*/
public class ExternalComponent {
@Expose
@@ -49,7 +47,7 @@ public class ExternalComponent {
}
public ExternalComponentState computeState(Exchange camelExchange) {
- return new ExternalComponentState("INIT", "no desc");
+ return new ExternalComponentState("INIT", "no desc", 0);
}
public ExternalComponent(ExternalComponentState initialState) {
diff --git a/src/main/java/org/onap/clamp/loop/components/external/ExternalComponentState.java b/src/main/java/org/onap/clamp/loop/components/external/ExternalComponentState.java
index 6a723c24..a220ee1d 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/ExternalComponentState.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/ExternalComponentState.java
@@ -29,18 +29,26 @@ import com.google.gson.annotations.Expose;
* This is a transient state reflecting the deployment status of a component. It
* can be Policy, DCAE, or whatever... This is object is generic. Clamp is now
* stateless, so it triggers the different components at runtime, the status per
- * component is stored here.
+ * component is stored here. The state level is used to re-compute the global
+ * state when multiple sub states are required for that computation (generally
+ * provided sequentially to the method computeState from the camel routes.
*
*/
-public class ExternalComponentState {
+public class ExternalComponentState implements Comparable<ExternalComponentState> {
@Expose
private String stateName;
@Expose
private String description;
+ private int stateLevel;
- public ExternalComponentState(String stateName, String description) {
+ public ExternalComponentState(String stateName, String description, int level) {
this.stateName = stateName;
this.description = description;
+ this.stateLevel = level;
+ }
+
+ public ExternalComponentState(String stateName, String description) {
+ this(stateName, description, 0);
}
public ExternalComponentState() {
@@ -58,4 +66,50 @@ public class ExternalComponentState {
public String toString() {
return stateName;
}
+
+ public int getLevel() {
+ return stateLevel;
+ }
+
+ public void setLevel(int priority) {
+ this.stateLevel = priority;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((stateName == null) ? 0 : stateName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ExternalComponentState other = (ExternalComponentState) obj;
+ if (stateName == null) {
+ if (other.stateName != null)
+ return false;
+ } else if (!stateName.equals(other.stateName))
+ return false;
+ return true;
+ }
+
+ /**
+ * This method compares this object by using the level of them.
+ *
+ * @param stateToCompare The state to compare to the current object
+ * @return If the one given in input has a higher level than the current object
+ * it returns -1, 1 otherwise and 0 if equals.
+ */
+ @Override
+ public int compareTo(ExternalComponentState stateToCompare) {
+ return Integer.compare(this.getLevel(), stateToCompare.getLevel());
+ }
+
}
diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
index acd6115f..68d598b5 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java
@@ -44,17 +44,22 @@ public class PolicyComponent extends ExternalComponent {
@Transient
private static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyComponent.class);
+ public static final ExternalComponentState IN_ERROR = new ExternalComponentState("IN_ERROR",
+ "There was an error during the sending to policy, the policy engine may be corrupted or inconsistent", 100);
public static final ExternalComponentState NOT_SENT = new ExternalComponentState("NOT_SENT",
- "The policies defined have NOT yet been created on the policy engine");
+ "The policies defined have NOT yet been created on the policy engine", 90);
public static final ExternalComponentState SENT = new ExternalComponentState("SENT",
- "The policies defined have been created but NOT deployed on the policy engine");
+ "The policies defined have been created but NOT deployed on the policy engine", 50);
public static final ExternalComponentState SENT_AND_DEPLOYED = new ExternalComponentState("SENT_AND_DEPLOYED",
- "The policies defined have been created and deployed on the policy engine");
- public static final ExternalComponentState IN_ERROR = new ExternalComponentState("IN_ERROR",
- "There was an error during the sending to policy, the policy engine may be corrupted or inconsistent");
+ "The policies defined have been created and deployed on the policy engine", 10);
public PolicyComponent() {
- super(NOT_SENT);
+ /*
+ * We assume it's good by default as we will receive the state for each policy
+ * on by one, each time we increase the level we can't decrease it anymore.
+ * That's why it starts with the lowest one SENT_AND_DEPLOYED.
+ */
+ super(SENT_AND_DEPLOYED);
}
@Override
@@ -103,21 +108,38 @@ public class PolicyComponent extends ExternalComponent {
return policyNamesList;
}
+ private static ExternalComponentState findNewState(boolean found, boolean deployed) {
+
+ ExternalComponentState newState = NOT_SENT;
+ if (found && deployed) {
+ newState = SENT_AND_DEPLOYED;
+ } else if (found) {
+ newState = SENT;
+ } else if (deployed) {
+ newState = IN_ERROR;
+ }
+ return newState;
+ }
+
+ private static ExternalComponentState mergeStates(ExternalComponentState oldState,
+ ExternalComponentState newState) {
+ return (oldState.compareTo(newState) < 0) ? newState : oldState;
+ }
+
+ /**
+ * This is a method that expect the results of the queries getPolicy and
+ * getPolicyDeployed for a unique policy (op,guard, config, etc ...). It
+ * re-computes the global policy state for each policy results given. Therefore
+ * this method is called multiple times from the camel route and must be reset
+ * for a new global policy state retrieval. The state to compute the global
+ * policy state is stored in this class.
+ *
+ */
@Override
public ExternalComponentState computeState(Exchange camelExchange) {
- boolean oneNotFound = (boolean) camelExchange.getIn().getExchange().getProperty("atLeastOnePolicyNotFound");
- boolean oneNotDeployed = (boolean) camelExchange.getIn().getExchange()
- .getProperty("atLeastOnePolicyNotDeployed");
-
- if (oneNotFound && oneNotDeployed) {
- this.setState(NOT_SENT);
- } else if (!oneNotFound && oneNotDeployed) {
- this.setState(SENT);
- } else if (!oneNotFound && !oneNotDeployed) {
- this.setState(SENT_AND_DEPLOYED);
- } else {
- this.setState(IN_ERROR);
- }
+ this.setState(mergeStates(this.getState(),
+ findNewState((boolean) camelExchange.getIn().getExchange().getProperty("policyFound"),
+ (boolean) camelExchange.getIn().getExchange().getProperty("policyDeployed"))));
return this.getState();
}
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
index 33148f0b..dd156d8f 100644
--- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java
@@ -25,6 +25,7 @@ package org.onap.clamp.policy.operational;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
@@ -33,16 +34,15 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import org.apache.commons.lang3.math.NumberUtils;
+import org.onap.clamp.loop.Loop;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
import org.yaml.snakeyaml.Yaml;
/**
- *
* This class contains the code required to support the sending of Legacy
* operational payload to policy engine. This will probably disappear in El
* Alto.
- *
*/
public class LegacyOperationalPolicy {
@@ -76,6 +76,13 @@ public class LegacyOperationalPolicy {
return jsonElement;
}
+ /**
+ * This method rework the payload attribute (yaml) that is normally wrapped in a
+ * string when coming from the UI.
+ *
+ * @param policyJson The operational policy json config
+ * @return The same object reference but modified
+ */
public static JsonElement reworkPayloadAttributes(JsonElement policyJson) {
for (JsonElement policy : policyJson.getAsJsonObject().get("policies").getAsJsonArray()) {
JsonElement payloadElem = policy.getAsJsonObject().get("payload");
@@ -135,9 +142,15 @@ public class LegacyOperationalPolicy {
return mapResult;
}
+ /**
+ * This method transforms the configuration json to a Yaml format.
+ *
+ * @param operationalPolicyJsonElement The operational policy json config
+ * @return The Yaml as string
+ */
public static String createPolicyPayloadYamlLegacy(JsonElement operationalPolicyJsonElement) {
JsonElement opPolicy = fulfillPoliciesTreeField(
- removeAllQuotes(reworkPayloadAttributes(operationalPolicyJsonElement.getAsJsonObject().deepCopy())));
+ removeAllQuotes(reworkPayloadAttributes(operationalPolicyJsonElement.getAsJsonObject().deepCopy())));
Map<?, ?> jsonMap = createMap(opPolicy);
DumperOptions options = new DumperOptions();
options.setDefaultScalarStyle(ScalarStyle.PLAIN);
@@ -147,4 +160,22 @@ public class LegacyOperationalPolicy {
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
return (new Yaml(options)).dump(jsonMap);
}
+
+ /**
+ * This method load mandatory field in the operational policy configuration
+ * JSON.
+ *
+ * @param configurationsJson The operational policy JSON
+ * @param loop The parent loop object
+ */
+ public static void preloadConfiguration(JsonObject configurationsJson, Loop loop) {
+ if (configurationsJson.entrySet().isEmpty()) {
+ JsonObject controlLoopName = new JsonObject();
+ controlLoopName.addProperty("controlLoopName",
+ loop != null ? loop.getName() : "Empty (NO loop loaded yet)");
+ JsonObject controlLoop = new JsonObject();
+ controlLoop.add("controlLoop", controlLoopName);
+ configurationsJson.add("operational_policy", controlLoop);
+ }
+ }
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index 62c5a1e9..86f8ac39 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -38,7 +38,6 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -91,17 +90,16 @@ public class OperationalPolicy implements Serializable, Policy {
/**
* The constructor.
*
- * @param name
- * The name of the operational policy
- * @param loop
- * The loop that uses this operational policy
- * @param configurationsJson
- * The operational policy property in the format of json
+ * @param name The name of the operational policy
+ * @param loop The loop that uses this operational policy
+ * @param configurationsJson The operational policy property in the format of
+ * json
*/
public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson) {
this.name = name;
this.loop = loop;
this.configurationsJson = configurationsJson;
+ LegacyOperationalPolicy.preloadConfiguration(this.configurationsJson, loop);
}
@Override
@@ -117,11 +115,6 @@ public class OperationalPolicy implements Serializable, Policy {
return loop;
}
- @Override
- public JsonObject getJsonRepresentation() {
- return configurationsJson;
- }
-
public JsonObject getConfigurationsJson() {
return configurationsJson;
}
@@ -131,6 +124,11 @@ public class OperationalPolicy implements Serializable, Policy {
}
@Override
+ public JsonObject getJsonRepresentation() {
+ return null;
+ }
+
+ @Override
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -184,7 +182,7 @@ public class OperationalPolicy implements Serializable, Policy {
metadata.addProperty("policy-id", this.name);
operationalPolicyDetails.add("properties", LegacyOperationalPolicy
- .reworkPayloadAttributes(this.configurationsJson.get("operational_policy").deepCopy()));
+ .reworkPayloadAttributes(this.configurationsJson.get("operational_policy").deepCopy()));
Gson gson = new GsonBuilder().create();
@@ -204,9 +202,8 @@ public class OperationalPolicy implements Serializable, Policy {
// Now using the legacy payload fo Dublin
JsonObject payload = new JsonObject();
payload.addProperty("policy-id", this.getName());
- payload.addProperty("content", URLEncoder.encode(
- LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(this.configurationsJson.get("operational_policy")),
- StandardCharsets.UTF_8.toString()));
+ payload.addProperty("content", URLEncoder.encode(LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(
+ this.configurationsJson.get("operational_policy")), StandardCharsets.UTF_8.toString()));
String opPayload = new GsonBuilder().setPrettyPrinting().create().toJson(payload);
logger.info("Operational policy payload: " + opPayload);
return opPayload;
@@ -222,11 +219,9 @@ public class OperationalPolicy implements Serializable, Policy {
JsonElement guardsList = this.getConfigurationsJson().get("guard_policies");
if (guardsList != null) {
- for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) {
- JsonObject guard = new JsonObject();
- guard.addProperty("policy-id", guardElem.getKey());
- guard.add("content", guardElem.getValue());
- result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard));
+ for (JsonElement guardElem : guardsList.getAsJsonArray()) {
+ result.put(guardElem.getAsJsonObject().get("policy-id").getAsString(),
+ new GsonBuilder().create().toJson(guardElem));
}
}
logger.info("Guard policy payload: " + result);
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
new file mode 100644
index 00000000..f6f3f498
--- /dev/null
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.policy.operational;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSyntaxException;
+
+import java.io.IOException;
+import java.util.Map.Entry;
+
+import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+
+public class OperationalPolicyRepresentationBuilder {
+
+ /**
+ * This method generates the operational policy json representation that will be
+ * used by ui for rendering. It uses the model (VF and VFModule) defined in the
+ * loop object to do so, so it's dynamic. It also uses the operational policy
+ * schema template defined in the resource folder.
+ *
+ * @param modelJson The loop model json
+ * @return The json representation
+ * @throws JsonSyntaxException If the schema template cannot be parsed
+ * @throws IOException In case of issue when opening the schema template
+ */
+ public static JsonObject generateOperationalPolicySchema(JsonObject modelJson)
+ throws JsonSyntaxException, IOException {
+ JsonObject jsonSchema = JsonUtils.GSON.fromJson(
+ ResourceFileUtil.getResourceAsString("clds/json-schema/operational_policies/operational_policy.json"),
+ JsonObject.class);
+ jsonSchema.get("schema").getAsJsonObject().get("items").getAsJsonObject().get("properties").getAsJsonObject()
+ .get("configurationsJson").getAsJsonObject().get("properties").getAsJsonObject()
+ .get("operational_policy").getAsJsonObject().get("properties").getAsJsonObject().get("policies")
+ .getAsJsonObject().get("items").getAsJsonObject().get("properties").getAsJsonObject().get("target")
+ .getAsJsonObject().get("anyOf").getAsJsonArray().addAll(createAnyOfArray(modelJson));
+ return jsonSchema;
+ }
+
+ private static JsonObject createSchemaProperty(String title, String type, String defaultValue, String readOnlyFlag,
+ String[] enumArray) {
+ JsonObject property = new JsonObject();
+ property.addProperty("title", title);
+ property.addProperty("type", type);
+ property.addProperty("default", defaultValue);
+ property.addProperty("readOnly", readOnlyFlag);
+
+ if (enumArray != null) {
+ JsonArray jsonArray = new JsonArray();
+ property.add("enum", jsonArray);
+ for (String val : enumArray) {
+ jsonArray.add(val);
+ }
+ }
+ return property;
+ }
+
+ private static JsonArray createVnfSchema(JsonObject modelJson) {
+ JsonArray vnfSchemaArray = new JsonArray();
+ JsonObject modelVnfs = modelJson.get("resourceDetails").getAsJsonObject().get("VF").getAsJsonObject();
+
+ for (Entry<String, JsonElement> entry : modelVnfs.entrySet()) {
+ JsonObject vnfOneOfSchema = new JsonObject();
+ vnfOneOfSchema.addProperty("title", "VNF" + "-" + entry.getKey());
+ JsonObject properties = new JsonObject();
+ properties.add("type", createSchemaProperty("Type", "string", "VNF", "True", null));
+ properties.add("resourceID", createSchemaProperty("Resource ID", "string",
+ modelVnfs.get(entry.getKey()).getAsJsonObject().get("name").getAsString(), "True", null));
+
+ vnfOneOfSchema.add("properties", properties);
+ vnfSchemaArray.add(vnfOneOfSchema);
+ }
+ return vnfSchemaArray;
+ }
+
+ private static JsonArray createVfModuleSchema(JsonObject modelJson) {
+ JsonArray vfModuleOneOfSchemaArray = new JsonArray();
+ JsonObject modelVfModules = modelJson.get("resourceDetails").getAsJsonObject().get("VFModule")
+ .getAsJsonObject();
+
+ for (Entry<String, JsonElement> entry : modelVfModules.entrySet()) {
+ JsonObject vfModuleOneOfSchema = new JsonObject();
+ vfModuleOneOfSchema.addProperty("title", "VFMODULE" + "-" + entry.getKey());
+ JsonObject properties = new JsonObject();
+ properties.add("type", createSchemaProperty("Type", "string", "VFMODULE", "True", null));
+ properties.add("resourceID",
+ createSchemaProperty("Resource ID", "string",
+ modelVfModules.get(entry.getKey()).getAsJsonObject().get("vfModuleModelName").getAsString(),
+ "True", null));
+ properties.add("modelInvariantId",
+ createSchemaProperty("Model Invariant Id (ModelInvariantUUID)", "string", modelVfModules
+ .get(entry.getKey()).getAsJsonObject().get("vfModuleModelInvariantUUID").getAsString(),
+ "True", null));
+ properties.add("modelVersionId",
+ createSchemaProperty("Model Version Id (ModelUUID)", "string",
+ modelVfModules.get(entry.getKey()).getAsJsonObject().get("vfModuleModelUUID").getAsString(),
+ "True", null));
+ properties.add("modelName",
+ createSchemaProperty("Model Name", "string",
+ modelVfModules.get(entry.getKey()).getAsJsonObject().get("vfModuleModelName").getAsString(),
+ "True", null));
+ properties.add("modelVersion", createSchemaProperty("Model Version", "string",
+ modelVfModules.get(entry.getKey()).getAsJsonObject().get("vfModuleModelVersion").getAsString(),
+ "True", null));
+ properties
+ .add("modelCustomizationId",
+ createSchemaProperty("Customization ID", "string", modelVfModules.get(entry.getKey())
+ .getAsJsonObject().get("vfModuleModelCustomizationUUID").getAsString(), "True",
+ null));
+
+ vfModuleOneOfSchema.add("properties", properties);
+ vfModuleOneOfSchemaArray.add(vfModuleOneOfSchema);
+ }
+ return vfModuleOneOfSchemaArray;
+ }
+
+ private static JsonArray createAnyOfArray(JsonObject modelJson) {
+ JsonArray targetOneOfStructure = new JsonArray();
+ targetOneOfStructure.addAll(createVnfSchema(modelJson));
+ targetOneOfStructure.addAll(createVfModuleSchema(modelJson));
+ return targetOneOfStructure;
+ }
+}
diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html
index 4809ffab..8257d87d 100644
--- a/src/main/resources/META-INF/resources/swagger.html
+++ b/src/main/resources/META-INF/resources/swagger.html
@@ -4509,7 +4509,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2018-07-06 11:58:45 CEST
+Last updated 2019-08-12 03:34:46 PDT
</div>
</div>
</body>
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 52f79bef..cec02579 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,7 +51,21 @@ info.build.version=@project.version@
### server.ssl.key-store=file:/tmp/mykey.jks
### server.ssl.key-store-password=mypass
### server.ssl.key-password=mypass
-server.port=8080
+server.port=8443
+## Config part for Server certificates
+# Can be a classpath parameter instead of file:/
+server.ssl.key-store=classpath:/clds/aaf/org.onap.clamp.p12
+server.ssl.key-store-password=China in the Spring
+server.ssl.key-password=China in the Spring
+server.ssl.key-store-type=PKCS12
+server.ssl.key-alias=clamp@clamp.onap.org
+
+## Config part for Client certificates
+server.ssl.client-auth=want
+server.ssl.trust-store=classpath:/clds/aaf/truststoreONAPall.jks
+server.ssl.trust-store-password=changeit
+
+#server.http-to-https-redirection.port=8080
server.servlet.context-path=/
#Modified engine-rest applicationpath
@@ -141,6 +155,7 @@ clamp.config.policy.api.password=zb!XztG34
clamp.config.policy.pap.url=http4://policy.api.simpledemo.onap.org:6969
clamp.config.policy.pap.userName=healthcheck
clamp.config.policy.pap.password=zb!XztG34
+
clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
clamp.config.policy.pdpUrl2=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123
clamp.config.policy.papUrl=http://policy.api.simpledemo.onap.org:8081/pap/ , testpap, alpha123
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 534dc481..dcad32ed 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -255,5 +255,5 @@ clamp.config.cadi.cadiTruststorePassword=enc:Mj0YQqNCUKbKq2lPp1kTFQWeqLxaBXKNwd5
#clamp.config.cadi.oauthTokenUrl=https://AAF_LOCATE_URL/AAF_NS.token:2.0/token
#clamp.config.cadi.oauthIntrospectUrll=https://AAF_LOCATE_URL/AAF_NS.introspect:2.0/introspect
clamp.config.cadi.aafEnv=DEV
-clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/AAF_NS.service:2.0
+clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.service:2.1
clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US
diff --git a/src/main/resources/clds/aaf/ssl/clamp.key b/src/main/resources/clds/aaf/ssl/clamp.key
new file mode 100644
index 00000000..fcf68bfa
--- /dev/null
+++ b/src/main/resources/clds/aaf/ssl/clamp.key
@@ -0,0 +1,32 @@
+Bag Attributes
+ friendlyName: clamp@clamp.onap.org
+ localKeyID: 54 69 6D 65 20 31 35 35 33 37 38 37 35 31 38 33 30 33
+Key Attributes: <No Attributes>
+-----BEGIN PRIVATE KEY-----
+MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC4nLg3HAYzgJTr
+C9WdZypwz0UzcQcCFXwEUUA8StwtMwx0OahJiEJRdFY6fmydq4MzFgZ6HQt/M7dY
+0l8phLHpGTVdrFMgW8yZer8bwNcSSiPVRy8j0s8lBHdR+KofG+yA19xg6lCYDX78
+yfeA2jZ52FhVWavyGHS4whWlw8T1EGbZZqXZCFgc7zHjUXuG1mo2ropppJkouf9g
+WEH2Vx16YiosgZzftRW1N3KJ7JozcEtS/j4w/pNyS7HOQDWWGTDk6Us4bt8Zg4gd
+1FeID0FmnEEGRKP+XscsGNwMd06MBsCAOutHkpFtS+UT3cr8xIKewL7uPq24X3ke
+W148togFAgMBAAECggEATncV+R5pKFS7dteV2IvzxvTh1cZxkxoslu0t3zJ2OKPc
+5D1pYK+QeGx5Be2cHru6TOlMoXRc4ZjKke8AUXY74/Y573GB91vtL0KznYkuIHDw
+oALcb153eqVWTbniHMzSjcSxv2N4E9iQo8L39oVI6CrjCIvPgFuSqMCdUNJPkVTI
+4nsarTfLK4fzi7IbWzi9JdE1QRNIxcCMcYJRnLZMdneMLBleR0UL82Xc2KOy5SEt
+zyKYCQ8zS247FKolnOrDkhKxXI5fzdDpRK5AQSsAykUPWlYq7pzKjY/dU9rMRohx
+YSltFjPZ3sQ3UKqqIqhZS+GoVuZoc925WyhViPsqtQKBgQDsL4LFfPWN8nnsusQp
+VR3T7HvvwXuEVAydlaJMwZU0cRYN+L7RHHjDoXZZrNJDIDzNoWnBLKRGx3mtLmgJ
+9Pa6SxN6Oc8oo6jzv2D59g1PVjNOMOYTCTb/2Xum4LMLaeeF57HkWxzeA3Ws47++
+gXwzQpbE90tp1Ys4uXD3JoivvwKBgQDIGZTwLGhLSegdAjG83WEgmdtzT1kjvx0Q
+A8IR2jkgkTJHdKiuslJ8Z3/XufHEwWMWwfs1XLwxYluoo1y9eNvNeHZXjLqjL62c
+I3034F9IvvTUqFcxam2WdoklXbAiSvLUo/9exPgOuVxok6Zv1imRgGb/vYV9vyG7
+86MRuQu5OwKBgQC9E3fcA6JMpY3H3uhEsngzfMDm+fyYvfRvfyezzNFWbyWZv8V6
+gBGJg0vMlFarGDa044BW/hbw9qXI5zqwpeOS1aFdGsRlo0cRAuduk/Spy7c85FZ7
+bMgT4BZmTMHo5DpNb2NxDSO59AkThCuvJde47ZjnS5WavzI6EfKGWNnZ3wKBgQCF
+QiwjCp/mS/DtqLFxAsmVSYGROG231aXILYiIFRloa+ndFn7j4NP4D4FfLHErRFL2
+K/ddIUYfaU57b1fqwts26ht90LXWyYDH9AaHOMCcFLe+C+INgcA7rPNG1C7hl6JC
+JHmEJo7AV4eICZSU9D44rRdrB08oYCpaHjYiLmb1UwKBgQCWCDJ4p2DrNL9hzj3K
+kzvM5saXrfI4aVBXVt9rw9s1d/WG8JOpnmHcnLPb6Tj59rDktrLCLv0sVstMwNVJ
+sOO+qsgn1VoZalcVhhjdONm5YvhJQgz0F7Y2xkr6g/AuMPz2YigGfm7fe/z7rc+L
+q9Ua2HmUS8DDBy7W89MNZJNkDQ==
+-----END PRIVATE KEY-----
diff --git a/src/main/resources/clds/aaf/ssl/clamp.pem b/src/main/resources/clds/aaf/ssl/clamp.pem
new file mode 100644
index 00000000..ccb0097d
--- /dev/null
+++ b/src/main/resources/clds/aaf/ssl/clamp.pem
@@ -0,0 +1,64 @@
+Bag Attributes
+ friendlyName: clamp@clamp.onap.org
+ localKeyID: 54 69 6D 65 20 31 35 35 33 37 38 37 35 31 38 33 30 33
+subject=CN = clamp, emailAddress = , OU = clamp@clamp.onap.org, OU = OSAAF, O = ONAP, C = US
+
+issuer=C = US, O = ONAP, OU = OSAAF, CN = intermediateCA_9
+
+-----BEGIN CERTIFICATE-----
+MIIEKDCCAxCgAwIBAgIIWY+5kgf/UG4wDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE
+BhMCVVMxDTALBgNVBAoMBE9OQVAxDjAMBgNVBAsMBU9TQUFGMRkwFwYDVQQDDBBp
+bnRlcm1lZGlhdGVDQV85MB4XDTE5MDMyMTE2MTY1OFoXDTIwMDMyMTE2MTY1OFow
+bDEOMAwGA1UEAwwFY2xhbXAxDzANBgkqhkiG9w0BCQEWADEdMBsGA1UECwwUY2xh
+bXBAY2xhbXAub25hcC5vcmcxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQKDARPTkFQ
+MQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALic
+uDccBjOAlOsL1Z1nKnDPRTNxBwIVfARRQDxK3C0zDHQ5qEmIQlF0Vjp+bJ2rgzMW
+BnodC38zt1jSXymEsekZNV2sUyBbzJl6vxvA1xJKI9VHLyPSzyUEd1H4qh8b7IDX
+3GDqUJgNfvzJ94DaNnnYWFVZq/IYdLjCFaXDxPUQZtlmpdkIWBzvMeNRe4bWajau
+immkmSi5/2BYQfZXHXpiKiyBnN+1FbU3consmjNwS1L+PjD+k3JLsc5ANZYZMOTp
+Szhu3xmDiB3UV4gPQWacQQZEo/5exywY3Ax3TowGwIA660eSkW1L5RPdyvzEgp7A
+vu4+rbhfeR5bXjy2iAUCAwEAAaOB8jCB7zAJBgNVHRMEAjAAMA4GA1UdDwEB/wQE
+AwIF4DAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwVAYDVR0jBE0w
+S4AUgfeZWxC5yIze81Je6k5poEM+rN2hMKQuMCwxDjAMBgNVBAsMBU9TQUFGMQ0w
+CwYDVQQKDARPTkFQMQswCQYDVQQGEwJVU4IBBzAdBgNVHQ4EFgQU+GZ6wmWDPrmq
+Wd1/NtMYiCQ8Dg4wOwYDVR0RBDQwMoIFY2xhbXCCHWNsYW1wLmFwaS5zaW1wbGVk
+ZW1vLm9uYXAub3JnggpjbGFtcC5vbmFwMA0GCSqGSIb3DQEBCwUAA4IBAQCFZdhB
+U6xm6l0vj4q89onLx4opTPvwGNRc0n402lifkPYXseFtphZSHIf2Sg0mFTH4KHb4
+FdMyBzq1+f5WLU+xRC1nT4eGJ0FvRR6204/fGVrzJTS67phnRnxr2WZzLPW0wPJe
+K8SzN6tkUgE7/a/s0T/htE/blDxWh75+tA2jQlgj1Ri0y9A1J8wx++REKjGlHjFN
+53aiipsB+wC/oEMzYL4qEPiYPI0Lr3Lsay1F7f6cvDT4+EYzBLMFuwCvpcnHgSMS
+4fFj2ROmUG2+CC23B88Q0WNxjLPq/CrmHZZBsqwruPJ0cSuCQxfshTQ6uZhcjtu8
+6TRYkIcL0x9r/AHP
+-----END CERTIFICATE-----
+Bag Attributes
+ friendlyName: CN=intermediateCA_9,OU=OSAAF,O=ONAP,C=US
+subject=C = US, O = ONAP, OU = OSAAF, CN = intermediateCA_9
+
+issuer=OU = OSAAF, O = ONAP, C = US
+
+-----BEGIN CERTIFICATE-----
+MIIEdTCCAl2gAwIBAgIBBzANBgkqhkiG9w0BAQsFADAsMQ4wDAYDVQQLDAVPU0FB
+RjENMAsGA1UECgwET05BUDELMAkGA1UEBhMCVVMwHhcNMTgwODE3MTg1MTM3WhcN
+MjMwODE3MTg1MTM3WjBHMQswCQYDVQQGEwJVUzENMAsGA1UECgwET05BUDEOMAwG
+A1UECwwFT1NBQUYxGTAXBgNVBAMMEGludGVybWVkaWF0ZUNBXzkwggEiMA0GCSqG
+SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCv0HHUkba3uNtNI3jPKimUcd6RNwmhSCJL
+neMWpnjqp5/A+HCKyNsEaT4y177hNLmCm/aMm1u2JIfikc+8wEqLCSBBPz+P0h+d
+o+sZ7U+4oeQizdYYpEdzHJ2SieHHa8vtu80rU3nO2NEIkuYC20HcKSEtl8fFKsk3
+nqlhY+tGfYJPTXcDOQAO40BTcgat3C3uIJHkWJJ4RivunE4LEuRv9QyKgAw7rkJV
+v+f7guqpZlXy6dzAkuU7XULWcgo55MkZlssoiErMvEZJad5aWKvRY3g7qUjaQ6wO
+15wOAUoRBW96eeZZbytgn8kybcBy++Ue49gPtgm1MF/KlAsp0MD5AgMBAAGjgYYw
+gYMwHQYDVR0OBBYEFIH3mVsQuciM3vNSXupOaaBDPqzdMB8GA1UdIwQYMBaAFFNV
+M/JL69BRscF4msEoMXvv6u1JMBIGA1UdEwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/
+BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjANBgkqhkiG9w0B
+AQsFAAOCAgEADxNymiCNr2e37iLReoaxKmZvwox0cTiNAaj7iafRzmwIoY3VXO8Q
+ix5IYcp4FaQ7fV1jyp/AmaSnyHf6Osl0sx8PxsQkO7ALttxKUrjfbvNSVUA2C/vl
+u5m7UVJLIUtFDZBWanzUSmkTsYLHpiANFQKd2c/cU1qXcyzgJVFEFVyyHNkF7Is+
++pjG9M1hwQHOoTnEuU013P7X1mHek+RXEfhJWwe7UsZnBKZaZKbQZu7hEtqKWYp/
+QsHgnjoLYXsh0WD5rz/mBxdTdDLGpFqWDzDqb8rsYnqBzoowvsasV8X8OSkov0Ht
+8Yka0ckFH9yf8j1Cwmbl6ttuonOhky3N/gwLEozuhy7TPcZGVyzevF70kXy7g1CX
+kpFGJyEHXoprlNi8FR4I+NFzbDe6a2cFow1JN19AJ9Z5Rk5m7M0mQPaQ4RcikjB3
+aoLsASCJTm1OpOFHfxEKiBW4Lsp3Uc5/Rb9ZNbfLrwqWZRM7buW1e3ekLqntgbky
+uKKISHqVJuw/vXHl1jNibEo9+JuQ88VNuAcm7WpGUogeCa2iAlPTckPZei+MwZ8w
+tpvxTyYlZEC8DWzY1VC29+W2N5cvh01e2E3Ql08W1zL63dqrgdEZ3VWjzooYi4ep
+BmMXTvouW+Flyvcw/0oTcfN0biDIt0mCkZ5CQVjfGL9DTOYteR5hw+k=
+-----END CERTIFICATE-----
diff --git a/src/main/resources/clds/camel/routes/dcae-flows.xml b/src/main/resources/clds/camel/routes/dcae-flows.xml
index 395077a8..46935819 100644
--- a/src/main/resources/clds/camel/routes/dcae-flows.xml
+++ b/src/main/resources/clds/camel/routes/dcae-flows.xml
@@ -2,19 +2,16 @@
<route id="deploy-loop">
<from uri="direct:deploy-loop" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Deploying the loop: ${exchangeProperty[loopObject].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Deploying the loop')" />
<setBody>
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="getDeployPayload(${exchangeProperty[loopObject]})" />
</setBody>
<setProperty propertyName="dcaeDeploymentId">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="generateDeploymentId()" />
</setProperty>
<setHeader headerName="CamelHttpMethod">
@@ -35,20 +32,17 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to deploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}"></log>
<toD
uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=300000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
<convertBodyTo type="java.lang.String" />
<setProperty propertyName="dcaeResponse">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="convertDcaeResponse(${body})" />
</setProperty>
<setProperty propertyName="dcaeStatusUrl">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="getStatusUrl(${exchangeProperty[dcaeResponse]})" />
</setProperty>
<to
@@ -63,6 +57,9 @@
StatusUrl:${exchangeProperty[dcaeStatusUrl]})
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>DCAE</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -70,8 +67,7 @@
<route id="undeploy-loop">
<from uri="direct:undeploy-loop" />
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Undeploying the loop: ${exchangeProperty[loopObject].getName()} : ${exchangeProperty[loopObject].getDcaeDeploymentId()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Undeploying the loop')" />
@@ -82,8 +78,7 @@
</simple>
<doTry>
<setBody>
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="getUndeployPayload(${exchangeProperty[loopObject]})" />
</setBody>
<setHeader headerName="CamelHttpMethod">
@@ -105,20 +100,17 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to undeploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}"></log>
<toD
uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=300000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
<convertBodyTo type="java.lang.String" />
<setProperty propertyName="dcaeResponse">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="convertDcaeResponse(${body})" />
</setProperty>
<setProperty propertyName="dcaeStatusUrl">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="getStatusUrl(${exchangeProperty[dcaeResponse]})" />
</setProperty>
<to
@@ -130,13 +122,15 @@
<setProperty propertyName="logMessage">
<simple>UNDEPLOY loop status</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>DCAE</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
</when>
<otherwise>
- <log
- loggingLevel="WARNING"
+ <log loggingLevel="WARNING"
message="Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !','WARNING',${exchangeProperty[loopObject]})" />
@@ -146,8 +140,7 @@
</route>
<route id="get-dcae-deployment-status">
<from uri="direct:get-dcae-deployment-status" />
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Getting DCAE deployment status for loop: ${exchangeProperty[loopObject].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting Deployment status')" />
@@ -167,8 +160,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to query Closed Loop status: ${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}"></log>
<toD
uri="${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=30000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -179,6 +171,9 @@
<setProperty propertyName="logMessage">
<simple>DCAE deployment status</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>DCAE</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
diff --git a/src/main/resources/clds/camel/routes/loop-flows.xml b/src/main/resources/clds/camel/routes/loop-flows.xml
index ede899e7..036e8efc 100644
--- a/src/main/resources/clds/camel/routes/loop-flows.xml
+++ b/src/main/resources/clds/camel/routes/loop-flows.xml
@@ -5,9 +5,7 @@
<simple>${header.loopName}</simple>
</setBody>
<setProperty propertyName="loopObject">
- <method
- ref="org.onap.clamp.loop.LoopService"
- method="getLoop" />
+ <method ref="org.onap.clamp.loop.LoopService" method="getLoop" />
</setProperty>
<when>
@@ -15,26 +13,24 @@
<setHeader headerName="CamelHttpResponseCode">
<constant>404</constant>
</setHeader>
- <log
- loggingLevel="WARNING"
- message="Loop not found in database: ${body}" />
+ <log loggingLevel="WARN" message="Loop not found in database: ${body}" />
<stop />
</when>
</route>
+
<route id="update-policy-status-for-loop">
<from uri="direct:update-policy-status-for-loop" />
- <setProperty propertyName="atLeastOnePolicyNotFound">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <setProperty propertyName="atLeastOnePolicyNotDeployed">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
<setProperty propertyName="policyComponent">
<simple>${exchangeProperty[loopObject].getComponent('POLICY')}
</simple>
</setProperty>
- <log
- loggingLevel="INFO"
+ <setProperty propertyName="policyFound">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ <setProperty propertyName="policyDeployed">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ <log loggingLevel="INFO"
message="Processing all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" />
<split>
<simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
@@ -45,32 +41,17 @@
<setProperty propertyName="policyType">
<simple>${body.getModelType()}</simple>
</setProperty>
+ <setProperty propertyName="policyVersion">
+ <simple>1.0.0</simple>
+ </setProperty>
<setBody>
<constant>null</constant>
</setBody>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
- <setProperty propertyName="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <to uri="direct:get-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotFound">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
- <to uri="direct:get-deployment-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotDeployed">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
+ <to uri="direct:verify-one-policy" />
</split>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" />
<split>
<simple>${exchangeProperty[loopObject].getOperationalPolicies()}
@@ -81,35 +62,19 @@
<setProperty propertyName="policyType">
<simple>onap.policies.controlloop.Operational</simple>
</setProperty>
+ <setProperty propertyName="policyVersion">
+ <simple>1</simple>
+ </setProperty>
<setProperty propertyName="operationalPolicy">
<simple>${body}</simple>
</setProperty>
<setBody>
<constant>null</constant>
</setBody>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
- <setProperty propertyName="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <to uri="direct:get-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotFound">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
- <to uri="direct:get-deployment-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotDeployed">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
-
- <log
- loggingLevel="INFO"
+ <to uri="direct:verify-one-policy" />
+ <log loggingLevel="INFO"
message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" />
<split>
<simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()}
@@ -120,45 +85,29 @@
<setProperty propertyName="policyType">
<simple>onap.policies.controlloop.Guard</simple>
</setProperty>
+ <setProperty propertyName="policyVersion">
+ <simple>1</simple>
+ </setProperty>
<setBody>
<constant>null</constant>
</setBody>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Processing Guard Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
- <setProperty propertyName="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">false</simple>
- </setProperty>
- <to uri="direct:get-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotFound">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
- <to uri="direct:get-deployment-policy" />
- <when>
- <simple> ${header.CamelHttpResponseCode} != 200 </simple>
- <setProperty propertyName="atLeastOnePolicyNotDeployed">
- <simple resultType="java.lang.Boolean">true</simple>
- </setProperty>
- </when>
+ <to uri="direct:verify-one-policy" />
</split>
</split>
<setProperty propertyName="policyState">
- <simple> ${exchangeProperty[policyComponent].computeState(*)}
+ <simple> ${exchangeProperty[policyComponent].getState()}
</simple>
</setProperty>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Policy state set to: ${exchangeProperty[policyState].getStateName()}" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('Policy state set to: ${exchangeProperty[policyState].getStateName()}','INFO','POLICY',${exchangeProperty[loopObject]})" />
</route>
<route id="update-dcae-status-for-loop">
<from uri="direct:update-dcae-status-for-loop" />
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Updating DCAE status for loop: ${exchangeProperty[loopObject].getName()}" />
<setProperty propertyName="dcaeComponent">
<simple>${exchangeProperty[loopObject].getComponent('DCAE')}</simple>
@@ -175,8 +124,7 @@
<simple> ${header.CamelHttpResponseCode} == 200 </simple>
<convertBodyTo type="java.lang.String" />
<setProperty propertyName="dcaeResponse">
- <method
- ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ <method ref="org.onap.clamp.loop.components.external.DcaeComponent"
method="convertDcaeResponse(${body})" />
</setProperty>
</when>
@@ -186,8 +134,7 @@
<simple> ${exchangeProperty[dcaeComponent].computeState(*)}
</simple>
</setProperty>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="DCAE state set to: ${exchangeProperty[dcaeState].getStateName()} - DCAE message: ${exchangeProperty[dcaeResponse].getError()}" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('DCAE state set to: ${exchangeProperty[dcaeState].getStateName()} - message: ${exchangeProperty[dcaeResponse].getError()}','INFO','DCAE',${exchangeProperty[loopObject]})" />
@@ -195,53 +142,78 @@
</route>
<route id="direct:update-loop-state">
<from uri="direct:update-loop-state" />
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Updating status for loop: ${exchangeProperty[loopObject].getName()}" />
<choice>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' and ${exchangeProperty['policyState'].getStateName()} == 'NOT_SENT'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'BLUEPRINT_DEPLOYED' and ${exchangeProperty['policyState'].getStateName()}
+ == 'NOT_SENT'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DESIGN')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLATION_FAILED'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' or
+ ${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_INSTALLATION_FAILED'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLATION_FAILED' or ${exchangeProperty['policyState'].getStateName()} == 'IN_ERROR'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_UNINSTALLATION_FAILED' or
+ ${exchangeProperty['policyState'].getStateName()} == 'IN_ERROR'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and
+ ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'RUNNING')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and
+ ${exchangeProperty['policyState'].getStateName()} == 'SENT'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'STOPPED')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'BLUEPRINT_DEPLOYED' or ${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' and
+ ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'SUBMITTED')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_INSTALLATION' or ${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_UNINSTALLATION' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'PROCESSING_MICROSERVICE_INSTALLATION' or
+ ${exchangeProperty['dcaeState'].getStateName()} ==
+ 'PROCESSING_MICROSERVICE_UNINSTALLATION' and
+ ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'WAITING')" />
</when>
<when>
- <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} != 'NOT_SENT'</simple>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} ==
+ 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and
+ ${exchangeProperty['policyState'].getStateName()} != 'NOT_SENT'
+ </simple>
<to
uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DEPLOYED')" />
</when>
</choice>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}" />
<to
uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}','INFO',${exchangeProperty[loopObject]})" />
diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml
index 537354f1..75ac66c6 100644
--- a/src/main/resources/clds/camel/routes/policy-flows.xml
+++ b/src/main/resources/clds/camel/routes/policy-flows.xml
@@ -1,10 +1,40 @@
<routes xmlns="http://camel.apache.org/schema/spring">
+ <route id="verify-one-policy">
+ <from uri="direct:verify-one-policy" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="policyFound">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <log loggingLevel="WARN"
+ message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}" />
+ </when>
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-deployment-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="policyDeployed">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <log loggingLevel="WARN"
+ message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}" />
+ </when>
+ <setProperty propertyName="newPolicyState">
+ <simple>${exchangeProperty[policyComponent].computeState(*)}</simple>
+ </setProperty>
+ </route>
+
<route id="get-policy">
<from uri="direct:get-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Getting Policy: ${exchangeProperty[policyName]}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')" />
@@ -23,11 +53,10 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
- message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log>
+ <log loggingLevel="INFO"
+ message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log>
<toD
- uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
<doFinally>
<to uri="direct:reset-raise-http-exception-flag" />
<to
@@ -37,6 +66,9 @@
Policy status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -45,8 +77,7 @@
<route id="get-deployment-policy">
<from uri="direct:get-deployment-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')" />
@@ -65,8 +96,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to get policy deployment status: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/deployed"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/deployed?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -79,6 +109,9 @@
status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -86,8 +119,7 @@
<route id="create-micro-service-policy">
<from uri="direct:create-micro-service-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Creating Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Micro Service Policy')" />
@@ -113,8 +145,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to create microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -127,6 +158,9 @@
status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -135,8 +169,7 @@
<route id="delete-micro-service-policy">
<from uri="direct:delete-micro-service-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Deleting Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Micro Service Policy')" />
@@ -158,8 +191,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -173,6 +205,9 @@
status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -181,8 +216,7 @@
<route id="create-operational-policy">
<from uri="direct:create-operational-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Creating Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Operational Policy')" />
@@ -208,8 +242,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to create operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -222,6 +255,9 @@
status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -230,8 +266,7 @@
<route id="delete-operational-policy">
<from uri="direct:delete-operational-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Deleting Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Operational Policy')" />
@@ -253,8 +288,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to delete operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -267,6 +301,9 @@
status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -275,8 +312,7 @@
<route id="create-guard-policy">
<from uri="direct:create-guard-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Creating Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')" />
@@ -302,8 +338,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -315,6 +350,9 @@
<simple>${exchangeProperty[guardPolicy].getKey()} creation status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -323,8 +361,7 @@
<route id="delete-guard-policy">
<from uri="direct:delete-guard-policy" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Guard Policy')" />
@@ -346,8 +383,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1"></log>
<toD
uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -360,6 +396,9 @@
<simple>${exchangeProperty[guardPolicy].getKey()} removal status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -368,8 +407,7 @@
<route id="add-all-to-active-pdp-group">
<from uri="direct:add-all-to-active-pdp-group" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')" />
@@ -395,8 +433,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies"></log>
<toD
uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies?bridgeEndpoint=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;useSystemProperties=true&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -408,6 +445,9 @@
<setProperty propertyName="logMessage">
<simple>PDP Group push ALL status</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doFinally>
</doTry>
@@ -416,8 +456,7 @@
<route id="remove-all-policy-from-active-pdp-group">
<from uri="direct:remove-all-policy-from-active-pdp-group" />
<doTry>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Removing policies from active PDP group for loop: ${exchangeProperty[loopObject].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing policies PDP group')" />
@@ -445,8 +484,7 @@
<simple>${exchangeProperty[X-ONAP-PartnerName]}
</simple>
</setHeader>
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log>
<toD
uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
@@ -454,6 +492,9 @@
<simple>${exchangeProperty[policyName]} PDP Group removal status
</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</split>
<doCatch>
@@ -464,6 +505,9 @@
<setProperty propertyName="logMessage">
<simple>PDP Group removal, Error reported: ${exception}</simple>
</setProperty>
+ <setProperty propertyName="logComponent">
+ <simple>POLICY</simple>
+ </setProperty>
<to uri="direct:dump-loop-log-http-response" />
</doCatch>
<doFinally>
diff --git a/src/main/resources/clds/camel/routes/utils-flows.xml b/src/main/resources/clds/camel/routes/utils-flows.xml
index adf843ff..bbbc46a2 100644
--- a/src/main/resources/clds/camel/routes/utils-flows.xml
+++ b/src/main/resources/clds/camel/routes/utils-flows.xml
@@ -8,10 +8,21 @@
<route id="dump-loop-log-http-response">
<from uri="direct:dump-loop-log-http-response" />
- <log
- loggingLevel="INFO"
+ <log loggingLevel="INFO"
message="${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}" />
- <to
- uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO',${exchangeProperty[loopObject]})" />
+ <choice>
+ <when>
+ <simple>${exchangeProperty[logComponent]} == null</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO',${exchangeProperty[loopObject]})" />
+ </when>
+ <otherwise>
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO','${exchangeProperty[logComponent]}',${exchangeProperty[loopObject]})" />
+ <setProperty propertyName="logComponent">
+ <constant>null</constant>
+ </setProperty>
+ </otherwise>
+ </choice>
</route>
</routes> \ No newline at end of file
diff --git a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json
new file mode 100644
index 00000000..93738c80
--- /dev/null
+++ b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json
@@ -0,0 +1,362 @@
+{
+ "schema": {
+ "uniqueItems": "true",
+ "format": "tabs",
+ "type": "array",
+ "minItems": 1,
+ "maxItems": 1,
+ "title": "Operational policies",
+ "items": {
+ "type": "object",
+ "title": "Operational Policy Item",
+ "id": "operational_policy_item",
+ "headerTemplate": "{{self.name}}",
+ "required": [
+ "name",
+ "configurationsJson"
+ ],
+ "properties": {
+ "name": {
+ "type": "string",
+ "title": "Operational policy name",
+ "readOnly": "True"
+ },
+ "configurationsJson": {
+ "type": "object",
+ "title": "Configuration",
+ "required": [
+ "operational_policy",
+ "guard_policies"
+ ],
+ "properties": {
+ "operational_policy": {
+ "type": "object",
+ "title": "Related Parameters",
+ "required": [
+ "controlLoop",
+ "policies"
+ ],
+ "properties": {
+ "controlLoop": {
+ "type": "object",
+ "title": "Control Loop details",
+ "required": [
+ "timeout",
+ "abatement",
+ "trigger_policy",
+ "controlLoopName"
+ ],
+ "properties": {
+ "timeout": {
+ "type": "string",
+ "title": "Overall Time Limit",
+ "default": "0",
+ "format": "number"
+ },
+ "abatement": {
+ "type": "string",
+ "title": "Abatement",
+ "enum": [
+ "True",
+ "False"
+ ]
+ },
+ "trigger_policy": {
+ "type": "string",
+ "title": "Policy Decision Entry"
+ },
+ "controlLoopName": {
+ "type": "string",
+ "title": "Control loop name",
+ "readOnly": "True"
+ }
+ }
+ },
+ "policies": {
+ "uniqueItems": "true",
+ "id": "policies_array",
+ "type": "array",
+ "title": "Policy Decision Tree",
+ "format": "tabs-top",
+ "items": {
+ "title": "Policy Decision",
+ "type": "object",
+ "id": "policy_item",
+ "headerTemplate": "{{self.id}} - {{self.recipe}}",
+ "format": "categories",
+ "basicCategoryTitle": "recipe",
+ "required": [
+ "id",
+ "recipe",
+ "retry",
+ "timeout",
+ "actor",
+ "success",
+ "failure",
+ "failure_timeout",
+ "failure_retries",
+ "failure_exception",
+ "failure_guard",
+ "target"
+ ],
+ "properties": {
+ "id": {
+ "default": "Policy 1",
+ "title": "Policy ID",
+ "type": "string"
+ },
+ "recipe": {
+ "title": "Recipe",
+ "type": "string",
+ "enum": [
+ "Restart",
+ "Rebuild",
+ "Migrate",
+ "Health-Check",
+ "ModifyConfig",
+ "VF Module Create",
+ "VF Module Delete",
+ "Reroute"
+ ]
+ },
+ "retry": {
+ "default": "0",
+ "title": "Number of Retry",
+ "type": "string",
+ "format": "number"
+ },
+ "timeout": {
+ "default": "0",
+ "title": "Timeout",
+ "type": "string",
+ "format": "number"
+ },
+ "actor": {
+ "title": "Actor",
+ "type": "string",
+ "enum": [
+ "APPC",
+ "SO",
+ "VFC",
+ "SDNC",
+ "SDNR"
+ ]
+ },
+ "payload": {
+ "title": "Payload (YAML)",
+ "type": "string",
+ "format": "textarea"
+ },
+ "success": {
+ "default": "final_success",
+ "title": "When Success",
+ "type": "string"
+ },
+ "failure": {
+ "default": "final_failure",
+ "title": "When Failure",
+ "type": "string"
+ },
+ "failure_timeout": {
+ "default": "final_failure_timeout",
+ "title": "When Failure Timeout",
+ "type": "string"
+ },
+ "failure_retries": {
+ "default": "final_failure_retries",
+ "title": "When Failure Retries",
+ "type": "string"
+ },
+ "failure_exception": {
+ "default": "final_failure_exception",
+ "title": "When Failure Exception",
+ "type": "string"
+ },
+ "failure_guard": {
+ "default": "final_failure_guard",
+ "title": "When Failure Guard",
+ "type": "string"
+ },
+ "target": {
+ "type": "object",
+ "required": [
+ "type",
+ "resourceID"
+ ],
+ "anyOf": [
+ {
+ "title": "User Defined",
+ "additionalProperties":"True",
+ "properties": {
+ "type": {
+ "title": "Target type",
+ "type": "string",
+ "default": "",
+ "enum": [
+ "VNF",
+ "VFMODULE",
+ "VM"
+ ]
+ },
+ "resourceID": {
+ "title": "Target type",
+ "type": "string",
+ "default": ""
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "guard_policies": {
+ "type": "array",
+ "format": "tabs-top",
+ "title": "Associated Guard policies",
+ "items": {
+ "headerTemplate": "{{self.policy-id}} - {{self.content.recipe}}",
+ "anyOf": [
+ {
+ "title": "Guard MinMax",
+ "type": "object",
+ "properties": {
+ "policy-id": {
+ "type": "string",
+ "default": "guard.minmax.new",
+ "pattern": "^(guard.minmax\\..*)$"
+ },
+ "content": {
+ "properties": {
+ "actor": {
+ "type": "string",
+ "enum": [
+ "APPC",
+ "SO",
+ "VFC",
+ "SDNC",
+ "SDNR"
+ ]
+ },
+ "recipe": {
+ "type": "string",
+ "enum": [
+ "Restart",
+ "Rebuild",
+ "Migrate",
+ "Health-Check",
+ "ModifyConfig",
+ "VF Module Create",
+ "VF Module Delete",
+ "Reroute"
+ ]
+ },
+ "targets": {
+ "type": "string",
+ "default": ".*"
+ },
+ "clname": {
+ "type": "string",
+ "template": "{{loopName}}",
+ "watch": {
+ "loopName": "operational_policy_item.configurationsJson.operational_policy.controlLoop.controlLoopName"
+ }
+ },
+ "guardActiveStart": {
+ "type": "string",
+ "default": "00:00:00Z"
+ },
+ "guardActiveEnd": {
+ "type": "string",
+ "default": "10:00:00Z"
+ },
+ "min": {
+ "type": "string",
+ "default": "0"
+ },
+ "max": {
+ "type": "string",
+ "default": "1"
+ }
+ }
+ }
+ }
+ },
+ {
+ "title": "Guard Frequency",
+ "type": "object",
+ "properties": {
+ "policy-id": {
+ "type": "string",
+ "default": "guard.frequency.new",
+ "pattern": "^(guard.frequency\\..*)$"
+ },
+ "content": {
+ "properties": {
+ "actor": {
+ "type": "string",
+ "enum": [
+ "APPC",
+ "SO",
+ "VFC",
+ "SDNC",
+ "SDNR"
+ ]
+ },
+ "recipe": {
+ "type": "string",
+ "enum": [
+ "Restart",
+ "Rebuild",
+ "Migrate",
+ "Health-Check",
+ "ModifyConfig",
+ "VF Module Create",
+ "VF Module Delete",
+ "Reroute"
+ ]
+ },
+ "targets": {
+ "type": "string",
+ "default": ".*"
+ },
+ "clname": {
+ "type": "string",
+ "template": "{{loopName}}",
+ "watch": {
+ "loopName": "operational_policy_item.configurationsJson.operational_policy.controlLoop.controlLoopName"
+ }
+ },
+ "guardActiveStart": {
+ "type": "string",
+ "default": "00:00:00Z"
+ },
+ "guardActiveEnd": {
+ "type": "string",
+ "default": "10:00:00Z"
+ },
+ "limit": {
+ "type": "string"
+ },
+ "timeWindow": {
+ "type": "string"
+ },
+ "timeUnits": {
+ "type": "string",
+ "enum":["minute","hour","day","week","month","year"]
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}