fix catalogdb cvfnc customization
[so.git] / asdc-controller / src / main / java / org / onap / so / asdc / installer / heat / ToscaResourceInstaller.java
index ebc705c..e283fb2 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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
@@ -39,7 +41,10 @@ import org.hibernate.exception.LockAcquisitionException;
 import org.onap.sdc.api.notification.IArtifactInfo;
 import org.onap.sdc.api.notification.IResourceInstance;
 import org.onap.sdc.api.notification.IStatusData;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
 import org.onap.sdc.tosca.parser.enums.SdcTypes;
 import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -51,6 +56,7 @@ import org.onap.sdc.toscaparser.api.Property;
 import org.onap.sdc.toscaparser.api.RequirementAssignment;
 import org.onap.sdc.toscaparser.api.RequirementAssignments;
 import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.elements.StatefulEntityType;
 import org.onap.sdc.toscaparser.api.functions.GetInput;
 import org.onap.sdc.toscaparser.api.parameters.Input;
 import org.onap.sdc.utils.DistributionStatusEnum;
@@ -59,6 +65,8 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
 import org.onap.so.asdc.installer.ASDCElementInfo;
 import org.onap.so.asdc.installer.BigDecimalVersion;
 import org.onap.so.asdc.installer.IVfModuleData;
+import org.onap.so.asdc.installer.PnfResourceStructure;
+import org.onap.so.asdc.installer.ResourceStructure;
 import org.onap.so.asdc.installer.ToscaResourceStructure;
 import org.onap.so.asdc.installer.VfModuleArtifact;
 import org.onap.so.asdc.installer.VfModuleStructure;
@@ -71,6 +79,7 @@ import org.onap.so.db.catalog.beans.CollectionResource;
 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
 import org.onap.so.db.catalog.beans.ConfigurationResource;
 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
+import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.beans.CvnfcCustomization;
 import org.onap.so.db.catalog.beans.HeatEnvironment;
 import org.onap.so.db.catalog.beans.HeatFiles;
@@ -81,6 +90,8 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkResource;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.Service;
 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
 import org.onap.so.db.catalog.beans.SubType;
@@ -91,7 +102,6 @@ import org.onap.so.db.catalog.beans.VfModule;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResource;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.beans.VnfcCustomization;
 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
@@ -106,6 +116,8 @@ import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
 import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
 import org.onap.so.db.catalog.data.repository.ServiceRepository;
 import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
@@ -121,9 +133,12 @@ import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
 import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
+import org.onap.so.logger.ErrorCode;
 import org.onap.so.logger.MessageEnum;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.orm.ObjectOptimisticLockingFailureException;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -133,6 +148,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 @Component
 public class ToscaResourceInstaller {
 
+       protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
+
+       protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
+
        protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
 
        protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
@@ -149,6 +168,12 @@ public class ToscaResourceInstaller {
 
        protected static final String MSO = "SO";
 
+       protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
+
+       protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
+
+       private static String CUSTOMIZATION_UUID = "customizationUUID";
+
 
        @Autowired
        protected ServiceRepository serviceRepo;
@@ -173,9 +198,6 @@ public class ToscaResourceInstaller {
 
        @Autowired
        protected VnfResourceRepository vnfRepo;
-
-       @Autowired
-       protected VnfCustomizationRepository vnfCustomizationRepo;
        
        @Autowired
        protected VFModuleRepository vfModuleRepo;
@@ -220,15 +242,21 @@ public class ToscaResourceInstaller {
        @Autowired
        protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
        
-       protected static final MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC,ToscaResourceInstaller.class);
+       @Autowired
+       protected PnfResourceRepository pnfResourceRepository;
+
+       @Autowired
+       protected PnfCustomizationRepository pnfCustomizationRepository;
+
+       protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
 
        public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
                boolean status = false;
                VfResourceStructure vfResourceStructure = vfResourceStruct;
                try {
-                   status = vfResourceStructure.isDeployedSuccessfully();
+                       status = vfResourceStructure.isDeployedSuccessfully();
                } catch (RuntimeException e) {
-                   status = false;
+                       status = false;
                }
                try {                                   
                        Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID()); 
@@ -256,15 +284,16 @@ public class ToscaResourceInstaller {
                        }
                        return status;
                } catch (Exception e) {
-                       logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError,
+                       logger
+                               .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
                                        "Exception - isResourceAlreadyDeployed");
                        throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
                }
        }
 
        public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
