Search in sources :

Example 6 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class ServiceEBBLoaderTest method traverseVrfConfigurationTest.

@Test
public void traverseVrfConfigurationTest() throws VrfBondingServiceException, JsonProcessingException {
    List<Resource> resource = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    Service service = new Service();
    List<ConfigurationResourceCustomization> resourceCustomizations = new ArrayList<>();
    ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization();
    configuration.setModelCustomizationUUID("123");
    resourceCustomizations.add(configuration);
    service.setConfigurationCustomizations(resourceCustomizations);
    Relationship relationship = new Relationship();
    relationship.setRelatedTo("vpn-binding");
    RelationshipList relationshipList = new RelationshipList();
    relationshipList.getRelationship().add(relationship);
    org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
    aaiLocalNetwork.setNetworkId("localNetworkId");
    aaiLocalNetwork.setRelationshipList(relationshipList);
    RelatedInstance relatedVpnBinding = new RelatedInstance();
    relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
    RelatedInstance relatedLocalNetwork = new RelatedInstance();
    relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
    doReturn(aaiLocalNetwork).when(mockBbInputSetupUtils).getAAIL3Network("localNetworkInstanceId");
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "1", false, null);
    serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, serviceResource, service, relatedVpnBinding, relatedLocalNetwork);
    assertEquals(resource.size(), 1);
    assertEquals(aaiResourceIds.size(), 0);
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) Relationship(org.onap.aai.domain.yang.Relationship) Pair(org.javatuples.Pair) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 7 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class HeatBridgeImpl method buildAddVserverLInterfacesToAaiAction.

@Override
public void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources, final List<String> oobMgtNetIds, String cloudOwner) throws HeatBridgeException {
    Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT);
    List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE);
    if (portIds == null)
        return;
    for (String portId : portIds) {
        boolean isL2Multicast = false;
        Port port = osClient.getPortById(portId);
        Network network = osClient.getNetworkById(port.getNetworkId());
        if (!StringUtils.isEmpty(port.getDeviceId())) {
            LInterface lIf = new LInterface();
            lIf.setInterfaceId(port.getId());
            lIf.setInterfaceName(port.getName());
            lIf.setMacaddr(port.getMacAddress());
            lIf.setNetworkName(network.getName());
            lIf.setIsPortMirrored(false);
            lIf.setIsIpUnnumbered(false);
            lIf.setInMaint(false);
            if (port.getProfile() != null && port.getProfile().get("trusted") != null) {
                String trusted = port.getProfile().get("trusted").toString();
                if (Boolean.parseBoolean(trusted)) {
                    isL2Multicast = true;
                }
            }
            lIf.setL2Multicasting(isL2Multicast);
            lIf.setInterfaceType(getInterfaceType(nodeType, port.getvNicType()));
            lIf.setRelationshipList(new RelationshipList());
            if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) {
                lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER);
            } else {
                lIf.setInterfaceRole(port.getvNicType());
            }
            // Update l-interface to the vserver
            transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())), Optional.of(lIf));
            updateLInterfaceIps(port, lIf);
            if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) {
                Server server = getOpenstackServerById(port.getDeviceId());
                createVlanAndSriovVF(port, lIf, server.getHypervisorHostname());
                updateSriovPfToSriovVF(port, lIf);
            }
        }
    }
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) Port(org.openstack4j.model.network.Port) L3Network(org.onap.aai.domain.yang.L3Network) Network(org.openstack4j.model.network.Network) LInterface(org.onap.aai.domain.yang.LInterface) IPAddressString(inet.ipaddr.IPAddressString)

Example 8 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class AaiHelper method getVserverRelationshipList.

/**
 * Build vserver relationship object to entities: pserver, vf-module, image, flavor
 *
 * @param cloudOwner AAI cloudOwner value
 * @param cloudRegionId AAI cloud-region identifier
 * @param genericVnfId AAI generic-vnf identifier
 * @param vfModuleId AAI vf-module identifier
 * @param server Openstack Server object
 * @throws HeatBridgeException
 */
public RelationshipList getVserverRelationshipList(final String cloudOwner, final String cloudRegionId, final String genericVnfId, final String vfModuleId, final Server server) throws HeatBridgeException {
    RelationshipList relationshipList = new RelationshipList();
    List<Relationship> relationships = relationshipList.getRelationship();
    // vserver to pserver relationship
    if (!StringUtils.isEmpty(server.getHypervisorHostname())) {
        Relationship pserverRelationship = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname())));
        relationships.add(pserverRelationship);
    }
    // vserver to vnfc relationship
    /*
         * if (!StringUtils.isEmpty(server.getName())) {
         * relationships.add(createVnfRelationshiptoVserver(server.getName(), genericVnfId, vfModuleId)); }
         */
    // vserver to generic-vnf relationship
    Relationship genericVnfRelationship = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId)));
    relationships.add(genericVnfRelationship);
    // vserver to vf-module relationship
    Relationship vfModuleRelationship = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId)));
    relationships.add(vfModuleRelationship);
    // vserver to image relationship
    if (server.getImage() != null) {
        Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).image(server.getImage().getId())));
        relationships.add(imageRel);
    }
    // vserver to flavor relationship
    if (server.getFlavor() != null) {
        Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).flavor(server.getFlavor().getId())));
        relationships.add(flavorRel);
    }
    return relationshipList;
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Relationship(org.onap.aai.domain.yang.Relationship)

