Search in sources :

Example 11 with IfL2vlan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.

the class IfmCLIUtil method showVlanOutput.

static void showVlanOutput(InterfaceInfo ifaceInfo, Interface iface, CommandSession session) {
    StringBuilder sb = new StringBuilder();
    Formatter fmt = new Formatter(sb);
    IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
    int vlanId = l2vlan != null ? l2vlan.getVlanId() != null ? l2vlan.getVlanId().getValue() : 0 : 0;
    session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT_LINE1, iface.getName()));
    sb.setLength(0);
    session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT, "", ifaceInfo == null ? UNSET : ifaceInfo.getDpId(), ifaceInfo == null ? UNSET : ifaceInfo.getPortName(), vlanId));
    sb.setLength(0);
    session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT, ifaceInfo == null ? UNSET : ifaceInfo.getInterfaceTag(), ifaceInfo == null ? UNSET : ifaceInfo.getPortNo(), ifaceInfo == null ? UNSET : ifaceInfo.getAdminState(), ifaceInfo == null ? UNSET : ifaceInfo.getOpState()));
    sb.setLength(0);
    session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT + "%n", iface.getDescription(), "", "", ""));
    sb.setLength(0);
    fmt.close();
}
Also used : Formatter(java.util.Formatter) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 12 with IfL2vlan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.

the class VlanMemberConfigListener method add.

@Override
public void add(@Nonnull Interface newInterface) {
    IfL2vlan ifL2vlan = newInterface.getAugmentation(IfL2vlan.class);
    if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
        return;
    }
    addVlanMember(newInterface);
}
Also used : IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 13 with IfL2vlan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.

the class VlanMemberConfigListener method remove.

@Override
public void remove(@Nonnull Interface removedInterface) {
    IfL2vlan ifL2vlan = removedInterface.getAugmentation(IfL2vlan.class);
    if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
        return;
    }
    removeVlanMember(removedInterface);
}
Also used : IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 14 with IfL2vlan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.

the class InterfaceServiceUtil method getVlanId.

public static short getVlanId(String interfaceName, DataBroker broker) {
    InstanceIdentifier<Interface> id = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(interfaceName)).build();
    Optional<Interface> ifInstance = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION, id, broker);
    if (ifInstance.isPresent()) {
        IfL2vlan vlanIface = ifInstance.get().getAugmentation(IfL2vlan.class);
        return vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue().shortValue();
    }
    return -1;
}
Also used : InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 15 with IfL2vlan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.

the class ItmUtils method buildTunnelInterface.

public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName, List<TunnelOptions> tunnelOptions) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    Long monitoringInterval = null;
    if (vlanId > 0) {
        IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
        builder.addAugmentation(IfL2vlan.class, l2vlan);
    }
    LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}", monitorProtocol.getName(), monitorInterval);
    if (monitorInterval != null) {
        monitoringInterval = monitorInterval.longValue();
    }
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).setTunnelOptions(tunnelOptions).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Aggregations

IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)23 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)11 ArrayList (java.util.ArrayList)9 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 Collections (java.util.Collections)5 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)5 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BigInteger (java.math.BigInteger)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)4 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)4 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)4 List (java.util.List)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)3 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)3