-               logger.debug("Entering installTheComponentStatus for distributionId " + iStatus.getDistributionID()
-                               + " and ComponentName " + iStatus.getComponentName());
+               logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
+                       iStatus.getDistributionID(), iStatus.getComponentName());
 
                try {
                        WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
@@ -273,13 +302,79 @@ public class ToscaResourceInstaller {
                        watchdogCDStatusRepository.save(cdStatus);
 
                } catch (Exception e) {
-                       logger.debug("Exception caught in installTheComponentStatus " + e.getMessage());
+                       logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
                        throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
                }
        }
 
+       @Transactional(rollbackFor = {ArtifactInstallerException.class})
+       public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
+               throws ArtifactInstallerException {
+               if (resourceStruct instanceof VfResourceStructure) {
+                       installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
+               } else if (resourceStruct instanceof PnfResourceStructure) {
+                       installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
+               } else {
+                       logger.warn("Unrecognized resource type");
+               }
+       }
+
+       private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
+               throws ArtifactInstallerException {
+
+               // PCLO: in case of deployment failure, use a string that will represent
+               // the type of artifact that failed...
+               List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+               try {
+                       createToscaCsar(toscaResourceStruct);
+                       Service service = createService(toscaResourceStruct, resourceStruct);
+
+                       processResourceSequence(toscaResourceStruct, service);
+                       processPnfResources(toscaResourceStruct, service, resourceStruct);
+                       serviceRepo.save(service);
+
+                       WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+                               resourceStruct.getNotification().getDistributionID(), MSO);
+                       status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+                       watchdogCDStatusRepository.save(status);
+
+                       toscaResourceStruct.setSuccessfulDeployment();
+
+               } catch (Exception e) {
+                       logger.debug("Exception :", e);
+                       WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+                               resourceStruct.getNotification().getDistributionID(), MSO);
+                       status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+                       watchdogCDStatusRepository.save(status);
+                       Throwable dbExceptionToCapture = e;
+                       while (!(dbExceptionToCapture instanceof ConstraintViolationException
+                               || dbExceptionToCapture instanceof LockAcquisitionException)
+                               && (dbExceptionToCapture.getCause() != null)) {
+                               dbExceptionToCapture = dbExceptionToCapture.getCause();
+                       }
+
+                       if (dbExceptionToCapture instanceof ConstraintViolationException
+                               || dbExceptionToCapture instanceof LockAcquisitionException) {
+                               logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+                                       resourceStruct.getResourceInstance().getResourceName(),
+                                       resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+                                       "Exception - ASCDC Artifact already deployed", e);
+                       } else {
+                               String elementToLog = (!artifactListForLogging.isEmpty()
+                                       ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+                                       : "No element listed");
+                               logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+                                       ErrorCode.DataError.getValue(),
+                                       "Exception caught during installation of " + resourceStruct.getResourceInstance()
+                                               .getResourceName()
+                                               + ". Transaction rollback", e);
+                               throw new ArtifactInstallerException("Exception caught during installation of "
+                                       + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+                       }
+               }
+       }
        @Transactional(rollbackFor = { ArtifactInstallerException.class })
