summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/actors')
-rw-r--r--controlloop/common/actors/actor.appc/pom.xml32
-rw-r--r--controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java113
-rw-r--r--controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor1
-rw-r--r--controlloop/common/actors/actor.mso/pom.xml20
-rw-r--r--controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java58
-rw-r--r--controlloop/common/actors/actor.mso/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor1
-rw-r--r--controlloop/common/actors/actor.test/pom.xml41
-rw-r--r--controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java46
-rw-r--r--controlloop/common/actors/actorServiceProvider/pom.xml12
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java56
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java35
-rw-r--r--controlloop/common/actors/pom.xml32
12 files changed, 447 insertions, 0 deletions
diff --git a/controlloop/common/actors/actor.appc/pom.xml b/controlloop/common/actors/actor.appc/pom.xml
new file mode 100644
index 000000000..5f6519a47
--- /dev/null
+++ b/controlloop/common/actors/actor.appc/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actors</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>actor.appc</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actorServiceProvider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>appc</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>events</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
new file mode 100644
index 000000000..fe6bf40af
--- /dev/null
+++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * APPCActorServiceProvider
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.appc;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.appc.CommonHeader;
+import org.onap.policy.appc.Request;
+import org.onap.policy.controlloop.ControlLoopOperation;
+import org.onap.policy.controlloop.policy.Policy;
+
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+
+public class APPCActorServiceProvider implements Actor {
+
+ private static final ImmutableList<String> recipes = ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig");
+ private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
+ .put("Restart", ImmutableList.of("VM"))
+ .put("Rebuild", ImmutableList.of("VM"))
+ .put("Migrate", ImmutableList.of("VM"))
+ .put("ModifyConfig", ImmutableList.of("VFC"))
+ .build();
+ private static final ImmutableMap<String, List<String>> payloads = new ImmutableMap.Builder<String, List<String>>()
+ .put("ModifyConfig", ImmutableList.of("generic-vnf.vnf-id"))
+ .build();
+
+ @Override
+ public String actor() {
+ return "APPC";
+ }
+
+ @Override
+ public List<String> recipes() {
+ return ImmutableList.copyOf(recipes);
+ }
+
+ @Override
+ public List<String> recipeTargets(String recipe) {
+ return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList()));
+ }
+
+ @Override
+ public List<String> recipePayloads(String recipe) {
+ return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList()));
+ }
+
+
+ public static Request constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
+ //
+ // Construct an APPC request
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = onset.requestID;
+ request.CommonHeader.SubRequestID = operation.subRequestId;
+ request.Action = policy.recipe;
+
+ //
+ // TODO: do we need to take care of the target
+ //
+
+ //
+ // Handle the payload
+ //
+ if (policy.payload != null && !policy.payload.isEmpty()) {
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Add each payload entry
+ //
+ for (Map.Entry<String, String> entry : policy.payload.entrySet()) {
+ //
+ // TODO: entry key has ref$, value has {xxxx}
+ //
+ request.Payload.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+
+ request.Payload.put("AICVServerSelfLink", onset.AAI.get("vserver.selflink"));//.AICVServerSelfLink);
+ request.Payload.put("AICIdentity", onset.AAI.get("cloud-region.identity-url"));//AICIdentity);
+ //
+ // Return the request
+ //
+ return request;
+ }
+
+
+}
diff --git a/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor
new file mode 100644
index 000000000..5e76150c4
--- /dev/null
+++ b/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor
@@ -0,0 +1 @@
+com.att.ecomp.policy.controlloop.actor.appc.APPCActorServiceProvider \ No newline at end of file
diff --git a/controlloop/common/actors/actor.mso/pom.xml b/controlloop/common/actors/actor.mso/pom.xml
new file mode 100644
index 000000000..f0bbf48cb
--- /dev/null
+++ b/controlloop/common/actors/actor.mso/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actors</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>actor.mso</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actorServiceProvider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java b/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
new file mode 100644
index 000000000..d57e62634
--- /dev/null
+++ b/controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * MSOActorServiceProvider
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.mso;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+public class MSOActorServiceProvider implements Actor {
+
+ private static final ImmutableList<String> recipes = ImmutableList.of(
+ "VF Module Create");
+ private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
+ .put("VF Module Create", ImmutableList.of("VFC"))
+ .build();
+
+ @Override
+ public String actor() {
+ return "MSO";
+ }
+
+ @Override
+ public List<String> recipes() {
+ return ImmutableList.copyOf(recipes);
+ }
+
+ @Override
+ public List<String> recipeTargets(String recipe) {
+ return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList()));
+ }
+
+ @Override
+ public List<String> recipePayloads(String recipe) {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/controlloop/common/actors/actor.mso/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.mso/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor
new file mode 100644
index 000000000..aeed27b3b
--- /dev/null
+++ b/controlloop/common/actors/actor.mso/src/main/resources/META-INF/services/com.att.ecomp.policy.controlloop.actorServiceProvider.spi.Actor
@@ -0,0 +1 @@
+com.att.ecomp.policy.controlloop.actor.mso.MSOActorServiceProvider \ No newline at end of file
diff --git a/controlloop/common/actors/actor.test/pom.xml b/controlloop/common/actors/actor.test/pom.xml
new file mode 100644
index 000000000..9d8ffa48d
--- /dev/null
+++ b/controlloop/common/actors/actor.test/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actors</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>actor.test</artifactId>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/org/onap/policy/drools-applications/actor.appc/1.1.0-SNAPSHOT/actor.appc-1.1.0-SNAPSHOT.jar</additionalClasspathElement>
+ <additionalClasspathElement>${settings.localRepository}/org/onap/policy/drools-applications/actor.mso/1.1.0-SNAPSHOT/actor.mso-1.1.0-SNAPSHOT.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actorServiceProvider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java b/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java
new file mode 100644
index 000000000..f6eba49af
--- /dev/null
+++ b/controlloop/common/actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/Test.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * actor test
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.test;
+
+import static org.junit.Assert.*;
+
+import org.onap.policy.controlloop.actorServiceProvider.ActorService;
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+
+public class Test {
+
+ @org.junit.Test
+ public void test() {
+ System.out.println("Dumping actors");
+ ActorService actorService = ActorService.getInstance();
+ assertNotNull(actorService);
+ int num = 0;
+ for (Actor actor : actorService.actors()) {
+ System.out.println(actor.actor());
+ for (String recipe : actor.recipes()) {
+ System.out.println("\t" + recipe + " " + actor.recipeTargets(recipe) + " " + actor.recipePayloads(recipe));
+ }
+ num++;
+ }
+ System.out.println("Found " + num + " actors");
+ }
+
+}
diff --git a/controlloop/common/actors/actorServiceProvider/pom.xml b/controlloop/common/actors/actorServiceProvider/pom.xml
new file mode 100644
index 000000000..874871348
--- /dev/null
+++ b/controlloop/common/actors/actorServiceProvider/pom.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actors</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>actorServiceProvider</artifactId>
+</project>
diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java
new file mode 100644
index 000000000..2632d0752
--- /dev/null
+++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ActorService
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actorServiceProvider;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import com.google.common.collect.ImmutableList;
+
+public class ActorService {
+
+ private static ActorService service;
+
+ private ServiceLoader<Actor> loader;
+
+ private ActorService() {
+ loader = ServiceLoader.load(Actor.class);
+ }
+
+ public static synchronized ActorService getInstance() {
+ if (service == null) {
+ service = new ActorService();
+ }
+ return service;
+ }
+
+ public ImmutableList<Actor> actors() {
+ Iterator<Actor> iter = loader.iterator();
+ System.out.println("returning actors");
+ while (iter.hasNext()) {
+ System.out.println("Got " + iter.next().actor());
+ }
+
+ return ImmutableList.copyOf(loader.iterator());
+ }
+
+}
diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java
new file mode 100644
index 000000000..2492063c8
--- /dev/null
+++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Actor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actorServiceProvider.spi;
+
+import java.util.List;
+
+public interface Actor {
+
+ public String actor();
+
+ public List<String> recipes();
+
+ public List<String> recipeTargets(String recipe);
+
+ public List<String> recipePayloads(String recipe);
+
+}
diff --git a/controlloop/common/actors/pom.xml b/controlloop/common/actors/pom.xml
new file mode 100644
index 000000000..a00a3af52
--- /dev/null
+++ b/controlloop/common/actors/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>actors</artifactId>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>common</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>actorServiceProvider</module>
+ <module>actor.appc</module>
+ <module>actor.mso</module>
+ <module>actor.test</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>policy-yaml</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>