summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java47
1 files changed, 41 insertions, 6 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
index e70ca5f2f9..3f5e41745b 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
@@ -36,6 +36,8 @@ import org.onap.sdc.tosca.datatypes.model.NodeType;
import org.onap.sdc.tosca.datatypes.model.RelationshipTemplate;
import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.heat.datatypes.HeatBoolean;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
import org.openecomp.sdc.heat.datatypes.model.PropertiesMapKeyTypes;
@@ -67,6 +69,8 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase {
private static final Logger logger = LoggerFactory.getLogger(ResourceTranslationNovaServerImpl.class);
private static final String BLOCK_DEVICE_MAPPING_DEVICE_NAME = "device_name";
private static final String VOL_ATTACH_DEVICE_PROPERTY_NAME = "device";
+ private static final String FABRIC_CONFIGURATION_KEY = "fabric_configuration_monitoring";
+
@Override
protected void translate(TranslateTo translateTo) {
@@ -350,14 +354,43 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase {
}
List<Map<String, Object>> heatNetworkList = (List<Map<String, Object>>) networks;
-
+
+
for (Map<String, Object> heatNetwork : heatNetworkList) {
- getOrTranslatePortTemplate(translateTo, heatNetwork.get(
- Constants.PORT_PROPERTY_NAME), translatedId, novaNodeTemplate);
+
+ Optional<Resource> portResourceOp = getOrTranslatePortTemplate(translateTo, heatNetwork.get(
+ Constants.PORT_PROPERTY_NAME), translatedId, novaNodeTemplate);
+ portResourceOp.ifPresent(portResource -> handleFabricConfiguration(translateTo, novaNodeTemplate.getType(), portResource));
+
}
+
+ }
+
+ private void handleFabricConfiguration(TranslateTo translateTo, String resourceType, Resource portResource ){
+
+ Optional<Object> valueSpacesProperty = HeatToToscaUtil.getResourceProperty(portResource, HeatConstants.VALUE_SPECS_PROPERTY_NAME);
+
+ valueSpacesProperty.filter(props -> props instanceof Map && MapUtils.isNotEmpty((Map)props)).ifPresent(valueSpecs ->{
+ Object value = ((Map)(valueSpecs)).get(HeatConstants.ATT_FABRIC_CONFIGURATION_REQUIRED);
+ if(value!= null && HeatBoolean.eval(value )){
+ addFabricConfigurationCapability(translateTo, resourceType);
+ }
+
+ });
+
+ }
+
+ private void addFabricConfigurationCapability(TranslateTo translateTo, String localType){
+
+ ServiceTemplate serviceTemplate = translateTo.getServiceTemplate();
+ Map<String, CapabilityDefinition> mapCapabilities = new HashMap<>();
+ CapabilityDefinition fabricConfigurationCap = new CapabilityDefinition();
+ fabricConfigurationCap.setType(ToscaCapabilityType.FABRIC_CONFIGURATION);
+ mapCapabilities.put(FABRIC_CONFIGURATION_KEY, fabricConfigurationCap);
+ DataModelUtil.addNodeTypeCapabilitiesDef (DataModelUtil.getNodeType(serviceTemplate, localType), mapCapabilities);
}
- private void getOrTranslatePortTemplate(TranslateTo translateTo,
+ private Optional<Resource> getOrTranslatePortTemplate(TranslateTo translateTo,
Object port,
String novaServerResourceId,
NodeTemplate novaNodeTemplate) {
@@ -367,7 +400,7 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase {
Optional<AttachedResourceId> attachedPortId = HeatToToscaUtil
.extractAttachedResourceId(heatFileName, heatOrchestrationTemplate, context, port);
if (!attachedPortId.isPresent() || !attachedPortId.get().isGetResource()) {
- return;
+ return Optional.empty();
}
String resourceId = (String) attachedPortId.get().getEntityId();
Resource portResource = HeatToToscaUtil.getResource(heatOrchestrationTemplate, resourceId, heatFileName);
@@ -377,7 +410,7 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase {
+ "Supported types are: {}, {}", resourceId, portResource.getType(),
HeatResourcesTypes.NEUTRON_PORT_RESOURCE_TYPE.getHeatResource(),
HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE.getHeatResource());
- return;
+ return Optional.empty();
} else if (HeatResourcesTypes.CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE
.getHeatResource().equals(portResource.getType())) {
Map<String, Object> properties = portResource.getProperties();
@@ -400,7 +433,9 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase {
logger.warn("NovaServer connect to port resource with id : {} and type : {}. This resource type"
+ " is not supported, therefore the connection to the port is ignored.", resourceId,
portResource.getType());
+ return Optional.empty();
}
+ return Optional.ofNullable(portResource);
}
private boolean isSupportedPortResource(Resource portResource) {