Example 9 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class AaiConnection method receiveVserverName.

public String receiveVserverName(final String genericId) {
    final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericId));
    final Optional<GenericVnf> response = getResourcesClient().get(GenericVnf.class, resourceUri);
    if (response.isPresent()) {
        final GenericVnf genericVnf = response.get();
        final RelationshipList relationshipList = genericVnf.getRelationshipList();
        if (relationshipList == null || relationshipList.getRelationship() == null) {
            return null;
        }
        for (final Relationship relationship : relationshipList.getRelationship()) {
            if (VSERVER.equals(relationship.getRelatedTo())) {
                final String vserverName = getRelatedToProperty(relationship, VSERVER_NAME);
                if (vserverName == null) {
                    final String cloudOwner = getRelationshipData(relationship, CLOUD_OWNER);
                    final String cloudId = getRelationshipData(relationship, CLOUD_REGION_ID);
                    final String tenantId = getRelationshipData(relationship, TENANT_ID);
                    final String vserverId = getRelationshipData(relationship, VSERVER_ID);
                    return receiveVserverNameFromParams(cloudOwner, cloudId, tenantId, vserverId);
                }
                return vserverName;
            }
        }
    }
    return null;
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.aai.domain.yang.GenericVnf) Relationship(org.onap.aai.domain.yang.Relationship) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)

Example 10 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class WorkflowActionTest method selectExecutionListVnfMacroReplaceTest.

@Test
public void selectExecutionListVnfMacroReplaceTest() throws Exception {
    String gAction = "replaceInstance";
    String resource = "Vnf";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace");
    execution.setVariable("serviceInstanceId", "123");
    execution.setVariable("vnfId", "1234");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    ServiceInstance serviceInstanceAAI = new ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId("123");
    org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
    org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
    vnf.setVnfId("1234");
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModule1");
    vnf.getVfModules().add(vfModule);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule2.setVfModuleId("vfModule2");
    vnf.getVfModules().add(vfModule2);
    serviceInstanceMSO.getVnfs().add(vnf);
    VfModule vfModuleAAI1 = new VfModule();
    vfModuleAAI1.setIsBaseVfModule(false);
    VfModule vfModuleAAI2 = new VfModule();
    vfModuleAAI2.setIsBaseVfModule(false);
    vfModuleAAI2.setVfModuleId("vfModule2");
    RelationshipList relationshipList = new RelationshipList();
    Relationship relationship = new Relationship();
    relationshipList.getRelationship().add(relationship);
    vfModuleAAI2.setRelationshipList(relationshipList);
    Relationships relationships = new Relationships("abc");
    Configuration config = new Configuration();
    config.setConfigurationId("configId");
    Optional<Configuration> configOp = Optional.of(config);
    Optional<Relationships> relationshipsOp = Optional.of(relationships);
    doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class));
    doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class));
    doReturn(vfModuleAAI1).when(bbSetupUtils).getAAIVfModule("1234", "vfModule1");
    doReturn(vfModuleAAI2).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
    doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
    doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
    for (ExecuteBuildingBlock executeBuildingBlock : ebbs) {
        assertEquals("123", executeBuildingBlock.getWorkflowResourceIds().getServiceInstanceId());
    }
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.aai.domain.yang.GenericVnf) RelationshipList(org.onap.aai.domain.yang.RelationshipList) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) Relationship(org.onap.aai.domain.yang.Relationship) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 Relationship (org.onap.aai.domain.yang.Relationship)10 Test (org.junit.Test)6 VfModule (org.onap.aai.domain.yang.VfModule)4 Server (org.openstack4j.model.compute.Server)4 ArrayList (java.util.ArrayList)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 AaiHelper (org.onap.so.heatbridge.helpers.AaiHelper)3 Pair (org.javatuples.Pair)2 Ignore (org.junit.Ignore)2 GenericVnf (org.onap.aai.domain.yang.GenericVnf)2 L3Network (org.onap.aai.domain.yang.L3Network)2 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)2 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)2 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)2 Flavor (org.openstack4j.model.compute.Flavor)2