Search in sources :

Example 1 with PortIdToSubport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubport in project netvirt by opendaylight.

the class NeutronPortChangeListener method createInterface.

private Interface createInterface(Port port) {
    String interfaceName = port.getUuid().getValue();
    IfL2vlan.L2vlanMode l2VlanMode = IfL2vlan.L2vlanMode.Trunk;
    InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
    IfL2vlanBuilder ifL2vlanBuilder = new IfL2vlanBuilder();
    Network network = neutronvpnUtils.getNeutronNetwork(port.getNetworkId());
    Boolean isVlanTransparent = network.isVlanTransparent();
    if (isVlanTransparent != null && isVlanTransparent) {
        l2VlanMode = IfL2vlan.L2vlanMode.Transparent;
    } else {
        PortIdToSubport portIdToSubport = neutronvpnUtils.getPortIdToSubport(port.getUuid());
        if (portIdToSubport != null) {
            l2VlanMode = IfL2vlan.L2vlanMode.TrunkMember;
            ifL2vlanBuilder.setVlanId(new VlanId(portIdToSubport.getVlanId().intValue()));
            String parentRefName = portIdToSubport.getTrunkPortId().getValue();
            ParentRefsBuilder parentRefsBuilder = new ParentRefsBuilder().setParentInterface(parentRefName);
            interfaceBuilder.addAugmentation(parentRefsBuilder.build());
            SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
            interfaceBuilder.addAugmentation(splitHorizon);
        }
    }
    ifL2vlanBuilder.setL2vlanMode(l2VlanMode);
    interfaceBuilder.setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(ifL2vlanBuilder.build());
    if (NeutronvpnUtils.getPortSecurityEnabled(port)) {
        InterfaceAclBuilder interfaceAclBuilder = new InterfaceAclBuilder();
        interfaceAclBuilder.setPortSecurityEnabled(true);
        neutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, port);
        interfaceBuilder.addAugmentation(interfaceAclBuilder.build());
    } else if (neutronvpnConfig.isLimitBumtrafficToDhcpserver() && NeutronvpnUtils.isDhcpServerPort(port)) {
        interfaceBuilder.addAugmentation(neutronvpnUtils.getDhcpInterfaceAcl(port));
    }
    return interfaceBuilder.build();
}
Also used : IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan) InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) PortIdToSubport(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubport) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Aggregations

L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan)1 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)1 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)1 IfL2vlanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder)1 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)1 SplitHorizon (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon)1 SplitHorizonBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder)1 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)1 InterfaceAclBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder)1 ElanInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder)1 PortIdToSubport (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubport)1 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)1