-       public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
+       public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
                        throws ArtifactInstallerException {             
                VfResourceStructure vfResourceStructure = vfResourceStruct;
                extractHeatInformation(toscaResourceStruct, vfResourceStructure);       
@@ -289,8 +384,7 @@ public class ToscaResourceInstaller {
                List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
                try {
                        createToscaCsar(toscaResourceStruct);                   
-                       createService(toscaResourceStruct, vfResourceStruct);                   
-                       Service service = toscaResourceStruct.getCatalogService();                              
+                       Service service = createService(toscaResourceStruct, vfResourceStruct);
                        List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
                        
                
@@ -336,18 +430,18 @@ public class ToscaResourceInstaller {
 
                        if (dbExceptionToCapture instanceof ConstraintViolationException
                                        || dbExceptionToCapture instanceof LockAcquisitionException) {
-                               logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED,
-                                               vfResourceStructure.getResourceInstance().getResourceName(),
-                                               vfResourceStructure.getNotification().getServiceVersion(), "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e);
+                               logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+                                       vfResourceStructure.getResourceInstance().getResourceName(),
+                                       vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+                                       "Exception - ASCDC Artifact already deployed", e);
                        } else {
                                String elementToLog = (!artifactListForLogging.isEmpty()
                                                ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
                                                : "No element listed");
-                               logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError,
-                                               "Exception caught during installation of "
-                                                               + vfResourceStructure.getResourceInstance().getResourceName()
-                                                               + ". Transaction rollback",
-                                               e);
+                               logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+                                       ErrorCode.DataError.getValue(),
+                                       "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
+                                               + ". Transaction rollback", e);
                                throw new ArtifactInstallerException("Exception caught during installation of "
                                                + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
                        }
@@ -420,8 +514,6 @@ public class ToscaResourceInstaller {
                logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
        }
 
-       private static String CUSTOMIZATION_UUID = "customizationUUID";
-
        private static String getValue(Object value, List<Input> servInputs) {
                String output = null;
                if(value instanceof Map) {
@@ -478,42 +570,42 @@ public class ToscaResourceInstaller {
                }
        }
 
-    protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
-                                    Service service) throws ArtifactInstallerException {
-        List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
+       protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
+                                                                       Service service) throws ArtifactInstallerException {
+               List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
 
                if (nodeTemplatesVLList != null) {
                        for (NodeTemplate vlNode : nodeTemplatesVLList) {
-                String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
-
-                TempNetworkHeatTemplateLookup tempNetworkLookUp =
-                                                                tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
-
-                if (tempNetworkLookUp != null) {
-                    HeatTemplate heatTemplate =
-                                              heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
-                    if (heatTemplate != null) {
-                        NetworkResourceCustomization networkCustomization =
-                                                                          createNetwork (vlNode,
-                                                                                         toscaResourceStruct,
-                                                                                         heatTemplate,
-                                                                                         tempNetworkLookUp.getAicVersionMax (),
-                                                                                         tempNetworkLookUp.getAicVersionMin (),
-                                                                                         service);
-                        service.getNetworkCustomizations ().add (networkCustomization);
-                    } else {
-                        throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
-                                                              + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+                               String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
+
+                               TempNetworkHeatTemplateLookup tempNetworkLookUp =
+                                                                                                                               tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
+
+                               if (tempNetworkLookUp != null) {
+                                       HeatTemplate heatTemplate =
+                                                                                         heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
+                                       if (heatTemplate != null) {
+                                               NetworkResourceCustomization networkCustomization =
+                                                                                                                                                 createNetwork (vlNode,
+                                                                                                                                                                                toscaResourceStruct,
+                                                                                                                                                                                heatTemplate,
+                                                                                                                                                                                tempNetworkLookUp.getAicVersionMax (),
+                                                                                                                                                                                tempNetworkLookUp.getAicVersionMin (),
+                                                                                                                                                                                service);
+                                               service.getNetworkCustomizations ().add (networkCustomization);
+                                       } else {
+                                               throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
+                                                                                                                         + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
                                        }
                                } else {
-                    NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
-                                                                                       toscaResourceStruct,
-                                                                                       null,
-                                                                                       null,
-                                                                                       null,
-                                                                                       service);
-                    service.getNetworkCustomizations().add (networkCustomization);
-                    logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+                                       NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
+                                                                                                                                                                          toscaResourceStruct,
+                                                                                                                                                                          null,
+                                                                                                                                                                          null,
+                                                                                                                                                                          null,
+                                                                                                                                                                          service);
+                                       service.getNetworkCustomizations().add (networkCustomization);
+                                       logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
                                                                        + networkResourceModelName);
                                }                                       
                                
@@ -530,6 +622,62 @@ public class ToscaResourceInstaller {
                        }
                }
        }
+       
+       
+       protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
+               Metadata metadata = nodeTemplate.getMetaData();
+               ConfigurationResource configResource = new ConfigurationResource();
+               configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+               configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+               configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+               configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+               configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+               configResource.setToscaNodeType(nodeTemplate.getType());
+               return configResource;
+       }
+       
+       protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, 
+                       ServiceProxyResourceCustomization spResourceCustomization ) {
+               Metadata metadata = nodeTemplate.getMetaData();
+               
+               ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+               
+               ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+               
+               Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+               
+               configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+               configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+               
+               configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+               configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+               configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+               configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
+       
+               configCustomizationResource.setConfigurationResource(configResource);
+               configResourceCustomizationSet.add(configCustomizationResource);
+
+               configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);   
+               return configCustomizationResource;
+       }
+       
+       
+       protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(List<NodeTemplate> configurationNodeTemplatesList,  
+                       ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
+               Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
+               for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
+                       StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+                       String type = entityType.getType();
+                       
+                       if(VLAN_NETWORK_RECEPTOR.equals(type)) {
+                               configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate, 
+                                               toscaResourceStructure,spResourceCustomization));
+                               break;
+                       }
+               }
+               
+               return configurationResourceCust;
+       }
                
        protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
                
@@ -544,18 +692,24 @@ public class ToscaResourceInstaller {
                
                if (serviceProxyResourceList != null) {
                        for (NodeTemplate spNode : serviceProxyResourceList) {
-                               serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
-                                                               
+                               serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);                                                                
                                serviceProxyList.add(serviceProxy);
-
+                               Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy);
+                               
                                for (NodeTemplate configNode : configurationNodeTemplatesList) {
                                                                                
                                                List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
                                                for (RequirementAssignment requirement :  requirementsList) {
                                                        if (requirement.getNodeTemplateName().equals(spNode.getName())) {
-                                                               ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy);
-                                                                                                                               
-                                                               configurationResourceList.add(configurationResource);
+                                                               ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
+                                                               
+                                                               Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
+                                                                               .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
+                                                                               .findFirst();
+                                                               if(!matchingObject.isPresent()){                                                                                                                                        
+                                                                       configurationResourceList.add(configurationResource);
+                                                               }
+                                                               
                                                                break;
                                                        }
                                                }
@@ -632,6 +786,123 @@ public class ToscaResourceInstaller {
                }
        }
        
