diff options
author | ramverma <ram.krishna.verma@est.tech> | 2019-08-16 10:13:09 +0000 |
---|---|---|
committer | ramverma <ram.krishna.verma@est.tech> | 2019-08-16 10:13:09 +0000 |
commit | ebd5d6f5d1973298a62b581f2e604528993d56d2 (patch) | |
tree | 8805d6f1e331bf07c9f2ee21229a852e52bda3b1 /plugins/forwarding-plugins | |
parent | 2326847dac621c3718023be059cc1648f69bd31e (diff) |
Add LifecycleApiForwarder in policy/distribution
* Adding implementation of LifecycleApiForwarder in policy/distribution
for forwarding policy to new components (PAP & API).
* Adding related test cases and json files for testing.
* Created a rest simulator to use for testing the API calls.
* Fixed review comments
Issue-ID: POLICY-1890
Change-Id: I6682e0366206d3f4ac77f60b676f40a0fd1aad02
Signed-off-by: ramverma <ram.krishna.verma@est.tech>
Diffstat (limited to 'plugins/forwarding-plugins')
14 files changed, 1024 insertions, 64 deletions
diff --git a/plugins/forwarding-plugins/pom.xml b/plugins/forwarding-plugins/pom.xml index 2f508efc..f4503300 100644 --- a/plugins/forwarding-plugins/pom.xml +++ b/plugins/forwarding-plugins/pom.xml @@ -61,5 +61,10 @@ <artifactId>mockito-all</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java index 8ba7bdbe..ab1a737a 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroup.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java @@ -22,34 +22,27 @@ package org.onap.policy.distribution.forwarding.lifecycle.api; import lombok.Getter; -import org.onap.policy.common.parameters.annotations.Min; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; /** - * Holds the parameters for the{@link LifecycleApiPolicyForwarder}. + * Holds the parameters for the {@link LifecycleApiPolicyForwarder}. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ @Getter @NotNull @NotBlank -public class LifecycleApiPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup { +public class LifecycleApiForwarderParameters extends PolicyForwarderConfigurationParameterGroup { public static final String POLICY_FORWARDER_PLUGIN_CLASS = LifecycleApiPolicyForwarder.class.getName(); - private String policyApiHostName; - @Min(value = 1) - private int policyApiPort; - private String policyApiUserName; - private String policyApiPassword; - private String policyPapHostName; - @Min(value = 1) - private int policyPapPort; - private String policyPapUserName; - private String policyPapPassword; + private LifecycleApiParameters apiParameters; + private LifecycleApiParameters papParameters; private boolean isHttps; private boolean deployPolicies = true; - public LifecycleApiPolicyForwarderParameterGroup() { - super(LifecycleApiPolicyForwarderParameterGroup.class.getSimpleName()); + public LifecycleApiForwarderParameters() { + super(LifecycleApiForwarderParameters.class.getSimpleName()); } } diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java new file mode 100644 index 00000000..ed9ed9e0 --- /dev/null +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.lifecycle.api; + +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.Min; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup; + +/** + * Holds the parameters for the {@link LifecycleApiPolicyForwarder}. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@NotNull +@NotBlank +public class LifecycleApiParameters extends PolicyForwarderConfigurationParameterGroup { + + private String hostName; + @Min(value = 1) + private int port; + private String userName; + private String password; + + public LifecycleApiParameters() { + super(LifecycleApiParameters.class.getSimpleName()); + } +} diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java index 4b8acb10..5cd9966d 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java @@ -20,12 +20,35 @@ package org.onap.policy.distribution.forwarding.lifecycle.api; +import com.google.common.collect.ImmutableMap; + +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; +import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; +import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.PolicyForwardingException; +import org.onap.policy.models.pap.concepts.PdpDeployPolicies; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies & policy @@ -35,7 +58,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; */ public class LifecycleApiPolicyForwarder implements PolicyForwarder { - private LifecycleApiPolicyForwarderParameterGroup forwarderParameters; + private static final String DEPLOY_POLICY_URI = "/policy/pap/v1/pdps/policies"; + private static final String CREATE_POLICY_TYPE_URI = "/policy/api/v1/policytypes/"; + private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleApiPolicyForwarder.class); + private LifecycleApiForwarderParameters forwarderParameters; /** * {@inheritDoc}. @@ -49,9 +75,101 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { * {@inheritDoc}. */ @Override - public void forward(final Collection<ToscaEntity> policies) throws PolicyForwardingException { - // TODO: add implementation + public void forward(final Collection<ToscaEntity> entities) throws PolicyForwardingException { + final List<ToscaEntity> failedEntities = new ArrayList<>(); + for (final ToscaEntity entity : entities) { + forwardSingleEntity(failedEntities, entity); + } + if (!failedEntities.isEmpty()) { + throw new PolicyForwardingException( + "Failed forwarding the following entities: " + Arrays.toString(failedEntities.toArray())); + } + } + + private void forwardSingleEntity(final List<ToscaEntity> failedEntities, final ToscaEntity entity) { + Response policyCreated = null; + try { + if (entity instanceof ToscaServiceTemplate) { + final ToscaServiceTemplate toscaServiceTemplate = (ToscaServiceTemplate) entity; + if (null != toscaServiceTemplate.getPolicyTypes() && !toscaServiceTemplate.getPolicyTypes().isEmpty()) { + createPolicyType(toscaServiceTemplate); + } + if (null != toscaServiceTemplate.getToscaTopologyTemplate() + && null != toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() + && !toscaServiceTemplate.getToscaTopologyTemplate().getPolicies().isEmpty() + && !toscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).entrySet().isEmpty()) { + policyCreated = createPolicy(toscaServiceTemplate); + } + if (forwarderParameters.isDeployPolicies() && policyCreated != null) { + deployPolicy(policyCreated.readEntity(ToscaServiceTemplate.class)); + } + } else { + throw new PolicyForwardingException("The entity is not of type ToscaServiceTemplate - " + entity); + } + } catch (final Exception exp) { + LOGGER.error(exp.getMessage(), exp); + failedEntities.add(entity); + } } + private Response createPolicyType(final ToscaServiceTemplate toscaServiceTemplate) + throws PolicyForwardingException { + return invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON), CREATE_POLICY_TYPE_URI, + true); + } + + private Response createPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException { + final ToscaPolicy policy = toscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0).entrySet() + .iterator().next().getValue(); + return invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON), + CREATE_POLICY_TYPE_URI + policy.getType() + "/versions/" + policy.getTypeVersion() + "/policies", true); + } + + private Response deployPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException { + final PdpDeployPolicies pdpPolicies = new PdpDeployPolicies(); + final List<ToscaPolicyIdentifierOptVersion> policyIdentifierList = new ArrayList<>(); + for (final Map<String, ToscaPolicy> policyMap : toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()) { + final String policyId = policyMap.entrySet().iterator().next().getValue().getMetadata().get("policy-id"); + final String policyVersion = + policyMap.entrySet().iterator().next().getValue().getMetadata().get("policy-version"); + final ToscaPolicyIdentifierOptVersion toscaPolicyIdentifier = + new ToscaPolicyIdentifierOptVersion(policyId, policyVersion); + policyIdentifierList.add(toscaPolicyIdentifier); + } + pdpPolicies.setPolicies(policyIdentifierList); + return invokeHttpClient(Entity.entity(pdpPolicies, MediaType.APPLICATION_JSON), DEPLOY_POLICY_URI, false); + } + + private Response invokeHttpClient(final Entity<?> entity, final String path, final boolean wantApi) + throws PolicyForwardingException { + Response response = null; + try { + response = getHttpClient(wantApi).post(path, entity, ImmutableMap.of(HttpHeaders.ACCEPT, + MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)); + if (response.getStatus() != Status.OK.getStatusCode()) { + LOGGER.error( + "Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}", + path, entity, response.getStatus(), response.getStatusInfo()); + throw new PolicyForwardingException("Failed creating the entity - " + entity); + } + } catch (final HttpClientConfigException exception) { + LOGGER.error( + "Invocation of path " + path + " failed for entity " + entity + " due to error opening Http client", + exception); + throw new PolicyForwardingException("Failed creating the entity - " + entity, exception); + } + return response; + } + + private HttpClient getHttpClient(final boolean wantApi) throws HttpClientConfigException { + final boolean https = forwarderParameters.isHttps(); + final LifecycleApiParameters parameters = + (wantApi ? forwarderParameters.getApiParameters() : forwarderParameters.getPapParameters()); + final BusTopicParams params = BusTopicParams.builder().clientName("Policy Distribution").useHttps(https) + .hostname(parameters.getHostName()).port(parameters.getPort()).userName(parameters.getUserName()) + .password(parameters.getPassword()).serializationProvider(GsonMessageBodyHandler.class.getName()) + .build(); + return HttpClientFactoryInstance.getClientFactory().build(params); + } } diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroupTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java index fe27b74f..fd8422d6 100644 --- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderParameterGroupTest.java +++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java @@ -21,6 +21,7 @@ package org.onap.policy.distribution.forwarding.lifecycle.api; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -28,60 +29,60 @@ import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.distribution.forwarding.xacml.pdp.testclasses.CommonTestData; /** - * Class to perform unit test of {@link LifecycleApiPolicyForwarderParameterGroup}. + * Class to perform unit test of {@link LifecycleApiForwarderParameters}. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ -public class LifecycleApiPolicyForwarderParameterGroupTest { +public class LifecycleApiForwarderParametersTest { - private static final String POLICY_API_HOST_NAME = "10.10.10.10"; - private static final int POLICY_API_PORT = 1234; - private static final String POLICY_API_USER = "api_user"; - private static final String POLICY_API_PASSWORD = "api_password"; - private static final String POLICY_PAP_HOST_NAME = "20.20.20.20"; - private static final int POLICY_PAP_PORT = 4321; - private static final String POLICY_PAP_USER = "pap_user"; - private static final String POLICY_PAP_PASSWORD = "pap_password"; + private static final String POLICY_API_HOST_NAME = "0.0.0.0"; + private static final int POLICY_API_PORT = 6969; + private static final String POLICY_API_USER = "healthcheck"; + private static final String POLICY_API_PASSWORD = "zb!XztG34"; + private static final String POLICY_PAP_HOST_NAME = "0.0.0.0"; + private static final int POLICY_PAP_PORT = 6969; + private static final String POLICY_PAP_USER = "healthcheck"; + private static final String POLICY_PAP_PASSWORD = "zb!XztG34"; @Test public void testValidParameters() { - final LifecycleApiPolicyForwarderParameterGroup configurationParameters = + final LifecycleApiForwarderParameters configurationParameters = CommonTestData.getPolicyForwarderParameters( "src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json", - LifecycleApiPolicyForwarderParameterGroup.class); + LifecycleApiForwarderParameters.class); - assertEquals(LifecycleApiPolicyForwarderParameterGroup.class.getSimpleName(), + assertEquals(LifecycleApiForwarderParameters.class.getSimpleName(), configurationParameters.getName()); - assertTrue(configurationParameters.isHttps()); + assertFalse(configurationParameters.isHttps()); assertTrue(configurationParameters.isDeployPolicies()); - assertEquals(POLICY_API_HOST_NAME, configurationParameters.getPolicyApiHostName()); - assertEquals(POLICY_API_PORT, configurationParameters.getPolicyApiPort()); - assertEquals(POLICY_API_USER, configurationParameters.getPolicyApiUserName()); - assertEquals(POLICY_API_PASSWORD, configurationParameters.getPolicyApiPassword()); - assertEquals(POLICY_PAP_HOST_NAME, configurationParameters.getPolicyPapHostName()); - assertEquals(POLICY_PAP_PORT, configurationParameters.getPolicyPapPort()); - assertEquals(POLICY_PAP_USER, configurationParameters.getPolicyPapUserName()); - assertEquals(POLICY_PAP_PASSWORD, configurationParameters.getPolicyPapPassword()); + assertEquals(POLICY_API_HOST_NAME, configurationParameters.getApiParameters().getHostName()); + assertEquals(POLICY_API_PORT, configurationParameters.getApiParameters().getPort()); + assertEquals(POLICY_API_USER, configurationParameters.getApiParameters().getUserName()); + assertEquals(POLICY_API_PASSWORD, configurationParameters.getApiParameters().getPassword()); + assertEquals(POLICY_PAP_HOST_NAME, configurationParameters.getPapParameters().getHostName()); + assertEquals(POLICY_PAP_PORT, configurationParameters.getPapParameters().getPort()); + assertEquals(POLICY_PAP_USER, configurationParameters.getPapParameters().getUserName()); + assertEquals(POLICY_PAP_PASSWORD, configurationParameters.getPapParameters().getPassword()); assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus()); } @Test public void testInvalidParameters() { - final LifecycleApiPolicyForwarderParameterGroup configurationParameters = + final LifecycleApiForwarderParameters configurationParameters = CommonTestData.getPolicyForwarderParameters( "src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json", - LifecycleApiPolicyForwarderParameterGroup.class); + LifecycleApiForwarderParameters.class); assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus()); } @Test public void testEmptyParameters() { - final LifecycleApiPolicyForwarderParameterGroup configurationParameters = + final LifecycleApiForwarderParameters configurationParameters = CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json", - LifecycleApiPolicyForwarderParameterGroup.class); + LifecycleApiForwarderParameters.class); assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus()); } diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java new file mode 100644 index 00000000..4d837cdf --- /dev/null +++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.lifecycle.api; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import java.util.ArrayList; +import java.util.Collection; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.common.parameters.ParameterGroup; +import org.onap.policy.common.parameters.ParameterService; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.distribution.forwarding.PolicyForwardingException; +import org.onap.policy.distribution.forwarding.xacml.pdp.testclasses.CommonTestData; +import org.onap.policy.distribution.forwarding.xacml.pdp.testclasses.LifecycleApiSimulatorMain; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to perform unit test of {@link LifecycleApiPolicyForwarder}. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class LifecycleApiPolicyForwarderTest { + + private static final String POLICY = "src/test/resources/parameters/sample_policy.json"; + private static final String POLICY_ERROR = "src/test/resources/parameters/sample_policy_failure.json"; + private static final String POLICY_TYPE = "src/test/resources/parameters/sample_policy_type.json"; + private StandardCoder standardCoder = new StandardCoder(); + private static LifecycleApiSimulatorMain simulator = new LifecycleApiSimulatorMain(); + + /** + * Set up. + * + * @throws CoderException if any error occurs + * @throws PolicyForwardingException if any error occurs + * @throws InterruptedException if any error occurs + */ + @BeforeClass + public static void setUp() throws PolicyForwardingException, CoderException, InterruptedException { + final ParameterGroup parameterGroup = CommonTestData.getPolicyForwarderParameters( + "src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json", + LifecycleApiForwarderParameters.class); + ParameterService.register(parameterGroup); + simulator.startLifecycycleApiSimulator(); + if (!NetworkUtil.isTcpPortOpen("0.0.0.0", 6969, 6, 10000L)) { + throw new IllegalStateException("cannot connect to port 6969"); + } + } + + /** + * Tear down. + */ + @AfterClass + public static void tearDown() { + ParameterService.deregister(LifecycleApiForwarderParameters.class.getSimpleName()); + simulator.stopLifecycycleApiSimulator(); + } + + @Test + public void testForwardPolicyUsingSimulator() throws Exception { + + final ToscaServiceTemplate toscaServiceTemplate1 = + standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class); + final ToscaServiceTemplate toscaServiceTemplate2 = + standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class); + + final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder(); + forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName()); + + final Collection<ToscaEntity> policies = new ArrayList<>(); + policies.add(toscaServiceTemplate1); + policies.add(toscaServiceTemplate2); + + forwarder.forward(policies); + } + + @Test + public void testForwardPolicyFailureUsingSimulator() throws Exception { + + final ToscaServiceTemplate toscaServiceTemplate1 = + standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class); + final ToscaServiceTemplate toscaServiceTemplate2 = + standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class); + final ToscaServiceTemplate toscaServiceTemplate3 = + standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_ERROR), ToscaServiceTemplate.class); + final ToscaEntity unsupportedPolicy = new UnsupportedPolicy(); + + final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder(); + forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName()); + + final Collection<ToscaEntity> policies = new ArrayList<>(); + policies.add(toscaServiceTemplate1); + policies.add(toscaServiceTemplate2); + policies.add(toscaServiceTemplate3); + policies.add(unsupportedPolicy); + + assertThatThrownBy(() -> forwarder.forward(policies)).isInstanceOf(PolicyForwardingException.class) + .hasMessageContaining("Failed forwarding the following entities:"); + } + + class UnsupportedPolicy extends ToscaEntity { + + @Override + public String getName() { + return "unsupported"; + } + } +} diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycleApiSimulatorMain.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycleApiSimulatorMain.java new file mode 100644 index 00000000..9aa68876 --- /dev/null +++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycleApiSimulatorMain.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.xacml.pdp.testclasses; + +import org.onap.policy.common.endpoints.http.server.RestServer; +import org.onap.policy.common.endpoints.parameters.RestServerParameters; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.distribution.forwarding.PolicyForwardingException; +import org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiPolicyForwarder; +import org.onap.policy.distribution.main.rest.aaf.AafDistributionFilter; + +/** + * The class for starting/stopping simulator for testing {@link LifecycleApiPolicyForwarder} . + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class LifecycleApiSimulatorMain { + private RestServer restServer; + + /** + * Starts the simulator. + * + * @throws PolicyForwardingException if error occurs + * @throws CoderException if error occurs + */ + public void startLifecycycleApiSimulator() throws PolicyForwardingException, CoderException { + final StandardCoder standardCoder = new StandardCoder(); + final RestServerParameters restServerParameters = standardCoder.decode( + ResourceUtils.getResourceAsString("src/test/resources/parameters/RestServerParameters.json"), + RestServerParameters.class); + restServer = new RestServer(restServerParameters, AafDistributionFilter.class, + LifecycycleApiSimulatorEndpoint.class); + if (!restServer.start()) { + throw new PolicyForwardingException("Failed to start rest simulator. Check log for more details..."); + } + } + + /** + * Shut down Execution. + */ + public void stopLifecycycleApiSimulator() { + if (restServer != null) { + restServer.stop(); + } + } +} diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycycleApiSimulatorEndpoint.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycycleApiSimulatorEndpoint.java new file mode 100644 index 00000000..f07605f0 --- /dev/null +++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/xacml/pdp/testclasses/LifecycycleApiSimulatorEndpoint.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.forwarding.xacml.pdp.testclasses; + +import io.swagger.annotations.ApiParam; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onap.policy.models.pap.concepts.PdpDeployPolicies; +import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to provide rest end points for LifecycycleApiSimulator. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Path("/policy") +@Produces(MediaType.APPLICATION_JSON) +public class LifecycycleApiSimulatorEndpoint { + + /** + * Create policy type endpoint. + * + * @param body the post body + * @return the response object + */ + @POST + @Path("/api/v1/policytypes") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createPolicyTypes(final ToscaServiceTemplate body) { + return Response.status(Response.Status.OK).entity(body).build(); + } + + /** + * Create policy endpoint. + * + * @param policyTypeId the policy type id + * @param policyTypeVersion the policy type version + * @param body the post body + * @return the response object + */ + @POST + @Path("/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createPolicies(@PathParam("policyTypeId") final String policyTypeId, + @PathParam("policyTypeVersion") final String policyTypeVersion, + @ApiParam(value = "Entity body of policy", required = true) final ToscaServiceTemplate body) { + if ("onap.policies.controlloop.operational.ApexFailure".equals(policyTypeId)) { + return Response.status(Response.Status.NOT_FOUND).build(); + } else { + return Response.status(Response.Status.OK).entity(body).build(); + } + } + + /** + * Deploy policy endpoint. + * + * @param policies the post body + * @return the response object + */ + @POST + @Path("/pap/v1/pdps/policies") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response deployPolicies(final PdpDeployPolicies policies) { + return Response.status(Response.Status.OK).entity(new PdpGroupDeployResponse()).build(); + } +} diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json index 0bb54279..0791e1ae 100644 --- a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json +++ b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json @@ -1,12 +1,16 @@ { - "policyApiHostName": "10.10.10.10", - "policyApiPort": 1234, - "policyApiUserName": "api_user", - "policyApiPassword": "api_password", - "policyPapHostName": "20.20.20.20", - "policyPapPort": "4321", - "policyPapUserName": "pap_user", - "policyPapPassword": "pap_password", - "isHttps": true, - "deployPolicies": true + "apiParameters": { + "hostName": "0.0.0.0", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34" + }, + "papParameters": { + "hostName": "0.0.0.0", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34" + }, + "isHttps": false, + "deployPolicies": true }
\ No newline at end of file diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json index b10be731..ca0558a6 100644 --- a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json +++ b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json @@ -1,12 +1,16 @@ { - "policyApiHostName": "", - "policyApiPort": -1, - "policyApiUserName": "api_user", - "policyApiPassword": "api_password", - "policyPapHostName": "", - "policyPapPort": "-2", - "policyPapUserName": "pap_user", - "policyPapPassword": "pap_password", - "isHttps": true, - "deployPolicies": true + "apiParameters": { + "hostName": "", + "port": -1, + "userName": "healthcheck", + "password": "zb!XztG34" + }, + "papParameters": { + "hostName": "", + "port": -2, + "userName": "healthcheck", + "password": "zb!XztG34" + }, + "isHttps": false, + "deployPolicies": true }
\ No newline at end of file diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/RestServerParameters.json b/plugins/forwarding-plugins/src/test/resources/parameters/RestServerParameters.json new file mode 100644 index 00000000..86aee276 --- /dev/null +++ b/plugins/forwarding-plugins/src/test/resources/parameters/RestServerParameters.json @@ -0,0 +1,6 @@ +{ + "host": "0.0.0.0", + "port": 6969, + "userName": "healthcheck", + "password": "zb!XztG34" +} diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy.json b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy.json new file mode 100644 index 00000000..d8651ce4 --- /dev/null +++ b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy.json @@ -0,0 +1,101 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "operational.sampledomain": { + "type": "onap.policies.controlloop.operational.Apex", + "typeVersion": "1.0.0", + "name": "onap.policies.controlloop.operational.apex.Sampledomain", + "version": "1.0.0", + "metadata": { + "policy-id": "onap.policies.controlloop.operational.apex.Sampledomain" + }, + "properties": { + "content": { + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policy_type_impl": "The implementation logic of the policy can come here", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "DCAEConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.25:30227/events/DCAE_CL_OUTPUT/11/12?timeout=30000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + }, + "eventOutputParameters": { + "APPCProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.25:30227/events/APPC-LCM-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "APPCLCMRequestEvent" + } + }, + "eventNameFilter": "APPCConfigModifyRequestEvent" + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/outputevents.log" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + } + } + } + } + } + ] + } +}
\ No newline at end of file diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_failure.json b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_failure.json new file mode 100644 index 00000000..1d30f08b --- /dev/null +++ b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_failure.json @@ -0,0 +1,101 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "operational.sampledomain": { + "type": "onap.policies.controlloop.operational.ApexFailure", + "typeVersion": "1.0.0", + "name": "onap.policies.controlloop.operational.apex.Sampledomain", + "version": "1.0.0", + "metadata": { + "policy-id": "onap.policies.controlloop.operational.apex.Sampledomain" + }, + "properties": { + "content": { + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policy_type_impl": "The implementation logic of the policy can come here", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "DCAEConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.25:30227/events/DCAE_CL_OUTPUT/11/12?timeout=30000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + }, + "eventOutputParameters": { + "APPCProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.25:30227/events/APPC-LCM-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "APPCLCMRequestEvent" + } + }, + "eventNameFilter": "APPCConfigModifyRequestEvent" + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/outputevents.log" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + } + } + } + } + } + ] + } +}
\ No newline at end of file diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_type.json b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_type.json new file mode 100644 index 00000000..8795b132 --- /dev/null +++ b/plugins/forwarding-plugins/src/test/resources/parameters/sample_policy_type.json @@ -0,0 +1,284 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "policy_types": [ + { + "onap.policies.controlloop.operational.Apex": { + "version": "1.0.0", + "description": "Operational Policy for Control Loops using the APEX PDP", + "properties": { + "engine_service": { + "type": "onap.datatypes.policies.controlloop.operational.apex.EngineService", + "description": "APEX Engine Service Parameters" + }, + "inputs": { + "type": "map", + "description": "Inputs for handling events coming into the APEX engine", + "entry_schema": { + "type": "onap.datatypes.policies.controlloop.operational.apex.EventHandler" + } + }, + "outputs": { + "type": "map", + "description": "Outputs for handling events going out of the APEX engine", + "entry_schema": { + "type": "onap.datatypes.policies.controlloop.operational.apex.EventHandler" + } + }, + "environment": { + "type": "list", + "description": "Envioronmental parameters for the APEX engine", + "entry_schema": { + "type": "onap.datatypes.policies.controlloop.operational.apex.Environment" + } + } + } + } + } + ], + "data_types": [ + { + "onap.datatypes.policies.controlloop.operational.apex.EngineService": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "name": { + "type": "string", + "description": "Specifies the engine name", + "required": false, + "default": "ApexEngineService" + }, + "version": { + "type": "string", + "description": "Specifies the engine version in double dotted format", + "required": false, + "default": "1.0.0" + }, + "id": { + "type": "int", + "description": "Specifies the engine id", + "required": true + }, + "instance_count": { + "type": "int", + "description": "Specifies the number of engine threads that should be run", + "required": true + }, + "deployment_port": { + "type": "int", + "description": "Specifies the port to connect to for engine administration", + "required": false, + "default": 1 + }, + "policy_model_file_name": { + "type": "string", + "description": "The name of the file from which to read the APEX policy model", + "required": false, + "default": "" + }, + "policy_type_impl": { + "type": "string", + "description": "The policy type implementation from which to read the APEX policy model", + "required": false, + "default": "" + }, + "periodic_event_period": { + "type": "string", + "description": "The time interval in milliseconds for the periodic scanning event, 0 means \"don't scan\"", + "required": false, + "default": 0 + }, + "engine": { + "type": "onap.datatypes.policies.controlloop.operational.apex.engineservice.Engine", + "description": "The parameters for all engines in the APEX engine service", + "required": true + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.EventHandler": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "name": { + "type": "string", + "description": "Specifies the event handler name, if not specified this is set to the key name", + "required": false + }, + "carrier_technology": { + "type": "onap.datatypes.policies.controlloop.operational.apex.CarrierTechnology", + "description": "Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka)", + "required": true + }, + "event_protocol": { + "type": "onap.datatypes.policies.controlloop.operational.apex.EventProtocol", + "description": "Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO)", + "required": true + }, + "event_name": { + "type": "string", + "description": "Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent", + "required": false + }, + "event_name_filter": { + "type": "string", + "description": "Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through", + "required": false + }, + "synchronous_mode": { + "type": "bool", + "description": "Specifies the event handler is syncronous (receive event and send response)", + "required": false, + "default": false + }, + "synchronous_peer": { + "type": "string", + "description": "The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode", + "required": false, + "default": "" + }, + "synchronous_timeout": { + "type": "int", + "description": "The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode", + "required": false, + "default": "" + }, + "requestor_mode": { + "type": "bool", + "description": "Specifies the event handler is in requestor mode (send event and wait for response mode)", + "required": false, + "default": false + }, + "requestor_peer": { + "type": "string", + "description": "The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode", + "required": false, + "default": "" + }, + "requestor_timeout": { + "type": "int", + "description": "The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode", + "required": false, + "default": "" + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.CarrierTechnology": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "label": { + "type": "string", + "description": "The label (name) of the carrier technology (such as REST, Kafka, WebSocket)", + "required": true + }, + "plugin_parameter_class_name": { + "type": "string", + "description": "The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class", + "required": false + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.EventProtocol": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "label": { + "type": "string", + "description": "The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO)", + "required": true + }, + "event_protocol_plugin_class": { + "type": "string", + "description": "The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class", + "required": false + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.Environmental": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "name": { + "type": "string", + "description": "The name of the environment variable", + "required": true + }, + "value": { + "type": "string", + "description": "The value of the environment variable", + "required": true + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.engineservice.Engine": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "context": { + "type": "onap.datatypes.policies.controlloop.operational.apex.engineservice.engine.Context", + "description": "The properties for handling context in APEX engines, defaults to using Java maps for context", + "required": false + }, + "executors": { + "type": "map", + "description": "The plugins for policy executors used in engines such as javascript, MVEL, Jython", + "required": true, + "entry_schema": { + "description": "The plugin class path for this policy executor", + "type": "string" + } + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.engineservice.engine.Context": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "distributor": { + "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin", + "description": "The plugin to be used for distributing context between APEX PDPs at runtime", + "required": false + }, + "schemas": { + "type": "map", + "description": "The plugins for context schemas available in APEX PDPs such as Java and Avro", + "required": false, + "entry_schema": { + "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin" + } + }, + "locking": { + "type": "onap.datatypes.policies.controlloop.operational.apex.plugin", + "description": "The plugin to be used for locking context in and between APEX PDPs at runtime", + "required": false + }, + "persistence": { + "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin", + "description": "The plugin to be used for persisting context for APEX PDPs at runtime", + "required": false + } + } + } + }, + { + "onap.datatypes.policies.controlloop.operational.apex.Plugin": { + "derived_from": "tosca.datatypes.Root", + "properties": { + "name": { + "type": "string", + "description": "The name of the executor such as Javascript, Jython or MVEL", + "required": true + }, + "plugin_class_name": { + "type": "string", + "description": "The class path of the plugin class for this executor" + } + } + } + } + ] +}
\ No newline at end of file |