From a0f2f88faabaed5e24a5fd9ae3ceb1f7fa428d7c Mon Sep 17 00:00:00 2001 From: "Mnushkin, Dmitry" Date: Wed, 24 Jun 2020 10:32:40 -0400 Subject: Update sim case for sdnc updated what we write to aai to match sdnc Issue-ID: SO-3004 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ic223034fc8805c956637e8443e162c71456da476 --- .../onap/so/simulator/actions/aai/ProcessVnfc.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'so-simulator/src/main/java/org') diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java index f790d804ca..954ebdd013 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java @@ -1,12 +1,18 @@ package org.onap.so.simulator.actions.aai; +import java.io.InputStream; +import java.util.List; import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; import com.consol.citrus.actions.AbstractTestAction; import com.consol.citrus.context.TestContext; @@ -56,6 +62,26 @@ public class ProcessVnfc extends AbstractTestAction { aaiResourceClient.connect(vnfcURI, vserverURI); aaiResourceClient.connect(vserverURI, pserverURI); aaiResourceClient.connect(vfModuleURI, vnfcURI); + } else if (context.getVariable("requestAction").equals("CreateVfModuleInstance") + && context.getVariable("serviceAction").equals("activate")) { + // For recreate after soft delete + AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "zauk51bfrwl09oam001"); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, + context.getVariable("cloudOwner"), context.getVariable("cloudRegion"), + context.getVariable("tenant"), "d29f3151-592d-4011-9356-ad047794e236"); + + Relationships relationships = aaiResourceClient.get(vnfcURI).getRelationships().get(); + List uris = relationships.getRelatedUris(AAIObjectType.VSERVER); + if (uris.isEmpty() || uris.size() == 0) { + if (!aaiResourceClient.exists(vserverURI)) { + AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider(); + InputStream vserverFile = + new ClassPathResource("openstack/gr_api/CreateVserver.json").getInputStream(); + Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class); + aaiResourceClient.create(vserverURI, vserver); + } + aaiResourceClient.connect(vnfcURI, vserverURI); + } } } catch (Exception e) { logger.debug("Exception in ProcessVnfc.doExecute", e); -- cgit 1.2.3-korg