@Test public void testResolveExternalLayer2Group() throws Exception { Class<NodeMapper> class1 = NodeMapper.class; Method method = class1.getDeclaredMethod("resolveExternalLayer2Group", new Class[]{ User.class, Node.class, VirtualNetwork.class, UserIntentVnMapping.class, boolean.class }); method.setAccessible(true); boolean generatingVirtualRouter = true; User user = mock(User.class); Node node = mock(Node.class); Property property = mock(Property.class); Property property1 = mock(Property.class); NodeId nodeId = mock(NodeId.class); VirtualNetwork virtualNetwork = mock(VirtualNetwork.class); UserIntentVnMapping userIntentVnMapping = mock(UserIntentVnMapping.class); PhysicalNodeId physicalNodeId = mock(PhysicalNodeId.class); VirtualNodes virtualNodes_temp = mock(VirtualNodes.class); PropertyValues propertyValues = mock(PropertyValues.class); StringValue stringValue = mock(StringValue.class); List<Property> propertyList = new ArrayList<Property>(); List<VirtualNode> virtualNodes = new ArrayList<VirtualNode>(); List<StringValue> stringValueList = new ArrayList<StringValue>(); List<IntentVnMappingResult> intentVnMappingResultList = new ArrayList<IntentVnMappingResult>(); stringValueList.add(stringValue); when(node.getProperty()).thenReturn(propertyList); PowerMockito.mockStatic(IntentResolverUtils.class); PowerMockito.when(IntentResolverUtils.getNodeProperty(node.getProperty(), new PropertyName("location"))) .thenReturn(property); PowerMockito.when(IntentResolverUtils.generatePhysicalNodeIdFromNodeLocationProperty(property)) .thenReturn(physicalNodeId); when(physicalNodeId.getValue()).thenReturn(new String("test")); when(virtualNetwork.getVirtualNodes()).thenReturn(virtualNodes_temp); when(virtualNodes_temp.getVirtualNode()).thenReturn(virtualNodes); PowerMockito.when(IntentResolverUtils.getNodeProperty(node.getProperty(), new PropertyName("ip-prefix"))) .thenReturn(property1); when(property1.getPropertyValues()).thenReturn(propertyValues); when(propertyValues.getStringValue()).thenReturn(stringValueList); when(stringValue.getValue()) .thenReturn(new String("192.168.1.1/24")) .thenReturn(new String("test")); when(property.getPropertyValues()).thenReturn(propertyValues); when(node.getNodeId()).thenReturn(nodeId); when(nodeId.getValue()).thenReturn(new String("00001111-1111-0000-0000-000011112222")); when(userIntentVnMapping.getIntentVnMappingResult()).thenReturn(intentVnMappingResultList); method.invoke(nodeMapper, user, node, virtualNetwork, userIntentVnMapping, generatingVirtualRouter); verify(node).getNodeId(); }
protected void resolveExternalLayer2Group(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping, boolean generatingVirtualRouter) throws IntentResolutionException { Property property = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("location")); if ( null == property ) { throw new IntentResolutionException("Can not get the location property of the node " + node.getNodeId().getValue() + "."); } PhysicalNodeId physicalNodeId = IntentResolverUtils .generatePhysicalNodeIdFromNodeLocationProperty(property); List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement>(1); AttributeValue attributeValue = new AttributeValueBuilder() .setStringValue(physicalNodeId.getValue()) .build(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue) .setAttributeMatchPattern(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements.add(physicalResourceRequirement); VirtualNode virtualNode = new VirtualNodeBuilder() .setNodeId(new VirtualNodeId(UUID.randomUUID().toString())) .setNodeType(generatingVirtualRouter ? VirtualNode.NodeType.Vrouter : VirtualNode.NodeType.Vswitch) .setVirtualPort(new LinkedList<VirtualPort>()) .setPhysicalResourceRequirement(physicalResourceRequirements) .build(); virtualNetwork.getVirtualNodes().getVirtualNode().add(virtualNode); ExternalMacAddresses externalMacAddresses = new ExternalMacAddressesBuilder() .setExternalMacAddress(new ArrayList<MacAddress>(0)) .build(); ExternalIpPrefixes externalIpPrefixes = null; if ( generatingVirtualRouter ) { Property property1 = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("ip-prefix")); if ( null != property1 ) { List<IpPrefix> ipPrefixes = new ArrayList<IpPrefix>(1); IpPrefix ipPrefix = new IpPrefix( new Ipv4Prefix(property1.getPropertyValues().getStringValue().get(0).getValue())); ipPrefixes.add(ipPrefix); externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(ipPrefixes) .build(); } else { externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(new ArrayList<IpPrefix>(0)) .build(); } } List<PhysicalResourceRequirement> physicalResourceRequirements1 = new ArrayList<PhysicalResourceRequirement>(1); AttributeValue attributeValue1 = new AttributeValueBuilder() .setStringValue(property.getPropertyValues().getStringValue().get(0).getValue()) .build(); PhysicalResourceRequirement physicalResourceRequirement1 = new PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue1) .setAttributeMatchPattern(PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements1.add(physicalResourceRequirement1); VirtualPort virtualPort = new VirtualPortBuilder() .setPortId(new VirtualPortId(UUID.randomUUID().toString())) .setPortType(VirtualPort.PortType.External) .setExternalMacAddresses(externalMacAddresses) .setExternalIpPrefixes(externalIpPrefixes) .setPhysicalResourceRequirement(physicalResourceRequirements1) .build(); virtualNode.getVirtualPort().add(virtualPort); List<VirtualResource> virtualResources = new ArrayList<VirtualResource>(1); VirtualResource virtualResource = new VirtualResourceBuilder() .setVirtualResourceId(new VirtualResourceId(UUID.randomUUID().toString())) .setVirtualResourceType(VirtualResource.VirtualResourceType.Vport) .setVirtualResourceEntityId(new VirtualResourceEntityId(virtualPort.getPortId().getValue())) .setParentVirtualResourceEntityId(new VirtualResourceEntityId(virtualNode.getNodeId().getValue())) .setOrder(0L) .build(); virtualResources.add(virtualResource); IntentVnMappingResult intentVnMappingResult = new IntentVnMappingResultBuilder() .setIntentId(new IntentId(node.getNodeId().getValue())) .setIntentType(IntentVnMappingResult.IntentType.Node) .setVirtualResource(virtualResources) .build(); userIntentVnMapping.getIntentVnMappingResult().add(intentVnMappingResult); return; }
NodeMapper { protected void resolveExternalLayer2Group(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping, boolean generatingVirtualRouter) throws IntentResolutionException { Property property = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("location")); if ( null == property ) { throw new IntentResolutionException("Can not get the location property of the node " + node.getNodeId().getValue() + "."); } PhysicalNodeId physicalNodeId = IntentResolverUtils .generatePhysicalNodeIdFromNodeLocationProperty(property); List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement>(1); AttributeValue attributeValue = new AttributeValueBuilder() .setStringValue(physicalNodeId.getValue()) .build(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue) .setAttributeMatchPattern(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements.add(physicalResourceRequirement); VirtualNode virtualNode = new VirtualNodeBuilder() .setNodeId(new VirtualNodeId(UUID.randomUUID().toString())) .setNodeType(generatingVirtualRouter ? VirtualNode.NodeType.Vrouter : VirtualNode.NodeType.Vswitch) .setVirtualPort(new LinkedList<VirtualPort>()) .setPhysicalResourceRequirement(physicalResourceRequirements) .build(); virtualNetwork.getVirtualNodes().getVirtualNode().add(virtualNode); ExternalMacAddresses externalMacAddresses = new ExternalMacAddressesBuilder() .setExternalMacAddress(new ArrayList<MacAddress>(0)) .build(); ExternalIpPrefixes externalIpPrefixes = null; if ( generatingVirtualRouter ) { Property property1 = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("ip-prefix")); if ( null != property1 ) { List<IpPrefix> ipPrefixes = new ArrayList<IpPrefix>(1); IpPrefix ipPrefix = new IpPrefix( new Ipv4Prefix(property1.getPropertyValues().getStringValue().get(0).getValue())); ipPrefixes.add(ipPrefix); externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(ipPrefixes) .build(); } else { externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(new ArrayList<IpPrefix>(0)) .build(); } } List<PhysicalResourceRequirement> physicalResourceRequirements1 = new ArrayList<PhysicalResourceRequirement>(1); AttributeValue attributeValue1 = new AttributeValueBuilder() .setStringValue(property.getPropertyValues().getStringValue().get(0).getValue()) .build(); PhysicalResourceRequirement physicalResourceRequirement1 = new PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue1) .setAttributeMatchPattern(PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements1.add(physicalResourceRequirement1); VirtualPort virtualPort = new VirtualPortBuilder() .setPortId(new VirtualPortId(UUID.randomUUID().toString())) .setPortType(VirtualPort.PortType.External) .setExternalMacAddresses(externalMacAddresses) .setExternalIpPrefixes(externalIpPrefixes) .setPhysicalResourceRequirement(physicalResourceRequirements1) .build(); virtualNode.getVirtualPort().add(virtualPort); List<VirtualResource> virtualResources = new ArrayList<VirtualResource>(1); VirtualResource virtualResource = new VirtualResourceBuilder() .setVirtualResourceId(new VirtualResourceId(UUID.randomUUID().toString())) .setVirtualResourceType(VirtualResource.VirtualResourceType.Vport) .setVirtualResourceEntityId(new VirtualResourceEntityId(virtualPort.getPortId().getValue())) .setParentVirtualResourceEntityId(new VirtualResourceEntityId(virtualNode.getNodeId().getValue())) .setOrder(0L) .build(); virtualResources.add(virtualResource); IntentVnMappingResult intentVnMappingResult = new IntentVnMappingResultBuilder() .setIntentId(new IntentId(node.getNodeId().getValue())) .setIntentType(IntentVnMappingResult.IntentType.Node) .setVirtualResource(virtualResources) .build(); userIntentVnMapping.getIntentVnMappingResult().add(intentVnMappingResult); return; } }
NodeMapper { protected void resolveExternalLayer2Group(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping, boolean generatingVirtualRouter) throws IntentResolutionException { Property property = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("location")); if ( null == property ) { throw new IntentResolutionException("Can not get the location property of the node " + node.getNodeId().getValue() + "."); } PhysicalNodeId physicalNodeId = IntentResolverUtils .generatePhysicalNodeIdFromNodeLocationProperty(property); List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement>(1); AttributeValue attributeValue = new AttributeValueBuilder() .setStringValue(physicalNodeId.getValue()) .build(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue) .setAttributeMatchPattern(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements.add(physicalResourceRequirement); VirtualNode virtualNode = new VirtualNodeBuilder() .setNodeId(new VirtualNodeId(UUID.randomUUID().toString())) .setNodeType(generatingVirtualRouter ? VirtualNode.NodeType.Vrouter : VirtualNode.NodeType.Vswitch) .setVirtualPort(new LinkedList<VirtualPort>()) .setPhysicalResourceRequirement(physicalResourceRequirements) .build(); virtualNetwork.getVirtualNodes().getVirtualNode().add(virtualNode); ExternalMacAddresses externalMacAddresses = new ExternalMacAddressesBuilder() .setExternalMacAddress(new ArrayList<MacAddress>(0)) .build(); ExternalIpPrefixes externalIpPrefixes = null; if ( generatingVirtualRouter ) { Property property1 = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("ip-prefix")); if ( null != property1 ) { List<IpPrefix> ipPrefixes = new ArrayList<IpPrefix>(1); IpPrefix ipPrefix = new IpPrefix( new Ipv4Prefix(property1.getPropertyValues().getStringValue().get(0).getValue())); ipPrefixes.add(ipPrefix); externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(ipPrefixes) .build(); } else { externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(new ArrayList<IpPrefix>(0)) .build(); } } List<PhysicalResourceRequirement> physicalResourceRequirements1 = new ArrayList<PhysicalResourceRequirement>(1); AttributeValue attributeValue1 = new AttributeValueBuilder() .setStringValue(property.getPropertyValues().getStringValue().get(0).getValue()) .build(); PhysicalResourceRequirement physicalResourceRequirement1 = new PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue1) .setAttributeMatchPattern(PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements1.add(physicalResourceRequirement1); VirtualPort virtualPort = new VirtualPortBuilder() .setPortId(new VirtualPortId(UUID.randomUUID().toString())) .setPortType(VirtualPort.PortType.External) .setExternalMacAddresses(externalMacAddresses) .setExternalIpPrefixes(externalIpPrefixes) .setPhysicalResourceRequirement(physicalResourceRequirements1) .build(); virtualNode.getVirtualPort().add(virtualPort); List<VirtualResource> virtualResources = new ArrayList<VirtualResource>(1); VirtualResource virtualResource = new VirtualResourceBuilder() .setVirtualResourceId(new VirtualResourceId(UUID.randomUUID().toString())) .setVirtualResourceType(VirtualResource.VirtualResourceType.Vport) .setVirtualResourceEntityId(new VirtualResourceEntityId(virtualPort.getPortId().getValue())) .setParentVirtualResourceEntityId(new VirtualResourceEntityId(virtualNode.getNodeId().getValue())) .setOrder(0L) .build(); virtualResources.add(virtualResource); IntentVnMappingResult intentVnMappingResult = new IntentVnMappingResultBuilder() .setIntentId(new IntentId(node.getNodeId().getValue())) .setIntentType(IntentVnMappingResult.IntentType.Node) .setVirtualResource(virtualResources) .build(); userIntentVnMapping.getIntentVnMappingResult().add(intentVnMappingResult); return; } NodeMapper(DataBroker dataBroker); }
NodeMapper { protected void resolveExternalLayer2Group(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping, boolean generatingVirtualRouter) throws IntentResolutionException { Property property = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("location")); if ( null == property ) { throw new IntentResolutionException("Can not get the location property of the node " + node.getNodeId().getValue() + "."); } PhysicalNodeId physicalNodeId = IntentResolverUtils .generatePhysicalNodeIdFromNodeLocationProperty(property); List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement>(1); AttributeValue attributeValue = new AttributeValueBuilder() .setStringValue(physicalNodeId.getValue()) .build(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue) .setAttributeMatchPattern(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements.add(physicalResourceRequirement); VirtualNode virtualNode = new VirtualNodeBuilder() .setNodeId(new VirtualNodeId(UUID.randomUUID().toString())) .setNodeType(generatingVirtualRouter ? VirtualNode.NodeType.Vrouter : VirtualNode.NodeType.Vswitch) .setVirtualPort(new LinkedList<VirtualPort>()) .setPhysicalResourceRequirement(physicalResourceRequirements) .build(); virtualNetwork.getVirtualNodes().getVirtualNode().add(virtualNode); ExternalMacAddresses externalMacAddresses = new ExternalMacAddressesBuilder() .setExternalMacAddress(new ArrayList<MacAddress>(0)) .build(); ExternalIpPrefixes externalIpPrefixes = null; if ( generatingVirtualRouter ) { Property property1 = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("ip-prefix")); if ( null != property1 ) { List<IpPrefix> ipPrefixes = new ArrayList<IpPrefix>(1); IpPrefix ipPrefix = new IpPrefix( new Ipv4Prefix(property1.getPropertyValues().getStringValue().get(0).getValue())); ipPrefixes.add(ipPrefix); externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(ipPrefixes) .build(); } else { externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(new ArrayList<IpPrefix>(0)) .build(); } } List<PhysicalResourceRequirement> physicalResourceRequirements1 = new ArrayList<PhysicalResourceRequirement>(1); AttributeValue attributeValue1 = new AttributeValueBuilder() .setStringValue(property.getPropertyValues().getStringValue().get(0).getValue()) .build(); PhysicalResourceRequirement physicalResourceRequirement1 = new PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue1) .setAttributeMatchPattern(PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements1.add(physicalResourceRequirement1); VirtualPort virtualPort = new VirtualPortBuilder() .setPortId(new VirtualPortId(UUID.randomUUID().toString())) .setPortType(VirtualPort.PortType.External) .setExternalMacAddresses(externalMacAddresses) .setExternalIpPrefixes(externalIpPrefixes) .setPhysicalResourceRequirement(physicalResourceRequirements1) .build(); virtualNode.getVirtualPort().add(virtualPort); List<VirtualResource> virtualResources = new ArrayList<VirtualResource>(1); VirtualResource virtualResource = new VirtualResourceBuilder() .setVirtualResourceId(new VirtualResourceId(UUID.randomUUID().toString())) .setVirtualResourceType(VirtualResource.VirtualResourceType.Vport) .setVirtualResourceEntityId(new VirtualResourceEntityId(virtualPort.getPortId().getValue())) .setParentVirtualResourceEntityId(new VirtualResourceEntityId(virtualNode.getNodeId().getValue())) .setOrder(0L) .build(); virtualResources.add(virtualResource); IntentVnMappingResult intentVnMappingResult = new IntentVnMappingResultBuilder() .setIntentId(new IntentId(node.getNodeId().getValue())) .setIntentType(IntentVnMappingResult.IntentType.Node) .setVirtualResource(virtualResources) .build(); userIntentVnMapping.getIntentVnMappingResult().add(intentVnMappingResult); return; } NodeMapper(DataBroker dataBroker);  }
NodeMapper { protected void resolveExternalLayer2Group(User user, Node node, VirtualNetwork virtualNetwork, UserIntentVnMapping userIntentVnMapping, boolean generatingVirtualRouter) throws IntentResolutionException { Property property = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("location")); if ( null == property ) { throw new IntentResolutionException("Can not get the location property of the node " + node.getNodeId().getValue() + "."); } PhysicalNodeId physicalNodeId = IntentResolverUtils .generatePhysicalNodeIdFromNodeLocationProperty(property); List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement> physicalResourceRequirements = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement>(1); AttributeValue attributeValue = new AttributeValueBuilder() .setStringValue(physicalNodeId.getValue()) .build(); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement physicalResourceRequirement = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue) .setAttributeMatchPattern(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.virtual.network.rev151010.virtual.node.instance.PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements.add(physicalResourceRequirement); VirtualNode virtualNode = new VirtualNodeBuilder() .setNodeId(new VirtualNodeId(UUID.randomUUID().toString())) .setNodeType(generatingVirtualRouter ? VirtualNode.NodeType.Vrouter : VirtualNode.NodeType.Vswitch) .setVirtualPort(new LinkedList<VirtualPort>()) .setPhysicalResourceRequirement(physicalResourceRequirements) .build(); virtualNetwork.getVirtualNodes().getVirtualNode().add(virtualNode); ExternalMacAddresses externalMacAddresses = new ExternalMacAddressesBuilder() .setExternalMacAddress(new ArrayList<MacAddress>(0)) .build(); ExternalIpPrefixes externalIpPrefixes = null; if ( generatingVirtualRouter ) { Property property1 = IntentResolverUtils .getNodeProperty(node.getProperty(), new PropertyName("ip-prefix")); if ( null != property1 ) { List<IpPrefix> ipPrefixes = new ArrayList<IpPrefix>(1); IpPrefix ipPrefix = new IpPrefix( new Ipv4Prefix(property1.getPropertyValues().getStringValue().get(0).getValue())); ipPrefixes.add(ipPrefix); externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(ipPrefixes) .build(); } else { externalIpPrefixes = new ExternalIpPrefixesBuilder() .setExternalIpPrefix(new ArrayList<IpPrefix>(0)) .build(); } } List<PhysicalResourceRequirement> physicalResourceRequirements1 = new ArrayList<PhysicalResourceRequirement>(1); AttributeValue attributeValue1 = new AttributeValueBuilder() .setStringValue(property.getPropertyValues().getStringValue().get(0).getValue()) .build(); PhysicalResourceRequirement physicalResourceRequirement1 = new PhysicalResourceRequirementBuilder() .setAttributeName(new AttributeName("location")) .setAttributeValue(attributeValue1) .setAttributeMatchPattern(PhysicalResourceRequirement.AttributeMatchPattern.Equal) .build(); physicalResourceRequirements1.add(physicalResourceRequirement1); VirtualPort virtualPort = new VirtualPortBuilder() .setPortId(new VirtualPortId(UUID.randomUUID().toString())) .setPortType(VirtualPort.PortType.External) .setExternalMacAddresses(externalMacAddresses) .setExternalIpPrefixes(externalIpPrefixes) .setPhysicalResourceRequirement(physicalResourceRequirements1) .build(); virtualNode.getVirtualPort().add(virtualPort); List<VirtualResource> virtualResources = new ArrayList<VirtualResource>(1); VirtualResource virtualResource = new VirtualResourceBuilder() .setVirtualResourceId(new VirtualResourceId(UUID.randomUUID().toString())) .setVirtualResourceType(VirtualResource.VirtualResourceType.Vport) .setVirtualResourceEntityId(new VirtualResourceEntityId(virtualPort.getPortId().getValue())) .setParentVirtualResourceEntityId(new VirtualResourceEntityId(virtualNode.getNodeId().getValue())) .setOrder(0L) .build(); virtualResources.add(virtualResource); IntentVnMappingResult intentVnMappingResult = new IntentVnMappingResultBuilder() .setIntentId(new IntentId(node.getNodeId().getValue())) .setIntentType(IntentVnMappingResult.IntentType.Node) .setVirtualResource(virtualResources) .build(); userIntentVnMapping.getIntentVnMappingResult().add(intentVnMappingResult); return; } NodeMapper(DataBroker dataBroker);   }