diff options
author | Ritu Sood <ritu.sood@intel.com> | 2017-08-23 07:52:20 -0700 |
---|---|---|
committer | Ritu Sood <ritu.sood@intel.com> | 2017-08-24 06:33:57 -0700 |
commit | 1c4fcf40b4cd33454bb57bde1e82a3819cb6ccff (patch) | |
tree | 1e0ea36076cf9249c2a66ef9eb3d331b10cb9493 /controlloop/common/actors/actor.vfc/src | |
parent | 945627aef4645a9a696aeb2150669e43aae9f98a (diff) |
Add VFC integration code
This patch adds VFC Actor code and updates drool template for VFC.
This is WIP patch. There are two opens for this patch that are
still in discussion
1) AA&I fields in onset event
2) VFC URL, username and password
Issue-ID: POLICY-57
Change-Id: Idc1d1fada295fa1c2e563ba37dd359f7b5c59f87
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Diffstat (limited to 'controlloop/common/actors/actor.vfc/src')
2 files changed, 95 insertions, 0 deletions
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java new file mode 100644 index 000000000..ffada0a81 --- /dev/null +++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. 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.vfc; + +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.vfc.VFCRequest; +import org.onap.policy.vfc.VFCHealRequest; +import org.onap.policy.vfc.VFCHealAdditionalParams; +import org.onap.policy.vfc.VFCHealActionVmInfo; +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 VFCActorServiceProvider implements Actor { + + private static final ImmutableList<String> recipes = ImmutableList.of("Restart"); + private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>() + .put("Restart", ImmutableList.of("VM")) + .build(); + + @Override + public String actor() { + return "VFC"; + } + + @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(); + } + + public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) { + + // Construct an VFC request + VFCRequest request = new VFCRequest(); + // TODO: Verify service-instance-id is part of onset event + request.nsInstanceId = onset.AAI.get("service-instance.service-instance-id"); + request.healRequest = new VFCHealRequest(); + request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id"); + request.healRequest.cause = operation.message; + + request.healRequest.additionalParams = new VFCHealAdditionalParams(); + switch (policy.getRecipe()) { + case "Restart": + // TODO: check target?? + request.healRequest.additionalParams.action = "restartvm"; + request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo(); + // TODO: Verify vserver-id and vserver-name is part of onset event + request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id"); + request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name"); + break; + default: + //TODO: default + break; + } + return request; + } + + +} diff --git a/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor new file mode 100644 index 000000000..3ccac9949 --- /dev/null +++ b/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor @@ -0,0 +1 @@ +org.onap.policy.controlloop.actor.vfc.APPCActorServiceProvider |