aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE.txt4
-rw-r--r--docs/architecture.rst17
-rw-r--r--docs/index.rst52
-rw-r--r--docs/release-notes.rst37
-rw-r--r--extra/docker/clamp/docker-compose.yml2
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java8
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java28
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Global.java31
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java50
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js10
-rw-r--r--src/main/resources/clds/templates/ui-alarm-default.json2
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java8
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java23
-rw-r--r--src/test/resources/clds/templates/ui-alarm-default.json2
-rw-r--r--src/test/resources/example/model-properties/holmes/modelBpmnProperties.json227
-rw-r--r--src/test/resources/example/model-properties/tca/modelBpmnProperties.json293
-rw-r--r--src/test/resources/http-cache/example/pdp/api/deletePolicy/.file1
-rw-r--r--src/test/resources/http-cache/example/pdp/api/deletePolicy/.header1
-rwxr-xr-xsrc/test/resources/http-cache/start_http_cache.sh2
-rwxr-xr-xsrc/test/resources/http-cache/third_party_proxy.py110
20 files changed, 540 insertions, 368 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
index bb235ffb2..1de272e1c 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START==========================================
* ===================================================================
-* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -34,6 +34,4 @@
*
* ============LICENSE_END============================================
*
-* ECOMP is a trademark and service mark of AT&T Intellectual Property.
-*
*/
diff --git a/docs/architecture.rst b/docs/architecture.rst
index 6211f121a..19c9b7052 100644
--- a/docs/architecture.rst
+++ b/docs/architecture.rst
@@ -1,21 +1,21 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-.. Copyright 2017 AT&T Intellectual Property. All rights reserved.
+.. Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
Clamp in ONAP Architecture
--------------------------
-CLAMP is a platform for designing and managing control loops. It is used to design
-a closed loop, configure it with specific parameters for a particular network
+CLAMP is a platform for designing and managing control loops. It is used to visualize
+a control loop, configure it with specific parameters for a particular network
service, then deploying and undeploying it. Once deployed, the user can also
update the loop with new parameters during runtime, as well as suspending and
restarting it.
-It interacts with other systems to deploy and execute the closed loop. For
-example, it pushes the control loop design to the SDC catalog, associating it
-with the VF resource. It requests from DCAE the instantiation of microservices
-to manage the closed loop flow. Further, it creates and updates multiple
+It interacts with other systems to deploy and execute the control loop. For
+example, it gets the control loop blueprint from SDC - DCAE-D.
+It requests from DCAE the instantiation of microservices
+to manage the control loop flow. Furthermore, it creates and updates multiple
policies in the Policy Engine that define the closed loop flow.
The ONAP CLAMP platform abstracts the details of these systems under the concept
@@ -25,6 +25,9 @@ place. This is essential for a self-service model of creating and managing
control loops, where no low-level user interaction with other components is
required.
+CLAMP also allows to visualize control loop metrics through a dashboard, in order
+to help operations understand how and when a control loop is triggered and takes action.
+
At a higher level, CLAMP is about supporting and managing the broad operational
life cycle of VNFs/VMs and ultimately ONAP components itself. It will offer the
ability to design, test, deploy and update control loop automation - both closed
diff --git a/docs/index.rst b/docs/index.rst
index 38044ab79..dfb19eb45 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,6 +1,6 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-.. Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+.. Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
CLAMP - Closed Loop Automation Management Platform
==================================================
@@ -40,32 +40,48 @@ CLAMP uses the API's exposed by the following ONAP components:
Delivery
--------
CLAMP component is composed of a UI layer and a BackEnd layer and packaged into a single container.
-CLAMP also requires a database instance with 2 DB, it uses MariaDB.
+CLAMP also requires a database instance with 1 DB, it uses MariaDB.
+CLAMP also uses an ELK stack (Elastic Search, Logstash and Kibana) for the Dashboard.
.. blockdiag::
blockdiag layers {
- orientation = portrait
- CLAMP_UI -> CLAMP_BACKEND;
- CLAMP_BACKEND -> CAMUNDADB;
- CLAMP_BACKEND -> CLDSDB;
- group l1 {
- color = blue;
- label = "CLAMP container";
- CLAMP_UI; CLAMP_BACKEND;
+ orientation = portrait
+ CLAMP_UI -> CLAMP_BACKEND;
+ CLAMP_BACKEND -> CLDSDB;
+ CLAMP_KIBANA -> CLAMP_ELASTICSEARCH;
+ CLAMP_LOGSTASH -> CLAMP_ELASTICSEARCH;
+ group l1 {
+ color = blue;
+ label = "CLAMP container";
+ CLAMP_UI; CLAMP_BACKEND;
+ }
+ group l3 {
+ color = orange;
+ label = "MariaDB container";
+ CLDSDB;
+ }
+ group l4 {
+ color = green;
+ label = "E_Search container";
+ CLAMP_ELASTICSEARCH;
+ }
+ group l5 {
+ color = green;
+ label = "Kibana container";
+ CLAMP_KIBANA;
+ }
+ group l6 {
+ color = green;
+ label = "LogStash container";
+ CLAMP_LOGSTASH;
+ }
}
- group l3 {
- color = orange;
- label = "MariaDB container";
- CAMUNDADB; CLDSDB;
- }
- }
-
Logging & Diagnostic Information
--------------------------------
-CLAMP uses logback framework to generate logs. The logback.xml file cand be found under the [src/main/resources/ folder](src/main/resources).
+CLAMP uses logback framework to generate logs. The logback.xml file can be found under the [src/main/resources/ folder](src/main/resources).
With the default log settings, all logs will be generated into console and into root.log file under the CLAMP root folder. The root.log file is not allowed to be appended, thus restarting the CLAMP will result in cleaning of the old log files.
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index a5b92804e..2e6fd4793 100644
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -1,6 +1,6 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-.. Copyright 2017 AT&T Intellectual Property. All rights reserved.
+.. Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
Release Notes
=============
@@ -8,7 +8,7 @@ Release Notes
Version: 2.0.0
--------------
-:Release Date: 2018-03-28
+:Release Date: 2018-06-25
**New Features**
@@ -16,19 +16,17 @@ The Beijing release is the second release of the Control Loop Automation Managem
The main goal of the Beijing release was to:
- - Enhance Platform maturity by improving CLAMP maturity matrix see `Wiki <https://wiki.onap.org/display/DW/Beijing+Release+Platform+Maturity>`_
+ - Enhance Platform maturity by improving CLAMP maturity matrix see `Wiki <https://wiki.onap.org/display/DW/Beijing+Release+Platform+Maturity>`_.
- Focus CLAMP on Closed loop runtime operations and control - this is reflected by the move of the design part to DCAE-D.
- Introduce CLAMP Dashboard for monitoring of active Closed Loops.
- - CLAMP is integrated with MSB
- - CLAMP has integrated SWAGGER
- - CLAMP main Core has been reworked for improved flexibility
+ - CLAMP is integrated with MSB.
+ - CLAMP has integrated SWAGGER.
+ - CLAMP main Core has been reworked for improved flexibility.
**Bug Fixes**
- - The full list of implemented user stories and epics is available on `JIRA <https://jira.onap.org/projects/CLAMP/versions/10314>`_
- This is technically the first release of CLAMP, previous release was the seed code contribution.
- As such, the defects fixed in this release were raised during the course of the release.
- Anything not closed is captured below under Known Issues. If you want to review the defects fixed in the Amsterdam release, refer to Jira link above.
+ - The full list of implemented user stories and epics is available on `BEIJING RELEASE <https://jira.onap.org/projects/CLAMP/versions/10314>`_
+ This includes the list of bugs that were fixed during the course of this release.
**Known Issues**
@@ -38,27 +36,26 @@ The main goal of the Beijing release was to:
Workaround:
- You have to close the CL and reopen it again. In that case the Deploy action will do something
+ You have to close the CL and reopen it again. In that case the Deploy action will do something.
**Security Issues**
- CLAMP is following the CII Best Practices Badge Program, results including security assesment can be found on the
- `project page <https://bestpractices.coreinfrastructure.org/projects/1197>`_
- CLAMP Code is formally scanned during build time, the goal of Beijing Release was to ensure that all Critical items are closed
- The remaining security issues and their workarounds are captured `here <https://wiki.onap.org/pages/viewpage.action?pageId=25440749>`_
+CLAMP is following the CII Best Practices Badge Program, results including security assesment can be found on the `project page <https://bestpractices.coreinfrastructure.org/projects/1197>`_.
+CLAMP Code is formally scanned during build time, the goal of Beijing Release was to ensure that all Critical items are closed.
+The remaining security issues and their workarounds are captured `here <https://wiki.onap.org/pages/viewpage.action?pageId=25440749>`_.
**Upgrade Notes**
- New Docker Containers are avaialble, an ELK stack is also now part of CLAMP deployments
+ New Docker Containers are avaialble, an ELK stack is also now part of CLAMP deployments.
**Deprecation Notes**
- The CLAMP Designer UI is now deprecated and unavailable, the design time is being onboarded into SDC - DCAE D
+ The CLAMP Designer UI is now deprecated and unavailable, the design time is being onboarded into SDC - DCAE D.
**Other**
- CLAMP Dashboard is now implemented, allows to monitor Closed Loops that are running by retrieving CL events on DMAAP
+ CLAMP Dashboard is now implemented, allows to monitor Closed Loops that are running by retrieving CL events on DMAAP.
Version: 1.1.0
--------------
@@ -77,7 +74,7 @@ The main goal of the Amsterdam release was to:
**Bug Fixes**
- - The full list of implemented user stories and epics is available on `JIRA <https://jira.onap.org/projects/CLAMP/versions/10313>`_
+ - The full list of implemented user stories and epics is available on `AMSTERDAM RELEASE <https://jira.onap.org/projects/CLAMP/versions/10313>`_
This is technically the first release of CLAMP, previous release was the seed code contribution.
As such, the defects fixed in this release were raised during the course of the release.
Anything not closed is captured below under Known Issues. If you want to review the defects fixed in the Amsterdam release, refer to Jira link above.
@@ -90,7 +87,7 @@ The main goal of the Amsterdam release was to:
Workaround:
If you have multiple service available (if not create a dummy one on SDC), just click on another one and then click back on the first one in the list. The ResourceVF should be provisioned now.
-.
+
- `CLAMP-69 <https://jira.onap.org/browse/CLAMP-69>`_ Deploy action does not always work.
The "Deploy" action does not work directly after submitting it.
diff --git a/extra/docker/clamp/docker-compose.yml b/extra/docker/clamp/docker-compose.yml
index 76992fd5d..69e471529 100644
--- a/extra/docker/clamp/docker-compose.yml
+++ b/extra/docker/clamp/docker-compose.yml
@@ -30,4 +30,4 @@ services:
- "../../../src/test/resources/http-cache/:/script/:ro"
ports:
- "8085:8085"
- command: /bin/sh -c "pip install requests && pip install simplejson && python -u /script/third_party_proxy.py -v true --port 8085 --root /thirdparty"
+ command: /bin/sh -c "pip install requests && pip install simplejson && python -u /script/third_party_proxy.py -v true --port 8085 --root /thirdparty --proxyaddress third_party_proxy:8085"
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
index f20668e59..26281dad4 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
@@ -25,6 +25,7 @@ package org.onap.clamp.clds.client;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.Date;
@@ -152,16 +153,19 @@ public class DcaeDispatcherServices {
* The deployment ID
* @param serviceTypeId
* Service type ID
- * @param blueprintInput
+ * @param blueprintInputJson
* The value for each blueprint parameters in a flat JSON
* @return The status URL
*/
- public String createNewDeployment(String deploymentId, String serviceTypeId) {
+ public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {
Date startTime = new Date();
LoggingUtils.setTargetContext("DCAE", "createNewDeployment");
try {
ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.deployment.template");
rootNode.put("serviceTypeId", serviceTypeId);
+ if (blueprintInputJson != null) {
+ rootNode.put("inputs", blueprintInputJson);
+ }
String apiBodyString = rootNode.toString();
logger.info("Dcae api Body String - " + apiBodyString);
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
index 9b8d9d9ce..118059d59 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
@@ -26,29 +26,26 @@ package org.onap.clamp.clds.model.properties;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Provide base ModelElement functionality. Perform base parsing of properties
- * for a ModelElement (such as, VesCollector, Policy, Tca, Holmes,
- * ...)
+ * for a ModelElement (such as, VesCollector, Policy, Tca, Holmes, ...)
*/
public abstract class AbstractModelElement {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
private final String type;
private final ModelBpmn modelBpmn;
private final String id;
protected String topicPublishes;
protected final JsonNode modelElementJsonNode;
private boolean isFound;
-
private final ModelProperties modelProp;
-
private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
@@ -118,6 +115,27 @@ public abstract class AbstractModelElement {
}
/**
+ * Return the Json value field of the json node element that has a name
+ * field equals to the given name.
+ */
+ public static JsonNode getJsonNodeByName(JsonNode nodeIn, String name) {
+ JsonNode vnode = null;
+ if (nodeIn != null) {
+ for (JsonNode node : nodeIn) {
+ if (node.path("name").asText().equals(name)) {
+ vnode = node.path("value");
+ }
+ }
+ }
+ if (vnode == null) {
+ logger.warn(LOG_ELEMENT_NOT_FOUND, name);
+ } else {
+ logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString());
+ }
+ return vnode;
+ }
+
+ /**
* Return the value field of the json node element that has a name field
* that equals the given name.
*/
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Global.java b/src/main/java/org/onap/clamp/clds/model/properties/Global.java
index ef36fef91..c4532b2ea 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/Global.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/Global.java
@@ -23,12 +23,12 @@
package org.onap.clamp.clds.model.properties;
-import java.util.List;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
+import java.util.List;
+
/**
* Parse global json properties.
* <p>
@@ -38,14 +38,15 @@ import com.fasterxml.jackson.databind.JsonNode;
* ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}]
*/
public class Global {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private String service;
- private String actionSet;
- private List<String> resourceVf;
- private List<String> resourceVfc;
- private List<String> location;
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class);
+ protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
+ private String service;
+ private String actionSet;
+ private List<String> resourceVf;
+ private List<String> resourceVfc;
+ private JsonNode deployParameters;
+ private List<String> location;
/**
* Parse global given json node.
@@ -58,6 +59,7 @@ public class Global {
actionSet = AbstractModelElement.getValueByName(globalNode, "actionSet");
resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf");
resourceVfc = AbstractModelElement.getValuesByName(globalNode, "vfc");
+ deployParameters = AbstractModelElement.getJsonNodeByName(globalNode, "deployParameters");
location = AbstractModelElement.getValuesByName(globalNode, "location");
}
@@ -83,6 +85,10 @@ public class Global {
return actionSet;
}
+ public void setActionSet(String actionSet) {
+ this.actionSet = actionSet;
+ }
+
/**
* @return the resourceVf
*/
@@ -128,4 +134,11 @@ public class Global {
this.location = location;
}
+ public JsonNode getDeployParameters() {
+ return deployParameters;
+ }
+
+ public void setDeployParameters(JsonNode deployParameters) {
+ this.deployParameters = deployParameters;
+ }
}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index e828f844f..2b6862dc5 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -377,6 +377,20 @@ public class CldsService extends SecureServiceBase {
return names;
}
+ private void fillInCldsModel(CldsModel model) {
+ if (model.getTemplateName() != null) {
+ CldsTemplate template = cldsDao.getTemplate(model.getTemplateName());
+ if (template != null) {
+ model.setTemplateId(template.getId());
+ model.setDocText(template.getPropText());
+ // This is to provide the Bpmn XML when Template part in UI
+ // is
+ // disabled
+ model.setBpmnText(template.getBpmnText());
+ }
+ }
+ }
+
/**
* REST service that saves and processes an action for a CLDS model by name.
*
@@ -400,7 +414,7 @@ public class CldsService extends SecureServiceBase {
@Produces(MediaType.APPLICATION_JSON)
public Response putModelAndProcessAction(@PathParam("action") String action,
@PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model)
- throws TransformerException, ParseException, GeneralSecurityException, DecoderException {
+ throws TransformerException, ParseException {
Date startTime = new Date();
CldsModel retrievedModel = null;
Boolean errorCase = false;
@@ -412,9 +426,7 @@ public class CldsService extends SecureServiceBase {
isAuthorized(permisionManage);
isAuthorizedForVf(model);
String userId = getUserId();
- String actionStateCd = CldsEvent.ACTION_STATE_INITIATED;
logger.info("PUT actionCd={}", actionCd);
- logger.info("PUT actionStateCd={}", actionStateCd);
logger.info("PUT modelName={}", modelName);
logger.info("PUT test={}", test);
logger.info("PUT bpmnText={}", model.getBpmnText());
@@ -422,17 +434,7 @@ public class CldsService extends SecureServiceBase {
logger.info("PUT userId={}", userId);
logger.info("PUT getTypeId={}", model.getTypeId());
logger.info("PUT deploymentId={}", model.getDeploymentId());
- if (model.getTemplateName() != null) {
- CldsTemplate template = cldsDao.getTemplate(model.getTemplateName());
- if (template != null) {
- model.setTemplateId(template.getId());
- model.setDocText(template.getPropText());
- // This is to provide the Bpmn XML when Template part in UI
- // is
- // disabled
- model.setBpmnText(template.getBpmnText());
- }
- }
+ this.fillInCldsModel(model);
// save model to db
model.setName(modelName);
model.save(cldsDao, getUserId());
@@ -568,9 +570,8 @@ public class CldsService extends SecureServiceBase {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsService: GET sdc services", getPrincipalName());
String retStr;
- String responseStr = sdcCatalogServices.getSdcServicesInformation(null);
try {
- retStr = createUiServiceFormatJson(responseStr);
+ retStr = createUiServiceFormatJson(sdcCatalogServices.getSdcServicesInformation(null));
} catch (IOException e) {
logger.error("IOException during SDC communication", e);
throw new SdcCommunicationException("IOException during SDC communication", e);
@@ -814,12 +815,12 @@ public class CldsService extends SecureServiceBase {
LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName());
Boolean errorCase = false;
try {
- try {
- checkForDuplicateServiceVf(modelName, model.getPropText());
- } catch (IOException | BadRequestException e) {
- errorCase = true;
- logger.error("Exception occured during duplicate check for service and VF", e);
- }
+ fillInCldsModel(model);
+ String bpmnJson = cldsBpmnTransformer.doXslTransformToString(model.getBpmnText());
+ logger.info("PUT bpmnJson={}", bpmnJson);
+ ModelProperties modelProp = new ModelProperties(modelName, model.getControlName(), CldsEvent.ACTION_DEPLOY,
+ false, bpmnJson, model.getPropText());
+ checkForDuplicateServiceVf(modelName, model.getPropText());
String deploymentId = "";
// If model is already deployed then pass same deployment id
if (model.getDeploymentId() != null && !model.getDeploymentId().isEmpty()) {
@@ -828,7 +829,7 @@ public class CldsService extends SecureServiceBase {
deploymentId = "closedLoop_" + UUID.randomUUID() + "_deploymentId";
}
String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId,
- model.getTypeId());
+ model.getTypeId(), modelProp.getGlobal().getDeployParameters());
String operationStatus = "processing";
long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10);
while ("processing".equalsIgnoreCase(operationStatus)) {
@@ -930,7 +931,8 @@ public class CldsService extends SecureServiceBase {
if (service != null && resourceVf != null && !resourceVf.isEmpty()) {
List<CldsModelProp> cldsModelPropList = cldsDao.getDeployedModelProperties();
for (CldsModelProp cldsModelProp : cldsModelPropList) {
- JsonNode currentNode = JacksonUtils.getObjectMapperInstance().readTree(cldsModelProp.getPropText()).get("global");
+ JsonNode currentNode = JacksonUtils.getObjectMapperInstance().readTree(cldsModelProp.getPropText())
+ .get("global");
String currentService = AbstractModelElement.getValueByName(currentNode, "service");
List<String> currentVf = AbstractModelElement.getValuesByName(currentNode, "vf");
if (currentVf != null && !currentVf.isEmpty()) {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
index 3a5faf592..04ba83a78 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
@@ -30,11 +30,11 @@ app.controller('DeploymentCtrl',
elementMap["global"] = [];
}
- var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" in e; });
- if (index == -1) {
- elementMap["global"].push({"deployParameters": parameters});
- } else {
- elementMap["global"][index]["deployParameters"] = parameters;
+ var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" == e["name"]; });
+ if (index == -1) {
+ elementMap["global"].push({"name": "deployParameters", "value": parameters});
+ } else {
+ elementMap["global"][index]["value"] = parameters;
}
}
diff --git a/src/main/resources/clds/templates/ui-alarm-default.json b/src/main/resources/clds/templates/ui-alarm-default.json
index 0d0835981..c851e6cdd 100644
--- a/src/main/resources/clds/templates/ui-alarm-default.json
+++ b/src/main/resources/clds/templates/ui-alarm-default.json
@@ -267,7 +267,7 @@
"jnxSpaceSNAProcessUp": "vDBE-EMS-Juniper: jnxSpaceSNAProcessUp",
"jnxSpaceNodeDown": "vDBE-EMS-Juniper: jnxSpaceNodeDown",
"jnxSpaceNodeUp": "vDBE-EMS-Juniper: jnxSpaceNodeUp",
- " jnxSpaceNodeRemoval": "vDBE-EMS-Juniper: jnxSpaceNodeRemoval",
+ "jnxSpaceNodeRemoval": "vDBE-EMS-Juniper: jnxSpaceNodeRemoval",
"jnxCmCfgChange": "vDBE-Juniper: jnxCmCfgChange",
"jnxCmRescueChange": "vDBE-Juniper: jnxCmRescueChange",
"jnxEventTrap": "vDBE-Juniper: jnxEventTrap",
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index 40dffcd6b..fc5cb040f 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -57,8 +57,8 @@ import org.springframework.test.context.junit4.SpringRunner;
public class CsarInstallerItCase {
private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar";
- private static final String SERVICE_UUID = "serviceUUID";
- private static final String RESOURCE1_UUID = "resource1UUID";
+ private static final String INVARIANT_SERVICE_UUID = "4cc5b45a-1f63-4194-8100-cd8e14248c92";
+ private static final String INVARIANT_RESOURCE1_UUID = "ba4d4b5d-f861-4155-886b-b1cdba5e0957";
@Autowired
private CsarInstaller csarInstaller;
@Autowired
@@ -84,8 +84,8 @@ public class CsarInstallerItCase {
Mockito.when(csarHelper.getServiceMetadata()).thenReturn(data);
Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper);
Mockito.when(csarHandler.getBlueprintArtifactName()).thenReturn(CSAR_ARTIFACT_NAME);
- Mockito.when(csarHandler.getBlueprintInvariantServiceUuid()).thenReturn(SERVICE_UUID);
- Mockito.when(csarHandler.getBlueprintInvariantResourceUuid()).thenReturn(RESOURCE1_UUID);
+ Mockito.when(csarHandler.getBlueprintInvariantServiceUuid()).thenReturn(INVARIANT_SERVICE_UUID);
+ Mockito.when(csarHandler.getBlueprintInvariantResourceUuid()).thenReturn(INVARIANT_RESOURCE1_UUID);
return csarHandler;
}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
index a7ab94c57..25daf01f3 100644
--- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
+++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
@@ -84,6 +85,17 @@ public class ModelPropertiesTest {
tca.getTcaItem().getTcaThresholds().get(1).getFieldPath());
assertEquals("GREATER_OR_EQUAL", tca.getTcaItem().getTcaThresholds().get(1).getOperator());
assertEquals(Integer.valueOf(123), tca.getTcaItem().getTcaThresholds().get(1).getThreshold());
+ // Test global prop
+ assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
+ assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
+ assertTrue(Arrays.equals(new String[] {
+ "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad"
+ }, prop.getGlobal().getResourceVf().toArray()));
+ assertTrue(Arrays.equals(new String[] {
+ "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1"
+ }, prop.getGlobal().getLocation().toArray()));
+ assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").asText());
+ assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").asText());
}
@Test
@@ -108,6 +120,17 @@ public class ModelPropertiesTest {
assertTrue(holmes.isFound());
assertEquals("configPolicy1", holmes.getConfigPolicyName());
assertEquals("blabla", holmes.getCorrelationLogic());
+ // Test global prop
+ assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
+ assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
+ assertTrue(Arrays.equals(new String[] {
+ "f5213e3a-9191-4362-93b5-b67f8d770e44"
+ }, prop.getGlobal().getResourceVf().toArray()));
+ assertTrue(Arrays.equals(new String[] {
+ "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1"
+ }, prop.getGlobal().getLocation().toArray()));
+ assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").asText());
+ assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").asText());
}
@Test
diff --git a/src/test/resources/clds/templates/ui-alarm-default.json b/src/test/resources/clds/templates/ui-alarm-default.json
index 0d0835981..c851e6cdd 100644
--- a/src/test/resources/clds/templates/ui-alarm-default.json
+++ b/src/test/resources/clds/templates/ui-alarm-default.json
@@ -267,7 +267,7 @@
"jnxSpaceSNAProcessUp": "vDBE-EMS-Juniper: jnxSpaceSNAProcessUp",
"jnxSpaceNodeDown": "vDBE-EMS-Juniper: jnxSpaceNodeDown",
"jnxSpaceNodeUp": "vDBE-EMS-Juniper: jnxSpaceNodeUp",
- " jnxSpaceNodeRemoval": "vDBE-EMS-Juniper: jnxSpaceNodeRemoval",
+ "jnxSpaceNodeRemoval": "vDBE-EMS-Juniper: jnxSpaceNodeRemoval",
"jnxCmCfgChange": "vDBE-Juniper: jnxCmCfgChange",
"jnxCmRescueChange": "vDBE-Juniper: jnxCmRescueChange",
"jnxEventTrap": "vDBE-Juniper: jnxEventTrap",
diff --git a/src/test/resources/example/model-properties/holmes/modelBpmnProperties.json b/src/test/resources/example/model-properties/holmes/modelBpmnProperties.json
index 43fecc9ea..6ac97ec85 100644
--- a/src/test/resources/example/model-properties/holmes/modelBpmnProperties.json
+++ b/src/test/resources/example/model-properties/holmes/modelBpmnProperties.json
@@ -1,109 +1,122 @@
{
- "Holmes_0i4n2mm": [
- {
- "name": "correlationalLogic",
- "value": "blabla"
- },
- {
- "name": "configPolicyName",
- "value": "configPolicy1"
- }
- ],
- "Policy_0honxgv": {
- "policy1": [
- {
- "name": "pname",
- "value": "policy1"
- },
- {
- "name": "pid",
- "value": "0"
- },
- {
- "name": "timeout",
- "value": "345"
- },
- {
- "policyConfigurations": [
- [
- {
- "name": "maxRetries",
- "value": [
- "3"
- ]
- },
- {
- "name": "retryTimeLimit",
- "value": [
- "180"
- ]
- },
- {
- "name": "_id",
- "value": [
- "dGLuNqg"
- ]
- },
- {
- "name": "parentPolicy",
- "value": [
- ""
- ]
- },
- {
- "name": "targetResourceId",
- "value": [
- "resourceid"
- ]
- }
- ]
- ]
- }
- ]
- },
- "global": [
- {
- "name": "actionSet",
- "value": [
- "vnfRecipe"
- ]
- },
- {
- "name": "vf",
- "value": [
- "f5213e3a-9191-4362-93b5-b67f8d770e44"
- ]
- },
- {
- "name": "location",
- "value": [
- "SNDGCA64",
- "ALPRGAED",
- "LSLEILAA",
- "MDTWNJC1"
- ]
- }
- ],
- "shared": {
- "byService": {
- "": {
- "vf": {
- "": ""
- },
- "location": {
- "": ""
- },
- "alarmCondition": {
- "": ""
- }
- }
- },
- "byVf": {
- "": {
- "vfc": {
- "": ""
- }
- }
- }
- }
+ "Holmes_0i4n2mm": [
+ {
+ "name": "correlationalLogic",
+ "value": "blabla"
+ },
+ {
+ "name": "configPolicyName",
+ "value": "configPolicy1"
+ }
+ ],
+ "Policy_0honxgv": {
+ "policy1": [
+ {
+ "name": "pname",
+ "value": "policy1"
+ },
+ {
+ "name": "pid",
+ "value": "0"
+ },
+ {
+ "name": "timeout",
+ "value": "345"
+ },
+ {
+ "policyConfigurations": [
+ [
+ {
+ "name": "maxRetries",
+ "value": [
+ "3"
+ ]
+ },
+ {
+ "name": "retryTimeLimit",
+ "value": [
+ "180"
+ ]
+ },
+ {
+ "name": "_id",
+ "value": [
+ "dGLuNqg"
+ ]
+ },
+ {
+ "name": "parentPolicy",
+ "value": [
+ ""
+ ]
+ },
+ {
+ "name": "targetResourceId",
+ "value": [
+ "resourceid"
+ ]
+ }
+ ]
+ ]
+ }
+ ]
+ },
+ "global": [
+ {
+ "name": "actionSet",
+ "value": [
+ "vnfRecipe"
+ ]
+ },
+ {
+ "name": "service",
+ "value": [
+ "4cc5b45a-1f63-4194-8100-cd8e14248c92"
+ ]
+ },
+ {
+ "name": "vf",
+ "value": [
+ "f5213e3a-9191-4362-93b5-b67f8d770e44"
+ ]
+ },
+ {
+ "name": "location",
+ "value": [
+ "SNDGCA64",
+ "ALPRGAED",
+ "LSLEILAA",
+ "MDTWNJC1"
+ ]
+ },
+ {
+ "name": "deployParameters",
+ "value": {
+ "input1": "value1",
+ "input2": "value2"
+ }
+ }
+ ],
+ "shared": {
+ "byService": {
+ "": {
+ "vf": {
+ "": ""
+ },
+ "location": {
+ "": ""
+ },
+ "alarmCondition": {
+ "": ""
+ }
+ }
+ },
+ "byVf": {
+ "": {
+ "vfc": {
+ "": ""
+ }
+ }
+ }
+ }
}
diff --git a/src/test/resources/example/model-properties/tca/modelBpmnProperties.json b/src/test/resources/example/model-properties/tca/modelBpmnProperties.json
index 8e2780cda..ce0f317dd 100644
--- a/src/test/resources/example/model-properties/tca/modelBpmnProperties.json
+++ b/src/test/resources/example/model-properties/tca/modelBpmnProperties.json
@@ -1,145 +1,152 @@
{
- "TCA_1jy9to4": {
- "group1": [
- {
- "name": "tname",
- "value": "group1"
- },
- {
- "name": "tuuid",
- "value": "f734f031-10aa-t8fb-330f-04dde2886325"
- },
- {
- "name": "tcaPolId",
- "value": "policy1"
- },
- {
- "name": "eventName",
- "value": "vFirewallBroadcastPackets"
- },
- {
- "name": "controlLoopSchemaType",
- "value": "VNF"
- },
- {
- "serviceConfigurations": [
- [
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
- "LESS_OR_EQUAL",
- "123",
- "ABATED"
- ],
- [
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
- "GREATER_OR_EQUAL",
- "123",
- "ONSET"
- ]
- ]
- }
- ]
- },
- "Policy_0honxgv": {
- "policy1": [
- {
- "name": "pname",
- "value": "policy1"
- },
- {
- "name": "pid",
- "value": "0"
- },
- {
- "name": "timeout",
- "value": "345"
- },
- {
- "policyConfigurations": [
- [
- {
- "name": "maxRetries",
- "value": [
- "3"
- ]
- },
- {
- "name": "retryTimeLimit",
- "value": [
- "180"
- ]
- },
- {
- "name": "_id",
- "value": [
- "dGLuNqg"
- ]
- },
- {
- "name": "parentPolicy",
- "value": [
- ""
- ]
- },
- {
- "name": "targetResourceId",
- "value": [
- "resourceid"
- ]
- }
- ]
- ]
- }
- ]
- },
- "global": [
- {
- "name": "actionSet",
- "value": [
- "vnfRecipe"
- ]
- },
- {
- "name": "service",
- "value": [
- "4cc5b45a-1f63-4194-8100-cd8e14248c92"
- ]
- },
- {
- "name": "vf",
- "value": [
- "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad"
- ]
- },
- {
- "name": "location",
- "value": [
- "SNDGCA64",
- "ALPRGAED",
- "LSLEILAA",
- "MDTWNJC1"
- ]
- }
- ],
- "shared": {
- "byService": {
- "": {
- "vf": {
- "": ""
- },
- "location": {
- "": ""
- },
- "alarmCondition": {
- "": ""
- }
- }
- },
- "byVf": {
- "": {
- "vfc": {
- "": ""
- }
- }
- }
- }
+ "TCA_1jy9to4": {
+ "group1": [
+ {
+ "name": "tname",
+ "value": "group1"
+ },
+ {
+ "name": "tuuid",
+ "value": "f734f031-10aa-t8fb-330f-04dde2886325"
+ },
+ {
+ "name": "tcaPolId",
+ "value": "policy1"
+ },
+ {
+ "name": "eventName",
+ "value": "vFirewallBroadcastPackets"
+ },
+ {
+ "name": "controlLoopSchemaType",
+ "value": "VNF"
+ },
+ {
+ "serviceConfigurations": [
+ [
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+ "LESS_OR_EQUAL",
+ "123",
+ "ABATED"
+ ],
+ [
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
+ "GREATER_OR_EQUAL",
+ "123",
+ "ONSET"
+ ]
+ ]
+ }
+ ]
+ },
+ "Policy_0honxgv": {
+ "policy1": [
+ {
+ "name": "pname",
+ "value": "policy1"
+ },
+ {
+ "name": "pid",
+ "value": "0"
+ },
+ {
+ "name": "timeout",
+ "value": "345"
+ },
+ {
+ "policyConfigurations": [
+ [
+ {
+ "name": "maxRetries",
+ "value": [
+ "3"
+ ]
+ },
+ {
+ "name": "retryTimeLimit",
+ "value": [
+ "180"
+ ]
+ },
+ {
+ "name": "_id",
+ "value": [
+ "dGLuNqg"
+ ]
+ },
+ {
+ "name": "parentPolicy",
+ "value": [
+ ""
+ ]
+ },
+ {
+ "name": "targetResourceId",
+ "value": [
+ "resourceid"
+ ]
+ }
+ ]
+ ]
+ }
+ ]
+ },
+ "global": [
+ {
+ "name": "actionSet",
+ "value": [
+ "vnfRecipe"
+ ]
+ },
+ {
+ "name": "service",
+ "value": [
+ "4cc5b45a-1f63-4194-8100-cd8e14248c92"
+ ]
+ },
+ {
+ "name": "vf",
+ "value": [
+ "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad"
+ ]
+ },
+ {
+ "name": "location",
+ "value": [
+ "SNDGCA64",
+ "ALPRGAED",
+ "LSLEILAA",
+ "MDTWNJC1"
+ ]
+ },
+ {
+ "name": "deployParameters",
+ "value": {
+ "input1": "value1",
+ "input2": "value2"
+ }
+ }
+ ],
+ "shared": {
+ "byService": {
+ "": {
+ "vf": {
+ "": ""
+ },
+ "location": {
+ "": ""
+ },
+ "alarmCondition": {
+ "": ""
+ }
+ }
+ },
+ "byVf": {
+ "": {
+ "vfc": {
+ "": ""
+ }
+ }
+ }
+ }
}
diff --git a/src/test/resources/http-cache/example/pdp/api/deletePolicy/.file b/src/test/resources/http-cache/example/pdp/api/deletePolicy/.file
new file mode 100644
index 000000000..0637a088a
--- /dev/null
+++ b/src/test/resources/http-cache/example/pdp/api/deletePolicy/.file
@@ -0,0 +1 @@
+[] \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/pdp/api/deletePolicy/.header b/src/test/resources/http-cache/example/pdp/api/deletePolicy/.header
new file mode 100644
index 000000000..6a280d972
--- /dev/null
+++ b/src/test/resources/http-cache/example/pdp/api/deletePolicy/.header
@@ -0,0 +1 @@
+{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"} \ No newline at end of file
diff --git a/src/test/resources/http-cache/start_http_cache.sh b/src/test/resources/http-cache/start_http_cache.sh
index fe9e9911f..47c3cc87b 100755
--- a/src/test/resources/http-cache/start_http_cache.sh
+++ b/src/test/resources/http-cache/start_http_cache.sh
@@ -34,4 +34,4 @@ fi
echo 'Installing requests packages for Python'
pip install requests
echo 'Executing the Http proxy in Cache mode only'
-python third_party_proxy.py --port 8080 --root /usr/src/http-cache-app/data-cache
+python third_party_proxy.py --port 8080 --root /usr/src/http-cache-app/data-cache --proxyaddress localhost:8085
diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py
index 72ea49587..29d34cc89 100755
--- a/src/test/resources/http-cache/third_party_proxy.py
+++ b/src/test/resources/http-cache/third_party_proxy.py
@@ -41,6 +41,7 @@ parser.add_argument("--root", "-r", default=tempfile.mkdtemp, type=str, help
parser.add_argument("--proxy" , type=str, help="Url of the Act as a proxy. If not set, this script only uses the cache and will return a 404 if files aren't found")
parser.add_argument("--port", "-P", type=int, default="8081", help="Port on which the proxy should listen to")
parser.add_argument("--verbose", "-v", type=bool, help="Print more information in case of error")
+parser.add_argument("--proxyaddress","-a", type=str, help="Address of this proxy, generally either third_party_proxy:8085 or localhost:8085 depending if started with docker-compose or not")
options = parser.parse_args()
@@ -49,6 +50,7 @@ HOST = options.proxy
AUTH = (options.username, options.password)
HEADERS = {'X-ECOMP-InstanceID':'CLAMP'}
CACHE_ROOT = options.root
+PROXY_ADDRESS=options.proxyaddress
def signal_handler(signal_sent, frame):
global httpd
@@ -116,7 +118,17 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
os.makedirs(cached_file, True)
with open(cached_file_header, 'w') as f:
- f.write("{\"Content-Length\": \"144\", \"Content-Type\": \"application/json\"}")
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+ with open(cached_file_content, 'w') as f:
+ f.write(jsonGenerated)
+ elif self.path.startswith("/dcae-operationstatus"):
+ print "self.path start with /dcae-operationstatus, generating response json..."
+ jsonGenerated = "{\"operationType\": \"operationType1\", \"status\": \"succeeded\"}"
+ print "jsonGenerated: " + jsonGenerated
+
+ os.makedirs(cached_file, True)
+ with open(cached_file_header, 'w') as f:
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
else:
@@ -215,27 +227,91 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
cached_file_header = "%s/.header" % (cached_file,)
_file_available = os.path.exists(cached_file_content)
- if not _file_available and not HOST:
- print("No file corresponding in cache and no HOST specified: %s" % HOST)
- self.send_response(404)
- return "404 Not found"
if not _file_available:
- print("Request for data currently not present in cache: %s" % (cached_file,))
+ if self.path.startswith("/dcae-deployments/"):
+ print "self.path start with /dcae-deployments/, generating response json..."
+ #jsondata = json.loads(self.data_string)
+ jsonGenerated = "{\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus\",\"test2\":\"test2\"}}"
+ print "jsonGenerated: " + jsonGenerated
+
+ os.makedirs(cached_file, True)
+ with open(cached_file_header, 'w') as f:
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+ with open(cached_file_content, 'w') as f:
+ f.write(jsonGenerated)
+ else:
+ if not HOST:
+ self.send_response(404)
+ return "404 Not found"
+
+ print("Request for data currently not present in cache: %s" % (cached_file,))
+
+ url = '%s%s' % (HOST, self.path)
+ print("url: %s" % (url,))
+ response = requests.put(url, data=self.data_string, headers=self.headers, stream=True)
+
+ if response.status_code == 200:
+ self._write_cache(cached_file, cached_file_header, cached_file_content, response)
+ else:
+ print('Error when requesting file :')
+ print('Requested url : %s' % (url,))
+ print('Status code : %s' % (response.status_code,))
+ print('Content : %s' % (response.content,))
+ self.send_response(response.status_code)
+ return response.content
+ else:
+ print("Request for data present in cache: %s" % (cached_file,))
+
+ self._send_content(cached_file_header, cached_file_content)
- url = '%s%s' % (HOST, self.path)
- print("url: %s" % (url,))
- response = requests.put(url, data=self.data_string, headers=self.headers, stream=True)
- if response.status_code == 200:
- self._write_cache(cached_file, cached_file_header, cached_file_content, response)
+ def do_DELETE(self):
+ print("\n\n\nGot a DELETE for %s " % self.path)
+ self.check_credentials()
+ print("self.headers:\n %s" % self.headers)
+
+ cached_file = '%s/%s' % (CACHE_ROOT, self.path,)
+ print("Cached file name before escaping : %s" % cached_file)
+ cached_file = cached_file.replace('<','&#60;').replace('>','&#62;').replace('?','&#63;').replace('*','&#42;').replace('\\','&#42;').replace(':','&#58;').replace('|','&#124;')
+ print("Cached file name after escaping (used for cache storage) : %s" % cached_file)
+ cached_file_content = "%s/.file" % (cached_file,)
+ cached_file_header = "%s/.header" % (cached_file,)
+
+ _file_available = os.path.exists(cached_file_content)
+
+ if not _file_available:
+ if self.path.startswith("/dcae-deployments/"):
+ print "self.path start with /dcae-deployments/, generating response json..."
+ #jsondata = json.loads(self.data_string)
+ jsonGenerated = "{\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus\",\"test2\":\"test2\"}}"
+ print "jsonGenerated: " + jsonGenerated
+
+ os.makedirs(cached_file, True)
+ with open(cached_file_header, 'w') as f:
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+ with open(cached_file_content, 'w') as f:
+ f.write(jsonGenerated)
else:
- print('Error when requesting file :')
- print('Requested url : %s' % (url,))
- print('Status code : %s' % (response.status_code,))
- print('Content : %s' % (response.content,))
- self.send_response(response.status_code)
- return response.content
+ if not HOST:
+ self.send_response(404)
+ return "404 Not found"
+
+ print("Request for data currently not present in cache: %s" % (cached_file,))
+
+ url = '%s%s' % (HOST, self.path)
+ print("url: %s" % (url,))
+ response = requests.put(url, data=self.data_string, headers=self.headers, stream=True)
+
+ if response.status_code == 200:
+ self._write_cache(cached_file, cached_file_header, cached_file_content, response)
+ else:
+ print('Error when requesting file :')
+ print('Requested url : %s' % (url,))
+ print('Status code : %s' % (response.status_code,))
+ print('Content : %s' % (response.content,))
+ self.send_response(response.status_code)
+ return response.content
else:
print("Request for data present in cache: %s" % (cached_file,))