Search in sources :

Example 1 with InterfaceAclBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder 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();
    ifL2vlanBuilder.setL2vlanMode(l2VlanMode);
    interfaceBuilder.setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, ifL2vlanBuilder.build());
    if (NeutronvpnUtils.getPortSecurityEnabled(port)) {
        InterfaceAclBuilder interfaceAclBuilder = new InterfaceAclBuilder();
        interfaceAclBuilder.setPortSecurityEnabled(true);
        NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, port);
        interfaceBuilder.addAugmentation(InterfaceAcl.class, interfaceAclBuilder.build());
        neutronvpnUtils.populateSubnetIpPrefixes(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.rev140508.L2vlan) InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) 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) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 2 with InterfaceAclBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder in project netvirt by opendaylight.

the class AclInstanceRecoveryHandler method recoverService.

@Override
public void recoverService(String entityId) {
    LOG.info("Recover ACL instance {}", entityId);
    Uuid aclId = new Uuid(entityId);
    Collection<AclInterface> aclInterfaces = aclDataUtil.getInterfaceList(aclId);
    for (AclInterface aclInterface : aclInterfaces) {
        String aclInterfaceId = aclInterface.getInterfaceId();
        Optional<Interface> interfaceOptional = AclServiceUtils.getInterface(dataBroker, aclInterfaceId);
        if (interfaceOptional.isPresent()) {
            Interface interfaceBefore = interfaceOptional.get();
            LOG.debug("Starting Recovery of acl Instance {} for interface {}", entityId, interfaceBefore.getName());
            InterfaceAcl interfaceAclBefore = interfaceBefore.getAugmentation(InterfaceAcl.class);
            List<Uuid> sgList = new ArrayList<>(interfaceAclBefore.getSecurityGroups());
            sgList.remove(aclId);
            InterfaceAcl interfaceAclAfter = new InterfaceAclBuilder(interfaceAclBefore).setSecurityGroups(sgList).build();
            Interface interfaceAfter = new InterfaceBuilder(interfaceBefore).addAugmentation(InterfaceAcl.class, interfaceAclAfter).build();
            aclInterfaceListener.update(null, interfaceBefore, interfaceAfter);
            aclInterfaceListener.update(null, interfaceAfter, interfaceBefore);
        } else {
            LOG.error("Interfaces not present for aclInterface {} ", aclInterfaceId);
        }
    }
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl) AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ServiceRecoveryInterface(org.opendaylight.genius.srm.ServiceRecoveryInterface)

Example 3 with InterfaceAclBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder in project netvirt by opendaylight.

the class NeutronPortChangeListener method handlePortSecurityUpdated.

private static InterfaceAclBuilder handlePortSecurityUpdated(Port portOriginal, Port portUpdated, boolean origSecurityEnabled, boolean updatedSecurityEnabled, InterfaceBuilder interfaceBuilder) {
    InterfaceAclBuilder interfaceAclBuilder = null;
    if (origSecurityEnabled != updatedSecurityEnabled) {
        interfaceAclBuilder = new InterfaceAclBuilder();
        interfaceAclBuilder.setPortSecurityEnabled(updatedSecurityEnabled);
        if (updatedSecurityEnabled) {
            // Handle security group enabled
            NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, portUpdated);
        } else {
            // Handle security group disabled
            interfaceAclBuilder.setSecurityGroups(new ArrayList<>());
            interfaceAclBuilder.setAllowedAddressPairs(new ArrayList<>());
        }
    } else {
        if (updatedSecurityEnabled) {
            // handle SG add/delete delta
            InterfaceAcl interfaceAcl = interfaceBuilder.getAugmentation(InterfaceAcl.class);
            interfaceAclBuilder = new InterfaceAclBuilder(interfaceAcl);
            interfaceAclBuilder.setSecurityGroups(NeutronvpnUtils.getUpdatedSecurityGroups(interfaceAcl.getSecurityGroups(), portOriginal.getSecurityGroups(), portUpdated.getSecurityGroups()));
            List<AllowedAddressPairs> updatedAddressPairs = NeutronvpnUtils.getUpdatedAllowedAddressPairs(interfaceAcl.getAllowedAddressPairs(), portOriginal.getAllowedAddressPairs(), portUpdated.getAllowedAddressPairs());
            interfaceAclBuilder.setAllowedAddressPairs(NeutronvpnUtils.getAllowedAddressPairsForFixedIps(updatedAddressPairs, portOriginal.getMacAddress(), portOriginal.getFixedIps(), portUpdated.getFixedIps()));
        }
    }
    return interfaceAclBuilder;
}
Also used : InterfaceAclBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl)

Aggregations

InterfaceAclBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder)3 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)2 InterfaceAcl (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl)2 ArrayList (java.util.ArrayList)1 ServiceRecoveryInterface (org.opendaylight.genius.srm.ServiceRecoveryInterface)1 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)1 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)1 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)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 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)1 ElanInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder)1