2 * ============LICENSE_START=======================================================
3 * controlloop event manager
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.eventmanager;
23 import java.io.Serializable;
24 import java.io.UnsupportedEncodingException;
25 import java.net.URLDecoder;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.LinkedList;
29 import java.util.UUID;
31 import org.onap.policy.aai.AaiGetVnfResponse;
32 import org.onap.policy.aai.AaiGetVserverResponse;
33 import org.onap.policy.aai.AaiManager;
34 import org.onap.policy.aai.util.AaiException;
35 import org.onap.policy.controlloop.ControlLoopEventStatus;
36 import org.onap.policy.controlloop.ControlLoopException;
37 import org.onap.policy.controlloop.ControlLoopNotificationType;
38 import org.onap.policy.controlloop.ControlLoopOperation;
39 import org.onap.policy.controlloop.VirtualControlLoopEvent;
40 import org.onap.policy.controlloop.VirtualControlLoopNotification;
41 import org.onap.policy.controlloop.policy.FinalResult;
42 import org.onap.policy.controlloop.policy.Policy;
43 import org.onap.policy.controlloop.processor.ControlLoopProcessor;
44 import org.onap.policy.drools.system.PolicyEngine;
45 import org.onap.policy.guard.GuardResult;
46 import org.onap.policy.guard.LockCallback;
47 import org.onap.policy.guard.PolicyGuard;
48 import org.onap.policy.guard.PolicyGuard.LockResult;
49 import org.onap.policy.guard.TargetLock;
50 import org.onap.policy.rest.RESTManager;
51 import org.slf4j.Logger;
52 import org.slf4j.LoggerFactory;
54 public class ControlLoopEventManager implements LockCallback, Serializable {
55 private static final String VM_NAME = "VM_NAME";
56 private static final String VNF_NAME = "VNF_NAME";
57 private static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id";
58 private static final String GENERIC_VNF_VNF_NAME = "generic-vnf.vnf-name";
59 private static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
60 private static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled";
61 private static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled";
64 * Additional time, in seconds, to add to a "lock" request. This ensures that the lock
65 * won't expire right before an operation completes.
67 private static final int ADDITIONAL_LOCK_SEC = 60;
69 private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
71 private static final long serialVersionUID = -1216568161322872641L;
72 public final String closedLoopControlName;
73 public final UUID requestID;
75 private String controlLoopResult;
76 private transient ControlLoopProcessor processor = null;
77 private VirtualControlLoopEvent onset;
78 private Integer numOnsets = 0;
79 private Integer numAbatements = 0;
80 private VirtualControlLoopEvent abatement;
81 private FinalResult controlLoopTimedOut = null;
83 private boolean isActivated = false;
84 private LinkedList<ControlLoopOperation> controlLoopHistory = new LinkedList<>();
85 private ControlLoopOperationManager currentOperation = null;
86 private transient TargetLock targetLock = null;
87 private AaiGetVnfResponse vnfResponse = null;
88 private AaiGetVserverResponse vserverResponse = null;
90 private static Collection<String> requiredAAIKeys = new ArrayList<>();
93 requiredAAIKeys.add("AICVServerSelfLink");
94 requiredAAIKeys.add("AICIdentity");
95 requiredAAIKeys.add("is_closed_loop_disabled");
96 requiredAAIKeys.add(VM_NAME);
99 public ControlLoopEventManager(String closedLoopControlName, UUID requestID) {
100 this.closedLoopControlName = closedLoopControlName;
101 this.requestID = requestID;
104 public String getControlLoopResult() {
105 return controlLoopResult;
108 public void setControlLoopResult(String controlLoopResult) {
109 this.controlLoopResult = controlLoopResult;
112 public Integer getNumOnsets() {
116 public void setNumOnsets(Integer numOnsets) {
117 this.numOnsets = numOnsets;
120 public Integer getNumAbatements() {
121 return numAbatements;
124 public void setNumAbatements(Integer numAbatements) {
125 this.numAbatements = numAbatements;
128 public boolean isActivated() {
132 public void setActivated(boolean isActivated) {
133 this.isActivated = isActivated;
136 public VirtualControlLoopEvent getOnsetEvent() {
140 public VirtualControlLoopEvent getAbatementEvent() {
141 return this.abatement;
144 public ControlLoopProcessor getProcessor() {
145 return this.processor;
149 * Activate a control loop event.
151 * @param event the event
152 * @return the VirtualControlLoopNotification
154 public VirtualControlLoopNotification activate(VirtualControlLoopEvent event) {
155 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(event);
158 // This method should ONLY be called ONCE
160 if (this.isActivated) {
161 throw new ControlLoopException("ControlLoopEventManager has already been activated.");
164 // Syntax check the event
166 checkEventSyntax(event);
169 // At this point we are good to go with this event
174 notification.setNotification(ControlLoopNotificationType.ACTIVE);
176 // Set ourselves as active
178 this.isActivated = true;
179 } catch (ControlLoopException e) {
180 logger.error("{}: activate by event threw: ", this, e);
181 notification.setNotification(ControlLoopNotificationType.REJECTED);
182 notification.setMessage(e.getMessage());
188 * Activate a control loop event.
190 * @param yamlSpecification the yaml specification
191 * @param event the event
192 * @return the VirtualControlLoopNotification
194 public VirtualControlLoopNotification activate(String yamlSpecification, VirtualControlLoopEvent event) {
195 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(event);
198 // This method should ONLY be called ONCE
200 if (this.isActivated) {
201 throw new ControlLoopException("ControlLoopEventManager has already been activated.");
204 // Syntax check the event
206 checkEventSyntax(event);
211 if (yamlSpecification == null || yamlSpecification.length() < 1) {
212 throw new ControlLoopException("yaml specification is null or 0 length");
214 } catch (ControlLoopException e) {
215 logger.error("{}: activate by YAML specification and event threw: ", this, e);
216 notification.setNotification(ControlLoopNotificationType.REJECTED);
217 notification.setMessage(e.getMessage());
221 String decodedYaml = null;
223 decodedYaml = URLDecoder.decode(yamlSpecification, "UTF-8");
224 if (decodedYaml != null && decodedYaml.length() > 0) {
225 yamlSpecification = decodedYaml;
227 } catch (UnsupportedEncodingException e) {
228 logger.error("{}: YAML decode in activate by YAML specification and event threw: ", this, e);
229 notification.setNotification(ControlLoopNotificationType.REJECTED);
230 notification.setMessage(e.getMessage());
236 // Parse the YAML specification
238 this.processor = new ControlLoopProcessor(yamlSpecification);
241 // At this point we are good to go with this event
248 notification.setNotification(ControlLoopNotificationType.ACTIVE);
250 // Set ourselves as active
252 this.isActivated = true;
253 } catch (ControlLoopException e) {
254 logger.error("{}: activate by YAML specification and event threw: ", this, e);
255 notification.setNotification(ControlLoopNotificationType.REJECTED);
256 notification.setMessage(e.getMessage());
262 * Check if the control loop is final.
264 * @return a VirtualControlLoopNotification if the control loop is final, otherwise
265 * <code>null</code> is returned
266 * @throws ControlLoopException if an error occurs
268 public VirtualControlLoopNotification isControlLoopFinal() throws ControlLoopException {
270 // Check if they activated us
272 if (!this.isActivated) {
273 throw new ControlLoopException("ControlLoopEventManager MUST be activated first.");
276 // Make sure we are expecting this call.
278 if (this.onset == null) {
279 throw new ControlLoopException("No onset event for ControlLoopEventManager.");
282 // Ok, start creating the notification
284 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(this.onset);
286 // Check if the overall control loop has timed out
288 if (this.isControlLoopTimedOut()) {
290 // Yes we have timed out
292 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
293 notification.setMessage("Control Loop timed out");
294 notification.getHistory().addAll(this.controlLoopHistory);
298 // Check if the current policy is Final
300 FinalResult result = this.processor.checkIsCurrentPolicyFinal();
301 if (result == null) {
303 // we are not at a final result
309 case FINAL_FAILURE_EXCEPTION:
310 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
311 notification.setMessage("Exception in processing closed loop");
314 case FINAL_FAILURE_RETRIES:
315 case FINAL_FAILURE_TIMEOUT:
316 case FINAL_FAILURE_GUARD:
317 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
320 notification.setNotification(ControlLoopNotificationType.FINAL_OPENLOOP);
323 notification.setNotification(ControlLoopNotificationType.FINAL_SUCCESS);
329 // Be sure to add all the history
331 notification.getHistory().addAll(this.controlLoopHistory);
336 * Process the control loop.
338 * @return a ControlLoopOperationManager
339 * @throws ControlLoopException if an error occurs
340 * @throws AaiException if an error occurs retrieving information from A&AI
342 public ControlLoopOperationManager processControlLoop() throws ControlLoopException, AaiException {
344 // Check if they activated us
346 if (!this.isActivated) {
347 throw new ControlLoopException("ControlLoopEventManager MUST be activated first.");
350 // Make sure we are expecting this call.
352 if (this.onset == null) {
353 throw new ControlLoopException("No onset event for ControlLoopEventManager.");
356 // Is there a current operation?
358 if (this.currentOperation != null) {
360 // Throw an exception, or simply return the current operation?
362 throw new ControlLoopException("Already working an Operation, do not call this method.");
365 // Ensure we are not FINAL
367 VirtualControlLoopNotification notification = this.isControlLoopFinal();
368 if (notification != null) {
370 // This is weird, we require them to call the isControlLoopFinal() method first
372 // We should really abstract this and avoid throwing an exception, because it really
373 // isn't an exception.
375 throw new ControlLoopException("Control Loop is in FINAL state, do not call this method.");
378 // Not final so get the policy that needs to be worked on.
380 Policy policy = this.processor.getCurrentPolicy();
381 if (policy == null) {
382 throw new ControlLoopException("ControlLoopEventManager: processor came upon null Policy.");
385 // And setup an operation
387 this.currentOperation = new ControlLoopOperationManager(this.onset, policy, this);
391 return this.currentOperation;
395 * Finish an operation.
397 * @param operation the operation
399 public void finishOperation(ControlLoopOperationManager operation) throws ControlLoopException {
401 // Verify we have a current operation
403 if (this.currentOperation != null) {
405 // Validate they are finishing the current operation
406 // PLD - this is simply comparing the policy. Do we want to equals the whole object?
408 if (this.currentOperation.policy.equals(operation.policy)) {
409 logger.debug("Finishing {} result is {}", this.currentOperation.policy.getRecipe(),
410 this.currentOperation.getOperationResult());
414 this.controlLoopHistory.addAll(this.currentOperation.getHistory());
416 // Move to the next Policy
418 this.processor.nextPolicyForResult(this.currentOperation.getOperationResult());
420 // Just null this out
422 this.currentOperation = null;
424 // TODO: Release our lock
428 logger.debug("Cannot finish current operation {} does not match given operation {}",
429 this.currentOperation.policy, operation.policy);
432 throw new ControlLoopException("No operation to finish.");
436 * Obtain a lock for the current operation.
438 * @return the lock result
439 * @throws ControlLoopException if an error occurs
441 public synchronized LockResult<GuardResult, TargetLock> lockCurrentOperation() throws ControlLoopException {
445 if (this.currentOperation == null) {
446 throw new ControlLoopException("Do not have a current operation.");
449 // Have we acquired it already?
451 if (this.targetLock != null) {
453 // TODO: Make sure the current lock is for the same target.
454 // Currently, it should be. But in the future it may not.
456 GuardResult result = PolicyGuard.lockTarget(targetLock,
457 this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
458 return new LockResult<>(result, this.targetLock);
463 LockResult<GuardResult, TargetLock> lockResult =
464 PolicyGuard.lockTarget(this.currentOperation.policy.getTarget().getType(),
465 this.currentOperation.getTargetEntity(), this.onset.getRequestId(), this,
466 this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
470 if (lockResult.getA().equals(GuardResult.LOCK_ACQUIRED)) {
472 // Yes, let's save it
474 this.targetLock = lockResult.getB();
481 * Release the lock for the current operation.
483 * @return the target lock
485 public synchronized TargetLock unlockCurrentOperation() {
486 if (this.targetLock == null) {
489 if (PolicyGuard.unlockTarget(this.targetLock)) {
490 TargetLock returnLock = this.targetLock;
491 this.targetLock = null;
497 public enum NEW_EVENT_STATUS {
498 FIRST_ONSET, SUBSEQUENT_ONSET, FIRST_ABATEMENT, SUBSEQUENT_ABATEMENT, SYNTAX_ERROR;
502 * An event onset/abatement.
504 * @param event the event
506 * @throws AaiException if an error occurs retrieving information from A&AI
508 public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) throws AaiException {
510 this.checkEventSyntax(event);
511 if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ONSET) {
513 // Check if this is our original ONSET
515 if (event.equals(this.onset)) {
517 // Query A&AI if needed
524 return NEW_EVENT_STATUS.FIRST_ONSET;
527 // Log that we got an onset
530 return NEW_EVENT_STATUS.SUBSEQUENT_ONSET;
531 } else if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) {
533 // Have we already got an abatement?
535 if (this.abatement == null) {
539 this.abatement = event;
541 // Keep track that we received another
543 this.numAbatements++;
547 return NEW_EVENT_STATUS.FIRST_ABATEMENT;
550 // Keep track that we received another
552 this.numAbatements++;
556 return NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT;
559 } catch (ControlLoopException e) {
560 logger.error("{}: onNewEvent threw: ", this, e);
562 return NEW_EVENT_STATUS.SYNTAX_ERROR;
566 * Set the control loop time out.
568 * @return a VirtualControlLoopNotification
570 public VirtualControlLoopNotification setControlLoopTimedOut() {
571 this.controlLoopTimedOut = FinalResult.FINAL_FAILURE_TIMEOUT;
572 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(this.onset);
573 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
574 notification.setMessage("Control Loop timed out");
575 notification.getHistory().addAll(this.controlLoopHistory);
579 public boolean isControlLoopTimedOut() {
580 return (this.controlLoopTimedOut == FinalResult.FINAL_FAILURE_TIMEOUT);
584 * Get the control loop timeout.
586 * @param defaultTimeout the default timeout
587 * @return the timeout
589 public int getControlLoopTimeout(Integer defaultTimeout) {
590 if (this.processor != null && this.processor.getControlLoop() != null) {
591 return this.processor.getControlLoop().getTimeout();
593 if (defaultTimeout != null) {
594 return defaultTimeout;
599 public AaiGetVnfResponse getVnfResponse() {
603 public AaiGetVserverResponse getVserverResponse() {
604 return vserverResponse;
608 * Check an event syntax.
610 * @param event the event syntax
611 * @throws ControlLoopException if an error occurs
613 public void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException {
614 if (event.getClosedLoopEventStatus() == null
615 || (event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET
616 && event.getClosedLoopEventStatus() != ControlLoopEventStatus.ABATED)) {
617 throw new ControlLoopException("Invalid value in closedLoopEventStatus");
619 if (event.getClosedLoopControlName() == null || event.getClosedLoopControlName().length() < 1) {
620 throw new ControlLoopException("No control loop name");
622 if (event.getRequestId() == null) {
623 throw new ControlLoopException("No request ID");
625 if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) {
628 if (event.getTarget() == null || event.getTarget().length() < 1) {
629 throw new ControlLoopException("No target field");
630 } else if (!VM_NAME.equalsIgnoreCase(event.getTarget()) && !VNF_NAME.equalsIgnoreCase(event.getTarget())
631 && !VSERVER_VSERVER_NAME.equalsIgnoreCase(event.getTarget())
632 && !GENERIC_VNF_VNF_ID.equalsIgnoreCase(event.getTarget())
633 && !GENERIC_VNF_VNF_NAME.equalsIgnoreCase(event.getTarget())) {
634 throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME");
636 if (event.getAai() == null) {
637 throw new ControlLoopException("AAI is null");
639 if (event.getAai().get(GENERIC_VNF_VNF_ID) == null && event.getAai().get(VSERVER_VSERVER_NAME) == null
640 && event.getAai().get(GENERIC_VNF_VNF_NAME) == null) {
641 throw new ControlLoopException(
642 "generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing");
647 * Query A&AI for an event.
649 * @param event the event
650 * @throws AaiException if an error occurs retrieving information from A&AI
652 public void queryAai(VirtualControlLoopEvent event) throws AaiException {
653 if (event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
654 || event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) {
656 if(isClosedLoopDisabled(event)) {
657 throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
660 // no need to query, as we already have the data
664 if(vnfResponse != null || vserverResponse != null) {
665 // query has already been performed
670 if (event.getAai().get(GENERIC_VNF_VNF_ID) != null || event.getAai().get(GENERIC_VNF_VNF_NAME) != null) {
671 vnfResponse = getAAIVnfInfo(event);
672 processVNFResponse(vnfResponse, event.getAai().get(GENERIC_VNF_VNF_ID) != null);
673 } else if (event.getAai().get(VSERVER_VSERVER_NAME) != null) {
674 vserverResponse = getAAIVserverInfo(event);
675 processVServerResponse(vserverResponse);
677 } catch (Exception e) {
678 logger.error("Exception from queryAai: ", e);
679 throw new AaiException("Exception from queryAai: " + e.toString());
684 * Process a response from A&AI for a VNF.
686 * @param aaiResponse the response from A&AI
687 * @param queryByVnfId <code>true</code> if the query was based on vnf-id, <code>false</code> if
688 * the query was based on vnf-name
689 * @throws AaiException if an error occurs processing the response
691 private static void processVNFResponse(AaiGetVnfResponse aaiResponse, boolean queryByVNFID) throws AaiException {
692 String queryTypeString = (queryByVNFID ? "vnf-id" : "vnf-name");
694 if (aaiResponse == null) {
695 throw new AaiException("AAI Response is null (query by " + queryTypeString + ")");
697 if (aaiResponse.getRequestError() != null) {
698 throw new AaiException("AAI Responded with a request error (query by " + queryTypeString + ")");
701 if (aaiResponse.getIsClosedLoopDisabled() != null) {
702 String value = aaiResponse.getIsClosedLoopDisabled();
703 if ("true".equalsIgnoreCase(value) || "T".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value)
704 || "Y".equalsIgnoreCase(value)) {
705 throw new AaiException("is-closed-loop-disabled is set to true (query by " + queryTypeString + ")");
710 private static void processVServerResponse(AaiGetVserverResponse aaiResponse) throws AaiException {
711 if (aaiResponse == null) {
712 throw new AaiException("AAI Response is null (query by vserver-name)");
714 if (aaiResponse.getRequestError() != null) {
715 throw new AaiException("AAI responded with a request error (query by vserver-name)");
718 if (aaiResponse.getIsClosedLoopDisabled() != null) {
719 String value = aaiResponse.getIsClosedLoopDisabled();
720 if ("true".equalsIgnoreCase(value) || "T".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value)
721 || "Y".equalsIgnoreCase(value)) {
722 throw new AaiException("is-closed-loop-disabled is set to true (query by vserver-name)");
728 * Is closed loop disabled for an event.
730 * @param event the event
731 * @return <code>true</code> if the contol loop is disabled, <code>false</code> otherwise
733 public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
734 if ("true".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
735 || "T".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
736 || "yes".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
737 || "Y".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))) {
740 return ("true".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
741 || "T".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
742 || "yes".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
743 || "Y".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
747 * Get the A&AI VService information for an event.
749 * @param event the event
750 * @return a AaiGetVserverResponse
751 * @throws ControlLoopException if an error occurs
753 public static AaiGetVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) throws ControlLoopException {
754 UUID requestId = event.getRequestId();
755 AaiGetVserverResponse response = null;
756 String vserverName = event.getAai().get(VSERVER_VSERVER_NAME);
759 if (vserverName != null) {
760 String aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
761 String aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
762 String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
763 String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
764 String url = aaiHostURL + aaiGetQueryByVserver;
765 logger.info("AAI Host URL by VServer: {}", url);
766 response = new AaiManager(new RESTManager()).getQueryByVserverName(url, aaiUser, aaiPassword, requestId,
769 } catch (Exception e) {
770 logger.error("getAAIVserverInfo exception: ", e);
771 throw new ControlLoopException("Exception in getAAIVserverInfo: ", e);
778 * Get A&AI VNF information for an event.
780 * @param event the event
781 * @return a AaiGetVnfResponse
782 * @throws ControlLoopException if an error occurs
784 public static AaiGetVnfResponse getAAIVnfInfo(VirtualControlLoopEvent event) throws ControlLoopException {
785 UUID requestId = event.getRequestId();
786 AaiGetVnfResponse response = null;
787 String vnfName = event.getAai().get(GENERIC_VNF_VNF_NAME);
788 String vnfId = event.getAai().get(GENERIC_VNF_VNF_ID);
790 String aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
791 String aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
792 String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
795 if (vnfName != null) {
796 String aaiGetQueryByVnfName = "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
797 String url = aaiHostURL + aaiGetQueryByVnfName;
798 logger.info("AAI Host URL by VNF name: {}", url);
799 response = new AaiManager(new RESTManager()).getQueryByVnfName(url, aaiUser, aaiPassword, requestId,
801 } else if (vnfId != null) {
802 String aaiGetQueryByVnfId = "/aai/v11/network/generic-vnfs/generic-vnf/";
803 String url = aaiHostURL + aaiGetQueryByVnfId;
804 logger.info("AAI Host URL by VNF ID: {}", url);
806 new AaiManager(new RESTManager()).getQueryByVnfId(url, aaiUser, aaiPassword, requestId, vnfId);
808 } catch (Exception e) {
809 logger.error("getAAIVnfInfo exception: ", e);
810 throw new ControlLoopException("Exception in getAAIVnfInfo: ", e);
817 public boolean isActive() {
823 public boolean releaseLock() {
829 public String toString() {
830 return "ControlLoopEventManager [closedLoopControlName=" + closedLoopControlName + ", requestID=" + requestID
831 + ", processor=" + processor + ", onset=" + (onset != null ? onset.getRequestId() : "null")
832 + ", numOnsets=" + numOnsets + ", numAbatements=" + numAbatements + ", isActivated=" + isActivated
833 + ", currentOperation=" + currentOperation + ", targetLock=" + targetLock + "]";