Add VnfInPlaceSoftwareUpdate for WFD
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / orchestration / AAIVnfResources.java
index a9a52bd..48a1c1e 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -20,6 +22,7 @@
 
 package org.onap.so.client.orchestration;
 
+import java.io.IOException;
 import java.util.Optional;
 
 import org.onap.so.bpmn.common.InjectionHelper;
@@ -27,21 +30,21 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
 import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIValidatorImpl;
 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
 import org.onap.so.client.aai.mapper.AAIObjectMapper;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
 public class AAIVnfResources {
-       private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIVnfResources.class);
+       private static final Logger logger = LoggerFactory.getLogger(AAIVnfResources.class);
        
        @Autowired
        private InjectionHelper injectionHelper;
@@ -49,6 +52,8 @@ public class AAIVnfResources {
        @Autowired
        private AAIObjectMapper aaiObjectMapper;
        
+       private AAIValidatorImpl aaiValidatorImpl= new AAIValidatorImpl();
+       
        public void createVnfandConnectServiceInstance(GenericVnf vnf, ServiceInstance serviceInstance) {
                AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
                vnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
@@ -124,4 +129,19 @@ public class AAIVnfResources {
                AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
                injectionHelper.getAaiClient().connect(tenantURI, vnfURI);
        }
+       
+       public boolean checkVnfClosedLoopDisabledFlag(String vnfId) {           
+               org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
+                               .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+                               .orElse(new org.onap.aai.domain.yang.GenericVnf());
+               return vnf.isIsClosedLoopDisabled();
+       }
+       
+       public boolean checkVnfPserversLockedFlag (String vnfId) throws IOException {           
+               org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient()
+                               .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
+                               .orElse(new org.onap.aai.domain.yang.GenericVnf());
+                       return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId());
+
+       }
 }