+       /**
+        * This is used to process the PNF specific resource, including resource and resource_customization. {@link
+        * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
+        */
+       protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
+               PnfResourceStructure resourceStructure) throws Exception {
+               logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
+
+               ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
+               EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
+               TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+
+               List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+               for (IEntityDetails entityDetails : entityDetailsList) {
+                       Metadata metadata = entityDetails.getMetadata();
+                       String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+                       String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+                       String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
+                       if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
+                               logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
+                                       customizationUUID, notifCustomizationUUID);
+
+                               if (checkExistingPnfResourceCutomization(customizationUUID)) {
+                                       logger.info("Resource customization UUID: {} already deployed", customizationUUID);
+                               } else {
+                                       PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
+                                       if (pnfResource == null) {
+                                               pnfResource = createPnfResource(entityDetails);
+                                       }
+                                       PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
+                                               pnfResource);
+                                       pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
+                                       toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
+                                       service.getPnfCustomizations().add(pnfResourceCustomization);
+                               }
+                       } else {
+                               logger
+                                       .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
+                                               customizationUUID, notifCustomizationUUID);
+                       }
+               }
+       }
+
+       private PnfResource findExistingPnfResource(Service service, String modelUuid) {
+               PnfResource pnfResource = null;
+               for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
+                       if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
+                               .getModelUUID().equals(modelUuid)) {
+                               pnfResource = pnfResourceCustomization.getPnfResources();
+                       }
+               }
+               if (pnfResource == null) {
+                       pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
+               }
+               return pnfResource;
+       }
+
+       private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
+               return pnfCustomizationRepository.findById(customizationUUID).isPresent();
+       }
+
+       /**
+        * Construct the {@link PnfResource} from {@link IEntityDetails} object.
+        */
+       private PnfResource createPnfResource(IEntityDetails entity) {
+               PnfResource pnfResource = new PnfResource();
+               Metadata metadata = entity.getMetadata();
+               pnfResource.setModelInvariantUUID(
+                       testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+               pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+               pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+               pnfResource.setModelVersion(
+                       testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+               pnfResource.setDescription(
+                       testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+               pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+               pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+               pnfResource.setToscaNodeType(entity.getToscaType());
+               return pnfResource;
+       }
+
+       /**
+        * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
+        */
+       private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
+               PnfResource pnfResource) {
+
+               PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+               Metadata metadata = entityDetails.getMetadata();
+               Map<String, Property> properties = entityDetails.getProperties();
+               pnfResourceCustomization
+                       .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+               pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+               pnfResourceCustomization
+                       .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+               pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
+               pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+               pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+               pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
+               pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
+               pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
+
+               pnfResourceCustomization.setPnfResources(pnfResource);
+
+               return pnfResourceCustomization;
+       }
+
+       /**
+        * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
+        */
+       private String getStringValue(Property property) {
+               if (null == property) {
+                       return "";
+               }
+               Object value = property.getValue();
+               return String.valueOf(value);
+       }
        
        protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
                        Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
@@ -649,7 +920,7 @@ public class ToscaResourceInstaller {
                        
                        // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
                        logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + 
-                                                  " matches Tosca VF Customization UUID: " +  vfCustomizationUUID);
+                                                          " matches Tosca VF Customization UUID: " +  vfCustomizationUUID);
                        
                        if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
                                
@@ -665,14 +936,14 @@ public class ToscaResourceInstaller {
                                        logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
                                        List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
                                                        .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
-                                       IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();     
+                                       IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();                                             
                                        
                                        logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
                                        
                                        Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
                                                        .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
-                                                   .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
-                                                   .findFirst();
+                                                       .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+                                                       .findFirst();
                                        if(matchingObject.isPresent()){
                                                VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, 
                                                                                                                                                                                         vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
@@ -684,19 +955,28 @@ public class ToscaResourceInstaller {
                                service.getVnfCustomizations().add(vnfResource);
                        } else{
                                logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
-                                                    "Tosca VF Customization UUID: " +  vfCustomizationUUID);
+                                                        "Tosca VF Customization UUID: " +  vfCustomizationUUID);
                        }
                }
        }
 
