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.List;
30 import java.util.UUID;
32 import org.onap.policy.aai.AaiGetVnfResponse;
33 import org.onap.policy.aai.AaiGetVserverResponse;
34 import org.onap.policy.aai.AaiManager;
35 import org.onap.policy.aai.AaiNqVServer;
36 import org.onap.policy.aai.util.AaiException;
37 import org.onap.policy.controlloop.ControlLoopEventStatus;
38 import org.onap.policy.controlloop.ControlLoopException;
39 import org.onap.policy.controlloop.ControlLoopNotificationType;
40 import org.onap.policy.controlloop.ControlLoopOperation;
41 import org.onap.policy.controlloop.VirtualControlLoopEvent;
42 import org.onap.policy.controlloop.VirtualControlLoopNotification;
43 import org.onap.policy.controlloop.policy.FinalResult;
44 import org.onap.policy.controlloop.policy.Policy;
45 import org.onap.policy.controlloop.processor.ControlLoopProcessor;
46 import org.onap.policy.drools.system.PolicyEngine;
47 import org.onap.policy.guard.GuardResult;
48 import org.onap.policy.guard.LockCallback;
49 import org.onap.policy.guard.PolicyGuard;
50 import org.onap.policy.guard.PolicyGuard.LockResult;
51 import org.onap.policy.guard.TargetLock;
52 import org.onap.policy.rest.RESTManager;
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
56 public class ControlLoopEventManager implements LockCallback, Serializable {
57 private static final String VM_NAME = "VM_NAME";
58 private static final String VNF_NAME = "VNF_NAME";
59 private static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id";
60 private static final String GENERIC_VNF_VNF_NAME = "generic-vnf.vnf-name";
61 private static final String VSERVER_VSERVER_NAME = "vserver.vserver-name";
62 private static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled";
63 private static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled";
66 * Additional time, in seconds, to add to a "lock" request. This ensures that the lock
67 * won't expire right before an operation completes.
69 private static final int ADDITIONAL_LOCK_SEC = 60;
71 private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
73 private static final long serialVersionUID = -1216568161322872641L;
74 public final String closedLoopControlName;
75 public final UUID requestID;
77 private String controlLoopResult;
78 private transient ControlLoopProcessor processor = null;
79 private VirtualControlLoopEvent onset;
80 private Integer numOnsets = 0;
81 private Integer numAbatements = 0;
82 private VirtualControlLoopEvent abatement;
83 private FinalResult controlLoopTimedOut = null;
85 private boolean isActivated = false;
86 private LinkedList<ControlLoopOperation> controlLoopHistory = new LinkedList<>();
87 private ControlLoopOperationManager currentOperation = null;
88 private transient TargetLock targetLock = null;
89 private AaiGetVnfResponse vnfResponse = null;
90 private AaiGetVserverResponse vserverResponse = null;
92 private static Collection<String> requiredAAIKeys = new ArrayList<>();
95 requiredAAIKeys.add("AICVServerSelfLink");
96 requiredAAIKeys.add("AICIdentity");
97 requiredAAIKeys.add("is_closed_loop_disabled");
98 requiredAAIKeys.add(VM_NAME);
101 public ControlLoopEventManager(String closedLoopControlName, UUID requestID) {
102 this.closedLoopControlName = closedLoopControlName;
103 this.requestID = requestID;
106 public String getClosedLoopControlName() {
107 return closedLoopControlName;
110 public String getControlLoopResult() {
111 return controlLoopResult;
114 public void setControlLoopResult(String controlLoopResult) {
115 this.controlLoopResult = controlLoopResult;
118 public Integer getNumOnsets() {
122 public void setNumOnsets(Integer numOnsets) {
123 this.numOnsets = numOnsets;
126 public Integer getNumAbatements() {
127 return numAbatements;
130 public void setNumAbatements(Integer numAbatements) {
131 this.numAbatements = numAbatements;
134 public boolean isActivated() {
138 public void setActivated(boolean isActivated) {
139 this.isActivated = isActivated;
142 public VirtualControlLoopEvent getOnsetEvent() {
146 public VirtualControlLoopEvent getAbatementEvent() {
147 return this.abatement;
150 public ControlLoopProcessor getProcessor() {
151 return this.processor;
154 public UUID getRequestID() {
159 * Activate a control loop event.
161 * @param event the event
162 * @return the VirtualControlLoopNotification
164 public VirtualControlLoopNotification activate(VirtualControlLoopEvent event) {
165 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(event);
168 // This method should ONLY be called ONCE
170 if (this.isActivated) {
171 throw new ControlLoopException("ControlLoopEventManager has already been activated.");
174 // Syntax check the event
176 checkEventSyntax(event);
179 // At this point we are good to go with this event
184 notification.setNotification(ControlLoopNotificationType.ACTIVE);
186 // Set ourselves as active
188 this.isActivated = true;
189 } catch (ControlLoopException e) {
190 logger.error("{}: activate by event threw: ", this, e);
191 notification.setNotification(ControlLoopNotificationType.REJECTED);
192 notification.setMessage(e.getMessage());
198 * Activate a control loop event.
200 * @param yamlSpecification the yaml specification
201 * @param event the event
202 * @return the VirtualControlLoopNotification
204 public VirtualControlLoopNotification activate(String yamlSpecification, VirtualControlLoopEvent event) {
205 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(event);
208 // This method should ONLY be called ONCE
210 if (this.isActivated) {
211 throw new ControlLoopException("ControlLoopEventManager has already been activated.");
214 // Syntax check the event
216 checkEventSyntax(event);
221 if (yamlSpecification == null || yamlSpecification.length() < 1) {
222 throw new ControlLoopException("yaml specification is null or 0 length");
224 } catch (ControlLoopException e) {
225 logger.error("{}: activate by YAML specification and event threw: ", this, e);
226 notification.setNotification(ControlLoopNotificationType.REJECTED);
227 notification.setMessage(e.getMessage());
231 String decodedYaml = null;
233 decodedYaml = URLDecoder.decode(yamlSpecification, "UTF-8");
234 if (decodedYaml != null && decodedYaml.length() > 0) {
235 yamlSpecification = decodedYaml;
237 } catch (UnsupportedEncodingException e) {
238 logger.error("{}: YAML decode in activate by YAML specification and event threw: ", this, e);
239 notification.setNotification(ControlLoopNotificationType.REJECTED);
240 notification.setMessage(e.getMessage());
246 // Parse the YAML specification
248 this.processor = new ControlLoopProcessor(yamlSpecification);
251 // At this point we are good to go with this event
258 notification.setNotification(ControlLoopNotificationType.ACTIVE);
260 // Set ourselves as active
262 this.isActivated = true;
263 } catch (ControlLoopException e) {
264 logger.error("{}: activate by YAML specification and event threw: ", this, e);
265 notification.setNotification(ControlLoopNotificationType.REJECTED);
266 notification.setMessage(e.getMessage());
272 * Check if the control loop is final.
274 * @return a VirtualControlLoopNotification if the control loop is final, otherwise
275 * <code>null</code> is returned
276 * @throws ControlLoopException if an error occurs
278 public VirtualControlLoopNotification isControlLoopFinal() throws ControlLoopException {
280 // Check if they activated us
282 if (!this.isActivated) {
283 throw new ControlLoopException("ControlLoopEventManager MUST be activated first.");
286 // Make sure we are expecting this call.
288 if (this.onset == null) {
289 throw new ControlLoopException("No onset event for ControlLoopEventManager.");
292 // Ok, start creating the notification
294 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(this.onset);
296 // Check if the overall control loop has timed out
298 if (this.isControlLoopTimedOut()) {
300 // Yes we have timed out
302 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
303 notification.setMessage("Control Loop timed out");
304 notification.getHistory().addAll(this.controlLoopHistory);
308 // Check if the current policy is Final
310 FinalResult result = this.processor.checkIsCurrentPolicyFinal();
311 if (result == null) {
313 // we are not at a final result
319 case FINAL_FAILURE_EXCEPTION:
320 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
321 notification.setMessage("Exception in processing closed loop");
324 case FINAL_FAILURE_RETRIES:
325 case FINAL_FAILURE_TIMEOUT:
326 case FINAL_FAILURE_GUARD:
327 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
330 notification.setNotification(ControlLoopNotificationType.FINAL_OPENLOOP);
333 notification.setNotification(ControlLoopNotificationType.FINAL_SUCCESS);
339 // Be sure to add all the history
341 notification.getHistory().addAll(this.controlLoopHistory);
346 * Process the control loop.
348 * @return a ControlLoopOperationManager
349 * @throws ControlLoopException if an error occurs
350 * @throws AaiException if an error occurs retrieving information from A&AI
352 public ControlLoopOperationManager processControlLoop() throws ControlLoopException, AaiException {
354 // Check if they activated us
356 if (!this.isActivated) {
357 throw new ControlLoopException("ControlLoopEventManager MUST be activated first.");
360 // Make sure we are expecting this call.
362 if (this.onset == null) {
363 throw new ControlLoopException("No onset event for ControlLoopEventManager.");
366 // Is there a current operation?
368 if (this.currentOperation != null) {
370 // Throw an exception, or simply return the current operation?
372 throw new ControlLoopException("Already working an Operation, do not call this method.");
375 // Ensure we are not FINAL
377 VirtualControlLoopNotification notification = this.isControlLoopFinal();
378 if (notification != null) {
380 // This is weird, we require them to call the isControlLoopFinal() method first
382 // We should really abstract this and avoid throwing an exception, because it really
383 // isn't an exception.
385 throw new ControlLoopException("Control Loop is in FINAL state, do not call this method.");
388 // Not final so get the policy that needs to be worked on.
390 Policy policy = this.processor.getCurrentPolicy();
391 if (policy == null) {
392 throw new ControlLoopException("ControlLoopEventManager: processor came upon null Policy.");
395 // And setup an operation
397 this.currentOperation = new ControlLoopOperationManager(this.onset, policy, this);
401 return this.currentOperation;
405 * Finish an operation.
407 * @param operation the operation
409 public void finishOperation(ControlLoopOperationManager operation) throws ControlLoopException {
411 // Verify we have a current operation
413 if (this.currentOperation != null) {
415 // Validate they are finishing the current operation
416 // PLD - this is simply comparing the policy. Do we want to equals the whole object?
418 if (this.currentOperation.policy.equals(operation.policy)) {
419 logger.debug("Finishing {} result is {}", this.currentOperation.policy.getRecipe(),
420 this.currentOperation.getOperationResult());
424 this.controlLoopHistory.addAll(this.currentOperation.getHistory());
426 // Move to the next Policy
428 this.processor.nextPolicyForResult(this.currentOperation.getOperationResult());
430 // Just null this out
432 this.currentOperation = null;
434 // TODO: Release our lock
438 logger.debug("Cannot finish current operation {} does not match given operation {}",
439 this.currentOperation.policy, operation.policy);
442 throw new ControlLoopException("No operation to finish.");
446 * Obtain a lock for the current operation.
448 * @return the lock result
449 * @throws ControlLoopException if an error occurs
451 public synchronized LockResult<GuardResult, TargetLock> lockCurrentOperation() throws ControlLoopException {
455 if (this.currentOperation == null) {
456 throw new ControlLoopException("Do not have a current operation.");
459 // Have we acquired it already?
461 if (this.targetLock != null) {
463 // TODO: Make sure the current lock is for the same target.
464 // Currently, it should be. But in the future it may not.
466 GuardResult result = PolicyGuard.lockTarget(targetLock,
467 this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
468 return new LockResult<>(result, this.targetLock);
473 LockResult<GuardResult, TargetLock> lockResult =
474 PolicyGuard.lockTarget(this.currentOperation.policy.getTarget().getType(),
475 this.currentOperation.getTargetEntity(), this.onset.getRequestId(), this,
476 this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
480 if (lockResult.getA().equals(GuardResult.LOCK_ACQUIRED)) {
482 // Yes, let's save it
484 this.targetLock = lockResult.getB();
491 * Release the lock for the current operation.
493 * @return the target lock
495 public synchronized TargetLock unlockCurrentOperation() {
496 if (this.targetLock == null) {
500 TargetLock returnLock = this.targetLock;
501 this.targetLock = null;
503 PolicyGuard.unlockTarget(returnLock);
505 // always return the old target lock so rules can retract it
509 public enum NEW_EVENT_STATUS {
510 FIRST_ONSET, SUBSEQUENT_ONSET, FIRST_ABATEMENT, SUBSEQUENT_ABATEMENT, SYNTAX_ERROR;
514 * An event onset/abatement.
516 * @param event the event
518 * @throws AaiException if an error occurs retrieving information from A&AI
520 public NEW_EVENT_STATUS onNewEvent(VirtualControlLoopEvent event) throws AaiException {
522 this.checkEventSyntax(event);
523 if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ONSET) {
525 // Check if this is our original ONSET
527 if (event.equals(this.onset)) {
529 // Query A&AI if needed
536 return NEW_EVENT_STATUS.FIRST_ONSET;
539 // Log that we got an onset
542 return NEW_EVENT_STATUS.SUBSEQUENT_ONSET;
543 } else if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) {
545 // Have we already got an abatement?
547 if (this.abatement == null) {
551 this.abatement = event;
553 // Keep track that we received another
555 this.numAbatements++;
559 return NEW_EVENT_STATUS.FIRST_ABATEMENT;
562 // Keep track that we received another
564 this.numAbatements++;
568 return NEW_EVENT_STATUS.SUBSEQUENT_ABATEMENT;
571 } catch (ControlLoopException e) {
572 logger.error("{}: onNewEvent threw: ", this, e);
574 return NEW_EVENT_STATUS.SYNTAX_ERROR;
578 * Set the control loop time out.
580 * @return a VirtualControlLoopNotification
582 public VirtualControlLoopNotification setControlLoopTimedOut() {
583 this.controlLoopTimedOut = FinalResult.FINAL_FAILURE_TIMEOUT;
584 VirtualControlLoopNotification notification = new VirtualControlLoopNotification(this.onset);
585 notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
586 notification.setMessage("Control Loop timed out");
587 notification.getHistory().addAll(this.controlLoopHistory);
591 public boolean isControlLoopTimedOut() {
592 return (this.controlLoopTimedOut == FinalResult.FINAL_FAILURE_TIMEOUT);
596 * Get the control loop timeout.
598 * @param defaultTimeout the default timeout
599 * @return the timeout
601 public int getControlLoopTimeout(Integer defaultTimeout) {
602 if (this.processor != null && this.processor.getControlLoop() != null) {
603 return this.processor.getControlLoop().getTimeout();
605 if (defaultTimeout != null) {
606 return defaultTimeout;
611 public AaiGetVnfResponse getVnfResponse() {
615 public AaiGetVserverResponse getVserverResponse() {
616 return vserverResponse;
620 * Check an event syntax.
622 * @param event the event syntax
623 * @throws ControlLoopException if an error occurs
625 public void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException {
626 if (event.getClosedLoopEventStatus() == null
627 || (event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET
628 && event.getClosedLoopEventStatus() != ControlLoopEventStatus.ABATED)) {
629 throw new ControlLoopException("Invalid value in closedLoopEventStatus");
631 if (event.getClosedLoopControlName() == null || event.getClosedLoopControlName().length() < 1) {
632 throw new ControlLoopException("No control loop name");
634 if (event.getRequestId() == null) {
635 throw new ControlLoopException("No request ID");
637 if (event.getClosedLoopEventStatus() == ControlLoopEventStatus.ABATED) {
640 if (event.getTarget() == null || event.getTarget().length() < 1) {
641 throw new ControlLoopException("No target field");
642 } else if (!VM_NAME.equalsIgnoreCase(event.getTarget()) && !VNF_NAME.equalsIgnoreCase(event.getTarget())
643 && !VSERVER_VSERVER_NAME.equalsIgnoreCase(event.getTarget())
644 && !GENERIC_VNF_VNF_ID.equalsIgnoreCase(event.getTarget())
645 && !GENERIC_VNF_VNF_NAME.equalsIgnoreCase(event.getTarget())) {
646 throw new ControlLoopException("target field invalid - expecting VM_NAME or VNF_NAME");
648 if (event.getAai() == null) {
649 throw new ControlLoopException("AAI is null");
651 if (event.getAai().get(GENERIC_VNF_VNF_ID) == null && event.getAai().get(VSERVER_VSERVER_NAME) == null
652 && event.getAai().get(GENERIC_VNF_VNF_NAME) == null) {
653 throw new ControlLoopException(
654 "generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing");
659 * Query A&AI for an event.
661 * @param event the event
662 * @throws AaiException if an error occurs retrieving information from A&AI
664 public void queryAai(VirtualControlLoopEvent event) throws AaiException {
665 if (event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
666 || event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) {
668 if (isClosedLoopDisabled(event)) {
669 throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
672 // no need to query, as we already have the data
676 if (vnfResponse != null || vserverResponse != null) {
677 // query has already been performed
682 if (event.getAai().get(GENERIC_VNF_VNF_ID) != null || event.getAai().get(GENERIC_VNF_VNF_NAME) != null) {
683 vnfResponse = getAAIVnfInfo(event);
684 processVNFResponse(vnfResponse, event.getAai().get(GENERIC_VNF_VNF_ID) != null);
685 } else if (event.getAai().get(VSERVER_VSERVER_NAME) != null) {
686 vserverResponse = getAAIVserverInfo(event);
687 processVServerResponse(vserverResponse);
689 } catch (Exception e) {
690 logger.error("Exception from queryAai: ", e);
691 throw new AaiException("Exception from queryAai: " + e.toString());
696 * Process a response from A&AI for a VNF.
698 * @param aaiResponse the response from A&AI
699 * @param queryByVnfId <code>true</code> if the query was based on vnf-id, <code>false</code> if
700 * the query was based on vnf-name
701 * @throws AaiException if an error occurs processing the response
703 private static void processVNFResponse(AaiGetVnfResponse aaiResponse, boolean queryByVNFID) throws AaiException {
704 String queryTypeString = (queryByVNFID ? "vnf-id" : "vnf-name");
706 if (aaiResponse == null) {
707 throw new AaiException("AAI Response is null (query by " + queryTypeString + ")");
709 if (aaiResponse.getRequestError() != null) {
710 throw new AaiException("AAI Responded with a request error (query by " + queryTypeString + ")");
713 if (aaiResponse.getIsClosedLoopDisabled()) {
714 throw new AaiException("is-closed-loop-disabled is set to true (query by " + queryTypeString + ")");
718 private static void processVServerResponse(AaiGetVserverResponse aaiResponse) throws AaiException {
719 if (aaiResponse == null) {
720 throw new AaiException("AAI Response is null (query by vserver-name)");
722 if (aaiResponse.getRequestError() != null) {
723 throw new AaiException("AAI responded with a request error (query by vserver-name)");
726 List<AaiNqVServer> lst = aaiResponse.getVserver();
731 AaiNqVServer svr = lst.get(0);
732 if (svr.getIsClosedLoopDisabled()) {
733 throw new AaiException("is-closed-loop-disabled is set to true (query by vserver-name)");
738 * Is closed loop disabled for an event.
740 * @param event the event
741 * @return <code>true</code> if the contol loop is disabled, <code>false</code> otherwise
743 public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
744 if ("true".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
745 || "T".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
746 || "yes".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))
747 || "Y".equalsIgnoreCase(event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED))) {
750 return ("true".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
751 || "T".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
752 || "yes".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
753 || "Y".equalsIgnoreCase(event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)));
757 * Get the A&AI VService information for an event.
759 * @param event the event
760 * @return a AaiGetVserverResponse
761 * @throws ControlLoopException if an error occurs
763 public static AaiGetVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) throws ControlLoopException {
764 UUID requestId = event.getRequestId();
765 AaiGetVserverResponse response = null;
766 String vserverName = event.getAai().get(VSERVER_VSERVER_NAME);
769 if (vserverName != null) {
770 String aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
771 String aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
772 String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
773 String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
774 String url = aaiHostURL + aaiGetQueryByVserver;
775 logger.info("AAI Host URL by VServer: {}", url);
776 response = new AaiManager(new RESTManager()).getQueryByVserverName(url, aaiUser, aaiPassword, requestId,
779 } catch (Exception e) {
780 logger.error("getAAIVserverInfo exception: ", e);
781 throw new ControlLoopException("Exception in getAAIVserverInfo: ", e);
788 * Get A&AI VNF information for an event.
790 * @param event the event
791 * @return a AaiGetVnfResponse
792 * @throws ControlLoopException if an error occurs
794 public static AaiGetVnfResponse getAAIVnfInfo(VirtualControlLoopEvent event) throws ControlLoopException {
795 UUID requestId = event.getRequestId();
796 AaiGetVnfResponse response = null;
797 String vnfName = event.getAai().get(GENERIC_VNF_VNF_NAME);
798 String vnfId = event.getAai().get(GENERIC_VNF_VNF_ID);
800 String aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
801 String aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
802 String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
805 if (vnfName != null) {
806 String aaiGetQueryByVnfName = "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
807 String url = aaiHostURL + aaiGetQueryByVnfName;
808 logger.info("AAI Host URL by VNF name: {}", url);
809 response = new AaiManager(new RESTManager()).getQueryByVnfName(url, aaiUser, aaiPassword, requestId,
811 } else if (vnfId != null) {
812 String aaiGetQueryByVnfId = "/aai/v11/network/generic-vnfs/generic-vnf/";
813 String url = aaiHostURL + aaiGetQueryByVnfId;
814 logger.info("AAI Host URL by VNF ID: {}", url);
816 new AaiManager(new RESTManager()).getQueryByVnfId(url, aaiUser, aaiPassword, requestId, vnfId);
818 } catch (Exception e) {
819 logger.error("getAAIVnfInfo exception: ", e);
820 throw new ControlLoopException("Exception in getAAIVnfInfo: ", e);
827 public boolean isActive() {
833 public boolean releaseLock() {
839 public String toString() {
840 return "ControlLoopEventManager [closedLoopControlName=" + closedLoopControlName + ", requestID=" + requestID
841 + ", processor=" + processor + ", onset=" + (onset != null ? onset.getRequestId() : "null")
842 + ", numOnsets=" + numOnsets + ", numAbatements=" + numAbatements + ", isActivated=" + isActivated
843 + ", currentOperation=" + currentOperation + ", targetLock=" + targetLock + "]";