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);
}
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);
}
}
}
}
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;
}
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;
}
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());
}
}
Aggregations