-       public void processWatchdog(String distributionId, String servideUUID) {
-               WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
+       public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
+                       String consumerId) {
+               WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
+                               distributionNotification, consumerId);
                watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
                
-               WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
-               watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
+               try{
+               
+                       WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
+                       watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
+                       
+               } catch(ObjectOptimisticLockingFailureException e){
+                       logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
+                       throw e;
+               }
        }
-
+       
        protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
                        VfResourceStructure vfResourceStructure) {
                for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
@@ -722,10 +1002,9 @@ public class ToscaResourceInstaller {
                                break;
                        case ASDCConfiguration.HEAT_NET:
                        case ASDCConfiguration.OTHER:
-                               logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT,
-                                               vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
-                                                               + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
-                                               "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported");
+                               logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
+                                       vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
+                                               .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
                                break;
                        default:
                                break;
@@ -871,9 +1150,7 @@ public class ToscaResourceInstaller {
        }
 
        protected Service createService(ToscaResourceStructure toscaResourceStructure,
-                       VfResourceStructure vfResourceStructure) {
-
-               toscaResourceStructure.getServiceMetadata();
+                       ResourceStructure resourceStructure) {
 
                Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
 
@@ -887,14 +1164,15 @@ public class ToscaResourceInstaller {
 
                        service.setServiceType(serviceMetadata.getValue("serviceType"));
                        service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+                       service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
 
                        service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
                        service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
                        service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
                        service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
 
-                       if (vfResourceStructure != null) 
-                               service.setWorkloadContext(vfResourceStructure.getNotification().getWorkloadContext());
+                       if (resourceStructure != null) 
+                               service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
                                                
                        service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
                        service.setCsar(toscaResourceStructure.getCatalogToscaCsar());                  
@@ -937,32 +1215,26 @@ public class ToscaResourceInstaller {
                return spCustomizationResource;
        }
        
-       protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
+       protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate, 
+                       ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
+                       Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
 
-               Metadata metadata = nodeTemplate.getMetaData();
-               
-               ConfigurationResource configResource = new ConfigurationResource();
+               ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate, 
+                               toscaResourceStructure,spResourceCustomization);
                
-               configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-               configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
-               configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-               configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
-               configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-               configResource.setToscaNodeType(nodeTemplate.getType());
-               
-               ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+               ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
                
                Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
                
-               configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-               configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-               
-               configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
-               configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
-               configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
-               configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
-               configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
+               StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+               String type = entityType.getType();
+               
+               if(NODES_VRF_ENTRY.equals(type)) {
+                       configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
+               }
+                       
                configCustomizationResource.setConfigurationResource(configResource);
+               
                configResourceCustomizationSet.add(configCustomizationResource);
 
                configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);   
@@ -974,7 +1246,7 @@ public class ToscaResourceInstaller {
                return configCustomizationResource;
        }
        
-       protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
+       protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
                
                Metadata fabricMetadata = nodeTemplate.getMetaData();
                
@@ -987,23 +1259,7 @@ public class ToscaResourceInstaller {
                configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
                configResource.setToscaNodeType(nodeTemplate.getType());
                
-               ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
-               
-               Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-               
-               configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-               configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-               
-               configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
-               configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
-               configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
-               configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
-               configCustomizationResource.setConfigurationResource(configResource);
-               configResourceCustomizationSet.add(configCustomizationResource);
-
-               configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
-               
-               return configCustomizationResource;
+               return configResource;
        }
 
        protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
@@ -1068,7 +1324,17 @@ public class ToscaResourceInstaller {
                
                }
 
-               if(networkResourceCustomization==null || !networkUUIDsMatch){
+               if (networkResourceCustomization!=null && !networkUUIDsMatch){
+                       
+                       NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
+                                       aicMax, aicMin);
+                       
+                       networkResourceCustomization.setNetworkResource(networkResource);                       
+                                       
+                       networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
+                       
+               }
+               else if(networkResourceCustomization==null){
                        networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
                                        toscaResourceStructure);
                                        
@@ -1228,16 +1494,32 @@ public class ToscaResourceInstaller {
                        crInstanceGroupCustomization.setModelCustomizationUUID(
                                        networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
                
-                       String quantityName = instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
-                       String fixedQuantity = quantityName.replace("NetworkCollection", "Fixed");
-                       if (toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
-                                       fixedQuantity + "_quantity") != null) {
-
-                               crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(
-                                               toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
-                                                               fixedQuantity + "_quantity"))); 
+                       // Loop through the template policy to find the subinterface_network_quantity property name.  Then extract the value for it.
+                       List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
+                       
+                       if(policyList != null){
+                               for(Policy policy : policyList){
+                                       for(String policyNetworkCollection : policy.getTargets()){
+                                               
+                                               if(policyNetworkCollection.equalsIgnoreCase(group.getName())){
+                                               
+                                                       Map<String, Object> propMap = policy.getPolicyProperties();
+                                       
+                                                       if(propMap.get("quantity") != null){
+                                                                                                                               
+                                                               String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString())); 
+                                       
+                                                               if(quantity != null){
+                                                                       crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
+                                                               }
+                                                                                               
+                                                       }
+                                       
+                                          }
+                                       }
+                               }       
                        }
