summaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java441
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java24
-rw-r--r--asdctool/src/main/resources/scripts/UUIDFix1707.sh35
4 files changed, 505 insertions, 1 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java
index 25132caf28..3218ed262e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java
@@ -27,6 +27,7 @@ import org.openecomp.sdc.asdctool.impl.migration.v1610.TitanFixUtils;
import org.openecomp.sdc.asdctool.impl.migration.v1610.ToscaArtifactsAlignment;
import org.openecomp.sdc.asdctool.impl.migration.v1702.DataTypesUpdate;
import org.openecomp.sdc.asdctool.impl.migration.v1702.Migration1702;
+import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707ArtifactUuidFix;
import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707RelationsFix;
import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707VnfFix;
import org.openecomp.sdc.be.auditing.api.IAuditingManager;
@@ -588,6 +589,11 @@ public class AppConfig {
public Migration1707VnfFix migration1707VnfFix() {
return new Migration1707VnfFix();
}
+ @Bean(name = "migration1707UuidFix")
+ public Migration1707ArtifactUuidFix migration1707ArtifactUuidFix() {
+ return new Migration1707ArtifactUuidFix();
+ }
+
// @Bean(name = "migration1707relationsFix")
// public Migration1707RelationsFix migration1707RelationsFix() {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java
new file mode 100644
index 0000000000..6ae0669151
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java
@@ -0,0 +1,441 @@
+package org.openecomp.sdc.asdctool.impl.migration.v1707;
+
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
+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.common.api.ArtifactTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import fj.data.Either;
+
+@org.springframework.stereotype.Component("migration1707UuidFix")
+public class Migration1707ArtifactUuidFix {
+
+ @Autowired
+ private TitanDao titanDao;
+
+ @Autowired
+ private ToscaOperationFacade toscaOperationFacade;
+
+ private static Logger log = LoggerFactory.getLogger(Migration1707ArtifactUuidFix.class.getName());
+
+ public boolean migrate(String fixServices, String runMode) {
+ List<Resource> vfLst = new ArrayList<>();
+ List<Service> serviceList = new ArrayList<>();
+
+ long time = System.currentTimeMillis();
+
+ if (fetchServices(fixServices, serviceList, time) == false) {
+ return false;
+ }
+ if (runMode.equals("service_vf") || runMode.equals("fix")) {
+ log.info("Mode {}. Find problem VFs", runMode);
+ if (fetchVf(serviceList, vfLst, time) == false) {
+ log.info("Mode {}. Find problem VFs finished with failure", runMode);
+ return false;
+ }
+ log.info("Mode {}. Find problem VFs finished with success", runMode);
+ }
+ if (runMode.equals("fix") || runMode.equals("fix_only_services")) {
+ log.info("Mode {}. Start fix", runMode);
+ if (fix(vfLst, serviceList) == false) {
+ log.info("Mode {}. Fix finished withh failure", runMode);
+ return false;
+ }
+ log.info("Mode {}. Fix finished withh success", runMode);
+ }
+
+ return true;
+ }
+
+ private boolean fetchVf(List<Service> serviceList, List<Resource> vfLst, long time) {
+ log.info("Find problem VF ");
+ if (serviceList.isEmpty()) {
+ log.info("No services as input");
+ return true;
+ }
+ Writer writer = null;
+ try {
+ String fileName = "problemVf_" + time + ".csv";
+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"));
+ writer.write("vf name, vf id, state, version, example service name\n");
+ Set<String> vfIds = new HashSet<>();
+ for (Service service : serviceList) {
+ List<ComponentInstance> componentInstances = service.getComponentInstances();
+ for (ComponentInstance ci : componentInstances) {
+ if (!vfIds.contains(ci.getComponentUid())) {
+ vfIds.add(ci.getComponentUid());
+ Either<Resource, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(ci.getComponentUid());
+ if (toscaElement.isRight()) {
+ log.info("Failed to fetch resource {} {}", ci.getComponentUid(), toscaElement.right().value());
+ return false;
+ }
+ Resource resource = toscaElement.left().value();
+ vfLst.add(resource);
+ writeModuleResultToFile(writer, resource, service);
+ writer.flush();
+ titanDao.commit();
+ }
+ }
+ }
+ log.info("output file with list of Vf : {}", fileName);
+ } catch (Exception e) {
+ log.info("Failed to fetch services ", e);
+ return false;
+ } finally {
+ titanDao.commit();
+ try {
+ writer.flush();
+ writer.close();
+ } catch (Exception ex) {
+ /* ignore */}
+ }
+ return true;
+ }
+
+ private boolean fetchServices(String fixServices, List<Service> serviceList, long time) {
+ log.info("Find problem Services {}", fixServices);
+ Writer writer = null;
+
+ try {
+ String fileName = "problemService_" + time + ".csv";
+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"));
+ writer.write("service name, service id, state, version\n");
+
+ Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
+ hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ if (fixServices.equals("distributed_only")) {
+ hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ hasProps.put(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTED.name());
+ }
+
+ Map<GraphPropertyEnum, Object> hasNotProps = new HashMap<>();
+ hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
+ log.info("Try to fetch services with properties {} and not {}", hasProps, hasNotProps);
+
+ Either<List<GraphVertex>, TitanOperationStatus> servicesByCriteria = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, hasNotProps, JsonParseFlagEnum.ParseAll);
+ if (servicesByCriteria.isRight()) {
+ log.info("Failed to fetch services {}", servicesByCriteria.right().value());
+ return false;
+ }
+ List<GraphVertex> services = servicesByCriteria.left().value();
+ for (GraphVertex gv : services) {
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreComponentInstances(false);
+ filter.setIgnoreArtifacts(false);
+ filter.setIgnoreGroups(false);
+
+ Either<Service, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(gv.getUniqueId());
+ if (toscaElement.isRight()) {
+ log.info("Failed to fetch service {} {}", gv.getUniqueId(), toscaElement.right().value());
+ return false;
+ }
+ Service service = toscaElement.left().value();
+ List<ComponentInstance> componentInstances = service.getComponentInstances();
+ boolean isProblematic = false;
+ if (componentInstances == null) {
+ log.info("No instances for service {} ", gv.getUniqueId());
+ continue;
+ }
+ String serviceName = (String) gv.getMetadataProperty(GraphPropertyEnum.NAME);
+
+ for (ComponentInstance ci : componentInstances) {
+ Map<String, ArtifactDefinition> deploymentArtifacts = ci.getDeploymentArtifacts();
+ List<GroupInstance> groupInstances = ci.getGroupInstances();
+ if (groupInstances == null || groupInstances.isEmpty()) {
+ log.info("No instance groups for instance {} in service {} id {} ", ci.getName(), serviceName, gv.getUniqueId());
+ continue;
+ }
+
+ for (GroupInstance gi : groupInstances) {
+ if (gi.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
+ if (isProblematicGroupInstance(gi, ci.getName(), serviceName, deploymentArtifacts)) {
+ isProblematic = true;
+ break;
+ }
+ }
+ }
+ if (isProblematic) {
+ serviceList.add(service);
+ writeModuleResultToFile(writer, service, null);
+ writer.flush();
+ }
+ }
+ titanDao.commit();
+ }
+ log.info("output file with list of services : {}", fileName);
+ } catch (Exception e) {
+ log.info("Failed to fetch services ", e);
+ return false;
+ } finally {
+ titanDao.commit();
+ try {
+ writer.flush();
+ writer.close();
+ } catch (Exception ex) {
+ /* ignore */}
+ }
+ return true;
+ }
+
+ private boolean isProblematicGroupInstance(GroupInstance gi, String instName, String servicename, Map<String, ArtifactDefinition> deploymentArtifacts) {
+ List<String> artifacts = gi.getArtifacts();
+ List<String> artifactsUuid = gi.getArtifactsUuid();
+ List<String> instArtifactsUuid = gi.getGroupInstanceArtifactsUuid();
+
+ if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
+ log.info("No instance groups for instance {} in service {} ", instName, servicename);
+ return false;
+ }
+ if (artifacts.size() < artifactsUuid.size()) {
+ log.info(" artifacts.size() < artifactsUuid.size() inst {} in service {} ", instName, servicename);
+ return true;
+ }
+ if (artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty())) {
+ log.info(" artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty() inst {} in service {} ", instName, servicename);
+ return true;
+ }
+ if (artifactsUuid.contains(null)) {
+ log.info(" artifactsUuid.contains(null) inst {} in service {} ", instName, servicename);
+ return true;
+ }
+
+ for (String artifactId : artifacts) {
+ String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
+ ArtifactDefinition artifactDefinition = deploymentArtifacts.get(artifactlabel);
+ if (artifactDefinition == null) {
+ log.info(" artifactDefinition == null label {} inst {} in service {} ", artifactlabel, instName, servicename);
+ return true;
+ }
+ ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType());
+ if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
+ if (!artifactId.equals(artifactDefinition.getUniqueId())) {
+ log.info(" !artifactId.equals(artifactDefinition.getUniqueId() artifact {} artId {} inst {} in service {} ", artifactlabel, artifactId, instName, servicename);
+ return true;
+ }
+ if (!artifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
+ log.info(" artifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
+ return true;
+ }
+ } else {
+ if (!instArtifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
+ log.info(" instArtifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean fix(List<Resource> vfLst, List<Service> serviceList) {
+ boolean res = true;
+
+ if (vfLst != null && !vfLst.isEmpty()) {
+ res = fixVf(vfLst);
+ if (res) {
+ for (Component component : vfLst) {
+ TopologyTemplate topologyTemplate = ModelConverter.convertToToscaElement(component);
+ Map<String, GroupDataDefinition> groups = topologyTemplate.getGroups();
+ res = fixDataOnGraph(component.getUniqueId(), VertexTypeEnum.GROUPS, EdgeLabelEnum.GROUPS, groups);
+ }
+ }
+ }
+
+ if (res == true && serviceList != null && !serviceList.isEmpty()) {
+ res = fixServices(serviceList);
+ if (res) {
+ for (Component component : serviceList) {
+ TopologyTemplate topologyTemplate = ModelConverter.convertToToscaElement(component);
+ Map<String, MapGroupsDataDefinition> groups = topologyTemplate.getInstGroups();
+ res = fixDataOnGraph(component.getUniqueId(), VertexTypeEnum.INST_GROUPS, EdgeLabelEnum.INST_GROUPS, groups);
+ }
+ }
+ }
+
+ return res;
+ }
+
+ private <T extends ToscaDataDefinition> boolean fixDataOnGraph(String componentId, VertexTypeEnum vertexTypeEnum, EdgeLabelEnum edgeLabelEnum, Map<String, T> groups) {
+ boolean res = true;
+ Either<GraphVertex, TitanOperationStatus> getResponse = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (getResponse.isRight()) {
+ log.debug("Couldn't fetch component unique id {}, error: {}", componentId, getResponse.right().value());
+ res = false;
+
+ }
+ if (res) {
+ GraphVertex componentVertex = getResponse.left().value();
+
+ GraphVertex toscaDataVertex = null;
+ Either<GraphVertex, TitanOperationStatus> groupVertexEither = titanDao.getChildVertex(componentVertex, edgeLabelEnum, JsonParseFlagEnum.ParseJson);
+ if (groupVertexEither.isRight()) {
+ res = false;
+ log.debug("failed to get child {} vertex for component unique id {}, error: {}", edgeLabelEnum, componentId, groupVertexEither.right().value());
+ }
+ if (res) {
+ toscaDataVertex = groupVertexEither.left().value();
+ toscaDataVertex.setJson(groups);
+ Either<GraphVertex, TitanOperationStatus> updatevertexEither = titanDao.updateVertex(toscaDataVertex);
+ if (updatevertexEither.isRight()) {
+ log.debug("failed to update vertex for component unique id {}, error: {}", componentId, updatevertexEither.right().value());
+ titanDao.rollback();
+ return false;
+ }
+ }
+ }
+
+ titanDao.commit();
+
+ return res;
+ }
+
+ private boolean fixServices(List<Service> serviceList) {
+ for (Service service : serviceList) {
+ log.debug("Migration1707ArtifactUuidFix fix service: id {}, name {} ", service.getUniqueId(), service.getName());
+ List<ComponentInstance> instances = service.getComponentInstances();
+ for (ComponentInstance instance : instances) {
+ Map<String, ArtifactDefinition> artifactsMap = instance.getDeploymentArtifacts();
+ List<GroupInstance> groupsList = instance.getGroupInstances();
+ if (groupsList != null && artifactsMap != null) {
+ for (GroupInstance group : groupsList) {
+ if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
+ log.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", service.getUniqueId(), group.getName());
+ List<String> groupArtifacts = new ArrayList<String>(group.getArtifacts());
+
+ group.getArtifacts().clear();
+ group.getArtifactsUuid().clear();
+ group.getGroupInstanceArtifacts().clear();
+ group.getGroupInstanceArtifactsUuid().clear();
+
+ for (String artifactId : groupArtifacts) {
+ String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
+ log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
+ if (!artifactlabel.isEmpty() && artifactsMap.containsKey(artifactlabel)) {
+ ArtifactDefinition artifact = artifactsMap.get(artifactlabel);
+ ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType());
+ String correctArtifactId = artifact.getUniqueId();
+ String correctArtifactUUID = artifact.getArtifactUUID();
+ if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
+
+ log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
+ group.getArtifacts().add(correctArtifactId);
+ if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
+ group.getArtifactsUuid().add(correctArtifactUUID);
+ }
+ }else{
+ log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
+ group.getGroupInstanceArtifacts().add(correctArtifactId);
+ if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
+ group.getGroupInstanceArtifactsUuid().add(correctArtifactUUID);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ return true;
+
+ }
+
+ private boolean fixVf(List<Resource> vfLst) {
+ for (Resource resource : vfLst) {
+ log.debug("Migration1707ArtifactUuidFix fix resource: id {}, name {} ", resource.getUniqueId(), resource.getName());
+ Map<String, ArtifactDefinition> artifactsMap = resource.getDeploymentArtifacts();
+ List<GroupDefinition> groupsList = resource.getGroups();
+ if (groupsList != null && artifactsMap != null) {
+ for (GroupDefinition group : groupsList) {
+ if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
+ log.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", resource.getUniqueId(), group.getName());
+ List<String> groupArtifacts = new ArrayList<String>(group.getArtifacts());
+ group.getArtifacts().clear();
+ group.getArtifactsUuid().clear();
+ for (String artifactId : groupArtifacts) {
+ String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
+ log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
+ if (!artifactlabel.isEmpty() && artifactsMap.containsKey(artifactlabel)) {
+ ArtifactDefinition artifact = artifactsMap.get(artifactlabel);
+ String correctArtifactId = artifact.getUniqueId();
+ String correctArtifactUUID = artifact.getArtifactUUID();
+ log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
+ group.getArtifacts().add(correctArtifactId);
+ if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
+ group.getArtifactsUuid().add(correctArtifactUUID);
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ return true;
+ }
+
+ private String findArtifactLabelFromArtifactId(String artifactId) {
+ String artifactLabel = "";
+
+ int index = artifactId.lastIndexOf(".");
+ if (index > 0 && index + 1 < artifactId.length())
+ artifactLabel = artifactId.substring(index + 1);
+ return artifactLabel;
+ }
+
+ private void writeModuleResultToFile(Writer writer, org.openecomp.sdc.be.model.Component component, Service service) {
+ try {
+ // "service name, service id, state, version
+ StringBuffer sb = new StringBuffer(component.getName());
+ sb.append(",").append(component.getUniqueId()).append(",").append(component.getLifecycleState()).append(",").append(component.getVersion());
+ if (service != null) {
+ sb.append(",").append(service.getName());
+ }
+ sb.append("\n");
+ writer.write(sb.toString());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java
index c3d8743b86..d3935000fe 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java
@@ -34,6 +34,7 @@ import org.openecomp.sdc.asdctool.impl.migration.v1610.TitanFixUtils;
import org.openecomp.sdc.asdctool.impl.migration.v1610.ToscaArtifactsAlignment;
import org.openecomp.sdc.asdctool.impl.migration.v1702.Migration1702;
import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707;
+import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707ArtifactUuidFix;
import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707Config;
import org.openecomp.sdc.asdctool.impl.migration.v1707.DistributionStatusUpdate;
import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707VnfFix;
@@ -69,7 +70,8 @@ public class MigrationMenu {
DISTRIBUTION_STATUS_UPDATE_1707("distribution-status-update-1707", "distributionStatusUpdate"),
VFMODULES_PROPERTIES_ADDING("vfModules-properties-adding", "vfModulesPropertiesAdding"),
MIGRATION_1707_RELATIONS_FIX("fix-relations-after-migration-1707", "migration1707relationsFix"),
- MIGRATION_1707_VNF_FIX("fix-vnf-after-migration-1707", "migration1707vnfFix");
+ MIGRATION_1707_VNF_FIX("fix-vnf-after-migration-1707", "migration1707vnfFix"),
+ MIGRATION_1707_UUID_FIX("fix-UUID-1707", "migration1707UuidFix");
// UPDATE_DATA_TYPES("update_data_types", "updateDataTypes");
private String value, beanName;
@@ -308,6 +310,25 @@ public class MigrationMenu {
// }
System.exit(0);
break;
+ case MIGRATION_1707_UUID_FIX:
+ if (args == null || args.length < 5) {
+ System.out.println("Usage: fix-UUID-1707 <configuration dir> <all/distributed_only> <services/service_vf/fix/fix_only_services>");
+ System.exit(1);
+ }
+ String fixServices = args[3];
+ String runMode = args[4];
+ log.info("Start fixing artifact UUID after 1707 migration with arguments run with configutation [{}] , for [{}] services", runMode, fixServices);
+
+ Migration1707ArtifactUuidFix migrationFix = (Migration1707ArtifactUuidFix) context.getBean(operationEnum.getBeanName());
+ isSuccessful = migrationFix.migrate(fixServices, runMode);
+ if (isSuccessful) {
+ log.info("Fixing artifacts UUID for 1707 was finished successfully");
+ } else{
+ log.info("Fixing artifacts UUID for 1707 has failed");
+ System.exit(2);
+ }
+ System.exit(0);
+ break;
default:
usageAndExit();
}
@@ -347,5 +368,6 @@ public class MigrationMenu {
System.out.println("Usage: vfModules-properties-adding <group_types_input_file path> <configuration dir>");
System.out.println("Usage: fix-relations-after-migration-1707 <configuration dir>");
System.out.println("Usage: fix-vnf-after-migration-1707 <configuration dir>");
+ System.out.println("Usage: fix-UUID-1707 <configuration dir> <all/distributed_only> <services/service_vf/fix/fix_only_services>");
}
}
diff --git a/asdctool/src/main/resources/scripts/UUIDFix1707.sh b/asdctool/src/main/resources/scripts/UUIDFix1707.sh
new file mode 100644
index 0000000000..d6bd8e8ff8
--- /dev/null
+++ b/asdctool/src/main/resources/scripts/UUIDFix1707.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+##############################
+# Distribution Status Update 1707
+##############################
+
+CURRENT_DIR=`pwd`
+BASEDIR=$(dirname $0)
+
+if [ ${BASEDIR:0:1} = "/" ]
+then
+ FULL_PATH=$BASEDIR
+else
+ FULL_PATH=$CURRENT_DIR/$BASEDIR
+fi
+
+source ${FULL_PATH}/baseOperation.sh
+
+mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
+
+command="java $JVM_LOG_FILE -cp $JARS $mainClass fix-UUID-1707 1707 $@"
+echo $command
+
+$command
+result=$?
+
+
+
+echo "***********************************"
+echo "***** $result *********************"
+echo "***********************************"
+
+exit $result
+
+