aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuli Shlosberg <ys9693@att.com>2017-11-26 19:05:23 +0200
committerMichael Lando <ml636r@att.com>2017-11-27 08:49:27 +0000
commit0566f581c0f310384f42838c388f57234ed1d60e (patch)
treedd782da7ebd4ce591876865a564b9c1f65eb5e66
parent4d8033eeb036943c05b3a5752b8f4cd4d705272f (diff)
sync 1.1.0 to master
Change-Id: I6e040f039895dd2ced55f95824473946b226fb5d Issue-ID: SDC-707 Signed-off-by: Yuli Shlosberg <ys9693@att.com>
-rw-r--r--asdc-tests/pom.xml2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java561
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java434
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java372
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java56
-rw-r--r--catalog-be/src/main/webapp/WEB-INF/web.xml4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadInfo.java10
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java71
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java149
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java62
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java36
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java10
-rw-r--r--openecomp-be/tools/build/scripts/generate-cassandra-init-cql.sh2
-rw-r--r--openecomp-be/tools/build/scripts/zusammen-generate-cassandra-init-cql.sh2
-rw-r--r--sdc-os-chef/pom.xml69
-rwxr-xr-xsdc-os-chef/scripts/docker_run.sh35
-rw-r--r--sdc-os-chef/scripts/docker_sanity_run.sh122
-rw-r--r--sdc-os-chef/scripts/sanity_run.sh117
-rw-r--r--sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb2
-rw-r--r--sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/alter_dox_db.cql8
-rw-r--r--sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/create_dox_db.cql60
-rw-r--r--sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/03-createDoxKeyspace.rb2
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vPCRF.csarbin0 -> 3836 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vSPGW.csarbin0 -> 3907 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcMmeVf.csarbin0 -> 4790 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcSpgwVf.csarbin0 -> 2804 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/cscf_si.csarbin0 -> 50982 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF.csarbin0 -> 4290 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF_v3.0.csarbin44851 -> 44977 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vSBC.csarbin0 -> 3771 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vfw.zipbin0 -> 3522 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vvg.zipbin0 -> 944 bytes
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/logback.xml25
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh4
-rw-r--r--sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java71
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java5
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java2
-rw-r--r--test-apis-ci/src/main/resources/logback.xml4
47 files changed, 1704 insertions, 666 deletions
diff --git a/asdc-tests/pom.xml b/asdc-tests/pom.xml
index bfb7920d51..a37d1e8a9c 100644
--- a/asdc-tests/pom.xml
+++ b/asdc-tests/pom.xml
@@ -268,7 +268,7 @@
<dependency>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-distribution-client</artifactId>
- <version>1.1.9-SNAPSHOT</version>
+ <version>1.1.32</version>
<scope>compile</scope>
</dependency>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 74bb55b63d..b7344e9911 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -191,7 +191,12 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
public static enum ArtifactOperationEnum {
- Create(), Update(), Delete(), Download();
+ Create(), Update(), Delete(), Download(), Link();
+
+ public static boolean isCreateOrLink(ArtifactOperationEnum operation) {
+ return (operation.equals(Create) || operation.equals(Link));
+
+ }
}
public class ArtifactOperationInfo {
@@ -3648,12 +3653,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
Either<ESArtifactData, CassandraOperationStatus> artifactfromES;
ESArtifactData esArtifactData;
if (esArtifactId != null && !esArtifactId.isEmpty() && artifactDefinition.getPayloadData() == null) {
+ log.debug("Try to fetch artifact from cassandra with id : {}", esArtifactId);
artifactfromES = artifactCassandraDao.getArtifact(esArtifactId);
if (artifactfromES.isRight()) {
CassandraOperationStatus resourceUploadStatus = artifactfromES.right().value();
StorageOperationStatus storageResponse = DaoStatusConverter.convertCassandraStatusToStorageStatus(resourceUploadStatus);
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(storageResponse);
- log.debug("Error when getting artifact from ES, error: {}", actionStatus.name());
+ log.debug("Error when getting artifact from ES, error: {} esid : {}", actionStatus.name(), esArtifactId);
return Either.right(componentsUtils.getResponseFormatByArtifactId(actionStatus, artifactDefinition.getArtifactDisplayName()));
}
esArtifactData = artifactfromES.left().value();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index a34bf00a7a..108e03c274 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -1178,6 +1178,11 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
return text;
}
+ public Either<Component, ActionStatus> shouldUpgradeToLatestDerived(Component clonedComponent) {
+ //general implementation. Must be error for service, VF . In ResourceBuisnessLogic exist override
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 6dc83bfc2b..66d8668fea 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -32,7 +32,6 @@ import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -42,15 +41,12 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
@@ -60,26 +56,20 @@ import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames;
-import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
-import org.openecomp.sdc.be.resources.data.PropertyValueData;
-import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
@@ -150,7 +140,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
containerComponent = validateComponentExists.left().value();
}
- if (ToscaUtils.isAtomicType(containerComponent)) {
+ if (ModelConverter.isAtomicComponent(containerComponent)) {
log.debug("Cannot attach resource instances to container resource of type {}", containerComponent.assetType());
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, containerComponent.assetType()));
}
@@ -209,7 +199,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
org.openecomp.sdc.be.model.Component containerComponent = validateComponentExists.left().value();
- if (ToscaUtils.isAtomicType(containerComponent)) {
+ if (ModelConverter.isAtomicComponent(containerComponent)) {
log.debug("Cannot attach resource instances to container resource of type {}", containerComponent.assetType());
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, containerComponent.assetType()));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 0ae546479a..1ab7ffb007 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -111,6 +111,7 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.heat.HeatParameterType;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
@@ -595,6 +596,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContent);
+ Either<Resource, ResponseFormat> genericResourceEither = handleResourceGenericType(preparedResource);
+ if (genericResourceEither.isRight()) {
+ log.debug("failed to get resource generic type. status is {}", genericResourceEither.right().value());
+ ResponseFormat responseFormat = genericResourceEither.right().value();
+ componentsUtils.auditResource(genericResourceEither.right().value(), csarInfo.getModifier(), preparedResource, "", "", updateResource, null);
+ return Either.right(responseFormat);
+ }
+
parseNodeTypeInfoYamlEither = this.handleNodeTypes(yamlFileName, preparedResource, yamlFileContent, shouldLock, nodeTypesArtifactsToHandle, createdArtifacts, nodeTypesInfo, csarInfo, nodeName);
if (parseNodeTypeInfoYamlEither.isRight()) {
ResponseFormat responseFormat = parseNodeTypeInfoYamlEither.right().value();
@@ -687,6 +696,17 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
+ private Either<Resource, ResponseFormat> handleResourceGenericType(Resource resource) {
+ Either<Resource, ResponseFormat> genericResourceEither = fetchAndSetDerivedFromGenericType(resource);
+ if (genericResourceEither.isRight()) {
+ return genericResourceEither;
+ }
+ if (resource.shouldGenerateInputs()) {
+ generateInputsFromGenericTypeProperties(resource, genericResourceEither.left().value());
+ }
+ return genericResourceEither;
+ }
+
private Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Resource oldResource) {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csarInfo.getCsar());
@@ -888,7 +908,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
handleNodeTypeArtifactsRes = Either.right(handleNodeTypeArtifactsRequestRes.right().value());
break;
}
- if (curOperation == ArtifactOperationEnum.Create) {
+ if (ArtifactOperationEnum.isCreateOrLink(curOperation)) {
createdArtifacts.addAll(handleNodeTypeArtifactsRequestRes.left().value());
}
handledNodeTypeArtifacts.addAll(handleNodeTypeArtifactsRequestRes.left().value());
@@ -917,6 +937,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
vfcToscaNames.put(nodeType.getKey(), toscaResourceName);
}
}
+ for(NodeTypeInfo cvfc : nodeTypesInfo.values()){
+ vfcToscaNames.put(cvfc.getType(), buildNestedToscaResourceName(ResourceTypeEnum.CVFC.name(), vfResourceName, cvfc.getType()));
+ }
return vfcToscaNames;
}
@@ -1107,7 +1130,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(validateRes.right().value());
}
// VF / PNF "derivedFrom" should be null (or ignored)
- if (ToscaUtils.isAtomicType(resource)) {
+ if (ModelConverter.isAtomicComponent(resource)) {
Either<Boolean, ResponseFormat> validateDerivedFromNotEmpty = validateDerivedFromNotEmpty(user, resource, AuditingActionEnum.CREATE_RESOURCE);
if (validateDerivedFromNotEmpty.isRight()) {
return Either.right(validateDerivedFromNotEmpty.right().value());
@@ -1233,7 +1256,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if(result == null){
newComplexVfc = buildCvfcRes.left().value();
- Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade.getLatestByToscaResourceName(newComplexVfc.getToscaResourceName());
+ Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade.getFullLatestComponentByToscaResourceName(newComplexVfc.getToscaResourceName());
if(oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND){
log.debug("Failed to fetch previous complex VFC by tosca resource name {}. Status is {}. ", newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value());
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
@@ -1461,7 +1484,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String nameWithouNamespacePrefix = nodeName.substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
String[] findTypes = nameWithouNamespacePrefix.split("\\.");
String resourceType = findTypes[0];
- return resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1) + "Cvfc";
+ String resourceName = resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1);
+ return addCvfcSuffixToResourceName(resourceName);
}
private Either<Resource, ResponseFormat> createResourceAndRIsFromYaml(String yamlName, Resource resource, ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative,
@@ -1869,25 +1893,27 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("************* Going to create all nodes {}", yamlName);
Either<Map<String, Resource>, ResponseFormat> createdResourcesFromdNodeTypeMap = this.handleNodeTypes(yamlName, resource, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeName);
+ log.debug("************* Finished to create all nodes {}", yamlName);
if (createdResourcesFromdNodeTypeMap.isRight()) {
log.debug("failed to resources from node types status is {}", createdResourcesFromdNodeTypeMap.right().value());
return Either.right(createdResourcesFromdNodeTypeMap.right().value());
}
- log.debug("************* Finished to create all nodes {}", yamlName);
log.debug("************* Going to create all resource instances {}", yamlName);
createResourcesInstancesEither = createResourceInstances(csarInfo.getModifier(), yamlName, resource, uploadComponentInstanceInfoMap, true, false, csarInfo.getCreatedNodes());
+ log.debug("************* Finished to create all resource instances {}", yamlName);
if (createResourcesInstancesEither.isRight()) {
log.debug("failed to create resource instances status is {}", createResourcesInstancesEither.right().value());
result = createResourcesInstancesEither;
return createResourcesInstancesEither;
}
- log.debug("************* Finished to create all resource instances for {}", yamlName);
resource = createResourcesInstancesEither.left().value();
log.debug("************* Going to create all relations {}", yamlName);
createResourcesInstancesEither = createResourceInstancesRelations(csarInfo.getModifier(), yamlName, resource, uploadComponentInstanceInfoMap);
+ log.debug("************* Finished to create all relations {}", yamlName);
+
if (createResourcesInstancesEither.isRight()) {
log.debug("failed to create relation between resource instances status is {}", createResourcesInstancesEither.right().value());
result = createResourcesInstancesEither;
@@ -1895,7 +1921,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
resource = createResourcesInstancesEither.left().value();
}
- log.debug("************* Finished to create all relations {}", yamlName);
log.debug("************* Going to create positions {}", yamlName);
Either<List<ComponentInstance>, ResponseFormat> eitherSetPosition = compositionBusinessLogic.setPositionsForComponentInstances(resource, csarInfo.getModifier().getUserId());
@@ -1987,6 +2012,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (eitherCreateResult.isRight()) {
return Either.right(eitherCreateResult.right().value());
}
+ Either<Resource, StorageOperationStatus> eitherGerResource = toscaOperationFacade.getToscaElement(resource.getUniqueId());
+ if (eitherGerResource.isRight()) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherGerResource.right().value()), resource);
+
+ return Either.right(responseFormat);
+
+ }
+ resource = eitherGerResource.left().value();
Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils);
if (artifacsMetaCsarStatus.isLeft()) {
@@ -1994,7 +2027,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String artifactsFileName = artifacsMetaCsarStatus.left().value().getKey();
String artifactsContents = artifacsMetaCsarStatus.left().value().getValue();
Either<Resource, ResponseFormat> createArtifactsFromCsar = Either.left(resource);
- if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.Create)
+ if (ArtifactOperationEnum.isCreateOrLink(artifactOperation.getArtifactOperationEnum()))
createArtifactsFromCsar = createResourceArtifactsFromCsar(csarInfo, resource, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
else
createArtifactsFromCsar = updateResourceArtifactsFromCsar(csarInfo, resource, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
@@ -2074,7 +2107,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void addNonMetaCreatedArtifactsToSupportRollback(ArtifactOperationInfo operation, List<ArtifactDefinition> createdArtifacts, Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts) {
- if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.Create && createdArtifacts != null && eitherNonMetaArtifacts.isLeft()) {
+ if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && createdArtifacts != null && eitherNonMetaArtifacts.isLeft()) {
Either<ArtifactDefinition, Operation> eitherResult = eitherNonMetaArtifacts.left().value();
if (eitherResult.isLeft()) {
createdArtifacts.add(eitherResult.left().value());
@@ -2140,16 +2173,27 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ArtifactTemplateInfo, Set<ArtifactTemplateInfo>> parsedGroup = new HashMap<ArtifactTemplateInfo, Set<ArtifactTemplateInfo>>();
for (List<ArtifactTemplateInfo> parsedGroupTemplateList : parsedArifactsCollection) {
+
for (ArtifactTemplateInfo parsedGroupTemplate : parsedGroupTemplateList) {
- parsedGroupTemplate.setGroupName("");
- Set<ArtifactTemplateInfo> parsedArtifactsNames = new HashSet<ArtifactTemplateInfo>();
- parsedArtifactsNames.add(parsedGroupTemplate);
- List<ArtifactTemplateInfo> relatedGroupTemplateList = parsedGroupTemplate.getRelatedArtifactsInfo();
- if (relatedGroupTemplateList != null && !relatedGroupTemplateList.isEmpty()) {
- createArtifactsGroupSet(parsedGroupTemplateList, parsedArtifactsNames);
+ if(parsedGroupTemplate.getGroupName() != null){
+ parsedGroupTemplate.setGroupName("");
+ Set<ArtifactTemplateInfo> parsedArtifactsNames = new HashSet<ArtifactTemplateInfo>();
+ parsedArtifactsNames.add(parsedGroupTemplate);
+ List<ArtifactTemplateInfo> relatedGroupTemplateList = parsedGroupTemplate.getRelatedArtifactsInfo();
+ if (relatedGroupTemplateList != null && !relatedGroupTemplateList.isEmpty()) {
+ createArtifactsGroupSet(parsedGroupTemplateList, parsedArtifactsNames);
+ }
+ parsedGroup.put(parsedGroupTemplate, parsedArtifactsNames);
+ }else{
+ List<ArtifactTemplateInfo> arrtifacts = new ArrayList<ArtifactTemplateInfo>();
+ arrtifacts.add(parsedGroupTemplate);
+ Either<Resource, ResponseFormat> resStatus = createGroupDeploymentArtifactsFromCsar(csarInfo, resource, arrtifacts, createdNewArtifacts, createdDeplymentArtifactsAfterDelete, labelCounter, shouldLock, inTransaction);
+ if (resStatus.isRight())
+ return resStatus;
+
}
- parsedGroup.put(parsedGroupTemplate, parsedArtifactsNames);
}
+
}
///////////////////////////////// find artifacts to
@@ -2670,42 +2714,40 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resStatus = createDeploymentArtifactsFromCsar(csarInfo, resource, artifactsGroup, artifactsUUIDGroup, groupTemplateInfo, createdNewArtifacts, artifactsFromResource, labelCounter, shouldLock, inTransaction);
if (resStatus.isRight())
return resStatus;
-
- Map<String, String> members = new HashMap<String, String>();
- associateMembersToArtifacts(createdNewArtifacts, artifactsFromResource, heatGroups, artifactsGroup, members);
-
- List<String> artifactsList = new ArrayList<String>(artifactsGroup);
- List<String> artifactsUUIDList = new ArrayList<String>(artifactsUUIDGroup);
-
- GroupDefinition groupDefinition = new GroupDefinition();
- groupDefinition.setName(groupName);
- groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
- groupDefinition.setArtifacts(artifactsList);
- groupDefinition.setArtifactsUuid(artifactsUUIDList);
-
- if (!members.isEmpty())
- groupDefinition.setMembers(members);
-
- List<GroupProperty> properties = new ArrayList<GroupProperty>();
- GroupProperty prop = new GroupProperty();
- prop.setName(Constants.IS_BASE);
- prop.setValue(Boolean.toString(groupTemplateInfo.isBase()));
- properties.add(prop);
-
- List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
- createdArtifacts.addAll(createdNewArtifacts);
- createdArtifacts.addAll(artifactsFromResource);
- Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeRes = groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, true);
- if (getLatestGroupTypeRes.isRight()) {
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getLatestGroupTypeRes.right().value())));
+ if(groupName != null && !groupName.isEmpty()){
+ Map<String, String> members = new HashMap<String, String>();
+ associateMembersToArtifacts(createdNewArtifacts, artifactsFromResource, heatGroups, artifactsGroup, members);
+
+ List<String> artifactsList = new ArrayList<String>(artifactsGroup);
+ List<String> artifactsUUIDList = new ArrayList<String>(artifactsUUIDGroup);
+
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setName(groupName);
+ groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
+ groupDefinition.setArtifacts(artifactsList);
+ groupDefinition.setArtifactsUuid(artifactsUUIDList);
+
+ if (!members.isEmpty())
+ groupDefinition.setMembers(members);
+
+ List<GroupProperty> properties = new ArrayList<GroupProperty>();
+ GroupProperty prop = new GroupProperty();
+ prop.setName(Constants.IS_BASE);
+ prop.setValue(Boolean.toString(groupTemplateInfo.isBase()));
+ properties.add(prop);
+
+ List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
+ createdArtifacts.addAll(createdNewArtifacts);
+ createdArtifacts.addAll(artifactsFromResource);
+ Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeRes = groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, true);
+ if (getLatestGroupTypeRes.isRight()) {
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getLatestGroupTypeRes.right().value())));
+ }
+ properties = createVfModuleAdditionalProperties(groupTemplateInfo.isBase(), groupName, properties, createdArtifacts, artifactsList, getLatestGroupTypeRes.left().value());
+ groupDefinition.convertFromGroupProperties(properties);
+
+ needToAdd.add(groupDefinition);
}
- properties = createVfModuleAdditionalProperties(groupTemplateInfo.isBase(), groupName, properties, createdArtifacts, artifactsList, getLatestGroupTypeRes.left().value());
- groupDefinition.convertFromGroupProperties(properties);
-
- // Either<GroupDefinition, ResponseFormat> createGroup = groupBusinessLogic.createGroup(resource.getUniqueId(), user.getUserId(), ComponentTypeEnum.RESOURCE, groupDefinition, inTransaction);
- // if (createGroup.isRight())
- // return Either.right(createGroup.right().value());
- needToAdd.add(groupDefinition);
}
ComponentParametersView componentParametersView = new ComponentParametersView();
componentParametersView.disableAll();
@@ -2858,7 +2900,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> vfCsarArtifactsToHandle = null;
- if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.Create) {
+ if (ArtifactOperationEnum.isCreateOrLink(artifactOperation.getArtifactOperationEnum())) {
vfCsarArtifactsToHandle = new EnumMap<>(ArtifactOperationEnum.class);
vfCsarArtifactsToHandle.put(artifactOperation.getArtifactOperationEnum(), artifactPathAndNameList);
} else {
@@ -2989,42 +3031,36 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("createDeploymentArtifactsFromCsar end");
if (resStatus.isRight())
return resStatus;
-
- Map<String, String> members = new HashMap<String, String>();
- associateMembersToArtifacts(createdArtifacts, null, heatGroups, artifactsGroup, members);
-
- List<String> artifactsList = new ArrayList<String>(artifactsGroup);
- List<String> artifactsUUIDList = new ArrayList<String>(artifactsUUIDGroup);
-
- GroupDefinition groupDefinition = new GroupDefinition();
- groupDefinition.setName(groupName);
- groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
- groupDefinition.setArtifacts(artifactsList);
- groupDefinition.setArtifactsUuid(artifactsUUIDList);
-
- if (!members.isEmpty())
- groupDefinition.setMembers(members);
- List<GroupProperty> properties = new ArrayList<GroupProperty>();
- GroupProperty prop = new GroupProperty();
- prop.setName(Constants.IS_BASE);
- prop.setValue(Boolean.toString(groupTemplateInfo.isBase()));
- properties.add(prop);
- Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeRes = groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, true);
- if (getLatestGroupTypeRes.isRight()) {
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getLatestGroupTypeRes.right().value())));
+ if(groupName != null && !groupName.isEmpty()){
+ Map<String, String> members = new HashMap<String, String>();
+ associateMembersToArtifacts(createdArtifacts, null, heatGroups, artifactsGroup, members);
+
+ List<String> artifactsList = new ArrayList<String>(artifactsGroup);
+ List<String> artifactsUUIDList = new ArrayList<String>(artifactsUUIDGroup);
+
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setName(groupName);
+ groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
+ groupDefinition.setArtifacts(artifactsList);
+ groupDefinition.setArtifactsUuid(artifactsUUIDList);
+
+ if (!members.isEmpty())
+ groupDefinition.setMembers(members);
+ List<GroupProperty> properties = new ArrayList<GroupProperty>();
+ GroupProperty prop = new GroupProperty();
+ prop.setName(Constants.IS_BASE);
+ prop.setValue(Boolean.toString(groupTemplateInfo.isBase()));
+ properties.add(prop);
+ Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeRes = groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, true);
+ if (getLatestGroupTypeRes.isRight()) {
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(getLatestGroupTypeRes.right().value())));
+ }
+ properties = createVfModuleAdditionalProperties(groupTemplateInfo.isBase(), groupName, properties, createdArtifacts, artifactsList, getLatestGroupTypeRes.left().value());
+ groupDefinition.convertFromGroupProperties(properties);
+ log.debug("createGroup start");
+
+ needToCreate.add(groupDefinition);
}
- properties = createVfModuleAdditionalProperties(groupTemplateInfo.isBase(), groupName, properties, createdArtifacts, artifactsList, getLatestGroupTypeRes.left().value());
- groupDefinition.convertFromGroupProperties(properties);
- log.debug("createGroup start");
-
- // Since in these groups we handle only artifacts, then no need to
- // fetch component instances
-
- // Either<GroupDefinition, ResponseFormat> createGroup = groupBusinessLogic.createGroup(comp, user, ComponentTypeEnum.RESOURCE, groupDefinition, inTransaction);
- // log.debug("createGroup end");
- // if (createGroup.isRight())
- // return Either.right(createGroup.right().value());
- needToCreate.add(groupDefinition);
}
ComponentParametersView componentParametersView = new ComponentParametersView();
@@ -3496,7 +3532,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName));
}
- allGroups.addAll(artifactTemplateInfoList);
+ if(!artifactsTypeKey.equalsIgnoreCase(ArtifactTemplateInfo.CSAR_ARTIFACT))
+ allGroups.addAll(artifactTemplateInfoList);
artifactsMap.put(artifactsTypeKey, artifactTemplateInfoList);
}
int counter = groupBusinessLogic.getNextVfModuleNameCounter(resource.getGroups());
@@ -3602,10 +3639,40 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
originResource = originCompMap.get(currentCompInstance.getComponentUid());
}
- if (originResource.getCapabilities() != null && !originResource.getCapabilities().isEmpty())
- instCapabilties.put(currentCompInstance, originResource.getCapabilities());
if (originResource.getRequirements() != null && !originResource.getRequirements().isEmpty())
instRequirements.put(currentCompInstance, originResource.getRequirements());
+ if (MapUtils.isNotEmpty(originResource.getCapabilities())) {
+ Map<String, List<CapabilityDefinition>> originCapabilities ;
+ if (MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilities())) {
+ originCapabilities = new HashMap<>();
+ originResource.getCapabilities().entrySet().stream().forEach(e ->{
+ List<CapabilityDefinition> list = e.getValue().stream().map(l -> new CapabilityDefinition(l)).collect(Collectors.toList());
+ originCapabilities.put(e.getKey(), list);
+ });
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
+ for(List<UploadCapInfo> capabilities : uploadComponentInstanceInfo.getCapabilities().values()){
+ for(UploadCapInfo capability :capabilities){
+ if(CollectionUtils.isNotEmpty(capability.getProperties())){
+ newPropertiesMap.put(capability.getName(), capability.getProperties().stream().collect(Collectors.toMap(p->p.getName(), p->p)));
+ }
+ }
+ }
+ for (List<CapabilityDefinition> capabilities : originCapabilities.values()) {
+ List<CapabilityDefinition> filteredCapabilities = capabilities.stream().filter(c -> newPropertiesMap.containsKey(c.getName())).collect(Collectors.toList());
+ for(CapabilityDefinition cap : filteredCapabilities){
+ Either<Boolean, ResponseFormat> updateRes = updatePropertyValues(cap.getProperties(),newPropertiesMap.get(cap.getName()), allDataTypes.left().value());
+ if(updateRes.isRight()){
+ log.debug("Failed to update capability properties of capability {} . Status is {}. ", cap.getName(), updateRes.right().value());
+ return Either.right(updateRes.right().value());
+ }
+ }
+ }
+ }
+ else{
+ originCapabilities = originResource.getCapabilities();
+ }
+ instCapabilties.put(currentCompInstance, originCapabilities);
+ }
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts().isEmpty())
instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
if (originResource.getArtifacts() != null && !originResource.getArtifacts().isEmpty())
@@ -3618,14 +3685,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(addPropertiesValueToRiRes);
}
} else {
- Either<Resource, ResponseFormat> genericResourceEither = fetchAndSetDerivedFromGenericType(originResource);
- if (genericResourceEither.isRight()) {
- return genericResourceEither;
- }
- log.trace("************* Going to add inputs from from original resource {} to resource instance. ", originResource.getName());
- if (originResource.shouldGenerateInputs())
- generateInputsFromGenericTypeProperties(originResource, genericResourceEither.left().value());
-
ResponseFormat addInputValueToRiRes = addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, yamlName, instInputs, allDataTypes.left().value());
if (addInputValueToRiRes.getStatus() != 200) {
return Either.right(addInputValueToRiRes);
@@ -3724,25 +3783,54 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(responseFormat);
}
+ if(resource.getResourceType() == ResourceTypeEnum.CVFC){
+ eitherGetResource = toscaOperationFacade.getToscaFullElement(resource.getUniqueId());
+ if (eitherGetResource.isRight()) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
+ return Either.right(responseFormat);
+ }
+ eitherGetResource = updateCalculatedCapReqWithSubstitutionMappings(eitherGetResource.left().value(), uploadResInstancesMap);
+ if (eitherGetResource.isRight()) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
+ return Either.right(responseFormat);
+ }
+ }
+
log.debug("************* in create relations, getResource start");
-
eitherGetResource = toscaOperationFacade.getToscaElement(resource.getUniqueId());
log.debug("************* in create relations, getResource end");
if (eitherGetResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
-
return Either.right(responseFormat);
-
}
- resource = eitherGetResource.left().value();
- if(resource.getResourceType() == ResourceTypeEnum.CVFC){
- eitherGetResource = updateCalculatedCapReqWithSubstitutionMappings(resource, uploadResInstancesMap);
- if (eitherGetResource.isRight()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
- return Either.right(responseFormat);
+ return Either.left(eitherGetResource.left().value());
+ }
+
+ private Either<Boolean, ResponseFormat> updatePropertyValues(List<ComponentInstanceProperty> properties, Map<String, UploadPropInfo> newProperties, Map<String, DataTypeDefinition> allDataTypes) {
+ for(ComponentInstanceProperty property : properties){
+ Either<String, StorageOperationStatus> updateRes = updatePropertyValue(property ,newProperties.get(property.getName()), allDataTypes);
+ if(updateRes.isRight()){
+ log.debug("Failed to update capability property {} . Status is {}. ", property.getName(), updateRes.right().value());
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateRes.right().value())));
}
}
- return Either.left(eitherGetResource.left().value());
+ return Either.left(true);
+ }
+
+ private Either<String, StorageOperationStatus> updatePropertyValue(ComponentInstanceProperty property, UploadPropInfo propertyInfo, Map<String, DataTypeDefinition> allDataTypes) {
+ String value = null;
+ List<GetInputValueDataDefinition> getInputs = null;
+ boolean isValidate = true;
+ if (null != propertyInfo && null != propertyInfo.getValue()) {
+ getInputs = propertyInfo.getGet_input();
+ isValidate = getInputs == null || getInputs.isEmpty();
+ if (isValidate) {
+ value = ImportUtils.getPropertyJsonStringValue(propertyInfo.getValue(), property.getType());
+ } else
+ value = ImportUtils.getPropertyJsonStringValue(propertyInfo.getValue(), ToscaTagNamesEnum.GET_INPUT.getElementName());
+ }
+ property.setValue(value);
+ return validatePropValueBeforeCreate(property, value, isValidate, null, allDataTypes);
}
private Either<Resource, StorageOperationStatus> updateCalculatedCapReqWithSubstitutionMappings(Resource resource, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
@@ -3763,7 +3851,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
if(updateRes == null){
- updateRes = toscaOperationFacade.getToscaElement( resource.getUniqueId());
+ updateRes = Either.left(resource);
}
return updateRes;
}
@@ -4010,25 +4098,28 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private ResponseFormat addPropertyValuesToRi(UploadComponentInstanceInfo uploadComponentInstanceInfo, Resource resource, Resource originResource, ComponentInstance currentCompInstance, String yamlName,
- Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, DataTypeDefinition> allDataTypes) {
+ Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, DataTypeDefinition> allDataTypes) {
Map<String, List<UploadPropInfo>> propMap = uploadComponentInstanceInfo.getProperties();
- if (propMap != null && propMap.size() > 0) {
- Map<String, PropertyDefinition> currPropertiesMap = new HashMap<String, PropertyDefinition>();
+ Map<String, PropertyDefinition> currPropertiesMap = new HashMap<String, PropertyDefinition>();
- List<PropertyDefinition> listFromMap = originResource.getProperties();
- if (listFromMap == null || listFromMap.isEmpty()) {
- log.debug("failed to find properties ");
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND);
- return responseFormat;
- }
- for (PropertyDefinition prop : listFromMap) {
- String propName = prop.getName();
- if (!currPropertiesMap.containsKey(propName)) {
- currPropertiesMap.put(propName, prop);
- }
+ List<PropertyDefinition> listFromMap = originResource.getProperties();
+ if ((propMap != null && !propMap.isEmpty()) && (listFromMap == null || listFromMap.isEmpty())) {
+ log.debug("failed to find properties ");
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND);
+ return responseFormat;
+ }
+ if(listFromMap == null || listFromMap.isEmpty()){
+ return componentsUtils.getResponseFormat(ActionStatus.OK);
+ }
+ for (PropertyDefinition prop : listFromMap) {
+ String propName = prop.getName();
+ if (!currPropertiesMap.containsKey(propName)) {
+ currPropertiesMap.put(propName, prop);
}
- List<ComponentInstanceProperty> instPropList = new ArrayList<>();
+ }
+ List<ComponentInstanceProperty> instPropList = new ArrayList<>();
+ if (propMap != null && propMap.size() > 0) {
for (List<UploadPropInfo> propertyList : propMap.values()) {
UploadPropInfo propertyInfo = propertyList.get(0);
@@ -4104,14 +4195,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// delete overriden property
currPropertiesMap.remove(property.getName());
}
- // add rest of properties
- if (!currPropertiesMap.isEmpty()) {
- for (PropertyDefinition value : currPropertiesMap.values()) {
- instPropList.add(new ComponentInstanceProperty(value));
- }
+ }
+ // add rest of properties
+ if (!currPropertiesMap.isEmpty()) {
+ for (PropertyDefinition value : currPropertiesMap.values()) {
+ instPropList.add(new ComponentInstanceProperty(value));
}
- instProperties.put(currentCompInstance.getUniqueId(), instPropList);
}
+ instProperties.put(currentCompInstance.getUniqueId(), instPropList);
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
@@ -4264,6 +4355,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(validRegDef);
}
+ @SuppressWarnings("unchecked")
public Either<ParsedToscaYamlInfo, ResponseFormat> parseResourceInfoFromYaml(String yamlFileName, Resource resource, String resourceYml, Map<String, String> createdNodesToscaResourceNames, Map<String, NodeTypeInfo> nodeTypesInfo, String nodeName) {
Map<String, Object> mappedToscaTemplate;
@@ -4317,7 +4409,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Resource> nodeNamespaceMap) {
Either<Resource, ResponseFormat> eitherResource = null;
- log.debug("{} - going to create resource instanse from CSAR", yamlName);
+ log.debug("createResourceInstances is {} - going to create resource instanse from CSAR", yamlName);
if (uploadResInstancesMap == null || uploadResInstancesMap.isEmpty()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE);
@@ -4332,13 +4424,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Iterator<Entry<String, UploadComponentInstanceInfo>> nodesInfoValue = uploadResInstancesMap.entrySet().iterator();
Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>();
while (nodesInfoValue.hasNext()) {
- log.debug("*************Going to create resource instances from {}", yamlName);
+ log.debug("*************Going to create resource instances {}", yamlName);
Entry<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoEntry = nodesInfoValue.next();
UploadComponentInstanceInfo uploadComponentInstanceInfo = uploadComponentInstanceInfoEntry.getValue();
// updating type if the type is node type name - we need to take the
// updated name
- log.debug("*************Going to create resource instance {}", uploadComponentInstanceInfo.getName());
+ log.debug("*************Going to create resource instances {}", uploadComponentInstanceInfo.getName());
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
uploadComponentInstanceInfo.setType(nodeNamespaceMap.get(uploadComponentInstanceInfo.getType()).getToscaResourceName());
}
@@ -4355,7 +4447,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ComponentTypeEnum containerComponentType = resource.getComponentType();
NodeTypeEnum containerNodeType = containerComponentType.getNodeType();
- //************
+
if (containerNodeType.equals(NodeTypeEnum.Resource) && MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilities()) && MapUtils.isNotEmpty(refResource.getCapabilities())) {
setCapabilityNamesTypes(refResource.getCapabilities(), uploadComponentInstanceInfo.getCapabilities());
Either<Map<String, List<CapabilityDefinition>>, ResponseFormat> getValidComponentInstanceCapabilitiesRes = getValidComponentInstanceCapabilities(refResource.getUniqueId(), refResource.getCapabilities(), uploadComponentInstanceInfo.getCapabilities());
@@ -4365,9 +4457,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
componentInstance.setCapabilities(getValidComponentInstanceCapabilitiesRes.left().value());
}
}
- //***********************
if (!existingnodeTypeMap.containsKey(uploadComponentInstanceInfo.getType())) {
- log.debug("createResourceInstances - not found latest version for resource instance with name {} and type ", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ log.debug("createResourceInstances - not found lates version for resource instance with name {} and type ", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
return Either.right(responseFormat);
}
@@ -4417,30 +4508,28 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(eitherGerResource.left().value());
}
-
+
private void setCapabilityNamesTypes(Map<String, List<CapabilityDefinition>> originCapabilities, Map<String, List<UploadCapInfo>> uploadedCapabilities) {
for(Entry<String, List<UploadCapInfo>> currEntry : uploadedCapabilities.entrySet()){
if(originCapabilities.containsKey(currEntry.getKey())){
currEntry.getValue().stream().forEach(cap -> cap.setType(currEntry.getKey()));
}
}
-
for(Map.Entry<String, List<CapabilityDefinition>> capabilities : originCapabilities.entrySet()){
capabilities.getValue().stream().forEach(cap -> {if(uploadedCapabilities.containsKey(cap.getName())){uploadedCapabilities.get(cap.getName()).stream().forEach(c -> {c.setName(cap.getName());c.setType(cap.getType());});};});
- }
+ }
+
}
-
-
private Either<Resource, ResponseFormat> validateResourceInstanceBeforeCreate(String yamlName, UploadComponentInstanceInfo uploadComponentInstanceInfo, Map<String, Resource> nodeNamespaceMap) {
- log.debug("going to validate resource instance with name {} and type {} before create", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ log.debug("validateResourceInstanceBeforeCreate - going to validate resource instance with name {} and type before create", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
Resource refResource = null;
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType());
} else {
Either<Resource, StorageOperationStatus> findResourceEither = toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(uploadComponentInstanceInfo.getType());
if (findResourceEither.isRight()) {
- log.debug("not found lates version for resource instance with name {} and type {}", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ log.debug("validateResourceInstanceBeforeCreate - not found lates version for resource instance with name {} and type ", uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
return Either.right(responseFormat);
}
@@ -4449,17 +4538,16 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
String componentState = refResource.getComponentMetadataDefinition().getMetadataDataDefinition().getState();
if (componentState.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
- log.debug("component instance of component {} can not be created because the component is in an illegal state {}.", refResource.getName(), componentState);
+ log.debug("validateResourceInstanceBeforeCreate - component instance of component {} can not be created because the component is in an illegal state {}.", refResource.getName(), componentState);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, refResource.getComponentType().getValue(), refResource.getName(), componentState);
return Either.right(responseFormat);
}
- if (!ToscaUtils.isAtomicType(refResource) && refResource.getResourceType() != ResourceTypeEnum.CVFC) {
- log.debug("ref resource type is {}", refResource.getResourceType());
+ if (!ModelConverter.isAtomicComponent(refResource) && refResource.getResourceType() != ResourceTypeEnum.CVFC) {
+ log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", refResource.getResourceType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
return Either.right(responseFormat);
}
- log.debug("validate resource instance with name {} and type {} before create, successful",uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
return Either.left(refResource);
}
@@ -4788,32 +4876,30 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
-
@SuppressWarnings("unchecked")
- private Either<Map<String, List<UploadCapInfo>>, ResponseFormat> createCapModuleFromYaml(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
- Map<String, List<UploadCapInfo>> moduleCap = new HashMap<String, List<UploadCapInfo>>();
- Either<Map<String, List<UploadCapInfo>>, ResponseFormat> response = Either.left(moduleCap);
- Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils.findFirstToscaListElement(nodeTemplateJsonMap, ToscaTagNamesEnum.CAPABILITIES);
- if (toscaRequirements.isLeft()) {
- List<Object> jsonCapabilities = toscaRequirements.left().value();
-
- for (Object jsonCapObj : jsonCapabilities) {
- // Requirement
- Map<String, Object> capJsonWrapper = (Map<String, Object>) jsonCapObj;
- String capName = capJsonWrapper.keySet().iterator().next();
- Either<UploadCapInfo, ResponseFormat> eitherCap = createModuleNodeTemplateCap(capJsonWrapper.get(capName));
+ private Either<Map<String, List<UploadReqInfo>>, ResponseFormat> createReqModuleFromYaml(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
+ Map<String, List<UploadReqInfo>> moduleRequirements = new HashMap<String, List<UploadReqInfo>>();
+ Either<Map<String, List<UploadReqInfo>>, ResponseFormat> response = Either.left(moduleRequirements);
+ Either<List<Object>, ResultStatusEnum> requirementsListRes = ImportUtils.findFirstToscaListElement(nodeTemplateJsonMap, ToscaTagNamesEnum.REQUIREMENTS);
+
+ if (requirementsListRes.isLeft()) {
+ for (Object jsonReqObj : requirementsListRes.left().value()) {
+ String reqName = ((Map<String, Object>) jsonReqObj).keySet().iterator().next();
+ Object reqJson = ((Map<String, Object>) jsonReqObj).get(reqName);
+ Either<UploadReqInfo, ResponseFormat> eitherCap = addModuleNodeTemplateReq(nodeTemplateInfo, moduleRequirements, reqJson, reqName);
if (eitherCap.isRight()) {
- log.info("error when creating Requirement:{}, for node:{}", capName, nodeTemplateInfo);
return Either.right(eitherCap.right().value());
- } else {
- UploadCapInfo requirementDef = eitherCap.left().value();
- requirementDef.setName(capName);
- if (moduleCap.containsKey(capName)) {
- moduleCap.get(capName).add(requirementDef);
- } else {
- List<UploadCapInfo> list = new ArrayList<UploadCapInfo>();
- list.add(requirementDef);
- moduleCap.put(capName, list);
+ }
+ }
+ } else {
+ Either<Map<String,Object>, ResultStatusEnum> requirementsMapRes = ImportUtils.findFirstToscaMapElement(nodeTemplateJsonMap, ToscaTagNamesEnum.REQUIREMENTS);
+ if (requirementsMapRes.isLeft()) {
+ for (Map.Entry<String, Object> entry: requirementsMapRes.left().value().entrySet()) {
+ String reqName = entry.getKey();
+ Object reqJson = entry.getValue();
+ Either<UploadReqInfo, ResponseFormat> eitherCap = addModuleNodeTemplateReq(nodeTemplateInfo, moduleRequirements, reqJson, reqName);
+ if (eitherCap.isRight()) {
+ return Either.right(eitherCap.right().value());
}
}
}
@@ -4821,31 +4907,49 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return response;
}
- @SuppressWarnings("unchecked")
- private Either<Map<String, List<UploadReqInfo>>, ResponseFormat> createReqModuleFromYaml(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
- Map<String, List<UploadReqInfo>> moduleRequirements = new HashMap<String, List<UploadReqInfo>>();
- Either<Map<String, List<UploadReqInfo>>, ResponseFormat> response = Either.left(moduleRequirements);
- Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils.findFirstToscaListElement(nodeTemplateJsonMap, ToscaTagNamesEnum.REQUIREMENTS);
- if (toscaRequirements.isLeft()) {
- List<Object> jsonRequirements = toscaRequirements.left().value();
-
- for (Object jsonRequirementObj : jsonRequirements) {
- // Requirement
- Map<String, Object> requirementJsonWrapper = (Map<String, Object>) jsonRequirementObj;
- String requirementName = requirementJsonWrapper.keySet().iterator().next();
- Either<UploadReqInfo, ResponseFormat> eitherRequirement = createModuleNodeTemplateReg(requirementJsonWrapper.get(requirementName));
- if (eitherRequirement.isRight()) {
- log.info("error when creating Requirement:{}, for node:{}", requirementName, nodeTemplateInfo);
- return Either.right(eitherRequirement.right().value());
- } else {
- UploadReqInfo requirementDef = eitherRequirement.left().value();
- requirementDef.setName(requirementName);
- if (moduleRequirements.containsKey(requirementName)) {
- moduleRequirements.get(requirementName).add(requirementDef);
- } else {
- List<UploadReqInfo> list = new ArrayList<UploadReqInfo>();
- list.add(requirementDef);
- moduleRequirements.put(requirementName, list);
+ private Either<UploadReqInfo, ResponseFormat> addModuleNodeTemplateReq(UploadComponentInstanceInfo nodeTemplateInfo,Map<String, List<UploadReqInfo>> moduleRequirements, Object requirementJson, String requirementName) {
+
+ Either<UploadReqInfo, ResponseFormat> eitherRequirement = createModuleNodeTemplateReg(requirementJson);
+ if (eitherRequirement.isRight()) {
+ log.info("error when creating Requirement:{}, for node:{}", requirementName, nodeTemplateInfo);
+ return Either.right(eitherRequirement.right().value());
+ } else {
+ UploadReqInfo requirementDef = eitherRequirement.left().value();
+ requirementDef.setName(requirementName);
+ if (moduleRequirements.containsKey(requirementName)) {
+ moduleRequirements.get(requirementName).add(requirementDef);
+ } else {
+ List<UploadReqInfo> list = new ArrayList<UploadReqInfo>();
+ list.add(requirementDef);
+ moduleRequirements.put(requirementName, list);
+ }
+ }
+ return Either.left(eitherRequirement.left().value());
+ }
+
+ @SuppressWarnings("unchecked")
+ private Either<Map<String, List<UploadCapInfo>>, ResponseFormat> createCapModuleFromYaml(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
+ Map<String, List<UploadCapInfo>> moduleCap = new HashMap<>();
+ Either<Map<String, List<UploadCapInfo>>, ResponseFormat> response = Either.left(moduleCap);
+ Either<List<Object>, ResultStatusEnum> capabilitiesListRes = ImportUtils.findFirstToscaListElement(nodeTemplateJsonMap, ToscaTagNamesEnum.CAPABILITIES);
+ if (capabilitiesListRes.isLeft()) {
+ for (Object jsonCapObj : capabilitiesListRes.left().value()) {
+ String key = ((Map<String, Object>) jsonCapObj).keySet().iterator().next();
+ Object capJson = ((Map<String, Object>) jsonCapObj).get(key);
+ Either<UploadCapInfo, ResponseFormat> eitherCap = addModuleNodeTemplateCap(nodeTemplateInfo, moduleCap, capJson, key);
+ if (eitherCap.isRight()) {
+ return Either.right(eitherCap.right().value());
+ }
+ }
+ } else {
+ Either<Map<String,Object>, ResultStatusEnum> capabilitiesMapRes = ImportUtils.findFirstToscaMapElement(nodeTemplateJsonMap, ToscaTagNamesEnum.CAPABILITIES);
+ if (capabilitiesMapRes.isLeft()) {
+ for (Map.Entry<String, Object> entry: capabilitiesMapRes.left().value().entrySet()) {
+ String capName = entry.getKey();
+ Object capJson = entry.getValue();
+ Either<UploadCapInfo, ResponseFormat> eitherCap = addModuleNodeTemplateCap(nodeTemplateInfo, moduleCap, capJson, capName);
+ if (eitherCap.isRight()) {
+ return Either.right(eitherCap.right().value());
}
}
}
@@ -4853,6 +4957,26 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return response;
}
+ private Either<UploadCapInfo, ResponseFormat> addModuleNodeTemplateCap(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, List<UploadCapInfo>> moduleCap, Object capJson, String key) {
+
+ Either<UploadCapInfo, ResponseFormat> eitherCap = createModuleNodeTemplateCap(capJson);
+ if (eitherCap.isRight()) {
+ log.info("error when creating Capability:{}, for node:{}", key, nodeTemplateInfo);
+ return Either.right(eitherCap.right().value());
+ } else {
+ UploadCapInfo capabilityDef = eitherCap.left().value();
+ capabilityDef.setKey(key);
+ if (moduleCap.containsKey(key)) {
+ moduleCap.get(key).add(capabilityDef);
+ } else {
+ List<UploadCapInfo> list = new ArrayList<UploadCapInfo>();
+ list.add(capabilityDef);
+ moduleCap.put(key, list);
+ }
+ }
+ return Either.left( eitherCap.left().value());
+ }
+
@SuppressWarnings("unchecked")
private Either<UploadCapInfo, ResponseFormat> createModuleNodeTemplateCap(Object capObject) {
UploadCapInfo capTemplateInfo = new UploadCapInfo();
@@ -5065,6 +5189,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
result = Either.right(validateFieldsResponse.right().value());
return result;
}
+
+ validateFieldsResponse = validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
+ if (validateFieldsResponse.isRight()) {
+ return Either.right(validateFieldsResponse.right().value());
+ }
// contact info normalization
newResource.setContactId(newResource.getContactId().toLowerCase());
@@ -5201,7 +5330,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.setCreatorUserId(user.getUserId());
resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
resource.setContactId(resource.getContactId().toLowerCase());
- if (StringUtils.isEmpty(resource.getToscaResourceName()) && !ToscaUtils.isAtomicType(resource)) {
+ if (StringUtils.isEmpty(resource.getToscaResourceName()) && !ModelConverter.isAtomicComponent(resource)) {
String resourceSystemName;
if(csarInfo != null && StringUtils.isNotEmpty(csarInfo.getVfResourceName())){
resourceSystemName = ValidationUtils.convertToSystemName(csarInfo.getVfResourceName());
@@ -5370,11 +5499,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
try {
if (resource.deriveFromGeneric()) {
- Either<Resource, ResponseFormat> genericResourceEither = fetchAndSetDerivedFromGenericType(resource);
+ Either<Resource, ResponseFormat> genericResourceEither = handleResourceGenericType(resource);
if (genericResourceEither.isRight())
return genericResourceEither;
- if (resource.shouldGenerateInputs())
- generateInputsFromGenericTypeProperties(resource, genericResourceEither.left().value());
}
Either<Resource, ResponseFormat> respStatus = createResourceTransaction(resource, user, isNormative, inTransaction);
@@ -5739,7 +5866,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// list
// This code is not called from import resources, because of root
// VF "derivedFrom" should be null (or ignored)
- if (ToscaUtils.isAtomicType(currentResource)) {
+ if (ModelConverter.isAtomicComponent(currentResource)) {
Either<Boolean, ResponseFormat> derivedFromNotEmptyEither = validateDerivedFromNotEmpty(null, newResource, null);
if (derivedFromNotEmptyEither.isRight()) {
log.debug("for updated resource {}, derived from field is empty", newResource.getName());
@@ -5953,7 +6080,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// validate template (derived from)
log.debug("validate derived from");
- if (!ToscaUtils.isAtomicType(resource) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
+ if (!ModelConverter.isAtomicComponent(resource) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
resource.setDerivedFrom(null);
}
eitherValidation = validateDerivedFromExist(user, resource, actionEnum);
@@ -6173,10 +6300,23 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* return Either.left(true); }
*/
- private Either<Boolean, ResponseFormat> validateResourceName(Resource currentResource, Resource updateInfoResource, boolean hasBeenCertified) {
+ private boolean isResourceNameEquals(Resource currentResource, Resource updateInfoResource) {
String resourceNameUpdated = updateInfoResource.getName();
String resourceNameCurrent = currentResource.getName();
- if (!resourceNameCurrent.equals(resourceNameUpdated)) {
+ if (resourceNameCurrent.equals(resourceNameUpdated))
+ return true;
+ // In case of CVFC type we should support the case of old VF with CVFC instances that were created without the "Cvfc" suffix
+ return (currentResource.getResourceType().equals(ResourceTypeEnum.CVFC)
+ && resourceNameUpdated.equals(addCvfcSuffixToResourceName(resourceNameCurrent)));
+ }
+
+ private String addCvfcSuffixToResourceName(String resourceName) {
+ return resourceName+"Cvfc";
+ }
+
+ private Either<Boolean, ResponseFormat> validateResourceName(Resource currentResource, Resource updateInfoResource, boolean hasBeenCertified) {
+ String resourceNameUpdated = updateInfoResource.getName();
+ if (!isResourceNameEquals(currentResource, updateInfoResource)) {
if (!hasBeenCertified) {
Either<Boolean, ResponseFormat> validateResourceNameResponse = validateComponentName(null, updateInfoResource, null);
if (validateResourceNameResponse.isRight()) {
@@ -7222,5 +7362,20 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
UiComponentDataTransfer dataTransfer = UiComponentDataConverter.getUiDataTransferFromResourceByParams(resource, dataParamsToReturn);
return Either.left(dataTransfer);
}
+ @Override
+ public Either<Component, ActionStatus> shouldUpgradeToLatestDerived(Component clonedComponent) {
+ Resource resource = (Resource) clonedComponent;
+ if (ModelConverter.isAtomicComponent(resource.getResourceType())) {
+ Either<Component, StorageOperationStatus> shouldUpgradeToLatestDerived = toscaOperationFacade.shouldUpgradeToLatestDerived(resource);
+ if (shouldUpgradeToLatestDerived.isRight()) {
+ return Either.right(componentsUtils.convertFromStorageResponse(shouldUpgradeToLatestDerived.right().value()));
+ }
+ return Either.left(shouldUpgradeToLatestDerived.left().value());
+ } else {
+ return super.shouldUpgradeToLatestDerived(clonedComponent);
+ }
+ }
+
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java
index fa051a9e3d..0f1bf4603d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java
@@ -49,11 +49,11 @@ public class ArtifactTemplateInfo {
public static final String ENV = "env";
public static final String IS_BASE = "isBase";
- private static final String CSAR_HEAT = "HEAT";
- private static final String CSAR_ARTIFACT = "artifacts";
- private static final String CSAR_NETWORK = "network";
- private static final String CSAR_VOLUME = "volume";
- private static final String CSAR_NESTED = "nested";
+ public static final String CSAR_HEAT = "HEAT";
+ public static final String CSAR_ARTIFACT = "artifacts";
+ public static final String CSAR_NETWORK = "network";
+ public static final String CSAR_VOLUME = "volume";
+ public static final String CSAR_NESTED = "nested";
private static final Object DESC = "description";
private static Logger log = LoggerFactory.getLogger(ArtifactTemplateInfo.class.getName());
String type;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
index 649f083903..41268188f9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
@@ -22,11 +22,16 @@
package org.openecomp.sdc.be.tosca;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
@@ -34,9 +39,14 @@ import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.tosca.ToscaUtils.SubstituitionEntry;
import org.openecomp.sdc.be.tosca.model.SubstitutionMapping;
import org.openecomp.sdc.be.tosca.model.ToscaCapability;
import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate;
@@ -47,14 +57,29 @@ import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import fj.data.Either;
-
+/**
+ * Allows to convert requirements\capabilities of a component to requirements\capabilities of a substitution mappings section of a tosca template
+ *
+ */
+@org.springframework.stereotype.Component("capabilty-requirement-convertor")
+@Scope(value = "singleton")
public class CapabiltyRequirementConvertor {
+
+ private static final String NO_CAPABILITIES = "No Capabilities for node type";
private static CapabiltyRequirementConvertor instance;
- public final static String PATH_DELIMITER = ".";
+ private static Logger logger = LoggerFactory.getLogger(CapabiltyRequirementConvertor.class.getName());
+ public static final String PATH_DELIMITER = ".";
+
+ @Autowired
+ private ToscaOperationFacade toscaOperationFacade;
protected CapabiltyRequirementConvertor() {
@@ -66,9 +91,13 @@ public class CapabiltyRequirementConvertor {
}
return instance;
}
-
- private static Logger log = LoggerFactory.getLogger(CapabiltyRequirementConvertor.class.getName());
-
+ /**
+ * Allows to convert capabilities of a component to capabilities of a substitution mappings section of a tosca template
+ * @param componentInstance
+ * @param dataTypes
+ * @param nodeTemplate
+ * @return
+ */
public Either<ToscaNodeTemplate, ToscaError> convertComponentInstanceCapabilties(ComponentInstance componentInstance, Map<String, DataTypeDefinition> dataTypes, ToscaNodeTemplate nodeTemplate) {
Map<String, List<CapabilityDefinition>> capabilitiesInst = componentInstance.getCapabilities();
@@ -77,12 +106,10 @@ public class CapabiltyRequirementConvertor {
capabilitiesInst.entrySet().forEach(e -> {
List<CapabilityDefinition> capList = e.getValue();
if (capList != null && !capList.isEmpty()) {
- capList.forEach(c -> {
- convertOverridenProperties(componentInstance, dataTypes, capabilties, c);
- });
+ capList.forEach(c -> convertOverridenProperties(componentInstance, dataTypes, capabilties, c));
}
});
- if (capabilties != null && !capabilties.isEmpty()) {
+ if (MapUtils.isNotEmpty(capabilties)) {
nodeTemplate.setCapabilities(capabilties);
}
}
@@ -92,15 +119,16 @@ public class CapabiltyRequirementConvertor {
private void convertOverridenProperties(ComponentInstance componentInstance, Map<String, DataTypeDefinition> dataTypes, Map<String, ToscaTemplateCapability> capabilties, CapabilityDefinition c) {
List<ComponentInstanceProperty> properties = c.getProperties();
if (properties != null && !properties.isEmpty()) {
- properties.stream().filter(p -> (p.getValueUniqueUid() != null)).forEach(p -> {
- convertOverridenProperty(componentInstance, dataTypes, capabilties, c, p);
- });
+ properties
+ .stream()
+ .filter(p -> p.getValue() != null || p.getDefaultValue() != null)
+ .forEach(p -> convertOverridenProperty(componentInstance, dataTypes, capabilties, c, p));
}
}
private void convertOverridenProperty(ComponentInstance componentInstance, Map<String, DataTypeDefinition> dataTypes, Map<String, ToscaTemplateCapability> capabilties, CapabilityDefinition c, ComponentInstanceProperty p) {
- if (log.isDebugEnabled()) {
- log.debug("Exist overriden property {} for capabity {} with value {}", p.getName(), c.getName(), p.getValue());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Exist overriden property {} for capabity {} with value {}", p.getName(), c.getName(), p.getValue());
}
ToscaTemplateCapability toscaTemplateCapability = capabilties.get(c.getName());
if (toscaTemplateCapability == null) {
@@ -117,109 +145,224 @@ public class CapabiltyRequirementConvertor {
}
private Object convertInstanceProperty(Map<String, DataTypeDefinition> dataTypes, ComponentInstance componentInstance, ComponentInstanceProperty prop) {
- log.debug("Convert property {} for instance {}", prop.getName(), componentInstance.getUniqueId());
+ logger.debug("Convert property {} for instance {}", prop.getName(), componentInstance.getUniqueId());
String propertyType = prop.getType();
String innerType = null;
if (prop.getSchema() != null && prop.getSchema().getProperty() != null) {
innerType = prop.getSchema().getProperty().getType();
}
- Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getValue(), innerType, dataTypes);
- return convertedValue;
+ String propValue = prop.getValue() == null ? prop.getDefaultValue() : prop.getValue();
+ return PropertyConvertor.getInstance().convertToToscaObject(propertyType, propValue, innerType, dataTypes);
}
-
+ /**
+ * Allows to convert requirements of a node type to tosca template requirements representation
+ * @param component
+ * @param nodeType
+ * @return
+ */
public Either<ToscaNodeType, ToscaError> convertRequirements(Component component, ToscaNodeType nodeType) {
List<Map<String, ToscaRequirement>> toscaRequirements = convertRequirementsAsList(component);
if (!toscaRequirements.isEmpty()) {
nodeType.setRequirements(toscaRequirements);
}
- log.debug("Finish convert Requirements for node type");
+ logger.debug("Finish convert Requirements for node type");
return Either.left(nodeType);
}
- public Either<SubstitutionMapping, ToscaError> convertSubstitutionMappingRequirements(Component component, SubstitutionMapping substitutionMapping) {
- Map<String, String[]> toscaRequirements = convertSubstitutionMappingRequirementsAsMap(component);
- if (!toscaRequirements.isEmpty()) {
- substitutionMapping.setRequirements(toscaRequirements);
+ /**
+ * Allows to convert component requirements to the tosca template substitution mappings requirements
+ * @param componentsCache
+ * @param component
+ * @param substitutionMappings
+ * @return
+ */
+ public Either<SubstitutionMapping, ToscaError> convertSubstitutionMappingRequirements(Map<String,Component> componentsCache, Component component, SubstitutionMapping substitutionMappings) {
+ Either<SubstitutionMapping, ToscaError> result = Either.left(substitutionMappings);
+ Either<Map<String, String[]>, ToscaError> toscaRequirementsRes = convertSubstitutionMappingRequirementsAsMap(componentsCache, component);
+ if(toscaRequirementsRes.isRight()){
+ result = Either.right(toscaRequirementsRes.right().value());
+ logger.error("Failed convert requirements for the component {}. ", component.getName());
+ } else if (MapUtils.isNotEmpty(toscaRequirementsRes.left().value())) {
+ substitutionMappings.setRequirements(toscaRequirementsRes.left().value());
+ result = Either.left(substitutionMappings);
+ logger.debug("Finish convert requirements for the component {}. ", component.getName());
}
- log.debug("Finish convert Requirements for node type");
-
- return Either.left(substitutionMapping);
+ return result;
}
private List<Map<String, ToscaRequirement>> convertRequirementsAsList(Component component) {
Map<String, List<RequirementDefinition>> requirements = component.getRequirements();
List<Map<String, ToscaRequirement>> toscaRequirements = new ArrayList<>();
if (requirements != null) {
- boolean isNodeType = ToscaUtils.isAtomicType(component);
for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) {
- entry.getValue().stream().filter(r -> (!isNodeType || (isNodeType && component.getUniqueId().equals(r.getOwnerId())) || (isNodeType && r.getOwnerId() == null))).forEach(r -> {
- ImmutablePair<String, ToscaRequirement> pair = convertRequirement(component, isNodeType, r);
+ entry.getValue().stream().filter(r -> filter(component, r.getOwnerId())).forEach(r -> {
+ ImmutablePair<String, ToscaRequirement> pair = convertRequirement(component, ModelConverter.isAtomicComponent(component), r);
Map<String, ToscaRequirement> requirement = new HashMap<>();
requirement.put(pair.left, pair.right);
toscaRequirements.add(requirement);
});
-
- log.debug("Finish convert Requirements for node type");
+ logger.debug("Finish convert Requirements for node type");
}
} else {
- log.debug("No Requirements for node type");
+ logger.debug("No Requirements for node type");
}
return toscaRequirements;
}
- private String getSubPathByFirstDelimiterAppearance(String path) {
- return path.substring(path.indexOf(PATH_DELIMITER) + 1);
+ private boolean filter(Component component, String ownerId) {
+ return !ModelConverter.isAtomicComponent(component) || isNodeTypeOwner(component, ownerId) || (ModelConverter.isAtomicComponent(component) && ownerId == null);
+ }
+
+ private boolean isNodeTypeOwner(Component component, String ownerId) {
+ return ModelConverter.isAtomicComponent(component) && component.getUniqueId().equals(ownerId);
}
private String getSubPathByLastDelimiterAppearance(String path) {
return path.substring(path.lastIndexOf(PATH_DELIMITER) + 1);
}
-
- //This function calls on Substitution Mapping region - the component is always non-atomic
- private Map<String, String[]> convertSubstitutionMappingRequirementsAsMap(Component component) {
+
+ private Either<Map<String, String[]>, ToscaError> convertSubstitutionMappingRequirementsAsMap(Map<String, Component> componentsCache, Component component) {
Map<String, List<RequirementDefinition>> requirements = component.getRequirements();
- Map<String, String[]> toscaRequirements = new HashMap<>();
+ Either<Map<String, String[]>, ToscaError> result;
if (requirements != null) {
- for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) {
- entry.getValue().stream().forEach(r -> {
- String fullReqName;
- String sourceCapName;
- if(ToscaUtils.isComplexVfc(component)){
- fullReqName = r.getName();
- sourceCapName = r.getParentName();
- } else {
- fullReqName = getRequirementPath(r);
- sourceCapName = getSubPathByFirstDelimiterAppearance(fullReqName);
- }
- log.debug("the requirement {} belongs to resource {} ", fullReqName, component.getUniqueId());
- if(sourceCapName!= null){
- toscaRequirements.put(fullReqName, new String[]{r.getOwnerName(), sourceCapName});
- }
- });
- log.debug("Finish convert Requirements for node type");
- }
+ result = buildAddSubstitutionMappingsRequirements(componentsCache, component, requirements);
} else {
- log.debug("No Requirements for node type");
+ result = Either.left(Maps.newHashMap());
+ logger.debug("No requirements for substitution mappings section of a tosca template of the component {}. ", component.getName());
}
- return toscaRequirements;
+ return result;
}
- private String getRequirementPath(RequirementDefinition r) {
- List<String> pathArray = Lists.reverse(r.getPath().stream()
- .map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path)))
- .collect(Collectors.toList()));
- return new StringBuilder().append(String.join(PATH_DELIMITER, pathArray)).append(PATH_DELIMITER).append(r.getName()).toString();
+ private Either<Map<String, String[]>, ToscaError> buildAddSubstitutionMappingsRequirements(Map<String, Component> componentsCache, Component component, Map<String, List<RequirementDefinition>> requirements) {
+
+ Map<String, String[]> toscaRequirements = new HashMap<>();
+ Either<Map<String, String[]>, ToscaError> result = null;
+ for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) {
+ Optional<RequirementDefinition> failedToAddRequirement = entry.getValue()
+ .stream()
+ .filter(r->!addEntry(componentsCache, toscaRequirements, component, r.getName(), r.getParentName(), r.getPath()))
+ .findAny();
+ if(failedToAddRequirement.isPresent()){
+ logger.error("Failed to convert requirement {} for substitution mappings section of a tosca template of the component {}. ",
+ failedToAddRequirement.get().getName(), component.getName());
+ result = Either.right(ToscaError.NODE_TYPE_REQUIREMENT_ERROR);
+ }
+ logger.debug("Finish convert requirements for the component {}. ", component.getName());
+ }
+ if(result == null){
+ result = Either.left(toscaRequirements);
+ }
+ return result;
+ }
+
+ private Either<Map<String, String[]>, ToscaError> buildAddSubstitutionMappingsCapabilities(Map<String, Component> componentsCache, Component component, Map<String, List<CapabilityDefinition>> capabilities) {
+ Map<String, String[]> toscaRequirements = new HashMap<>();
+ Either<Map<String, String[]>, ToscaError> result = null;
+ for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
+ Optional<CapabilityDefinition> failedToAddRequirement = entry.getValue()
+ .stream()
+ .filter(c->!addEntry(componentsCache, toscaRequirements, component, c.getName(), c.getParentName(), c.getPath()))
+ .findAny();
+ if(failedToAddRequirement.isPresent()){
+ logger.error("Failed to convert capalility {} for substitution mappings section of a tosca template of the component {}. ",
+ failedToAddRequirement.get().getName(), component.getName());
+ result = Either.right(ToscaError.NODE_TYPE_CAPABILITY_ERROR);
+ }
+ logger.debug("Finish convert capalilities for the component {}. ", component.getName());
+ }
+ if(result == null){
+ result = Either.left(toscaRequirements);
+ }
+ return result;
}
+ private boolean addEntry(Map<String,Component> componentsCache, Map<String, String[]> capReqMap, Component component, String name, String parentName, List<String> path){
+
+ SubstituitionEntry entry = new SubstituitionEntry(name, parentName, "");
+
+ if(shouldBuildSubstitutionName(component, path) && !buildSubstitutedNamePerInstance(componentsCache, component, name, path, entry)){
+ return false;
+ }
+ logger.debug("The requirement/capability {} belongs to the component {} ", entry.getFullName(), component.getUniqueId());
+ if (entry.getSourceName() != null) {
+ addEntry(capReqMap, component, path, entry);
+ }
+ logger.debug("Finish convert the requirement/capability {} for the component {}. ", entry.getFullName(), component.getName());
+ return true;
+
+ }
+
+ private boolean shouldBuildSubstitutionName(Component component, List<String> path) {
+ return !ToscaUtils.isComplexVfc(component) && CollectionUtils.isNotEmpty(path) && path.iterator().hasNext();
+ }
+
+ private boolean buildSubstitutedNamePerInstance(Map<String, Component> componentsCache, Component component, String name, List<String> path, SubstituitionEntry entry) {
+ Optional<ComponentInstance> ci = component.getComponentInstances().stream().filter(c->c.getUniqueId().equals(Iterables.getLast(path))).findFirst();
+ if(ci.isPresent()){
+ Either<String, Boolean> buildSubstitutedName = buildSubstitutedName(componentsCache, name, path, ci.get());
+ if(buildSubstitutedName.isRight()){
+ return false;
+ }
+ entry.setFullName(ci.get().getNormalizedName() + '.' + buildSubstitutedName.left().value());
+ entry.setSourceName(buildSubstitutedName.left().value());
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ private void addEntry(Map<String, String[]> toscaRequirements, Component component, List<String> capPath, SubstituitionEntry entry) {
+ Optional<ComponentInstance> findFirst = component.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(Iterables.getLast(capPath))).findFirst();
+ if (findFirst.isPresent()) {
+ entry.setOwner(findFirst.get().getNormalizedName());
+ }
+ toscaRequirements.put(entry.getFullName(), new String[] { entry.getOwner(), entry.getSourceName() });
+ }
+
+ private Either<String, Boolean> buildSubstitutedName(Map<String, Component> componentsCache, String name, List<String> path, ComponentInstance instance) {
+
+ Either<String, Boolean> result = null;
+ Either<Component, Boolean> getOriginRes = getOriginComponent(componentsCache, instance);
+ if(getOriginRes.isRight()){
+ logger.debug("Failed to build substituted name for the capability/requirement {}. Failed to get an origin component with uniqueId {}", name, instance.getComponentUid());
+ result = Either.right(false);
+ }
+ if(result == null){
+ result = buildSubstitutedName(componentsCache, getOriginRes.left().value(), Lists.newArrayList(path.subList(0, path.size()-1)), name);
+ }
+ return result;
+ }
+
+ private String getRequirementPath(Component component, RequirementDefinition r) {
+
+ // Evg : for the last in path take real instance name and not "decrypt" unique id. ( instance name can be change and not equal to id..)
+ // dirty quick fix. must be changed as capability redesign
+ List<String> capPath = r.getPath();
+ String lastInPath = capPath.get(capPath.size() - 1);
+ Optional<ComponentInstance> findFirst = component.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(lastInPath)).findFirst();
+ if (findFirst.isPresent()) {
+ String lastInPathName = findFirst.get().getNormalizedName();
+
+ if (capPath.size() > 1) {
+ List<String> pathArray = Lists.reverse(capPath.stream().map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path))).collect(Collectors.toList()));
+
+ return new StringBuilder().append(lastInPathName).append(PATH_DELIMITER).append(String.join(PATH_DELIMITER, pathArray.subList(1, pathArray.size() ))).append(PATH_DELIMITER).append(r.getName()).toString();
+ }else{
+ return new StringBuilder().append(lastInPathName).append(PATH_DELIMITER).append(r.getName()).toString();
+ }
+ }
+ return "";
+ }
+
private ImmutablePair<String, ToscaRequirement> convertRequirement(Component component, boolean isNodeType, RequirementDefinition r) {
String name = r.getName();
if (!isNodeType) {
- name = getRequirementPath(r);
+ name = getRequirementPath(component, r);
}
- log.debug("the requirement {} belongs to resource {} ", name, component.getUniqueId());
+ logger.debug("the requirement {} belongs to resource {} ", name, component.getUniqueId());
ToscaRequirement toscaRequirement = new ToscaRequirement();
List<Object> occurences = new ArrayList<>();
@@ -230,78 +373,101 @@ public class CapabiltyRequirementConvertor {
occurences.add(Integer.valueOf(r.getMaxOccurrences()));
}
toscaRequirement.setOccurrences(occurences);
- // toscaRequirement.setOccurrences(createOcurrencesRange(requirementDefinition.getMinOccurrences(),
- // requirementDefinition.getMaxOccurrences()));
toscaRequirement.setNode(r.getNode());
toscaRequirement.setCapability(r.getCapability());
toscaRequirement.setRelationship(r.getRelationship());
- ImmutablePair<String, ToscaRequirement> pair = new ImmutablePair<String, ToscaRequirement>(name, toscaRequirement);
- return pair;
+ return new ImmutablePair<>(name, toscaRequirement);
}
+ /**
+ * Allows to convert capabilities of a node type to tosca template capabilities
+ * @param component
+ * @param dataTypes
+ * @return
+ */
public Map<String, ToscaCapability> convertCapabilities(Component component, Map<String, DataTypeDefinition> dataTypes) {
Map<String, List<CapabilityDefinition>> capabilities = component.getCapabilities();
Map<String, ToscaCapability> toscaCapabilities = new HashMap<>();
if (capabilities != null) {
- boolean isNodeType = ToscaUtils.isAtomicType(component);
+ boolean isNodeType = ModelConverter.isAtomicComponent(component);
for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
- entry.getValue().stream().filter(c -> (!isNodeType || (isNodeType && component.getUniqueId().equals(c.getOwnerId())) || (isNodeType && c.getOwnerId() == null) )).forEach(c -> {
- convertCapabilty(component, toscaCapabilities, isNodeType, c, dataTypes);
-
- });
+ entry.getValue().stream().filter(c -> filter(component, c.getOwnerId())).forEach(c -> convertCapabilty(component, toscaCapabilities, isNodeType, c, dataTypes));
}
} else {
- log.debug("No Capabilities for node type");
+ logger.debug(NO_CAPABILITIES);
}
return toscaCapabilities;
}
-
- //This function calls on Substitution Mapping region - the component is always non-atomic
- public Map<String, String[]> convertSubstitutionMappingCapabilities(Component component, Map<String, DataTypeDefinition> dataTypes) {
- Map<String, List<CapabilityDefinition>> capabilities = component.getCapabilities();
- Map<String, String[]> toscaCapabilities = new HashMap<>();
+
+ /**
+ * Allows to convert capabilities of a server proxy node type to tosca template capabilities
+ * @param component
+ * @param proxyComponent
+ * @param instanceProxy
+ * @param dataTypes
+ * @return
+ */
+ public Map<String, ToscaCapability> convertProxyCapabilities(Component component, Component proxyComponent, ComponentInstance instanceProxy, Map<String, DataTypeDefinition> dataTypes) {
+ Map<String, List<CapabilityDefinition>> capabilities = instanceProxy.getCapabilities();
+ Map<String, ToscaCapability> toscaCapabilities = new HashMap<>();
if (capabilities != null) {
+ boolean isNodeType = ModelConverter.isAtomicComponent(component);
for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
- entry.getValue().stream().forEach(c -> {
- String fullCapName;
- String sourceReqName;
- if(ToscaUtils.isComplexVfc(component)){
- fullCapName = c.getName();
- sourceReqName = c.getParentName();
- } else {
- fullCapName = getCapabilityPath(c);
- sourceReqName = getSubPathByFirstDelimiterAppearance(fullCapName);
- }
- log.debug("the capabilty {} belongs to resource {} ", fullCapName, component.getUniqueId());
- if(sourceReqName!= null){
- toscaCapabilities.put(fullCapName, new String[]{c.getOwnerName(), sourceReqName});
- }
- });
+ entry.getValue().stream().forEach(c -> convertCapabilty(proxyComponent, toscaCapabilities, isNodeType, c, dataTypes));
}
} else {
- log.debug("No Capabilities for node type");
+ logger.debug(NO_CAPABILITIES);
}
return toscaCapabilities;
}
-
- private String getCapabilityPath(CapabilityDefinition c) {
- List<String> pathArray = Lists.reverse(c.getPath().stream()
- .map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path)))
- .collect(Collectors.toList()));
- return new StringBuilder().append(String.join(PATH_DELIMITER, pathArray)).append(PATH_DELIMITER).append(c.getName()).toString();
+
+ /**
+ * Allows to convert component capabilities to the tosca template substitution mappings capabilities
+ * @param componentsCache
+ * @param component
+ * @return
+ */
+ public Either<Map<String, String[]>, ToscaError> convertSubstitutionMappingCapabilities(Map<String, Component> componentsCache, Component component) {
+ Map<String, List<CapabilityDefinition>> capabilities = component.getCapabilities();
+ Either<Map<String, String[]>, ToscaError> res = null;
+ if (capabilities != null) {
+ res = buildAddSubstitutionMappingsCapabilities(componentsCache, component, capabilities);
+ } else {
+ logger.debug(NO_CAPABILITIES);
+ res = Either.left(new HashMap<>());
+ }
+ return res;
}
-
-
+ private String getCapabilityPath(CapabilityDefinition c, Component component) {
+ // Evg : for the last in path take real instance name and not "decrypt" unique id. ( instance name can be change and not equal to id..)
+ // dirty quick fix. must be changed as capability redesign
+ List<String> capPath = c.getPath();
+ String lastInPath = capPath.get(capPath.size() - 1);
+ Optional<ComponentInstance> findFirst = component.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(lastInPath)).findFirst();
+ if (findFirst.isPresent()) {
+ String lastInPathName = findFirst.get().getNormalizedName();
+
+ if (capPath.size() > 1) {
+ List<String> pathArray = Lists.reverse(capPath.stream().map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path))).collect(Collectors.toList()));
+
+ return new StringBuilder().append(lastInPathName).append(PATH_DELIMITER).append(String.join(PATH_DELIMITER, pathArray.subList(1, pathArray.size() ))).append(PATH_DELIMITER).append(c.getName()).toString();
+ }else{
+ return new StringBuilder().append(lastInPathName).append(PATH_DELIMITER).append(c.getName()).toString();
+ }
+ }
+ return "";
+ }
+
private void convertCapabilty(Component component, Map<String, ToscaCapability> toscaCapabilities, boolean isNodeType, CapabilityDefinition c, Map<String, DataTypeDefinition> dataTypes) {
String name = c.getName();
if (!isNodeType) {
- name = getCapabilityPath(c);
+ name = getCapabilityPath(c, component);
}
- log.debug("the capabilty {} belongs to resource {} ", name, component.getUniqueId());
+ logger.debug("the capabilty {} belongs to resource {} ", name, component.getUniqueId());
ToscaCapability toscaCapability = new ToscaCapability();
toscaCapability.setDescription(c.getDescription());
toscaCapability.setType(c.getType());
@@ -327,5 +493,61 @@ public class CapabiltyRequirementConvertor {
}
toscaCapabilities.put(name, toscaCapability);
}
+
+ Either<String, Boolean> buildSubstitutedName(Map<String, Component> originComponents, Component originComponent, List<String> path, String name) {
+ StringBuilder substitutedName = new StringBuilder();
+ boolean nameBuiltSuccessfully = true;
+ Either<String, Boolean> result;
+ if(CollectionUtils.isNotEmpty(path) && !ToscaUtils.isComplexVfc(originComponent)){
+ Collections.reverse(path);
+ Iterator<String> instanceIdIter = path.iterator();
+ nameBuiltSuccessfully = appendNameRecursively(originComponents, originComponent, instanceIdIter, substitutedName);
+ }
+ if(nameBuiltSuccessfully){
+ result = Either.left(substitutedName.append(name).toString());
+ } else {
+ result = Either.right(nameBuiltSuccessfully);
+ }
+ return result;
+ }
+
+ private boolean appendNameRecursively(Map<String, Component> originComponents, Component originComponent, Iterator<String> instanceIdIter, StringBuilder substitutedName) {
+ if(CollectionUtils.isNotEmpty(originComponent.getComponentInstances()) && instanceIdIter.hasNext()){
+ String instanceId = instanceIdIter.next();
+ Optional<ComponentInstance> instanceOpt = originComponent.getComponentInstances().stream().filter(i -> i.getUniqueId().equals(instanceId)).findFirst();
+ if(!instanceOpt.isPresent()){
+ logger.debug("Failed to find an instance with uniqueId {} on a component with uniqueId {}", instanceId, originComponent.getUniqueId());
+ return false;
+ }
+ Either<Component, Boolean> getOriginRes = getOriginComponent(originComponents, instanceOpt.get());
+ if(getOriginRes.isRight()){
+ return false;
+ }
+ appendNameRecursively(originComponents, getOriginRes.left().value(), instanceIdIter, substitutedName);
+ substitutedName.append(instanceOpt.get().getNormalizedName()).append('.');
+ return true;
+ }
+ return true;
+ }
+
+ private Either<Component, Boolean> getOriginComponent(Map<String, Component> originComponents, ComponentInstance instance) {
+ Either<Component, Boolean> result;
+ Either<Component, StorageOperationStatus> getOriginRes;
+ if(originComponents.containsKey(instance.getComponentUid())){
+ result = Either.left(originComponents.get(instance.getComponentUid()));
+ } else {
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreComponentInstances(false);
+ getOriginRes = toscaOperationFacade.getToscaElement(instance.getComponentUid(), filter);
+ if(getOriginRes.isRight()){
+ logger.debug("Failed to get an origin component with uniqueId {}", instance.getComponentUid());
+ result = Either.right(false);
+ } else {
+ result = Either.left(getOriginRes.left().value());
+ originComponents.put(getOriginRes.left().value().getUniqueId(), getOriginRes.left().value());
+ }
+ }
+ return result;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index a0cc347e09..2f4a385f69 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -52,6 +52,7 @@ import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
@@ -146,7 +147,8 @@ public class CsarUtils {
ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX +
"([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
"([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
- "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN;
+ "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
+ "([\\d\\w\\_\\-\\.\\s]+)";
public static final String VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS + DEL_PATTERN+
// Artifact Group (i.e Deployment/Informational)
@@ -274,7 +276,7 @@ public class CsarUtils {
zip.putNextEntry(new ZipEntry(DEFINITIONS_PATH + fileName));
zip.write(mainYaml);
//US798487 - Abstraction of complex types
- if (!ToscaUtils.isAtomicType(component)){
+ if (!ModelConverter.isAtomicComponent(component)){
log.debug("Component {} is complex - generating abstract type for it..", component.getName());
writeComponentInterface(component, zip, fileName);
}
@@ -331,7 +333,7 @@ public class CsarUtils {
zip.write(content);
// add component interface to zip
- if (!ToscaUtils.isAtomicType(innerComponent)) {
+ if (!ModelConverter.isAtomicComponent(innerComponent)) {
writeComponentInterface(innerComponent, zip, icFileName);
}
}
@@ -452,7 +454,7 @@ public class CsarUtils {
}
//if not atomic - insert inner components as well
- if(!ToscaUtils.isAtomicType(componentRI)) {
+ if(!ModelConverter.isAtomicComponent(componentRI)) {
addInnerComponentsToCache(componentCache, componentRI);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 8e0c312f1a..1f29eb2113 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
@@ -42,10 +43,29 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.GroupProperty;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementAndRelationshipPair;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.converters.ToscaValueBaseConverter;
import org.openecomp.sdc.be.tosca.model.IToscaMetadata;
@@ -87,10 +107,10 @@ public class ToscaExportHandler {
@Autowired
private ToscaOperationFacade toscaOperationFacade;
-
- private CapabiltyRequirementConvertor capabiltyRequirementConvertor = CapabiltyRequirementConvertor.getInstance();
+ @Autowired
+ private CapabiltyRequirementConvertor capabiltyRequirementConvertor;
private PropertyConvertor propertyConvertor = PropertyConvertor.getInstance();
-
+ Map<String,Component> originComponents = new HashMap<>();
private static Logger log = LoggerFactory.getLogger(ToscaExportHandler.class.getName());
@@ -105,9 +125,9 @@ public class ToscaExportHandler {
public static final String VOLUME_GROUP_KEY = "volume_group";
public static final String VF_MODULE_TYPE_BASE = "Base";
public static final String VF_MODULE_TYPE_EXPANSION = "Expansion";
- public static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultImports();
-
-
+ private static final String FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION = "convertToToscaTemplate - failed to get Default Imports section from configuration";
+ private static final String NOT_SUPPORTED_COMPONENT_TYPE = "Not supported component type {}";
+ protected static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultImports();
public Either<ToscaRepresentation, ToscaError> exportComponent(Component component) {
@@ -122,15 +142,16 @@ public class ToscaExportHandler {
}
public Either<ToscaRepresentation, ToscaError> exportComponentInterface(Component component) {
- if(null == DEFAULT_IMPORTS) {
- log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ if (null == DEFAULT_IMPORTS) {
+ log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- Either<ToscaTemplate, ToscaError> toscaTemplateRes = convertInterfaceNodeType(component, toscaTemplate, nodeTypes);
+ Either<ToscaTemplate, ToscaError> toscaTemplateRes = convertInterfaceNodeType(component, toscaTemplate,
+ nodeTypes);
if (toscaTemplateRes.isRight()) {
return Either.right(toscaTemplateRes.right().value());
}
@@ -179,8 +200,8 @@ public class ToscaExportHandler {
}
private Either<ToscaTemplate, ToscaError> convertToToscaTemplate(Component component) {
- if(null == DEFAULT_IMPORTS) {
- log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ if (null == DEFAULT_IMPORTS) {
+ log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
@@ -190,7 +211,7 @@ public class ToscaExportHandler {
toscaTemplate.setMetadata(convertMetadata(component));
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- if (ToscaUtils.isAtomicType(component)) {
+ if (ModelConverter.isAtomicComponent(component)) {
log.trace("convert component as node type");
return convertNodeType(component, toscaTemplate, nodeTypes);
} else {
@@ -208,6 +229,15 @@ public class ToscaExportHandler {
return Either.right(importsRes.right().value());
}
toscaNode = importsRes.left().value().left;
+ /*Either<Map<String, ToscaNodeType>, ToscaError> nodeTypesMapEither = createProxyNodeTypes(component);
+ if (nodeTypesMapEither.isRight()) {
+ log.debug("Failed to fetch normative service proxy resource by tosca name, error {}",
+ nodeTypesMapEither.right().value());
+ return Either.right(nodeTypesMapEither.right().value());
+ }
+ Map<String, ToscaNodeType> nodeTypesMap = nodeTypesMapEither.left().value();
+ if (nodeTypesMap != null && !nodeTypesMap.isEmpty())
+ toscaNode.setNode_types(nodeTypesMap);*/
Map<String, Component> componentCache = importsRes.left().value().right;
Either<Map<String, DataTypeDefinition>, TitanOperationStatus> dataTypesEither = dataTypeCache.getAll();
@@ -240,9 +270,9 @@ public class ToscaExportHandler {
topologyTemplate.setNode_templates(nodeTemplates.left().value());
}
- Map<String, ToscaGroupTemplate> groupsMap = null;
+ Map<String, ToscaGroupTemplate> groupsMap;
if (groups != null && !groups.isEmpty()) {
- groupsMap = new HashMap<String, ToscaGroupTemplate>();
+ groupsMap = new HashMap<>();
for (GroupDefinition group : groups) {
ToscaGroupTemplate toscaGroup = convertGroup(group);
groupsMap.put(group.getName(), toscaGroup);
@@ -252,7 +282,7 @@ public class ToscaExportHandler {
topologyTemplate.addGroups(groupsMap);
}
SubstitutionMapping substitutionMapping = new SubstitutionMapping();
- String toscaResourceName = null;
+ String toscaResourceName;
switch (component.getComponentType()) {
case RESOURCE:
toscaResourceName = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition()
@@ -263,19 +293,19 @@ public class ToscaExportHandler {
+ component.getComponentMetadataDefinition().getMetadataDataDefinition().getSystemName();
break;
default:
- log.debug("Not supported component type {}", component.getComponentType());
+ log.debug(NOT_SUPPORTED_COMPONENT_TYPE, component.getComponentType());
return Either.right(ToscaError.NOT_SUPPORTED_TOSCA_TYPE);
}
substitutionMapping.setNode_type(toscaResourceName);
- Either<SubstitutionMapping, ToscaError> capabilities = convertCapabilities(component, substitutionMapping,
- dataTypes);
+ Either<SubstitutionMapping, ToscaError> capabilities = convertCapabilities(component, substitutionMapping);
if (capabilities.isRight()) {
return Either.right(capabilities.right().value());
}
substitutionMapping = capabilities.left().value();
- Either<SubstitutionMapping, ToscaError> requirements = capabiltyRequirementConvertor.convertSubstitutionMappingRequirements(component, substitutionMapping);
+ Either<SubstitutionMapping, ToscaError> requirements = capabiltyRequirementConvertor
+ .convertSubstitutionMappingRequirements(originComponents, component, substitutionMapping);
if (requirements.isRight()) {
return Either.right(requirements.right().value());
}
@@ -356,19 +386,19 @@ public class ToscaExportHandler {
private Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> fillImports(Component component,
ToscaTemplate toscaTemplate) {
- if(null == DEFAULT_IMPORTS) {
- log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ if (null == DEFAULT_IMPORTS) {
+ log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
Map<String, Component> componentCache = new HashMap<>();
- if (!ToscaUtils.isAtomicType(component)) {
+ if (!ModelConverter.isAtomicComponent(component)) {
List<ComponentInstance> componentInstances = component.getComponentInstances();
if (componentInstances != null && !componentInstances.isEmpty()) {
- List<Map<String, Map<String, String>>> additionalImports =
- toscaTemplate.getImports() == null ? new ArrayList<>(DEFAULT_IMPORTS) : new ArrayList<>(toscaTemplate.getImports());
+ List<Map<String, Map<String, String>>> additionalImports = toscaTemplate.getImports() == null
+ ? new ArrayList<>(DEFAULT_IMPORTS) : new ArrayList<>(toscaTemplate.getImports());
List<Triple<String, String, Component>> dependecies = new ArrayList<>();
@@ -386,9 +416,8 @@ public class ToscaExportHandler {
importsListMember.put(keyNameBuilder.toString(), interfaceFiles);
additionalImports.add(importsListMember);
- componentInstances.forEach(ci -> {
- createDependency(componentCache, additionalImports, dependecies, ci);
- });
+ componentInstances.forEach(ci -> createDependency(componentCache, additionalImports, dependecies, ci));
+ originComponents.putAll(componentCache);
toscaTemplate.setDependencies(dependecies);
toscaTemplate.setImports(additionalImports);
}
@@ -407,7 +436,8 @@ public class ToscaExportHandler {
Component componentRI = componentCache.get(ci.getComponentUid());
if (componentRI == null) {
// all resource must be only once!
- Either<Component, StorageOperationStatus> resource = toscaOperationFacade.getToscaFullElement(ci.getComponentUid());
+ Either<Component, StorageOperationStatus> resource = toscaOperationFacade
+ .getToscaFullElement(ci.getComponentUid());
if (resource.isRight()) {
log.debug("Failed to fetch resource with id {} for instance {}");
}
@@ -429,7 +459,7 @@ public class ToscaExportHandler {
dependecies.add(new ImmutableTriple<String, String, Component>(artifactName,
artifactDefinition.getEsId(), fetchedComponent));
- if(!ToscaUtils.isAtomicType(componentRI)) {
+ if (!ModelConverter.isAtomicComponent(componentRI)) {
importsListMember = new HashMap<>();
Map<String, String> interfaceFiles = new HashMap<>();
interfaceFiles.put(IMPORTS_FILE_KEY, getInterfaceFilename(artifactName));
@@ -442,8 +472,7 @@ public class ToscaExportHandler {
}
public static String getInterfaceFilename(String artifactName) {
- String interfaceFileName = artifactName.substring(0, artifactName.lastIndexOf('.')) + ToscaExportHandler.TOSCA_INTERFACE_NAME;
- return interfaceFileName;
+ return artifactName.substring(0, artifactName.lastIndexOf('.')) + ToscaExportHandler.TOSCA_INTERFACE_NAME;
}
private Either<ToscaTemplate, ToscaError> convertNodeType(Component component, ToscaTemplate toscaNode,
@@ -466,7 +495,7 @@ public class ToscaExportHandler {
toscaNodeType = properties.left().value();
log.debug("Properties converted for {}", component.getUniqueId());
- //Extracted to method for code reuse
+ // Extracted to method for code reuse
return convertReqCapAndTypeName(component, toscaNode, nodeTypes, toscaNodeType, dataTypes);
}
@@ -496,7 +525,7 @@ public class ToscaExportHandler {
}
}
- //Extracted to method for code reuse
+ // Extracted to method for code reuse
return convertReqCapAndTypeName(component, toscaNode, nodeTypes, toscaNodeType, dataTypes);
}
@@ -510,15 +539,13 @@ public class ToscaExportHandler {
toscaNodeType = capabilities.left().value();
log.debug("Capabilities converted for {}", component.getUniqueId());
- Either<ToscaNodeType, ToscaError> requirements = capabiltyRequirementConvertor.convertRequirements(component,
- toscaNodeType);
+ Either<ToscaNodeType, ToscaError> requirements = capabiltyRequirementConvertor.convertRequirements(component, toscaNodeType);
if (requirements.isRight()) {
return Either.right(requirements.right().value());
}
toscaNodeType = requirements.left().value();
log.debug("Requirements converted for {}", component.getUniqueId());
-
String toscaResourceName;
switch (component.getComponentType()) {
case RESOURCE:
@@ -530,7 +557,7 @@ public class ToscaExportHandler {
+ component.getComponentMetadataDefinition().getMetadataDataDefinition().getSystemName();
break;
default:
- log.debug("Not supported component type {}", component.getComponentType());
+ log.debug(NOT_SUPPORTED_COMPONENT_TYPE, component.getComponentType());
return Either.right(ToscaError.NOT_SUPPORTED_TOSCA_TYPE);
}
@@ -558,7 +585,8 @@ public class ToscaExportHandler {
nodeTemplate.setType(componentInstance.getToscaComponentName());
Either<ToscaNodeTemplate, ToscaError> requirements = convertComponentInstanceRequirements(component,
- componentInstance, component.getComponentInstancesRelations(), nodeTemplate, componentCache.get(componentInstance.getComponentUid()));
+ componentInstance, component.getComponentInstancesRelations(), nodeTemplate,
+ componentCache.get(componentInstance.getComponentUid()));
if (requirements.isRight()) {
convertNodeTemplatesRes = Either.right(requirements.right().value());
break;
@@ -634,8 +662,9 @@ public class ToscaExportHandler {
List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId);
if (instanceInputsList != null) {
instanceInputsList.forEach(input -> {
-
- Supplier<String> supplier = () -> input.getValue() != null && !input.getValue().isEmpty()? input.getValue(): input.getDefaultValue();
+
+ Supplier<String> supplier = () -> input.getValue() != null && !input.getValue().isEmpty()
+ ? input.getValue() : input.getDefaultValue();
convertAndAddValue(dataTypes, componentInstance, props, input, supplier);
});
}
@@ -724,7 +753,8 @@ public class ToscaExportHandler {
Supplier<String> supplGroupType = () -> groupInstance.getType();
Supplier<String> supplDescription = () -> groupInstance.getDescription();
- Supplier<List<? extends GroupProperty>> supplProperties = () -> groupInstance.convertToGroupInstancesProperties();
+ Supplier<List<? extends GroupProperty>> supplProperties = () -> groupInstance
+ .convertToGroupInstancesProperties();
Supplier<String> supplgroupName = () -> groupInstance.getGroupName();
Supplier<String> supplInvariantUUID = () -> groupInstance.getInvariantUUID();
Supplier<String> supplGroupUUID = () -> groupInstance.getGroupUUID();
@@ -751,7 +781,8 @@ public class ToscaExportHandler {
toscaMetadata = new VfModuleToscaMetadata();
Map<String, Object> properties = fillGroupProperties(props.get());
- if(!properties.containsKey(VF_MODULE_DESC_KEY) || StringUtils.isEmpty((String) properties.get(VF_MODULE_DESC_KEY))){
+ if (!properties.containsKey(VF_MODULE_DESC_KEY)
+ || StringUtils.isEmpty((String) properties.get(VF_MODULE_DESC_KEY))) {
properties.put(VF_MODULE_DESC_KEY, description.get());
}
toscaGroup.setProperties(properties);
@@ -765,7 +796,7 @@ public class ToscaExportHandler {
private Map<String, Object> fillGroupProperties(List<? extends GroupProperty> groupProps) {
Map<String, Object> properties = new HashMap<>();
- if(groupProps != null){
+ if (groupProps != null) {
for (GroupProperty gp : groupProps) {
if (gp.getName().equals(Constants.IS_BASE)) {
Boolean isBase = Boolean.parseBoolean(gp.getValue());
@@ -800,72 +831,233 @@ public class ToscaExportHandler {
private ToscaNodeType createNodeType(Component component) {
ToscaNodeType toscaNodeType = new ToscaNodeType();
- if (ToscaUtils.isAtomicType(component)){
- if (((Resource) component).getDerivedFrom() != null){
+ if (ModelConverter.isAtomicComponent(component)) {
+ if (((Resource) component).getDerivedFrom() != null) {
toscaNodeType.setDerived_from(((Resource) component).getDerivedFrom().get(0));
}
- toscaNodeType.setDescription(component.getDescription()); // or name??
+ toscaNodeType.setDescription(component.getDescription()); // or
+ // name??
} else {
- String derivedFrom = null != component.getDerivedFromGenericType()? component.getDerivedFromGenericType() : "tosca.nodes.Root";
+ String derivedFrom = null != component.getDerivedFromGenericType() ? component.getDerivedFromGenericType()
+ : "tosca.nodes.Root";
toscaNodeType.setDerived_from(derivedFrom);
}
return toscaNodeType;
}
- //TODO save the capability(type or name) info on relation data
- private Either<ToscaNodeTemplate, ToscaError> convertComponentInstanceRequirements(Component component,
- ComponentInstance componentInstance, List<RequirementCapabilityRelDef> relations,
- ToscaNodeTemplate nodeTypeTemplate, Component originComponent) {
+ /*private Either<Map<String, ToscaNodeType>, ToscaError> createProxyNodeTypes(Component container) {
- List<ComponentInstance> instancesList = component.getComponentInstances();
- List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
- Map<String, List<RequirementDefinition>> reqMap = originComponent.getRequirements();
+ Map<String, ToscaNodeType> nodeTypesMap = null;
+ Either<Map<String, ToscaNodeType>, ToscaError> res = Either.left(nodeTypesMap);
- relations.stream().filter(p -> componentInstance.getUniqueId().equals(p.getFromNode())).forEach(rel -> {
- ComponentInstance toComponentInstance = instancesList.stream()
- .filter(i -> rel.getToNode().equals(i.getUniqueId())).findFirst().orElse(null);
- if (toComponentInstance == null) {
- log.debug("Failed to find relation between node {} to node {}", componentInstance.getName(),
- rel.getToNode());
- return;
- }
- RequirementAndRelationshipPair reqAndRelationshipPair = rel.getRelationships().get(0);
- ToscaTemplateRequirement toscaRequirement = new ToscaTemplateRequirement();
- toscaRequirement.setNode(toComponentInstance.getName());
- Optional<RequirementDefinition> findAny = reqMap.values().stream().flatMap(e -> e.stream())
- .filter(e -> e.getName().equals(reqAndRelationshipPair.getRequirement())).findAny();
- if (findAny.isPresent()) {
- RequirementDefinition reqDefinition = findAny.get();
- toscaRequirement.setCapability(reqDefinition.getCapability());
- toscaRequirement.setRelationship(reqDefinition.getRelationship());
- } else {
- // reqMap represents calculated requirements! if not found there, export data directly from the relation definition
- log.debug("Failed to find requirement {} definition for node {}", reqAndRelationshipPair.getRequirement(), componentInstance.getName());
- return;
+ List<ComponentInstance> componetInstances = container.getComponentInstances();
+
+ if (componetInstances == null || componetInstances.isEmpty())
+ return res;
+ Map<String, ComponentInstance> serviceProxyInstanceList = new HashMap<>();
+ List<ComponentInstance> proxyInst = componetInstances.stream().filter(p -> p.getOriginType().name().equals(OriginTypeEnum.ServiceProxy.name())).collect(Collectors.toList());
+ if(proxyInst != null && !proxyInst.isEmpty()){
+ for(ComponentInstance inst: proxyInst){
+ serviceProxyInstanceList.put(inst.getToscaComponentName(), inst);
}
- Map<String, ToscaTemplateRequirement> toscaReqMap = new HashMap<>();
- toscaReqMap.put(reqAndRelationshipPair.getRequirement(), toscaRequirement);
- toscaRequirements.add(toscaReqMap);
+ }
+
+ if (serviceProxyInstanceList.isEmpty())
+ return res;
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreCapabilities(false);
+ filter.setIgnoreComponentInstances(false);
+ Either<Resource, StorageOperationStatus> serviceProxyOrigin = toscaOperationFacade
+ .getLatestByName("serviceProxy");
+ if (serviceProxyOrigin.isRight()) {
+ log.debug("Failed to fetch normative service proxy resource by tosca name, error {}",
+ serviceProxyOrigin.right().value());
+ return Either.right(ToscaError.NOT_SUPPORTED_TOSCA_TYPE);
+ }
+ Component origComponent = serviceProxyOrigin.left().value();
+
+ nodeTypesMap = new HashMap<>();
+ for (Entry<String, ComponentInstance> entryProxy : serviceProxyInstanceList.entrySet()) {
+ Component serviceComponent = null;
+ ComponentParametersView componentParametersView = new ComponentParametersView();
+ componentParametersView.disableAll();
+ componentParametersView.setIgnoreCategories(false);
+ Either<Component, StorageOperationStatus> service = toscaOperationFacade
+ .getToscaElement(entryProxy.getValue().getSourceModelUid(), componentParametersView);
+ if (service.isRight()) {
+ log.debug("Failed to fetch resource with id {} for instance {}");
+ } else
+ serviceComponent = service.left().value();
+
+ ToscaNodeType toscaNodeType = createProxyNodeType(origComponent, serviceComponent, entryProxy.getValue());
+ nodeTypesMap.put(entryProxy.getKey(), toscaNodeType);
+ }
+
+ return Either.left(nodeTypesMap);
+ }*/
+
+ private ToscaNodeType createProxyNodeType(Component origComponent, Component proxyComponent,
+ ComponentInstance instance) {
+ ToscaNodeType toscaNodeType = new ToscaNodeType();
+ String derivedFrom = ((Resource) origComponent).getToscaResourceName();
+
+ toscaNodeType.setDerived_from(derivedFrom);
+ Either<Map<String, DataTypeDefinition>, TitanOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ if (dataTypesEither.isRight()) {
+ log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
+ }
+ Map<String, DataTypeDefinition> dataTypes = dataTypesEither.left().value();
+ Map<String, ToscaCapability> capabilities = this.capabiltyRequirementConvertor
+ .convertProxyCapabilities(origComponent, proxyComponent, instance, dataTypes);
+
+ toscaNodeType.setCapabilities(capabilities);
- });
+ return toscaNodeType;
+ }
+ private Either<ToscaNodeTemplate, ToscaError> convertComponentInstanceRequirements(Component component,
+ ComponentInstance componentInstance, List<RequirementCapabilityRelDef> relations,
+ ToscaNodeTemplate nodeTypeTemplate, Component originComponent) {
+
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
+ if(!addRequirements(component, componentInstance, relations, originComponent, toscaRequirements)){
+ log.debug("Failed to convert component instance requirements for the component instance {}. ", componentInstance.getName());
+ return Either.right(ToscaError.NODE_TYPE_REQUIREMENT_ERROR);
+ }
if (!toscaRequirements.isEmpty()) {
nodeTypeTemplate.setRequirements(toscaRequirements);
}
- log.debug("Finish convert Requirements for node type");
+ log.debug("Finished to convert requirements for the node type {} ", componentInstance.getName());
return Either.left(nodeTypeTemplate);
}
+ private boolean addRequirements(Component component, ComponentInstance componentInstance, List<RequirementCapabilityRelDef> relations, Component originComponent,
+ List<Map<String, ToscaTemplateRequirement>> toscaRequirements) {
+ boolean result;
+ List<RequirementCapabilityRelDef> filteredRelations = relations.stream().filter(p -> componentInstance.getUniqueId().equals(p.getFromNode())).collect(Collectors.toList());
+ if(CollectionUtils.isEmpty(filteredRelations)){
+ result = true;
+ } else {
+ result = !filteredRelations.stream().filter(rel -> !addRequirement(component,componentInstance, originComponent, component.getComponentInstances(), rel, toscaRequirements)).findFirst().isPresent();
+ }
+ return result;
+ }
+
+ private boolean addRequirement(Component component,ComponentInstance fromInstance, Component originComponent, List<ComponentInstance> instancesList, RequirementCapabilityRelDef rel, List<Map<String, ToscaTemplateRequirement>> toscaRequirements){
+
+ boolean result = true;
+ Map<String,Component> originComponents = new HashMap<>();
+ Map<String, List<RequirementDefinition>> reqMap = originComponent.getRequirements();
+ RequirementAndRelationshipPair reqAndRelationshipPair = rel.getRelationships().get(0);
+ Either<Component, StorageOperationStatus> getOriginRes = null;
+ Optional<RequirementDefinition> reqOpt = null;
+ Component toOriginComponent = null;
+ Optional<CapabilityDefinition> cap = null;
+ Either<String, Boolean> buildCapNameRes = null;
+ Either<String, Boolean> buildReqNameRes = null;
+
+ ComponentInstance toInstance = instancesList.stream().filter(i -> rel.getToNode().equals(i.getUniqueId())).findFirst().orElse(null);
+ if (toInstance == null) {
+ log.debug("Failed to find a relation from the node {} to the node {}", fromInstance.getName(), rel.getToNode());
+ result = false;
+ }
+ if(result){
- private Either<SubstitutionMapping, ToscaError> convertCapabilities(Component component, SubstitutionMapping substitutionMapping, Map<String, DataTypeDefinition> dataTypes) {
- Map<String, String[]> toscaCapabilities = capabiltyRequirementConvertor.convertSubstitutionMappingCapabilities(component, dataTypes);
+ if(component.getComponentType().equals(ComponentTypeEnum.SERVICE)) {
+ reqOpt = findRequirement(reqMap, reqAndRelationshipPair);
+ }
+ else {
+ reqOpt = findRequirement(reqMap, reqAndRelationshipPair.getRequirementUid());
+ }
+ if(!reqOpt.isPresent()){
+ log.debug("Failed to find a requirement with uniqueId {} on a component with uniqueId {}", reqAndRelationshipPair.getRequirementUid(), originComponent.getUniqueId());
+ result = false;
+ }
+ }
+ if(result){
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreComponentInstances(false);
+ filter.setIgnoreCapabilities(false);
+ getOriginRes = toscaOperationFacade.getToscaElement(toInstance.getComponentUid(), filter);
+ if(getOriginRes.isRight()){
+ log.debug("Failed to build substituted name for the requirement {}. Failed to get an origin component with uniqueId {}", reqOpt.get().getName(), toInstance.getComponentUid());
+ result = false;
+ }
+ }
+ if(result){
+ toOriginComponent = getOriginRes.left().value();
+ cap = toOriginComponent.getCapabilities().get(reqOpt.get().getCapability()).stream().filter(c -> c.getName().equals(reqAndRelationshipPair.getCapability())).findFirst();
+ if(!cap.isPresent()){
+ log.debug("Failed to find a capability with name {} on a component with uniqueId {}", reqAndRelationshipPair.getCapability(), originComponent.getUniqueId());
+ result = false;
+ }
+ }
+ if(result){
+ buildCapNameRes = capabiltyRequirementConvertor.buildSubstitutedName(originComponents, toOriginComponent, cap.get().getPath(), reqAndRelationshipPair.getCapability());
+ if(buildCapNameRes.isRight()){
+ log.debug("Failed to build a substituted capability name for the capability with name {} on a component with uniqueId {}", reqAndRelationshipPair.getCapability(), originComponent.getUniqueId());
+ result = false;
+ }
+ }
+ if(result){
+ buildReqNameRes = capabiltyRequirementConvertor.buildSubstitutedName(originComponents, originComponent, reqOpt.get().getPath(), reqAndRelationshipPair.getRequirement());
+ if(buildReqNameRes.isRight()){
+ log.debug("Failed to build a substituted requirement name for the requirement with name {} on a component with uniqueId {}", reqAndRelationshipPair.getRequirement(), originComponent.getUniqueId());
+ result = false;
+ }
+ }
+ if(result){
+ ToscaTemplateRequirement toscaRequirement = new ToscaTemplateRequirement();
+ Map<String, ToscaTemplateRequirement> toscaReqMap = new HashMap<>();
+ toscaRequirement.setNode(toInstance.getName());
+ toscaRequirement.setCapability(buildCapNameRes.left().value());
+ toscaReqMap.put(buildReqNameRes.left().value(), toscaRequirement);
+ toscaRequirements.add(toscaReqMap);
+ }
+ return result;
+ }
- if (!toscaCapabilities.isEmpty()) {
- substitutionMapping.setCapabilities(toscaCapabilities);
+ private Optional<RequirementDefinition> findRequirement(Map<String, List<RequirementDefinition>> reqMap, String reqId) {
+ for(List<RequirementDefinition> reqList: reqMap.values()){
+ Optional<RequirementDefinition> reqOpt = reqList.stream().filter(r -> r.getUniqueId().equals(reqId)).findFirst();
+ if(reqOpt.isPresent()){
+ return reqOpt;
+ }
}
- log.debug("Finish convert Capabilities for node type");
+ return Optional.empty();
+ }
+
+ private Optional<RequirementDefinition> findRequirement(Map<String, List<RequirementDefinition>> reqMap, RequirementAndRelationshipPair reqAndRelationshipPair) {
+ for(List<RequirementDefinition> reqList: reqMap.values()){
+ Optional<RequirementDefinition> reqOpt = reqList.stream().filter(r ->
+ isRequirmentBelongTo(reqAndRelationshipPair, r))
+ .findFirst();
+ if(reqOpt.isPresent()){
+ return reqOpt;
+ }
+ }
+ return Optional.empty();
+ }
+
+ private boolean isRequirmentBelongTo(RequirementAndRelationshipPair reqAndRelationshipPair, RequirementDefinition r) {
+ return StringUtils.isNotEmpty(r.getOwnerId()) && r.getOwnerId().equals(reqAndRelationshipPair.getRequirementOwnerId())
+ && StringUtils.isNotEmpty(r.getName()) && r.getName().equals(reqAndRelationshipPair.getRequirement());
+ }
- return Either.left(substitutionMapping);
+ private Either<SubstitutionMapping, ToscaError> convertCapabilities(Component component, SubstitutionMapping substitutionMappings) {
+
+ Either<SubstitutionMapping, ToscaError> result = Either.left(substitutionMappings);;
+ Either<Map<String, String[]>, ToscaError> toscaCapabilitiesRes = capabiltyRequirementConvertor
+ .convertSubstitutionMappingCapabilities(originComponents, component);
+ if(toscaCapabilitiesRes.isRight()){
+ result = Either.right(toscaCapabilitiesRes.right().value());
+ log.error("Failed convert capabilities for the component {}. ", component.getName());
+ } else if (MapUtils.isNotEmpty(toscaCapabilitiesRes.left().value())) {
+ substitutionMappings.setCapabilities(toscaCapabilitiesRes.left().value());
+ log.debug("Finish convert capabilities for the component {}. ", component.getName());
+ }
+ log.debug("Finished to convert capabilities for the component {}. ", component.getName());
+ return result;
}
private Either<ToscaNodeType, ToscaError> convertCapabilities(Component component, ToscaNodeType nodeType,
@@ -896,12 +1088,12 @@ public class ToscaExportHandler {
return null;
} else {
// skip not relevant for Tosca property
- if (property.getName().equals("dependencies")) {
+ if ("dependencies".equals(property.getName())) {
return null;
}
NodeTuple defaultNode = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
- return property.getName().equals("_defaultp_")
+ return "_defaultp_".equals(property.getName())
? new NodeTuple(representData("default"), defaultNode.getValueNode()) : defaultNode;
}
}
@@ -928,7 +1120,7 @@ public class ToscaExportHandler {
protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
throws IntrospectionException {
Collection<Property> fields = getPropertiesMap(type, BeanAccess.FIELD).values();
- return new LinkedHashSet<Property>(fields);
+ return new LinkedHashSet<>(fields);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
index 24586d9ea0..0c54e7229e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
@@ -34,17 +34,6 @@ import org.openecomp.sdc.be.model.Component;
public class ToscaUtils {
- public static boolean isAtomicType(Component component) {
- ComponentTypeEnum componentType = component.getComponentType();
- if (ComponentTypeEnum.RESOURCE.equals(componentType)) {
- ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceType();
- if (ResourceTypeEnum.CP == resourceType || ResourceTypeEnum.VL == resourceType || ResourceTypeEnum.VFC == resourceType || ResourceTypeEnum.VFCMT == resourceType || ResourceTypeEnum.ABSTRACT == resourceType) {
- return true;
- }
- }
- return false;
- }
-
public static boolean isComplexVfc(Component component) {
if (ComponentTypeEnum.RESOURCE == component.getComponentType()) {
ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceType();
@@ -55,7 +44,7 @@ public class ToscaUtils {
return false;
}
- public static Map<String, Object> objectToMap(Object objectToConvert, Class clazz) throws IllegalArgumentException, IllegalAccessException {
+ public static Map<String, Object> objectToMap(Object objectToConvert, Class<?> clazz) throws IllegalArgumentException, IllegalAccessException {
Map<String, Object> map = new HashMap<>();
List<Field> fields = new ArrayList<>();
@@ -76,4 +65,47 @@ public class ToscaUtils {
}
return fields;
}
+
+ public static class SubstituitionEntry{
+
+ private String fullName = "";
+ private String sourceName = "";
+ private String owner = "";
+
+ public SubstituitionEntry() {}
+
+ public SubstituitionEntry(String fullName, String sourceName, String owner) {
+ if(fullName != null)
+ this.fullName = fullName;
+ if(sourceName != null)
+ this.sourceName = sourceName;
+ if(owner != null)
+ this.owner = owner;
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+ public String getSourceName() {
+ return sourceName;
+ }
+
+ public void setSourceName(String sourceName) {
+ this.sourceName = sourceName;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+ }
+
}
diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml
index 16c6fd6756..5ed38e6bc1 100644
--- a/catalog-be/src/main/webapp/WEB-INF/web.xml
+++ b/catalog-be/src/main/webapp/WEB-INF/web.xml
@@ -95,7 +95,7 @@
<init-param>
<param-name>swagger.api.basepath</param-name>
- <param-value>http://localhost:8080/sdc2/rest</param-value>
+ <param-value>/sdc2/rest</param-value>
</init-param>
<init-param>
@@ -129,7 +129,7 @@
<init-param>
<param-name>swagger.api.basepath</param-name>
<!-- Check if second param can be added -->
- <param-value>http://localhost:8080/sdc</param-value>
+ <param-value>/sdc</param-value>
</init-param>
<init-param>
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadInfo.java
index 75707ee77c..52a7ec073e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadInfo.java
@@ -22,10 +22,20 @@ package org.openecomp.sdc.be.model;
public abstract class UploadInfo {
+ private String key;
+
private String type;
private String name;
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
public String getType() {
return type;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
index 1726c397ad..79360f6e10 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -44,6 +45,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
@@ -1338,32 +1340,49 @@ public abstract class BaseOperation {
// return StorageOperationStatus.OK;
// }
- protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group, ComponentInstanceDataDefinition componentInstance) {
-
- String componentInstanceName = componentInstance.getName();
- Long creationDate = System.currentTimeMillis();
- GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
- String groupUid = group.getUniqueId();
-
- groupInstance.setGroupUid(groupUid);
- groupInstance.setType(group.getType());
- groupInstance.setCustomizationUUID(generateCustomizationUUID());
- groupInstance.setCreationTime(creationDate);
- groupInstance.setModificationTime(creationDate);
- groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName()));
- groupInstance.setGroupName(group.getName());
- groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
- groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
- groupInstance.setArtifacts(group.getArtifacts());
- groupInstance.setArtifactsUuid(group.getArtifactsUuid());
- groupInstance.setProperties(group.getProperties());
- convertPropertiesToInstanceProperties(groupInstance.getProperties());
- groupInstance.setInvariantUUID(group.getInvariantUUID());
- groupInstance.setGroupUUID(group.getGroupUUID());
- groupInstance.setVersion(group.getVersion());
-
- return groupInstance;
- }
+ protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group, ComponentInstanceDataDefinition componentInstance, Map<String, ArtifactDataDefinition> instDeplArtifMap) {
+
+ String componentInstanceName = componentInstance.getName();
+ Long creationDate = System.currentTimeMillis();
+ GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
+ String groupUid = group.getUniqueId();
+
+ groupInstance.setGroupUid(groupUid);
+ groupInstance.setType(group.getType());
+ groupInstance.setCustomizationUUID(generateCustomizationUUID());
+ groupInstance.setCreationTime(creationDate);
+ groupInstance.setModificationTime(creationDate);
+ groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName()));
+ groupInstance.setGroupName(group.getName());
+ groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
+ groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
+ groupInstance.setArtifacts(group.getArtifacts());
+
+// List<String> fixedArtifactsUuid;
+// List<String> artifactsUuid = group.getArtifactsUuid();
+// if (instDeplArtifMap != null) {
+// fixedArtifactsUuid = new ArrayList<>();
+// artifactsUuid.forEach(u -> {
+// Optional<ArtifactDataDefinition> findFirst = instDeplArtifMap.values().stream().filter(a -> u.equals(a.getUniqueId())).findFirst();
+// if (findFirst.isPresent()) {
+// fixedArtifactsUuid.add(findFirst.get().getArtifactUUID());
+// } else {
+// fixedArtifactsUuid.add(u);
+// }
+// });
+// } else {
+// fixedArtifactsUuid = artifactsUuid;
+// }
+ groupInstance.setArtifactsUuid(group.getArtifactsUuid());
+ groupInstance.setProperties(group.getProperties());
+ convertPropertiesToInstanceProperties(groupInstance.getProperties());
+ groupInstance.setInvariantUUID(group.getInvariantUUID());
+ groupInstance.setGroupUUID(group.getGroupUUID());
+ groupInstance.setVersion(group.getVersion());
+
+ return groupInstance;
+ }
+
protected String buildGroupInstanceName(String instanceName, String groupName) {
return ValidationUtils.normalizeComponentInstanceName(instanceName) + ".." + groupName;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
index b642410548..7ff42ae42e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
@@ -793,7 +793,7 @@ public class NodeTemplateOperation extends BaseOperation {
for (Map.Entry<String, List<ArtifactDefinition>> groupArtifacts : groupInstancesArtifacts.entrySet()) {
Optional<GroupDefinition> groupOptional = groups.stream().filter(g -> g.getUniqueId().equals(groupArtifacts.getKey())).findFirst();
if (groupOptional.isPresent()) {
- GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition)groupOptional.get(), (ComponentInstanceDataDefinition)componentInstance);
+ GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition) groupOptional.get(), (ComponentInstanceDataDefinition) componentInstance, null);
groupInstance.setGroupInstanceArtifacts(groupArtifacts.getValue().stream().map(a -> a.getUniqueId()).collect(Collectors.toList()));
groupInstance.setGroupInstanceArtifactsUuid(groupArtifacts.getValue().stream().map(a -> a.getArtifactUUID()).collect(Collectors.toList()));
groupInstanceToCreate.put(groupInstance.getName(), groupInstance);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
index d986d77450..e530144fe0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
import fj.data.Either;
+import java.util.stream.Collectors;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -58,8 +59,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
@org.springframework.stereotype.Component("node-type-operation")
@@ -757,25 +760,49 @@ public class NodeTypeOperation extends ToscaElementOperation {
return DaoStatusConverter.convertTitanStatusToStorageStatus(error);
}
// must be only one
- GraphVertex newDerived = getParentResources.left().value().get(0);
- derivedResources.add(newDerived);
- StorageOperationStatus updateStatus = updateDataFromNewDerived(derivedResources, nodeTypeV, (NodeType)toscaElementToUpdate);
- if (updateStatus != StorageOperationStatus.OK) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update data for {} from new derived {} ", nodeTypeV.getUniqueId(), newDerived.getUniqueId(), updateStatus);
- return updateStatus;
- }
+ GraphVertex newDerivedV = getParentResources.left().value().get(0);
+ return updateDerived(toscaElementToUpdate, nodeTypeV, firstDerivedInChain, newDerivedV, false);
+ }
+ }
+ return StorageOperationStatus.OK;
+ }
- Either<Edge, TitanOperationStatus> deleteEdge = titanDao.deleteEdge(nodeTypeV, firstDerivedInChain, EdgeLabelEnum.DERIVED_FROM);
- if (deleteEdge.isRight()) {
- TitanOperationStatus deleteError = deleteEdge.right().value();
- log.debug("Failed to disassociate element {} from derived {} , error {}", nodeTypeV.getUniqueId(), firstDerivedInChain.getUniqueId(), deleteError);
- return DaoStatusConverter.convertTitanStatusToStorageStatus(deleteError);
- }
+ /**
+ *
+ * @param toscaElementToUpdate
+ * @param nodeTypeV
+ * @param preDerivedV
+ * @param newDerivedV
+ * @param mergeValues
+ * @return
+ */
+ protected <T extends ToscaElement> StorageOperationStatus updateDerived(T toscaElementToUpdate, GraphVertex nodeTypeV, GraphVertex preDerivedV, GraphVertex newDerivedV, boolean mergeValues) {
+ Set<String> preDerivedChainIdList = new HashSet();
+ preDerivedChainIdList.add(preDerivedV.getUniqueId());
+ Either<GraphVertex, TitanOperationStatus> childVertex = titanDao.getChildVertex(preDerivedV, EdgeLabelEnum.DERIVED_FROM, JsonParseFlagEnum.NoParse);
+ while (childVertex.isLeft()) {
+ GraphVertex currentChield = childVertex.left().value();
+ preDerivedChainIdList.add(currentChield.getUniqueId());
+ childVertex = titanDao.getChildVertex(currentChield, EdgeLabelEnum.DERIVED_FROM, JsonParseFlagEnum.NoParse);
+ }
- titanDao.createEdge(nodeTypeV, newDerived, EdgeLabelEnum.DERIVED_FROM, new HashMap<>());
- }
+ List<GraphVertex> derivedResources = new ArrayList<>();
+ derivedResources.add(newDerivedV);
+ StorageOperationStatus updateStatus = updateDataFromNewDerived(derivedResources, nodeTypeV, (NodeType) toscaElementToUpdate, mergeValues, preDerivedChainIdList);
+ if (updateStatus != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update data for {} from new derived {} ", nodeTypeV.getUniqueId(), newDerivedV.getUniqueId(), updateStatus);
+ return updateStatus;
+ }
+
+ Either<Edge, TitanOperationStatus> deleteEdge = titanDao.deleteEdge(nodeTypeV, preDerivedV, EdgeLabelEnum.DERIVED_FROM);
+ if (deleteEdge.isRight()) {
+ TitanOperationStatus deleteError = deleteEdge.right().value();
+ log.debug("Failed to disassociate element {} from derived {} , error {}", nodeTypeV.getUniqueId(), preDerivedV.getUniqueId(), deleteError);
+ return DaoStatusConverter.convertTitanStatusToStorageStatus(deleteError);
}
+ titanDao.createEdge(nodeTypeV, newDerivedV, EdgeLabelEnum.DERIVED_FROM, new HashMap<>());
+
return StorageOperationStatus.OK;
}
@@ -800,20 +827,20 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
- private StorageOperationStatus updateDataFromNewDerived(List<GraphVertex> newDerived, GraphVertex nodeTypeV, NodeType nodeToUpdate) {
+ private StorageOperationStatus updateDataFromNewDerived(List<GraphVertex> newDerived, GraphVertex nodeTypeV, NodeType nodeToUpdate, boolean mergeValues, Set<String> preDerivedChainIdList) {
EnumSet<EdgeLabelEnum> edgeLabels = EnumSet.of(EdgeLabelEnum.CAPABILITIES, EdgeLabelEnum.REQUIREMENTS, EdgeLabelEnum.PROPERTIES, EdgeLabelEnum.ATTRIBUTES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.ADDITIONAL_INFORMATION);
StorageOperationStatus status = null;
- for (EdgeLabelEnum edge : edgeLabels){
- status = updateDataByType(newDerived, nodeTypeV, edge, nodeToUpdate);
+ for (EdgeLabelEnum edge : edgeLabels) {
+ status = updateDataByType(newDerived, nodeTypeV, edge, nodeToUpdate, mergeValues, preDerivedChainIdList);
if (status != StorageOperationStatus.OK) {
break;
}
}
return status;
-
+
}
- private <T extends ToscaDataDefinition> StorageOperationStatus updateDataByType(List<GraphVertex> newDerivedList, GraphVertex nodeTypeV, EdgeLabelEnum label, NodeType nodeElement) {
+ private <T extends ToscaDataDefinition> StorageOperationStatus updateDataByType(List<GraphVertex> newDerivedList, GraphVertex nodeTypeV, EdgeLabelEnum label, NodeType nodeElement, boolean mergeValues, Set<String> preDerivedChainIdList) {
log.debug("Update data from derived for element {} type {}", nodeTypeV.getUniqueId(), label);
Either<GraphVertex, TitanOperationStatus> dataFromGraph = getDataVertex(nodeTypeV, label);
if (dataFromGraph.isRight()) {
@@ -824,9 +851,23 @@ public class NodeTypeOperation extends ToscaElementOperation {
GraphVertex dataV = dataFromGraph.left().value();
Map<String, T> mapFromGraph = (Map<String, T>) dataV.getJson();
- mapFromGraph.entrySet().removeIf(e -> e.getValue().getOwnerId() != null);
+ Map<String, T> valuesFrmPrev = null;
+ if (isSimpleHierarchy(label)) {
+ if (mergeValues) {
+ valuesFrmPrev = mapFromGraph.entrySet().stream().filter(e -> e.getValue().getOwnerId() != null).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+ mapFromGraph.entrySet().removeIf(e -> preDerivedChainIdList.contains(e.getValue().getOwnerId()));
+ } else {
+ final Map<String, T> valuesFrmPrevFinal = new HashMap<>();
+ mapFromGraph.entrySet().stream().forEach(e -> {
+ T value = e.getValue();
+ value = ToscaDataDefinition.removeAndCollectByOwnerId(value, preDerivedChainIdList);
+ valuesFrmPrevFinal.put(e.getKey(), value);
+ });
+ valuesFrmPrev = valuesFrmPrevFinal;
+ mapFromGraph.entrySet().removeIf(e->e.getValue().isEmpty());
+ }
-
Either<Map<String, T>, StorageOperationStatus> dataFromDerived = getDataFromDerived(newDerivedList, label);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
@@ -845,10 +886,74 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
return StorageOperationStatus.OK;
}
+
+ private boolean isSimpleHierarchy(EdgeLabelEnum label) {
+ switch (label) {
+ case PROPERTIES:
+ case ATTRIBUTES:
+ case ADDITIONAL_INFORMATION:
+ case ARTIFACTS:
+ case GROUPS:
+ case INPUTS:
+ return true;
+ default:
+ return false;
+ }
+ }
+
@Override
public <T extends ToscaElement> void fillToscaElementVertexData(GraphVertex elementV, T toscaElementToUpdate, JsonParseFlagEnum flag) {
fillMetadata(elementV, (NodeType) toscaElementToUpdate);
}
+ public Either<ToscaElement, StorageOperationStatus> shouldUpdateDerivedVersion(ToscaElement toscaElementToUpdate, GraphVertex nodeTypeV) {
+ NodeType nodeType = (NodeType) toscaElementToUpdate;
+
+ Either<GraphVertex, TitanOperationStatus> childVertex = titanDao.getChildVertex(nodeTypeV, EdgeLabelEnum.DERIVED_FROM, JsonParseFlagEnum.NoParse);
+ if (childVertex.isRight()) {
+ TitanOperationStatus getchildError = childVertex.right().value();
+ if (getchildError == TitanOperationStatus.NOT_FOUND) {
+ log.debug("derived resource for element {} not found", nodeTypeV.getUniqueId());
+ return Either.right(StorageOperationStatus.OK);
+ }
+
+ log.debug("Failed to fetch derived resource for element {} error {}", nodeTypeV.getUniqueId(), getchildError);
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getchildError));
+ }
+ GraphVertex firstDerivedInChain = childVertex.left().value();
+
+ String currentVersion = (String) firstDerivedInChain.getMetadataProperty(GraphPropertyEnum.VERSION);
+
+ Map<GraphPropertyEnum, Object> props = new HashMap<>();
+ props.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, nodeType.getDerivedFrom().get(0));
+ props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+
+ Map<GraphPropertyEnum, Object> propsHasNot = new HashMap<>();
+ propsHasNot.put(GraphPropertyEnum.IS_DELETED, true);
+ Either<List<GraphVertex>, TitanOperationStatus> byCriteria = titanDao.getByCriteria(VertexTypeEnum.NODE_TYPE, props, propsHasNot, JsonParseFlagEnum.NoParse);
+ if (byCriteria.isRight()) {
+ log.debug("Failed to fetch derived by props {} error {}", props, byCriteria.right().value());
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(byCriteria.right().value()));
+ }
+ List<GraphVertex> lastDerived = byCriteria.left().value();
+ // now supported only one derived!!! Change in future!(Evg)
+ GraphVertex derivedFromHighest = lastDerived.get(0);
+ String highestVersion = (String) derivedFromHighest.getMetadataProperty(GraphPropertyEnum.VERSION);
+ if (!highestVersion.equals(currentVersion)) {
+
+ // need to update to latest version of derived from
+ StorageOperationStatus updateDerived = updateDerived(toscaElementToUpdate, nodeTypeV, firstDerivedInChain, derivedFromHighest, true);
+
+ if (updateDerived != StorageOperationStatus.OK) {
+ log.debug("Failed to update {} to highest derived {} from error {}", nodeTypeV.getUniqueId(), derivedFromHighest.getUniqueId(), updateDerived);
+ return Either.right(updateDerived);
+ }
+ return getToscaElement(nodeTypeV.getUniqueId(), new ComponentParametersView());
+ }
+ // no version changes
+ return Either.right(StorageOperationStatus.OK);
+ }
+
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
index 51d122524c..f34975b073 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
@@ -1120,7 +1120,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
Map<String, GroupInstanceDataDefinition> groupInstanceToCreate = new HashMap<>();
for(GroupDataDefinition group:filteredGroups){
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "create new groupInstance {} ", group.getName());
- GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst);
+ GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst, instDeplArtifMap);
List<String> artifactsUid = new ArrayList<>();
List<String> artifactsId = new ArrayList<>();
for (ArtifactDataDefinition artifact : instDeplArtifMap.values()) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index b11036df49..394231938a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -275,8 +275,11 @@ public class ToscaOperationFacade {
public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName) {
return getLatestByName(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName);
-
}
+
+ public <T extends Component> Either<T, StorageOperationStatus> getFullLatestComponentByToscaResourceName(String toscaResourceName) {
+ return getLatestByName(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName, JsonParseFlagEnum.ParseAll);
+ }
public <T extends Component> Either<T, StorageOperationStatus> getLatestByName(String resourceName) {
return getLatestByName(GraphPropertyEnum.NAME, resourceName);
@@ -536,6 +539,39 @@ public class ToscaOperationFacade {
return getToscaElementByOperation(highestResource);
}
+ private <T extends Component> Either<T, StorageOperationStatus> getLatestByName(GraphPropertyEnum property, String nodeName, JsonParseFlagEnum parseFlag) {
+ Either<T, StorageOperationStatus> result;
+
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+ Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+
+ propertiesToMatch.put(property, nodeName);
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+
+ propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+
+ Either<List<GraphVertex>, TitanOperationStatus> highestResources = titanDao.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag);
+ if (highestResources.isRight()) {
+ TitanOperationStatus status = highestResources.right().value();
+ log.debug("failed to find resource with name {}. status={} ", nodeName, status);
+ result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
+ return result;
+ }
+
+ List<GraphVertex> resources = highestResources.left().value();
+ double version = 0.0;
+ GraphVertex highestResource = null;
+ for (GraphVertex vertex : resources) {
+ Object versionObj = vertex.getMetadataProperty(GraphPropertyEnum.VERSION);
+ double resourceVersion = Double.valueOf((String) versionObj);
+ if (resourceVersion > version) {
+ version = resourceVersion;
+ highestResource = vertex;
+ }
+ }
+ return getToscaElementByOperation(highestResource);
+ }
+
public <T extends Component> Either<List<T>, StorageOperationStatus> getBySystemName(ComponentTypeEnum componentType, String systemName) {
Either<List<T>, StorageOperationStatus> result = null;
@@ -2216,4 +2252,28 @@ public class ToscaOperationFacade {
return status;
}
+ public Either<Component, StorageOperationStatus> shouldUpgradeToLatestDerived(Resource clonedResource) {
+ String componentId = clonedResource.getUniqueId();
+ Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (getVertexEither.isRight()) {
+ log.debug("Couldn't fetch component with and unique id {}, error: {}", componentId, getVertexEither.right().value());
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVertexEither.right().value()));
+
+ }
+ GraphVertex nodeTypeV = getVertexEither.left().value();
+
+ ToscaElement toscaElementToUpdate = ModelConverter.convertToToscaElement(clonedResource);
+
+ Either<ToscaElement, StorageOperationStatus> shouldUpdateDerivedVersion = nodeTypeOperation.shouldUpdateDerivedVersion(toscaElementToUpdate, nodeTypeV);
+ if ( shouldUpdateDerivedVersion.isRight() && StorageOperationStatus.OK != shouldUpdateDerivedVersion.right().value() ){
+ log.debug("Failed to update derived version for node type {} derived {}, error: {}", componentId, clonedResource.getDerivedFrom().get(0), shouldUpdateDerivedVersion.right().value());
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVertexEither.right().value()));
+ }
+ if ( shouldUpdateDerivedVersion.isLeft() ){
+ return Either.left(ModelConverter.convertFromToscaElement(shouldUpdateDerivedVersion.left().value()));
+ }
+ return Either.left(clonedResource);
+ }
+
+
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
index 03a5f41d55..973b0ce069 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
@@ -94,6 +94,22 @@ public class ModelConverter {
return null;
}
}
+
+ public static boolean isAtomicComponent(Component component) {
+ ComponentTypeEnum componentType = component.getComponentType();
+ if (!componentType.equals(ComponentTypeEnum.RESOURCE)) {
+ return false;
+ }
+ Resource resource = (Resource) component;
+ ResourceTypeEnum resType = resource.getResourceType();
+ return isAtomicComponent(resType);
+ }
+
+ public static boolean isAtomicComponent(ResourceTypeEnum resourceType) {
+ if (resourceType == null || resourceType == ResourceTypeEnum.VF || resourceType == ResourceTypeEnum.PNF || resourceType == ResourceTypeEnum.CVFC)
+ return false;
+ return true;
+ }
// **********************************************************
public static VertexTypeEnum getVertexType(Component component) {
@@ -117,11 +133,7 @@ public class ModelConverter {
return vertexType;
}
- public static boolean isAtomicComponent(ResourceTypeEnum resourceType) {
- if (resourceType == null || resourceType == ResourceTypeEnum.VF || resourceType == ResourceTypeEnum.PNF || resourceType == ResourceTypeEnum.CVFC)
- return false;
- return true;
- }
+
private static Service convertToService(ToscaElement toscaElement) {
Service service = new Service();
@@ -303,6 +315,7 @@ public class ModelConverter {
relationshipPair.setCapabilityOwnerId(relation.getCapabilityOwnerId());
relationshipPair.setCapabilityUid(relation.getCapabilityId());
+ relationshipPair.setCapability(relation.getCapability());
relationshipPair.setRequirementOwnerId(relation.getRequirementOwnerId());
relationshipPair.setRequirementUid(relation.getRequirementId());
relationshipPair.setRequirement(relation.getRequirement());
@@ -991,18 +1004,7 @@ public class ModelConverter {
toscaElement.setMetadataValue(JsonPresentationFields.CONTACT_ID, component.getContactId());
}
- public static boolean isAtomicComponent(Component component) {
- ComponentTypeEnum componentType = component.getComponentType();
- if (!componentType.equals(ComponentTypeEnum.RESOURCE)) {
- return false;
- }
- Resource resource = (Resource) component;
- ResourceTypeEnum resType = resource.getResourceType();
- if (resType == ResourceTypeEnum.VFC || resType == ResourceTypeEnum.VFCMT || resType == ResourceTypeEnum.VL || resType == ResourceTypeEnum.CP || resType == ResourceTypeEnum.ABSTRACT) {
- return true;
- }
- return false;
- }
+
private static void setComponentInstancesToComponent(TopologyTemplate topologyTemplate, Component component) {
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
index df73adaa4a..b8d164e4aa 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.stream.Collectors;
import org.codehaus.jackson.annotate.JsonCreator;
@@ -104,4 +105,13 @@ public abstract class ToscaDataDefinition {
public boolean findUidMatch(String uid){
return uid.equals(getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID));
}
+ public <T extends ToscaDataDefinition> T removeByOwnerId(Set<String> ownerIdList) {
+ return (T) this;
+ }
+ public static <T extends ToscaDataDefinition> T removeAndCollectByOwnerId(T complexStructure, Set<String> ownerIdList) {
+ return complexStructure.removeByOwnerId(ownerIdList);
+ }
+ public boolean isEmpty(){
+ return false;
+ }
}
diff --git a/openecomp-be/tools/build/scripts/generate-cassandra-init-cql.sh b/openecomp-be/tools/build/scripts/generate-cassandra-init-cql.sh
index eaa9a3f59d..06065b1368 100644
--- a/openecomp-be/tools/build/scripts/generate-cassandra-init-cql.sh
+++ b/openecomp-be/tools/build/scripts/generate-cassandra-init-cql.sh
@@ -26,7 +26,7 @@ usage() { echo "Usage: $0 <db-cql-json-file> keyspace yes/no, for example: $0 ca
main()
{
- if [ $3 == 'yes' ]; then
+ if [ "$3" = "yes" ]; then
echo "CREATE KEYSPACE IF NOT EXISTS dox WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"
fi
echo "USE dox;"
diff --git a/openecomp-be/tools/build/scripts/zusammen-generate-cassandra-init-cql.sh b/openecomp-be/tools/build/scripts/zusammen-generate-cassandra-init-cql.sh
index b215fb3ce7..8cb422a121 100644
--- a/openecomp-be/tools/build/scripts/zusammen-generate-cassandra-init-cql.sh
+++ b/openecomp-be/tools/build/scripts/zusammen-generate-cassandra-init-cql.sh
@@ -27,7 +27,7 @@ usage() { echo "Usage: $0 <db-cql-json-file> keyspace yes/no, for example: $0 ca
main()
{
- if [ $3 == 'yes' ]; then
+ if [ "$3" = "yes" ]; then
echo "CREATE KEYSPACE IF NOT EXISTS $KEYSPACE_ZUSAMMEN WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };"
fi
echo "USE $KEYSPACE_ZUSAMMEN;"
diff --git a/sdc-os-chef/pom.xml b/sdc-os-chef/pom.xml
index f0bf6ec9ff..a14dfc5ae1 100644
--- a/sdc-os-chef/pom.xml
+++ b/sdc-os-chef/pom.xml
@@ -33,24 +33,17 @@
</goals>
<configuration>
<filesets>
- <fileset>
- <directory>${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\</directory>
- <followSymlinks>false</followSymlinks>
- <includes>
- <include>**/default.rb</include>
- </includes>
- </fileset>
<!-- static configuration files -->
<fileset>
<directory>${project.parent.basedir}/sdc-os-chef/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default</directory>
<followSymlinks>false</followSymlinks>
<includes>
- <include>Artifact-Generator.properties</include>
- <include>error-configuration.yaml</include>
- <include>ecomp-error-configuration.yaml</include>
- <include>logback.xml</include>
- </includes>
- </fileset>
+ <include>Artifact-Generator.properties</include>
+ <include>error-configuration.yaml</include>
+ <include>ecomp-error-configuration.yaml</include>
+ <include>logback.xml</include>
+ </includes>
+ </fileset>
<!-- BE WAR's -->
<fileset>
<directory>${project.parent.basedir}/sdc-os-chef/sdc-backend</directory>
@@ -74,6 +67,17 @@
<include>normatives.tar.gz</include>
</includes>
</fileset>
+ <fileset>
+ <directory>${project.basedir}/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/</directory>
+ <followSymlinks>false</followSymlinks>
+ <includes>
+ <include>**/default.rb</include>
+ </includes>
+ </fileset>
+ <fileset>
+ <directory>${project.basedir}/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/tools</directory>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
<!-- Sanity jar -->
<fileset>
<directory>${project.basedir}/sdc-sanity</directory>
@@ -104,7 +108,7 @@
${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\default.rb
</path>
<lines>
- <line>normal['version'] = "${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</line>
+ <line>normal['version'] ="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</line>
</lines>
</file>
</files>
@@ -255,6 +259,7 @@
</resources>
</configuration>
</execution>
+
<execution>
<id>copy-resources-test-apis-ci</id>
<phase>validate</phase>
@@ -273,6 +278,33 @@
</resources>
</configuration>
</execution>
+
+
+ <execution>
+ <id>copy-dox-files</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${project.parent.basedir}/openecomp-be</directory>
+ <includes>
+ <include>tools/build/**</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${project.parent.basedir}/openecomp-be</directory>
+ <includes>
+ <include>tools/install/**</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+
<execution>
<id>copy-normatives</id>
<phase>validate</phase>
@@ -306,11 +338,10 @@
<registry>nexus3.onap.org:10001</registry>
<authConfig>
<pull>
- <username>docker</username>
- <password>docker</password>
- </pull>
- </authConfig>
-
+ <username>docker</username>
+ <password>docker</password>
+ </pull>
+ </authConfig>
<images>
<!-- Build backend image -->
diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh
index ed4246d72c..79173c9654 100755
--- a/sdc-os-chef/scripts/docker_run.sh
+++ b/sdc-os-chef/scripts/docker_run.sh
@@ -56,19 +56,36 @@ fi
RELEASE=latest
LOCAL=false
-SKIPTESTS=false
+RUNTESTS=false
DEBUG_PORT="--publish 4000:4000"
while [ $# -gt 0 ]
do
case $1 in
- -r | --release ) shift 1 ; RELEASE=$1 ; shift 1 ;;
- -e | --environment ) shift 1 ; DEP_ENV=$1 ; shift 1 ;;
- -p | --port ) shift 1 ; PORT=$1 ; shift 1 ;;
- -l | --local ) LOCAL=true ; shift 1 ;;
- -s | --skipTests ) SKIPTESTS=true ; shift 1 ;;
- -h | --help ) usage ; exit 0 ;;
- * ) usage ; exit 1 ;;
+ -r | --release )
+ shift 1 ;
+ RELEASE=$1;
+ shift 1;;
+ -e | --environment )
+ shift 1;
+ DEP_ENV=$1;
+ shift 1 ;;
+ -p | --port )
+ shift 1 ;
+ PORT=$1;
+ shift 1 ;;
+ -l | --local )
+ LOCAL=true;
+ shift 1;;
+ -t | --runTests )
+ RUNTESTS=true;
+ shift 1 ;;
+ -h | --help )
+ usage;
+ exit 0;;
+ * )
+ usage;
+ exit 1;;
esac
done
@@ -187,7 +204,7 @@ echo -e ""
# sanityDocker
echo "docker run sdc-sanity..."
-if [ ${SKIPTESTS} = false ]; then
+if [ ${RUNTESTS} = true ]; then
echo "Triger sanity docker, please wait..."
if [ ${LOCAL} = false ]; then
docker pull ${PREFIX}/sdc-sanity:${RELEASE}
diff --git a/sdc-os-chef/scripts/docker_sanity_run.sh b/sdc-os-chef/scripts/docker_sanity_run.sh
new file mode 100644
index 0000000000..339b538f7a
--- /dev/null
+++ b/sdc-os-chef/scripts/docker_sanity_run.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+
+
+function usage {
+ echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -s|--skipTests <Run-without-sanityDocker>] [ -h|--help ]"
+}
+
+
+function cleanup {
+ echo "performing old dockers cleanup"
+ docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'`
+ for X in ${docker_ids}
+ do
+ docker rm -f ${X}
+ done
+}
+
+
+function dir_perms {
+ mkdir -p /data/logs/BE/SDC/SDC-BE
+ mkdir -p /data/logs/FE/SDC/SDC-FE
+ chmod -R 777 /data/logs
+}
+
+function monitor_docker {
+
+echo monitor $1 Docker
+sleep 10
+TIME_OUT=800
+INTERVAL=20
+TIME=0
+while [ "$TIME" -lt "$TIME_OUT" ]; do
+
+MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
+echo MATCH is -- $MATCH
+
+if [ -n "$MATCH" ]
+ then
+ echo DOCKER start finished in $TIME seconds
+ break
+ fi
+
+ echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
+ sleep $INTERVAL
+ TIME=$(($TIME+$INTERVAL))
+done
+
+if [ "$TIME" -ge "$TIME_OUT" ]
+ then
+ echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
+fi
+
+
+}
+
+
+RELEASE=latest
+LOCAL=false
+SKIPTESTS=false
+DEBUG_PORT="--publish 4000:4000"
+
+[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
+[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
+[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
+[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT}
+
+while test $# -gt 0; do
+ case $1 in
+ -r | --release )
+ shift
+ RELEASE=$1
+ ;;
+ -e | --environment )
+ shift
+ DEP_ENV=$1
+ ;;
+ -p | --port )
+ shift
+ PORT=$1
+ ;;
+ -l | --local )
+ shift
+ LOCAL=true
+ ;;
+ -s | --skipTests )
+ shift
+ SKIPTESTS=true
+ ;;
+ -h | --help )
+ usage
+ exit
+ ;;
+ * )
+ usage
+ exit 1
+ esac
+done
+
+[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
+
+
+
+
+export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
+export PREFIX=${NEXUS_DOCKER_REPO}'/openecomp'
+
+if [ ${LOCAL} = true ]; then
+ PREFIX='openecomp'
+fi
+
+echo ""
+
+
+# sanityDocker
+echo "docker run sdc-frontend..."
+if [ ${SKIPTESTS} = false ]; then
+echo "Triger sanity docker, please wait..."
+ if [ ${LOCAL} = false ]; then
+ docker pull ${PREFIX}/sdc-sanity:${RELEASE}
+ fi
+ docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 1.2g --memory-swap=1.2g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/sdc-sanity/target:/var/lib/tests/target --volume /data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume /data/environments:/root/chef-solo/environments --publish 8849:8849 --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE}
+fi
diff --git a/sdc-os-chef/scripts/sanity_run.sh b/sdc-os-chef/scripts/sanity_run.sh
new file mode 100644
index 0000000000..17d1642c73
--- /dev/null
+++ b/sdc-os-chef/scripts/sanity_run.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+
+function usage {
+ echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -s|--skipTests <Run-without-sanityDocker>] [ -h|--help ]"
+}
+
+
+function cleanup {
+ echo "performing old dockers cleanup"
+ docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc-sanity|sdc-sanity|Exit" | awk '{print $1}'`
+ for X in ${docker_ids}
+ do
+ docker rm -f ${X}
+ done
+}
+
+
+function dir_perms {
+ mkdir -p /data/logs/BE/SDC/SDC-BE
+ mkdir -p /data/logs/FE/SDC/SDC-FE
+ chmod -R 777 /data/logs
+}
+
+function monitor_docker {
+
+echo monitor $1 Docker
+sleep 5
+TIME_OUT=900
+INTERVAL=20
+TIME=0
+while [ "$TIME" -lt "$TIME_OUT" ]; do
+
+MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"`
+echo MATCH is -- $MATCH
+
+if [ -n "$MATCH" ]
+ then
+ echo DOCKER start finished in $TIME seconds
+ break
+ fi
+
+ echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
+ sleep $INTERVAL
+ TIME=$(($TIME+$INTERVAL))
+done
+
+if [ "$TIME" -ge "$TIME_OUT" ]
+ then
+ echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m"
+fi
+
+
+}
+
+
+RELEASE=latest
+LOCAL=false
+SKIPTESTS=false
+DEBUG_PORT="--publish 4000:4000"
+
+[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
+[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
+[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
+[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT}
+
+while [ "$1" != "" ]; do
+ case $1 in
+ -r | --release )
+ shift
+ RELEASE=${1}
+ ;;
+ -e | --environment )
+ shift
+ DEP_ENV=${1}
+ ;;
+ -p | --port )
+ shift
+ PORT=${1}
+ ;;
+ -l | --local )
+ shift
+ LOCAL=true
+ ;;
+ -s | --skipTests )
+ shift
+ SKIPTESTS=true
+ ;;
+ -h | --help )
+ usage
+ exit
+ ;;
+ * )
+ usage
+ exit 1
+ esac
+ shift
+done
+
+[ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
+
+export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
+export PREFIX=${NEXUS_DOCKER_REPO}'/openecomp'
+
+if [ ${LOCAL} = true ]; then
+ PREFIX='openecomp'
+fi
+
+## sanityDocker
+echo "docker run sdc-sanity..."
+if [ ${SKIPTESTS} = false ]; then
+echo "Triger sanity docker, please wait..."
+ if [ ${LOCAL} = false ]; then
+ docker pull ${PREFIX}/sdc-sanity:${RELEASE}
+ fi
+ docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 1g --memory-swap=1g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/sdc-sanity/target:/var/lib/tests/target --volume /data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume /data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume /data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE}
+fi \ No newline at end of file
diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb
index 646a14dc27..6bac10e196 100644
--- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb
+++ b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb
@@ -1 +1 @@
-normal['version'] = "1.2.0"
+normal['version'] ="1.2.0"
diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/alter_dox_db.cql b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/alter_dox_db.cql
deleted file mode 100644
index 70daf8bc6b..0000000000
--- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/alter_dox_db.cql
+++ /dev/null
@@ -1,8 +0,0 @@
-USE dox;
-ALTER TABLE vsp_information ADD questionnaire_data text;
-ALTER TABLE vsp_information ADD vlm_version frozen<version>;
-ALTER TABLE vsp_information ADD onboarding_method text;
-ALTER TABLE vsp_process ADD type text;
-alter table entitlement_pool ADD version_uuid text;
-alter table license_key_group ADD version_uuid text;
-delete from application_config where namespace='vsp.monitoring' and key = 'component.ceilometer';
diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/create_dox_db.cql b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/create_dox_db.cql
deleted file mode 100644
index e9aea31f7c..0000000000
--- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/files/default/create_dox_db.cql
+++ /dev/null
@@ -1,60 +0,0 @@
-USE dox;
-CREATE TYPE IF NOT EXISTS version (major int, minor int);
-CREATE TYPE IF NOT EXISTS user_candidate_version (version frozen<version>, user text);
-CREATE TABLE IF NOT EXISTS version_info (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id));
-CREATE TABLE IF NOT EXISTS version_info_deleted (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id));
-CREATE TABLE IF NOT EXISTS unique_value (type text, value text, PRIMARY KEY ((type, value)));
-CREATE TYPE IF NOT EXISTS choice_or_other (result text);
-CREATE TYPE IF NOT EXISTS multi_choice_or_other (results set<text>);
-CREATE TABLE IF NOT EXISTS vendor_license_model (vlm_id text, version frozen<version>, vendor_name text, description text, icon text, PRIMARY KEY ((vlm_id, version)));
-CREATE TABLE IF NOT EXISTS license_agreement (vlm_id text, version frozen<version>, la_id text, name text, description text, lic_term frozen<choice_or_other>, req_const text, fg_ids set<text>, PRIMARY KEY ((vlm_id, version), la_id));
-CREATE TABLE IF NOT EXISTS feature_group (vlm_id text, version frozen<version>, fg_id text, name text, description text, part_num text, ep_ids set<text>, lkg_ids set<text>, ref_la_ids set<text>, PRIMARY KEY ((vlm_id, version), fg_id));
-CREATE TABLE IF NOT EXISTS license_key_group (vlm_id text, version frozen<version>, lkg_id text,name text,description text, type text, operational_scope frozen<multi_choice_or_other>, ref_fg_ids set<text>, version_uuid text, PRIMARY KEY ((vlm_id, version), lkg_id));
-CREATE TABLE IF NOT EXISTS entitlement_pool (vlm_id text, version frozen<version>, ep_id text,name text,description text,threshold float,threshold_unit text,entitlement_metric frozen<choice_or_other>,increments text,aggregation_func frozen<choice_or_other>, operational_scope frozen<multi_choice_or_other>, time frozen<choice_or_other>,manufacturer_ref_num text,ref_fg_ids set<text>, version_uuid text, PRIMARY KEY ((vlm_id, version), ep_id));
-CREATE TABLE IF NOT EXISTS vsp_information (VSP_ID text, version frozen<version>, NAME text,DESCRIPTION text,CATEGORY text,SUB_CATEGORY text,ICON text,PACKAGE_NAME text,PACKAGE_VERSION text,vendor_name text, vendor_id text,LICENSE_AGREEMENT text,FEATURE_GROUPS list<text>,VALIDATION_DATA text,CONTENT_DATA blob, questionnaire_data text, vlm_version frozen<version>, is_old_version text, onboarding_method text, PRIMARY KEY ((VSP_ID, version)));
-CREATE TABLE IF NOT EXISTS package_details (VSP_ID text, version frozen<version>,DISPLAY_NAME text,vsp_name text,vsp_description text,VENDOR_NAME text,CATEGORY text,SUB_CATEGORY text,VENDOR_RELEASE text,PACKAGE_CHECKSUM text,PACKAGE_TYPE text,TRANSLATE_CONTENT blob,PRIMARY KEY ((VSP_ID, version)));
-CREATE TABLE IF NOT EXISTS vsp_network (vsp_id text, version frozen<version>, network_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), network_id));
-CREATE TABLE IF NOT EXISTS vsp_component (vsp_id text, version frozen<version>, component_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id));
-CREATE TABLE IF NOT EXISTS vsp_component_nic (vsp_id text, version frozen<version>, component_id text, nic_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, nic_id));
-CREATE TABLE IF NOT EXISTS vsp_component_image (vsp_id text, version frozen<version>, component_id text, image_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, image_id));
-CREATE TABLE IF NOT EXISTS vsp_process (vsp_id text, version frozen<version>, component_id text, process_id text, name text, description text, type text, artifact_name text, artifact blob, PRIMARY KEY ((vsp_id, version), component_id, process_id));
-CREATE TABLE IF NOT EXISTS vsp_service_artifact (vsp_id text, version frozen<version>, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
-CREATE TABLE IF NOT EXISTS vsp_service_template (vsp_id text, version frozen<version>, base_name text static, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
-CREATE TABLE IF NOT EXISTS vsp_enriched_service_template (vsp_id text, version frozen<version>, base_name text static, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
-CREATE TABLE IF NOT EXISTS vsp_enriched_service_artifact (vsp_id text, version frozen<version>, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
-CREATE TABLE IF NOT EXISTS application_config (namespace text, key text, value text, PRIMARY KEY (namespace, key));
-CREATE TABLE IF NOT EXISTS dox.Action (actionUUID text, actionInvariantUUID text, version frozen<version>, status text, name text, vendor_list set<text>, category_list set<text>, timestamp timestamp, user text, supportedModels set<text>, supportedComponents set<text>, data text, PRIMARY KEY ((actionInvariantUUID, version)));
-CREATE INDEX IF NOT EXISTS action_supportedComponents ON dox.Action (supportedComponents);
-CREATE INDEX IF NOT EXISTS action_category_list ON dox.Action (category_list);
-CREATE INDEX IF NOT EXISTS action_supportedModels ON dox.Action (supportedModels);
-CREATE INDEX IF NOT EXISTS action_vendor_list ON dox.Action (vendor_list);
-CREATE INDEX IF NOT EXISTS action_actionUUID ON dox.Action (actionUUID);
-CREATE TABLE IF NOT EXISTS dox.ecompcomponent(id text PRIMARY KEY, name text);
-CREATE TABLE IF NOT EXISTS vsp_component_artifact (vsp_id text, version frozen<version>, component_id text, artifact_type text, artifact_id text, name text, description text, artifact blob, PRIMARY KEY ((vsp_id, version), component_id, artifact_type, artifact_id));
-CREATE INDEX IF NOT EXISTS action_name ON dox.Action (name);
-CREATE TABLE IF NOT EXISTS action_artifact(artifactuuid text, effective_version int, artifact blob, PRIMARY KEY(artifactuuid, effective_version)) WITH CLUSTERING ORDER BY (effective_version DESC);
-CREATE TABLE IF NOT EXISTS vsp_orchestration_template_candidate (vsp_id text, version frozen<version>, files_data_structure text, content_data blob, PRIMARY KEY ((vsp_id, version)));
-CREATE TABLE IF NOT EXISTS vsp_deployment_flavor (vsp_id text, version frozen<version>, deployment_flavor_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), deployment_flavor_id));
-CREATE TABLE IF NOT EXISTS vsp_component_compute (vsp_id text, version frozen<version>, component_id text, compute_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, compute_id));
-CREATE TABLE IF NOT EXISTS vsp_component_dependency_model (vsp_id text, version frozen<version>, dependency_id text, sourcecomponent_id text, targetcomponent_id text, relation text, PRIMARY KEY ((vsp_id, version), dependency_id));
-CREATE TABLE IF NOT EXISTS activity_log (item_id text, version_id text, activity_id text, type text, user text, timestamp timestamp, success boolean, message text, comment text, PRIMARY KEY (item_id, version_id, activity_id));
-CREATE TABLE IF NOT EXISTS migration (id text, ismigrated boolean, primary key(id));
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.network', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "type": "string"<#if !manual>, "enum": [ "${network.name}" ], "default": "${network.name}"</#if> }, "dhcp": { "type": "boolean"<#if !manual>, "enum": [ ${network.dhcp?c} ], "default": ${network.dhcp?c}</#if> } }, "additionalProperties": false, "required": [ "name", "dhcp" ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.component', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "type": "string"<#if !manual>, "enum": [ "${component.name}" ], "default": "${component.name}"</#if> }, "displayName": { "type": "string"<#if !manual && component.displayName??>, "enum": [ "${component.displayName}" ], "default": "${component.displayName}"</#if> }, "vfcCode": { "type": "string" }, "nfcCode": { "type": "string" }, "nfcFunction": { "type": "string" }, "description": { "type": "string" } }, "additionalProperties": false, "required": [ "name"<#if !manual && component.displayName??>, "displayName"</#if> ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.compute', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "type": "string" <#if !manual>, "enum": [ "${compute.name}" ], "default": "${compute.name}"</#if> }, "description": { "type": "string", "maxLength": 300 } } }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.deployment', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "model": { "type": "string", "maxLength": 30, "pattern": "^[A-Za-z0-9_,-]*$" }, "description": { "type": "string", "maxLength": 300 }, "featureGroupId":{ "type": "string", "enum": [<#if featureGroupIds??> <#list featureGroupIds as featureGroupId> "${featureGroupId}"<#sep>,</#list> </#if> ] }, "componentComputeAssociations": { "type": "array", "properties": { "vfcid": { "type": "string" }, "computeFlavorid": { "type": "string" } }, "additionalProperties": false } }, "additionalProperties": false, "required": [ "model" ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.image', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "fileName": { "type": "string" }, "description": { "type": "string" } }, "additionalProperties": false }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'composition.nic', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "type": "string", "enum": [ "${nic.name}" ], "default": "${nic.name}" }, "description": { "type": "string" }<#if !manual><#if nic.networkId??>, "networkId": { "type": "string", "enum": [ "${nic.networkId}" ], "default": "${nic.networkId}" } </#if> <#elseif manual><#if nic.networkId??>, "networkId": { "type": "string", "enum": [ "${nic.networkId}" ], "default": "${nic.networkId}" } </#if> <#else>, "networkId": { "type": "string", "enum": [<#list networkIds as networkId> "${networkId}"<#sep>,</#list> ] } </#if>, "networkDescription": { "type": "string" }, "networkType": { "type": "string", "enum": [ "${nic.networkType}" ], "default": "${nic.networkType}" } }, "additionalProperties": false, "required": [ "name" ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'questionnaire.nic', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "protocols": { "type": "object", "properties": { "protocols": { "type": "array", "items": { "type": "string", "enum": [ "", "TCP", "UDP", "SCTP", "IPsec" ], "default": "" }, "minItems": 1 }, "protocolWithHighestTrafficProfile": { "$ref": "#/properties/protocols/properties/protocols/items" } }, "additionalProperties": false }, "ipConfiguration": { "type": "object", "properties": { "ipv4Required": { "type": "boolean", "default": true }, "ipv6Required": { "type": "boolean", "default": false } }, "additionalProperties": false }, "network": { "type": "object", "properties": { "networkDescription": { "type": "string", "pattern": "[A-Za-z]+", "maxLength": 300 } }, "additionalProperties": false }, "sizing": { "type": "object", "definitions": { "peakAndAvg": { "type": "object", "properties": { "peak": { "type": "number" }, "avg": { "type": "number" } }, "additionalProperties": false }, "packetsAndBytes": { "type": "object", "properties": { "packets": { "$ref": "#/properties/sizing/definitions/peakAndAvg" }, "bytes": { "$ref": "#/properties/sizing/definitions/peakAndAvg" } }, "additionalProperties": false } }, "properties": { "describeQualityOfService": { "type": "string" }, "inflowTrafficPerSecond": { "$ref": "#/properties/sizing/definitions/packetsAndBytes" }, "outflowTrafficPerSecond": { "$ref": "#/properties/sizing/definitions/packetsAndBytes" }, "flowLength": { "$ref": "#/properties/sizing/definitions/packetsAndBytes" }, "acceptableJitter": { "type": "object", "properties": { "mean": { "type": "number" }, "max": { "type": "number" }, "variable": { "type": "number" } }, "additionalProperties": false }, "acceptablePacketLoss": { "type": "number", "minimum": 0, "maximum": 100 } }, "additionalProperties": false } }, "additionalProperties": false }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'questionnaire.vsp', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "general": { "type": "object", "properties": { "affinityData": { "type": "string", "enum": [ "", "Affinity", "Anti Affinity", "None" ], "default": "" }, "availability": { "type": "object", "properties": { "useAvailabilityZonesForHighAvailability": { "type": "boolean", "default": false } }, "additionalProperties": false }, "regionsData": { "type": "object", "properties": { "multiRegion": { "type": "boolean", "default": false }, "regions": { "type": "array", "items": { "type": "string", "enum": [ "", "Alphareta", "Birmingham", "Dallas", "Fairfield CA", "Hayward CA", "Lisle", "Mission", "San Diego", "Secaucus" ], "default": "" } } }, "additionalProperties": false }, "storageDataReplication": { "type": "object", "properties": { "storageReplicationAcrossRegion": { "type": "boolean", "default": false }, "storageReplicationSize": { "type": "number", "maximum": 100, "exclusiveMaximum": true }, "storageReplicationFrequency": { "type": "number", "minimum": 5 }, "storageReplicationSource": { "type": "string", "maxLength": 300 }, "storageReplicationDestination": { "type": "string", "maxLength": 300 } }, "additionalProperties": false } }, "additionalProperties": false } }, "additionalProperties": false }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'questionnaire.component', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "general": { "type": "object", "properties": { "hypervisor": { "type": "object", "properties": { "hypervisor": { "type": "string", "enum": [ "KVM", "VMWare ESXi" ], "default": "KVM" }, "drivers": { "type": "string", "maxLength": 300, "pattern": "^[A-Za-z0-9_,-]*$" }, "containerFeaturesDescription": { "type": "string", "maxLength": 1000, "pattern": "^[A-Za-z0-9_, -]*$" } }, "additionalProperties": false }, "image": { "type": "object", "properties": { "providedBy": { "type": "string", "enum": [ "AIC", "Vendor" ], "default": "AIC" } }, "additionalProperties": false }, "disk": { "type": "object" , "properties": { "bootDiskSizePerVM": { "type": "number", "maximum": 100 }, "ephemeralDiskSizePerVM": { "type": "number", "maximum": 400 } }, "additionalProperties": false }, "recovery": { "type": "object", "properties": { "pointObjective": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "maximum": 15, "exclusiveMaximum ": true }, "timeObjective": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "maximum": 300, "exclusiveMaximum ": true }, "vmProcessFailuresHandling": { "type": "string" } }, "additionalProperties": false }, "dnsConfiguration": { "type": "string" }, "vmCloneUsage": { "type": "string", "maxLength": 300 } }, "additionalProperties": false }, "compute": { "type": "object", "properties": { "numOfVMs": { "type": "object", "properties": { "minimum": { "type": "number", "minimum": 0, "maximum": 100 }, "maximum": { "type": "number", "minimum": <#if (componentQuestionnaireData.compute.numOfVMs.minimum)?? && (componentQuestionnaireData.compute.numOfVMs.minimum)?is_number && ((componentQuestionnaireData.compute.numOfVMs.minimum) > 0 && (componentQuestionnaireData.compute.numOfVMs.minimum) <= 100)> ${componentQuestionnaireData.compute.numOfVMs.minimum}<#else> 0</#if> , "exclusiveMinimum": true, "maximum": 100 } }, "additionalProperties": false }, "guestOS": { "type": "object", "properties": { "name": { "type": "string", "maxLength": 50 }, "bitSize": { "type": "number", "enum": [ 64, 32 ], "default": 64 }, "tools": { "type": "string" } }, "additionalProperties": false } }, "additionalProperties": false }, "highAvailabilityAndLoadBalancing": { "type": "object", "properties": { "isComponentMandatory": { "type": "string", "enum": ["","YES", "NO"], "default": "" }, "highAvailabilityMode": { "type": "string", "enum": ["","geo-activeactive", "geo-activestandby", "local-activeactive", "local-activestandby"], "default": "" }, "failureLoadDistribution": { "type": "string", "maxLength": 1000 }, "nkModelImplementation": { "type": "string", "maxLength": 1000 }, "architectureChoice": { "type": "string", "maxLength": 1000 }, "slaRequirements": { "type": "string", "maxLength": 1000 }, "horizontalScaling": { "type": "string", "maxLength": 1000 }, "loadDistributionMechanism": { "type": "string", "maxLength": 1000 } }, "additionalProperties": false }, "network": { "type": "object", "properties": { "networkCapacity": { "type": "object", "properties": { "protocolWithHighestTrafficProfileAcrossAllNICs": { "type": "string", "enum": [ "", "TCP", "UDP", "SCTP", "IPsec" ], "default": "" }, "networkTransactionsPerSecond": { "type": "number" } }, "additionalProperties": false } }, "additionalProperties": false }, "storage": { "type": "object", "properties": { "backup": { "type": "object", "properties": { "backupType": { "type": "string", "enum": [ "On Site", "Off Site" ], "default": "On Site" }, "backupStorageSize": { "type": "number" }, "backupSolution": { "type": "string" }, "backupNIC": { "type": "string", "enum": [ ""<#if nicNames??><#list nicNames as nicName> , "${nicName}"</#list></#if> ], "default": "" } }, "additionalProperties": false }, "snapshotBackup": { "type": "object", "properties": { "snapshotFrequency": { "type": "number", "default": 24, "minimum": 1, "exclusiveMinimum": true } }, "additionalProperties": false }, "logBackup": { "type": "object", "properties": { "sizeOfLogFiles": { "type": "number", "maximum": 5, "exclusiveMaximum": true }, "logBackupFrequency": { "type": "number", "maximum": 4, "exclusiveMaximum": true }, "logRetentionPeriod": { "type": "number", "maximum": 15, "exclusiveMaximum": true }, "logFileLocation": { "type": "string", "maxLength": 300 } }, "additionalProperties": false } }, "additionalProperties": false } }, "additionalProperties": false }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'questionnaire.compute', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "vmSizing": { "type": "object", "properties": { "numOfCPUs": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "maximum": 16, "default": 2 }, "fileSystemSizeGB": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "default": 5 }, "persistentStorageVolumeSize": { "type": "number", "minimum": 0, "exclusiveMinimum": true }, "ioOperationsPerSec": { "type": "number", "minimum": 0, "exclusiveMinimum": true }, "cpuOverSubscriptionRatio": { "type": "string", "enum": [ "1:1", "4:1", "16:1" ], "default": "4:1" }, "memoryRAM": { "type": "string", "enum": [ "1 GB", "2 GB", "4 GB", "8 GB" ], "default": "1 GB" } }, "additionalProperties": false } } }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.schemaTemplates', 'questionnaire.image', '{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "format": { "type": "string", "enum": [ "aki","ami","ari","iso","qcow2","raw", "vdi","vhd","vmdk" ] }, "version": { "type": "string" }, "md5": { "type": "string" } }, "additionalProperties": false, "required": [ "version" ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.monitoring', 'compute.ceilometer', '{ "ceilometerMetricList": [ { "name": "instance", "type": "Gauge", "unit": "instance", "category": "compute", "description": "Existence of instance" }, { "name": "memory", "type": "Gauge", "unit": "MB", "category": "compute", "description": "Volume of RAM allocated to the instance" }, { "name": "memory.usage", "type": "Gauge", "unit": "MB", "category": "compute", "description": "Volume of RAM used by the instance from the amount of its allocated memory" }, { "name": "memory.resident", "type": "Gauge", "unit": "MB", "category": "compute", "description": "Volume of RAM used by the instance on the physical machine" }, { "name": "cpu", "type": "Cumulative", "unit": "ns", "category": "compute", "description": "CPU time used" }, { "name": "cpu_util", "type": "Gauge", "unit": "%", "category": "compute", "description": "Average CPU utilization" }, { "name": "cpu.delta", "type": "Delta", "unit": "ns", "category": "compute", "description": "CPU time used since previous datapoint" }, { "name": "vcpus", "type": "Gauge", "unit": "vcpu", "category": "compute", "description": "Number of virtual CPUs allocated to the instance" }, { "name": "disk.latency", "type": "Gauge", "unit": "ms", "category": "disk", "description": "Average disk latency" }, { "name": "disk.iops", "type": "Gauge", "unit": "count/s", "category": "disk", "description": "Average disk iops" }, { "name": "disk.device.latency", "type": "Gauge", "unit": "ms", "category": "disk", "description": "Average disk latency per device" }, { "name": "disk.device.iops", "type": "Gauge", "unit": "count/s", "category": "disk", "description": "Average disk iops per device" }, { "name": "disk.capacity", "type": "Gauge", "unit": "B", "category": "disk", "description": "The amount of disk that the instance can see" }, { "name": "disk.allocation", "type": "Gauge", "unit": "B", "category": "disk", "description": "The amount of disk occupied by the instance on the host machine" }, { "name": "disk.usage", "type": "Gauge", "unit": "B", "category": "disk", "description": "The physical size in bytes of the image container on the host" }, { "name": "disk.device.capacity", "type": "Gauge", "unit": "B", "category": "disk", "description": "The amount of disk per device that the instance can see" }, { "name": "disk.device.allocation", "type": "Gauge", "unit": "B", "category": "disk", "description": "The amount of disk per device occupied by the instance on the host machine" }, { "name": "disk.device.usage", "type": "Gauge", "unit": "B", "category": "disk", "description": "The physical size in bytes of the image container on the host per device" }, { "name": "disk.device.read.requests", "type": "Cumulative", "unit": "request", "category": "disk", "description": "Number of read requests" }, { "name": "disk.device.read.requests.rate", "type": "Gauge", "unit": "request/s", "category": "disk", "description": "Average rate of read requests" }, { "name": "disk.device.write.requests", "type": "Cumulative", "unit": "request", "category": "disk", "description": "Number of write requests" }, { "name": "disk.device.write.requests.rate", "type": "Gauge", "unit": "request/s", "category": "disk", "description": "Average rate of write requests" }, { "name": "disk.device.read.bytes", "type": "Cumulative", "unit": "B", "category": "disk", "description": "Volume of reads" }, { "name": "disk.device.read.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "disk", "description": "Average rate of reads" }, { "name": "disk.device.write.bytes", "type": "Cumulative", "unit": "B", "category": "disk", "description": "Volume of writes" }, { "name": "disk.device.write.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "disk", "description": "Average rate of writes" }, { "name": "disk.write.requests", "type": "Cumulative", "unit": "request", "category": "compute", "description": "Number of write requests" }, { "name": "disk.write.requests.rate", "type": "Gauge", "unit": "request/s", "category": "compute", "description": "Average rate of write requests" }, { "name": "disk.read.bytes", "type": "Cumulative", "unit": "B", "category": "compute", "description": "Volume of reads" }, { "name": "disk.read.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "compute", "description": "Average rate of reads" }, { "name": "disk.write.bytes", "type": "Cumulative", "unit": "B", "category": "compute", "description": "Volume of writes" }, { "name": "disk.write.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "compute", "description": "Average rate of writes" }, { "name": "disk.read.requests", "type": "Cumulative", "unit": "request", "category": "compute", "description": "Number of read requests" }, { "name": "disk.root.size", "type": "Gauge", "unit": "GB", "category": "compute", "description": "Size of root disk" }, { "name": "disk.ephemeral.size", "type": "Gauge", "unit": "GB", "category": "compute", "description": "Size of ephemeral disk" } ] }');
-INSERT INTO application_config (namespace,key,value) VALUES ('vsp.monitoring', 'port.ceilometer', '{ "ceilometerMetricList": [ { "name": "network.incoming.bytes", "type": "Cumulative", "unit": "B", "category": "network", "description": "Number of incoming bytes" }, { "name": "network.incoming.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "network", "description": "Average rate of incoming bytes" }, { "name": "network.outgoing.bytes", "type": "Cumulative", "unit": "B", "category": "network", "description": "Number of outgoing bytes" }, { "name": "network.outgoing.bytes.rate", "type": "Gauge", "unit": "B/s", "category": "network", "description": "Average rate of outgoing bytes" }, { "name": "network.incoming.packets", "type": "Cumulative", "unit": "packet", "category": "network", "description": "Number of incoming packets" }, { "name": "network.incoming.packets.rate", "type": "Gauge", "unit": "packet/s", "category": "network", "description": "Average rate of incoming packets" }, { "name": "network.outpoing.packets", "type": "Cumulative", "unit": "packet", "category": "network", "description": "Number of outgoing packets" }, { "name": "network.outgoing.packets.rate", "type": "Gauge", "unit": "packet/s", "category": "network", "description": "Average rate of outgoing packets" } ] }');
-USE zusammen_dox;
-CREATE TABLE IF NOT EXISTS item (item_id text primary key, item_info text, creation_time timestamp, modification_time timestamp);
-CREATE TABLE IF NOT EXISTS version (space text, item_id text, version_id text,base_version_id text,info text,relations text,creation_time timestamp,modification_time timestamp,PRIMARY KEY (( space, item_id ), version_id));
-CREATE TABLE IF NOT EXISTS version_elements (space text,item_id text,version_id text,element_ids set<text>,PRIMARY KEY (( space, item_id, version_id )));
-CREATE TABLE IF NOT EXISTS element_namespace (space text, item_id text, element_id text, namespace text, PRIMARY KEY ((space, item_id, element_id)));
-CREATE TABLE IF NOT EXISTS element (space text,item_id text,version_id text,element_id text,parent_id text,namespace text,info text,relations text,data blob,searchable_data blob,visualization blob,sub_element_ids set<text>,PRIMARY KEY (( space, item_id, version_id, element_id )));
diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/03-createDoxKeyspace.rb b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/03-createDoxKeyspace.rb
index 68c1870832..789f658694 100644
--- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/03-createDoxKeyspace.rb
+++ b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/recipes/03-createDoxKeyspace.rb
@@ -22,7 +22,7 @@ bash "onboard-db-schema-creation" do
code <<-EOH
cd /tmp/tools/build/scripts
chmod +x onboard-db-schema-creation.sh
- /tmp/tools/build/scripts/onboard-db-schema-creation.sh
+ bash /tmp/tools/build/scripts/onboard-db-schema-creation.sh
EOH
end
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vPCRF.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vPCRF.csar
new file mode 100644
index 0000000000..6f997bcf98
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vPCRF.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vSPGW.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vSPGW.csar
new file mode 100644
index 0000000000..e7eed4b7c6
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/Huawei_vSPGW.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcMmeVf.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcMmeVf.csar
new file mode 100644
index 0000000000..bf0e775102
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcMmeVf.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcSpgwVf.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcSpgwVf.csar
new file mode 100644
index 0000000000..0eacd74655
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/ZteEpcSpgwVf.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/cscf_si.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/cscf_si.csar
new file mode 100644
index 0000000000..da19f0dd29
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/cscf_si.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF.csar
new file mode 100644
index 0000000000..347b8bcced
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF_v3.0.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF_v3.0.csar
index 1c52cca12d..094810a3f7 100644
--- a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF_v3.0.csar
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vCSCF_v3.0.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vSBC.csar b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vSBC.csar
new file mode 100644
index 0000000000..ee60eed872
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vSBC.csar
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vfw.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vfw.zip
new file mode 100644
index 0000000000..b8273defea
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vfw.zip
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vvg.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vvg.zip
new file mode 100644
index 0000000000..dc9ef5d823
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vvg.zip
Binary files differ
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/logback.xml b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/logback.xml
new file mode 100644
index 0000000000..b41ee12695
--- /dev/null
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/logback.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="5 seconds">
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss} | %-5p | [%thread] %logger{5}:%L - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>logFile.log</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss} | %-5p | [%thread] %logger{5}:%L - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="com.memorynotfound" level="INFO"/>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration> \ No newline at end of file
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh
index 933f9af6e4..76338b2082 100644
--- a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh
@@ -93,7 +93,7 @@ if [ ${REMOTE_DEBUG} == "true" ]; then
JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;
fi
-cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
+cmd="java $JAVA_OPTION -Xms1024m -Xmx1024m -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
if [ $DEBUG == "true" ]
@@ -108,7 +108,7 @@ if [ ${RERUN} == "true" ]; then
echo "Prepare" ${TARGET_DIR}/${fileName} "file to rerun all failed tests ...";
prepareFailedXmlFile ${TARGET_DIR}/${fileName} $SUITE_FILE;
SUITE_FILE=${fileName};
- cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
+ cmd="java $JAVA_OPTION -Xms1024m -Xmx1024m -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
$cmd;
fi
fi
diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb
index c4323c233f..53482a7dd7 100644
--- a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb
+++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb
@@ -6,7 +6,7 @@ cwd "#{tests_base}"
code <<-EOH
cd "#{tests_base}"
jar_file=`ls test-apis*-jar-with-dependencies.jar`
- ./startTest.sh $jar_file #{ci_test_suite} > #{tests_base}/target/startTest.out 2>&1
+ ./startTest.sh $jar_file #{ci_test_suite} > #{tests_base}/target/startTest.log 2>&1
echo "return code from startTest.sh = [$?]"
EOH
timeout 72000
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
index b545145be8..fcbf3b2fee 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java
@@ -20,25 +20,15 @@
package org.openecomp.sdc.ci.tests.api;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
+import com.aventstack.extentreports.ExtentTest;
+import com.aventstack.extentreports.Status;
+import com.thinkaurelius.titan.core.TitanFactory;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanVertex;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
-import org.apache.log4j.Logger;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.rules.TestName;
@@ -47,11 +37,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
@@ -61,13 +47,8 @@ import org.openecomp.sdc.ci.tests.utils.cassandra.CassandraUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
-import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.*;
+import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestContext;
import org.testng.ITestResult;
@@ -78,20 +59,23 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
-import com.aventstack.extentreports.ExtentTest;
-import com.aventstack.extentreports.Status;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
+
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
public abstract class ComponentBaseTest {
// private static Logger logger = LoggerFactory.getLogger(ComponentBaseTest.class.getName());
-
- protected static Logger logger= Logger.getLogger(ComponentBaseTest.class);
+ protected static Logger logger= LoggerFactory.getLogger(ComponentBaseTest.class);
// public ComponentBaseTest(TestName testName, String className) {
@@ -118,12 +102,15 @@ public abstract class ComponentBaseTest {
public ComponentBaseTest(TestName name, String name2) {
// TODO Auto-generated constructor stub
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- lc.getLogger("com.thinkaurelius").setLevel(Level.INFO);
- lc.getLogger("com.datastax").setLevel(Level.INFO);
- lc.getLogger("io.netty").setLevel(Level.INFO);
- lc.getLogger("c.d").setLevel(Level.INFO);
- }
+// LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+// lc.getLogger("com.thinkaurelius").setLevel(Level.INFO);
+// lc.getLogger("com.datastax").setLevel(Level.INFO);
+// lc.getLogger("io.netty").setLevel(Level.INFO);
+// lc.getLogger("c.d").setLevel(Level.INFO);
+// lc.getLogger("o.a.h").setLevel(Level.INFO);
+// lc.getLogger("o.o.s.c.t.d.h").setLevel(Level.INFO);
+
+}
public static String getReportFolder() {
return REPORT_FOLDER;
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
index 9bb14d7f50..8bc967c877 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/run/StartTest.java
@@ -34,8 +34,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.utils.Utils;
//import org.junit.runner.JUnitCore;
@@ -94,7 +95,7 @@ public class StartTest {
}
public StartTest() {
- logger = Logger.getLogger(StartTest.class.getName());
+ logger = LoggerFactory.getLogger(StartTest.class.getName());
}
public static void enableLogger() {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
index 8764779c02..0f339b811c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
@@ -21,9 +21,9 @@
package org.openecomp.sdc.ci.tests.sanity;
-
-
-
+import com.aventstack.extentreports.Status;
+import com.clearspring.analytics.util.Pair;
+import fj.data.Either;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
@@ -52,11 +52,6 @@ import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
-import com.aventstack.extentreports.Status;
-import com.clearspring.analytics.util.Pair;
-
-import fj.data.Either;
-
import java.io.File;
@@ -86,7 +81,8 @@ public class Onboard extends ComponentBaseTest {
@Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "VNF_List")
public void onboardVNFShotFlow(String filepath, String vnfFile) throws Exception, Throwable {
setLog(vnfFile);
- System.out.println("print - >" + makeDistributionValue);
+ logger.info("Onboarding - > " + vnfFile);
+// System.out.println("Onboarding - > " + vnfFile);
runOnboardToDistributionFlow(filepath, vnfFile);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
index 7789231c22..c4b9764c96 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
@@ -187,7 +187,7 @@ public class ResponseParser {
Resource resource = null;
try {
// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended
-// mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
resource = mapper.readValue(response, Resource.class);
logger.debug(resource.toString());
diff --git a/test-apis-ci/src/main/resources/logback.xml b/test-apis-ci/src/main/resources/logback.xml
index 4723bc24cb..4b5e23c776 100644
--- a/test-apis-ci/src/main/resources/logback.xml
+++ b/test-apis-ci/src/main/resources/logback.xml
@@ -15,9 +15,9 @@
</encoder>
</appender>
- <logger name="com.memorynotfound" level="TRACE"/>
+ <logger name="com.memorynotfound" level="INFO"/>
- <root level="DEBUG">
+ <root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>