-               
+                                       
                        crInstanceGroupCustomization.setDescription(
                                        toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
                                                        instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
@@ -1254,7 +1536,6 @@ public class ToscaResourceInstaller {
 
                        networkInstanceGroupList.add(networkInstanceGroup);
 
-               //}
 
                toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
 
@@ -1354,8 +1635,12 @@ public class ToscaResourceInstaller {
                        //Populate VNFCInstanceGroupCustomization
                        VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
                        
-                       vfcInstanceGroupCustom.setModelCustomizationUUID(vnfResourceCustomization.getModelCustomizationUUID());
-                       vfcInstanceGroupCustom.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+                       vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
+                       vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
+                       
+                       vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);                      
+                       vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
+                       
                        vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
                                                
                        String getInputName = null;
@@ -1367,28 +1652,29 @@ public class ToscaResourceInstaller {
                                } 
                        }
                        vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
-                       
                        vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
-                       vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);            
+                       
                        
                return vfcInstanceGroupCustom;
 
        }
                
-       protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
+       protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
                        ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
-                       IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
-               
+                       IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
+                       Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
+
                VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
                                vfModuleData.getVfModuleModelCustomizationUUID());
-               if(vfModuleCustomization == null){              
+               if (vfModuleCustomization == null) {
                        VfModule vfModule = findExistingVfModule(vnfResource,
-                                       nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+                                       vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
                        Metadata vfMetadata = group.getMetadata();
-                       if(vfModule==null)
-                               vfModule=createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
-                       
+                       if (vfModule == null)
+                               vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
+
                        vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
+                       vfModuleCustomization.setVnfCustomization(vnfResource);
                        setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
                                        vfMetadata);
                        vfModuleCustomization.setVfModule(vfModule);
@@ -1397,154 +1683,199 @@ public class ToscaResourceInstaller {
                } else {
                        vfResourceStructure.setAlreadyDeployed(true);
                }
-               
-               //******************************************************************************************************************
-               //* Extract VFC's and CVFC's then add them to VFModule
-               //******************************************************************************************************************
-               
-               Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();                
+
+               // ******************************************************************************************************************
+               // * Extract VFC's and CVFC's then add them to VFModule
+               // ******************************************************************************************************************
+
+               Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new HashSet<CvnfcConfigurationCustomization>();
                Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
                Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
 
+               // Only set the CVNFC if this vfModule group is a member of it.
+               List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate,
+                               group);
+               String vfModuleMemberName = null;
+
+               for (NodeTemplate node : groupMembers) {
+                       vfModuleMemberName = node.getName();
+               }
+
                // Extract CVFC lists
-               List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
-                                               
-               for(NodeTemplate cvfcTemplate : cvfcList) {
-                                                                       
-                       CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(existingCvnfcSet, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                       
-                       if(existingCvnfcCustomization == null){
-                       
-                       //Extract associated VFC - Should always be just one
-                       List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
-                                               
-                       for(NodeTemplate vfcTemplate : vfcList) {
-                               
-                               VnfcCustomization vnfcCustomization = new VnfcCustomization();
-                               VnfcCustomization existingVnfcCustomization = null;
-                               
-                               existingVnfcCustomization = findExistingVfc(existingVnfcSet, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                                       
-                               // Only Add Abstract VNFC's to our DB, ignore all others
-                               if(existingVnfcCustomization == null && vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")){
-                                       vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                                       vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
-                                       vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
-                                       vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-                                       vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-       
-                                       vnfcCustomization.setModelVersion(
-                                                       testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-                                       vnfcCustomization.setDescription(
-                                                       testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-                                       vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
-                                       
-                                       vnfcCustomizations.add(vnfcCustomization);
-                                       existingVnfcSet.add(vnfcCustomization);
-                               }
+               List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate,
+                               SdcTypes.CVFC);
+
+               for (NodeTemplate cvfcTemplate : cvfcList) {
+boolean cvnfcVfModuleNameMatch = false;
                        
-                       // This check is needed incase the VFC subcategory is something other than Abstract.  In that case we want to skip adding that record to our DB.
-                       if(vnfcCustomization.getModelCustomizationUUID() != null){
-                               
-                               CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
-                               cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-                               cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
-                               cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
-                               cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-                               cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-       
-                               cvnfcCustomization.setModelVersion(
-                                               testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-                               cvnfcCustomization.setDescription(
-                                               testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-                               cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+                       for(NodeTemplate node : groupMembers){          
+                               vfModuleMemberName = node.getName();
                                
-                               if(existingVnfcCustomization != null){
-                                       cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
-                               }else{
-                                       cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+                               if(vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
+                                       cvnfcVfModuleNameMatch = true;
+                                       break;
                                }
-                               
-                               cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
-                               cvnfcCustomization.setVnfResourceCustomization(vnfResource);                                    
-                               
-                               cvnfcCustomizations.add(cvnfcCustomization);
-                               existingCvnfcSet.add(cvnfcCustomization);
+                       }               
                        
-                       //*****************************************************************************************************************************************
-                       //* Extract Fabric Configuration
-                       //*****************************************************************************************************************************************
-                       
-                       List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
-                                                               
-                       for(NodeTemplate fabricTemplate : fabricConfigList) {
-                                                                               
-                               ConfigurationResource fabricConfig = null;
-                               
-                               ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-                                                               
-                               if(existingConfig == null){
-                                       
-                                       ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
-                                       
-                                       fabricConfig = fabricConfigCustomization.getConfigurationResource();
-                                       
-                                       service.getConfigurationCustomizations().add(fabricConfigCustomization);
-                               }else {
-                                       fabricConfig = existingConfig;
+                       if(vfModuleMemberName != null && cvnfcVfModuleNameMatch){
+
+                               // Extract associated VFC - Should always be just one
+                               List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper()
+                                               .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+                               for (NodeTemplate vfcTemplate : vfcList) {
+
+                                       VnfcCustomization vnfcCustomization = new VnfcCustomization();
+                                       VnfcCustomization existingVnfcCustomization = null;
+
+                                       existingVnfcCustomization = findExistingVfc(existingVnfcSet,
+                                                       vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+                                       if (existingVnfcCustomization == null) {
+                                               vnfcCustomization = new VnfcCustomization();
+                                       } else {
+                                               vnfcCustomization = existingVnfcCustomization;
+                                       }
+
+                                       // Only Add Abstract VNFC's to our DB, ignore all others
+                                       if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
+                                                       .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
+                                               vnfcCustomization.setModelCustomizationUUID(
+                                                               vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+                                               vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+                                               vnfcCustomization.setModelInvariantUUID(
+                                                               vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+                                               vnfcCustomization
+                                                               .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+                                               vnfcCustomization
+                                                               .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+                                               vnfcCustomization.setModelVersion(
+                                                               testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+                                               vnfcCustomization.setDescription(testNull(
+                                                               vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+                                               vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+
+                                               vnfcCustomizations.add(vnfcCustomization);
+                                               existingVnfcSet.add(vnfcCustomization);
+                                       }
+
+                                       // This check is needed incase the VFC subcategory is
+                                       // something other than Abstract. In that case we want to
+                                       // skip adding that record to our DB.
+                                       if (vnfcCustomization.getModelCustomizationUUID() != null) {
+                                               CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+                                               cvnfcCustomization.setModelCustomizationUUID(
+                                                               cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+                                               cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+                                               cvnfcCustomization.setModelInvariantUUID(
+                                                               cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+                                               cvnfcCustomization
+                                                               .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+                                               cvnfcCustomization
+                                                               .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+                                               cvnfcCustomization.setModelVersion(
+                                                               testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+                                               cvnfcCustomization.setDescription(testNull(
+                                                               cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+                                               cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+                                               if (existingVnfcCustomization != null) {
+                                                       cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+                                               } else {
+                                                       cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+                                               }
+
+                                               cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
+                                                               .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+                                               cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
+                                                               .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+                                               cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+
+                                               cvnfcCustomizations.add(cvnfcCustomization);
+                                               existingCvnfcSet.add(cvnfcCustomization);
+
+                                               // *****************************************************************************************************************************************
+                                               // * Extract Fabric Configuration
+                                               // *****************************************************************************************************************************************
+
+                                               List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
+                                                               .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
+
+                                               for (NodeTemplate fabricTemplate : fabricConfigList) {
+
+                                                       ConfigurationResource fabricConfig = null;
+
+                                                       ConfigurationResource existingConfig = findExistingConfiguration(service,
+                                                                       fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+                                                       if (existingConfig == null) {
+
+                                                               fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
+
+                                                       } else {
+                                                               fabricConfig = existingConfig;
+                                                       }
+
+                                                       CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(
+                                                                       fabricTemplate, toscaResourceStructure, vnfResource, vfModuleCustomization,
+                                                                       cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
+                                                       cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
+                                                       
+                                                       fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
+                                               }
+                                               cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
+                                       }
+
                                }
-                               
-                               
-                               VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure, 
-                                                                                                                                                          vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
-                               
-                               vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
-                       }
-                       
+
                        }
-                       
-                  }
-                       
-                 }
-                       
-               } 
-               
+               }
                vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
-               vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
-               
+
                return vfModuleCustomization;
        }
        
-       protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct, 
+       protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct, 
             VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
-            ConfigurationResource configResource) {
+            ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
 
-               Metadata fabricMetadata = fabricTemplate.getMetaData();
+               Metadata fabricMetadata = fabricTemplate.getMetaData(); 
+                               
+               CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
                
+               cvnfcConfigurationCustomization.setConfigurationResource(configResource);
                
-               VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
+               cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
                
-               vfModuleToCvnfc.setConfigurationResource(configResource);
-               vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
-               vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-               vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
-               vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
-               vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
-               vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
+               cvnfcConfigurationCustomization.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+               cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
                
-               List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
+               List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
                
                if(policyList != null){
                        for(Policy policy : policyList){
-                               vfModuleToCvnfc.setPolicyName(policy.getName());
-                       }
+                               
+                               for(String policyCvfcTarget : policy.getTargets()){
+                                       
+                                       if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
+                               
+                                               Map<String, Object> propMap = policy.getPolicyProperties();
+
+                                               if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
+                                                       cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
+                                               }
+                                       }
+                               }
+                       }                       
                }
                
-               vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
-               vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
-               vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
-               
-               return vfModuleToCvnfc;
+               cvnfcConfigurationCustomization.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
+               cvnfcConfigurationCustomization.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
+               cvnfcConfigurationCustomization.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
+                       
+               return cvnfcConfigurationCustomization;
        }
                
        protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
@@ -1555,8 +1886,6 @@ public class ToscaResourceInstaller {
                                configResource = configurationResourceCustom.getConfigurationResource();
                        }
                }
-               if(configResource==null)
-                       configResource = configRepo.findResourceByModelUUID(modelUUID);
                
                return configResource;
        }
@@ -1569,10 +1898,6 @@ public class ToscaResourceInstaller {
                                vfModuleCustomization = vfModuleCustom;
                        }
                }
-               if(vfModuleCustomization==null)
-                       vfModuleCustomization = vfModuleCustomizationRepo
-                                       .findByModelCustomizationUUID(vfModuleModelCustomizationUUID);
-               
                return vfModuleCustomization;
        }
 
@@ -1664,7 +1989,7 @@ public class ToscaResourceInstaller {
        protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
                        VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
                        Metadata vfMetadata) {
-               
+                               
                Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
                                .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
                                                .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
@@ -1755,9 +2080,8 @@ public class ToscaResourceInstaller {
 
        protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
                        ToscaResourceStructure toscaResourceStructure, Service service) {
-               VnfResourceCustomization vnfResourceCustomization = vnfCustomizationRepo.findOneByModelCustomizationUUID(
-                               vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-               if(vnfResourceCustomization == null){           
+               VnfResourceCustomization vnfResourceCustomization = null;
+               if(vnfResourceCustomization == null){
                        VnfResource vnfResource = findExistingVnfResource(service,
                                        vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
                        
@@ -1767,17 +2091,16 @@ public class ToscaResourceInstaller {
                        vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
                                        vnfResource);
                        vnfResourceCustomization.setVnfResources(vnfResource);
+                       vnfResourceCustomization.setService(service);
                        vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
                        
-                       // Fetch VNFC Instance Group Info                               
+                       // Fetch VNFC Instance Group Info
                        List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
                                        .getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate,
                                                        "org.openecomp.groups.VfcInstanceGroup");
                                
                        for (Group group : groupList) { 
-                               
                                        VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(vfNodeTemplate, group, vnfResourceCustomization, toscaResourceStructure);
-                                       
                                        vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);                                
                        }                       
                }
@@ -1817,6 +2140,12 @@ public class ToscaResourceInstaller {
                vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
                                .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
 
+               vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
+                       .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+
+               vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
+                       .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+
                vnfResourceCustomization.setVnfResources(vnfResource);
                vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
                                vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));  
@@ -2029,6 +2358,20 @@ public class ToscaResourceInstaller {
                                + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
        }
        
+       protected String getPropertyInput(String propertyName){
+       
+               String inputName = new String();
+               
+               if (propertyName != null) { 
+                       int getInputIndex = propertyName.indexOf("{get_input="); 
+                       if (getInputIndex > -1) { 
+                               inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1); 
+                       } 
+               }
+               
+               return inputName;
+       }
+       
        
        protected static Timestamp getCurrentTimeStamp() {
                
@@ -2036,3 +2379,4 @@ public class ToscaResourceInstaller {
        }
 
 }
+