diff options
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/main/java')
9 files changed, 86 insertions, 64 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java index 565fbb766..76e791a6e 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/GraphExecutor.java @@ -20,6 +20,7 @@ */ package org.onap.appc.flow.controller.executorImpl; +import org.json.JSONObject; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.util.Enumeration; @@ -82,6 +83,17 @@ public class GraphExecutor implements FlowExecutorInterface { String fn = "GraphExecutor.execute "; log.debug(fn + "About to execute graph : " + transaction.getExecutionRPC()); + String payload = transaction.getPayload(); + log.debug("payload:" + payload); + + JSONObject json = new JSONObject(payload); + for (Object key : json.keySet()) { + String keyStr = (String)key; + Object keyvalue = json.get(keyStr); + String value= keyvalue.toString(); + ctx.setAttribute(keyStr, value); + log.debug("key: "+ keyStr + " value: " + keyvalue); + } Properties parms = new Properties(); for (Object key : ctx.getAttributeKeySet()) { String parmName = (String) key; diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/Vm.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/Vm.java index 2ff99328a..4808b53a2 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/Vm.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/Vm.java @@ -40,6 +40,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "vserverId", + "vmId", "vnfc" }) @XmlRootElement(name = "vm") @@ -49,6 +50,9 @@ public class Vm { @JsonProperty("vserver-id") protected String vserverId; @XmlElement(required = true) + @JsonProperty("vm-id") + protected String vmId; + @XmlElement(required = true) @JsonProperty("vnfc") protected Vnfcslist vnfc; @@ -102,7 +106,15 @@ public class Vm { @Override public String toString() { - return "Vm [vserverId=" + vserverId + ", vnfc=" + vnfc + "]"; + return "Vm [vserverId=" + vserverId + ", vmId=" + vmId + ", vnfc=" + vnfc + "]"; + } + + public String getVmId() { + return vmId; + } + + public void setVmId(String vmId) { + this.vmId = vmId; } } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/VnfInfo.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/VnfInfo.java index dce3238ba..eaf387dc8 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/VnfInfo.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/interfaceData/VnfInfo.java @@ -59,6 +59,9 @@ public class VnfInfo { @XmlElement(name = "vnf-type", required = true) @JsonProperty("vnf-type") protected String vnfType; + @XmlElement(name = "identity-url") + @JsonProperty("identity-url") + protected String identityUrl; @JsonProperty("vm") protected List<Vm> vm; @@ -166,7 +169,15 @@ public class VnfInfo { @Override public String toString() { return "VnfInfo [vnfId=" + vnfId + ", vnfName=" + vnfName - + ", vnfType=" + vnfType + ", vm=" + vm + "]"; + + ", vnfType=" + vnfType + ", identityUrl=" + identityUrl + ", vm=" + vm + "]"; + } + + public String getIdentityUrl() { + return identityUrl; + } + + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; } } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java index 1a7e2bc00..51595d576 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InputParamsCollector.java @@ -3,6 +3,7 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2018 Nokia. All rights reserved. + * Copyright (C) 2018 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. @@ -119,10 +120,10 @@ class InputParamsCollector { InventoryInfo inventoryInfo = new InventoryInfoExtractor().getInventoryInfo(ctx, vnfId); Capabilities capabilities = new CapabilitiesDataExtractor(dbService).getCapabilitiesData(ctx); - DependencyInfo dependencyInfo = getDependencyInfo(ctx); + ctx.setAttribute("artifact-content", null); log.info("Enter InputData"); - Input input = getInput(requestInfo, inventoryInfo, dependencyInfo, capabilities); + Input input = getInput(requestInfo, inventoryInfo, null, capabilities); log.info(fn + "Input parameters:" + input.toString()); ObjectMapper mapper = new ObjectMapper(); diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InventoryInfoExtractor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InventoryInfoExtractor.java index 79a8635ab..631b72cc0 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InventoryInfoExtractor.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/InventoryInfoExtractor.java @@ -3,6 +3,7 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2018 Nokia. All rights reserved. + * Copyright (C) 2018 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. @@ -35,13 +36,14 @@ class InventoryInfoExtractor { private static final EELFLogger log = EELFManager.getInstance().getLogger(InventoryInfoExtractor.class); - InventoryInfo getInventoryInfo(SvcLogicContext ctx, String vnfId) { + InventoryInfo getInventoryInfo(SvcLogicContext ctx, String vnfId) { String fn = "InventoryInfoExtractor.getInventoryInfo"; VnfInfo vnfInfo = new VnfInfo(); vnfInfo.setVnfId(vnfId); vnfInfo.setVnfName(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")); vnfInfo.setVnfType(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")); + vnfInfo.setIdentityUrl(getIdentityUrl(ctx,vnfInfo,vnfId)); String vmcount = ctx.getAttribute("tmp.vnfInfo.vm-count"); log.info(fn + "vmcount:" + vmcount); @@ -62,6 +64,7 @@ class InventoryInfoExtractor { private void processVm(SvcLogicContext ctx, VnfInfo vnfInfo, int index) { Vm vm = new Vm(); vm.setVserverId(ctx.getAttribute("tmp.vnfInfo.vm[" + index + "].vserver-id")); + vm.setVmId(ctx.getAttribute("tmp.vnfInfo.vm[" + index + "].vserver-selflink")); int vnfcCount = Integer.parseInt(ctx.getAttribute("tmp.vnfInfo.vm[" + index + "].vnfc-count")); if (vnfcCount > 0) { Vnfcslist vnfc = new Vnfcslist(); @@ -72,4 +75,24 @@ class InventoryInfoExtractor { vnfInfo.getVm().add(vm); } + + public String getIdentityUrl(SvcLogicContext ctx, VnfInfo vnfInfo, String vnfId) { + String identityUrl = ""; + for (String key : ctx.getAttributeKeySet()) { + log.debug("InventoryData " + key + "=" + ctx.getAttribute(key)); + } + String urlFromPayload= ctx.getAttribute("AICIdentity"); + log.info("Url from payload:" + urlFromPayload); + String urlFromAAI=ctx.getAttribute("tmp.vnfInfo.identity-url"); + + if(StringUtils.isNotBlank(urlFromPayload)){ + identityUrl=urlFromPayload; + }else if(StringUtils.isNotBlank(urlFromAAI)){ + identityUrl=urlFromAAI; + } + return identityUrl; + + + } + } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java index 22011e773..bd5144004 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/ResourceUriExtractor.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. + * Copyright (C) 2018 Nokia. All rights reserved. * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ============================================================================= @@ -25,15 +25,11 @@ import static org.onap.appc.flow.controller.utils.FlowControllerConstants.HTTP; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_CONTEXT; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_HOST_IP_ADDRESS; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION; -import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_SUB_CONTEXT; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_URL; -import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE; -import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PROTOCOL; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PORT; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_CONTEXT_URL; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import java.util.Properties; import org.apache.commons.lang.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -44,51 +40,37 @@ class ResourceUriExtractor { private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class); - String extractResourceUri(SvcLogicContext ctx, Properties prop) throws Exception { + String extractResourceUri(SvcLogicContext ctx) throws Exception { String resourceUri = ctx.getAttribute(INPUT_URL); if (StringUtils.isBlank(resourceUri)) { - resourceUri = getAddress(ctx, prop); + resourceUri = getAddress(ctx); log.info("resourceUri= " + resourceUri); - resourceUri += getContext(ctx, prop); + resourceUri += getContext(ctx); log.info("resourceUri= " + resourceUri); - resourceUri += getSubContext(ctx, prop); + } log.info("resourceUri= " + resourceUri); return resourceUri; } - private String getAddress(SvcLogicContext ctx, Properties prop) { + private String getAddress(SvcLogicContext ctx) { String address = ctx.getAttribute(INPUT_HOST_IP_ADDRESS); - String portPath = ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "." - + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT); - String port = prop.getProperty(portPath); + String port = ctx.getAttribute(REST_PORT); return HTTP + address + ":" + port; } - private String getContext(SvcLogicContext ctx, Properties prop) throws Exception { + private String getContext(SvcLogicContext ctx) throws Exception { String context; - String urlPath = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION) - + "." + REST_CONTEXT_URL; if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_CONTEXT))) { context = "/" + ctx.getAttribute(INPUT_CONTEXT); - } else if (prop.getProperty(urlPath) != null) { - context = "/" + prop.getProperty(urlPath); + } else if (StringUtils.isNotBlank(ctx.getAttribute(REST_CONTEXT_URL))) { + context = "/" + ctx.getAttribute(REST_CONTEXT_URL); } else { throw new Exception("Could not find the context for operation " + ctx.getAttribute(INPUT_REQUEST_ACTION)); } return context; } - private String getSubContext(SvcLogicContext ctx, Properties prop) throws Exception { - String subContext = ""; - if (StringUtils.isNotBlank(ctx.getAttribute(INPUT_SUB_CONTEXT))) { - subContext = "/" + ctx.getAttribute(INPUT_SUB_CONTEXT); - } else if (prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context") != null) { - subContext = "/" + prop.getProperty(ctx.getAttribute(INPUT_REQUEST_ACTION) + ".sub-context"); - } - return subContext; - } - } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java index b8625db84..074310986 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/RestServiceNode.java @@ -31,7 +31,6 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; import java.util.Map; -import java.util.Properties; import org.apache.commons.lang3.StringUtils; import org.onap.appc.flow.controller.data.Transaction; import org.onap.appc.flow.controller.executorImpl.RestExecutor; @@ -42,7 +41,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; public class RestServiceNode implements SvcLogicJavaPlugin { private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class); - public static final String APPC_CONFIG_DIR_VAR = "APPC_CONFIG_DIR"; static final String REST_RESPONSE = "restResponse"; @@ -80,14 +78,11 @@ public class RestServiceNode implements SvcLogicJavaPlugin { log.info(fn + "Getting Key = " + key + "and Value = " + ctx.getAttribute(key)); } - Properties prop = loadProperties(); - log.info("Loaded Properties " + prop.toString()); - - String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop); + String resourceUri = resourceUriExtractor.extractResourceUri(ctx); log.info("Rest Constructed URL : " + resourceUri); - Transaction transaction = transactionHandler.buildTransaction(ctx, prop, resourceUri); + Transaction transaction = transactionHandler.buildTransaction(ctx, resourceUri); Map<String, String> output = restExecutor.execute(transaction, ctx); String json = output.get(REST_RESPONSE); @@ -110,12 +105,5 @@ public class RestServiceNode implements SvcLogicJavaPlugin { } } - private Properties loadProperties() throws Exception { - String directory = envVariables.getenv(APPC_CONFIG_DIR_VAR); - if (directory == null) { - throw new Exception("Cannot find Property file: " + APPC_CONFIG_DIR_VAR); - } - String path = directory + APPC_SOUTHBOUND; - return PropertiesLoader.load(path); - } + } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java index 71ab8f7aa..3a0a6a633 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/TransactionHandler.java @@ -3,6 +3,7 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2018 Nokia. All rights reserved. + * Copyright (C) 2018 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. @@ -21,10 +22,9 @@ package org.onap.appc.flow.controller.node; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE; -import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNF_TYPE; -import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PROTOCOL; +import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_USER; +import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REST_PWD; -import java.util.Properties; import org.apache.commons.lang3.StringUtils; import org.onap.appc.flow.controller.data.Transaction; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -34,16 +34,12 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; */ class TransactionHandler { - Transaction buildTransaction(SvcLogicContext ctx, Properties prop, String resourceUri) + Transaction buildTransaction(SvcLogicContext ctx, String resourceUri) throws Exception { String inputRequestAction = ctx.getAttribute(INPUT_REQUEST_ACTION); String inputRequestActionType = ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE); - String vnfType = ctx.getAttribute(VNF_TYPE); - if (StringUtils.isBlank(vnfType)) { - throw new Exception("Don't know vnf type to send REST request for " + INPUT_REQUEST_ACTION + " - " +vnfType); - } if (StringUtils.isBlank(inputRequestActionType)) { throw new Exception("Don't know REST operation for Action " + inputRequestActionType); } @@ -56,13 +52,10 @@ class TransactionHandler { transaction.setExecutionRPC(inputRequestActionType); transaction.setAction(INPUT_REQUEST_ACTION); - String userKey = vnfType + "." + REST_PROTOCOL + "." + inputRequestAction + ".user"; - String passwordKey = vnfType + "." + REST_PROTOCOL + "." + inputRequestAction + ".password"; - transaction.setuId(prop.getProperty(userKey)); - transaction.setPswd(prop.getProperty(passwordKey)); - if (StringUtils.isBlank(transaction.getuId()) || StringUtils.isBlank(transaction.getPswd())) { - throw new Exception ("User Id or Password is not set !!!"); - } + + transaction.setuId(ctx.getAttribute(REST_USER)); + transaction.setPswd(ctx.getAttribute(REST_PWD)); + return transaction; } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java index 275dd431f..fee6b677a 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java @@ -118,7 +118,7 @@ public class FlowControllerConstants { public static final String REST_PROTOCOL = "REST"; public static final String HEALTHCHECK ="HealthCheck"; public static final String REST_USER="user"; - public static final String REST_PWD="password"; + public static final String REST_PWD="pwd"; public static final String REST_PORT="port"; public static final String REST_CONTEXT_URL="url"; } |