Search in sources :

Example 46 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsCommand method removeIface.

/**
 * Removes an interface from a VPLS.
 *
 * @param vplsName the name of the VLPS
 * @param ifaceName the name of the interface to remove
 */
protected void removeIface(String vplsName, String ifaceName) {
    if (vplsName == null) {
        print(INSERT_VPLS_NAME);
        return;
    }
    if (ifaceName == null) {
        print(INSERT_INTERFACE);
        return;
    }
    VplsData vplsData = vpls.getVpls(vplsName);
    Interface iface = getInterface(ifaceName);
    if (vplsData == null) {
        print(VPLS_NOT_FOUND, vplsName);
        return;
    }
    if (CHANGING_STATE.contains(vplsData.state())) {
        // when a VPLS is updating, we shouldn't try modify it.
        print("VPLS %s still updating, please wait it finished", vplsData.name());
        return;
    }
    if (iface == null) {
        print(IFACE_NOT_FOUND, ifaceName);
        return;
    }
    if (!vplsData.interfaces().contains(iface)) {
        print(IFACE_NOT_ASSOCIATED, ifaceName, vplsName);
        return;
    }
    vpls.removeInterface(vplsData, iface);
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) Interface(org.onosproject.net.intf.Interface)

Example 47 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class InterfaceConfigTest method testAddRemoveInterface.

@Test
public void testAddRemoveInterface() throws Exception {
    InterfaceConfig config = new InterfaceConfig();
    config.init(cp1, "KEY", data, mapper, delegate);
    Set<VlanId> vlanTagged = ImmutableSet.of(VlanId.vlanId((short) 33), VlanId.vlanId((short) 44));
    String newName = "interface5";
    Interface toAdd1 = new Interface(newName, cp1, ImmutableList.of(getIp(5, 1), getIp(5, 2)), getMac(5), vl1, null, vlanTagged, vl1);
    config.addInterface(toAdd1);
    assertThat(config.isValid(), is(true));
    assertThat(config.getInterfaces(), allOf(notNullValue(), hasSize(5)));
    assertThat(findInterface(config.getInterfaces(), name1), notNullValue());
    assertThat(findInterface(config.getInterfaces(), name2), notNullValue());
    assertThat(findInterface(config.getInterfaces(), name3), notNullValue());
    Interface addedInterface1 = findInterface(config.getInterfaces(), newName);
    checkInterface(addedInterface1, 5);
    assertThat(addedInterface1.vlan(), is(vl1));
    assertThat(addedInterface1.vlanTagged(), allOf(notNullValue(), hasSize(2)));
    config.removeInterface(newName);
    assertThat(config.getInterfaces(), allOf(notNullValue(), hasSize(4)));
    assertThat(findInterface(config.getInterfaces(), newName), nullValue());
    newName = getName(6);
    Interface toAdd2 = new Interface(newName, cp1, ImmutableList.of(getIp(6, 1), getIp(6, 2)), getMac(6), vl1, VlanId.vlanId((short) 77), null, vl1);
    config.addInterface(toAdd2);
    Interface addedInterface2 = findInterface(config.getInterfaces(), newName);
    checkInterface(addedInterface2, 6);
    assertThat(addedInterface2.vlan(), is(vl1));
    assertThat(addedInterface2.vlanUntagged().toShort(), is((short) 77));
}
Also used : VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) Test(org.junit.Test)

Example 48 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsIntentUtility method buildUniIntents.

/**
 * Builds unicast Intents for a VPLS.
 *
 * @param vplsData the VPLS
 * @param hosts the hosts of the VPLS
 * @param appId application ID for Intents
 * @return unicast Intents for the VPLS
 */
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
    Set<Interface> interfaces = vplsData.interfaces();
    if (interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<Intent> uniIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
    hosts.forEach(host -> {
        FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
        Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
        Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
        Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
        uniIntents.add(uniIntent);
    });
    return uniIntents;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) LoggerFactory(org.slf4j.LoggerFactory) VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 49 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsIntentUtility method buildBrcIntents.

/**
 * Builds broadcast Intents for a VPLS.
 *
 * @param vplsData the VPLS
 * @param appId the application id for Intents
 * @return broadcast Intents for the VPLS
 */
public static Set<Intent> buildBrcIntents(VplsData vplsData, ApplicationId appId) {
    Set<Interface> interfaces = vplsData.interfaces();
    // At least two or more network interfaces to build broadcast Intents
    if (interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<Intent> brcIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
    // Generates broadcast Intents from any network interface to other
    // network interface from the VPLS.
    interfaces.forEach(src -> {
        FilteredConnectPoint srcFcp = VplsIntentUtility.buildFilteredConnectedPoint(src);
        Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(VplsIntentUtility::buildFilteredConnectedPoint).collect(Collectors.toSet());
        Key key = VplsIntentUtility.buildKey(PREFIX_BROADCAST, srcFcp.connectPoint(), vplsData.name(), MacAddress.BROADCAST, appId);
        Intent brcIntent = buildBrcIntent(key, appId, srcFcp, dstFcps, vplsData.encapsulationType(), resourceGroup);
        brcIntents.add(brcIntent);
    });
    return brcIntents;
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 50 with Interface

use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.

the class VplsCodec method decode.

@Override
public VplsData decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    List<String> names = new ArrayList<>();
    json.findValues(NAME).forEach(jsonNode -> {
        names.add(jsonNode.asText());
    });
    Collection<Interface> interfaceList = new ArrayList<>();
    JsonNode interfacesJeson = json.findValue(INTERFACES);
    JsonCodec<Interface> interfaceCodec = context.codec(Interface.class);
    if (interfacesJeson != null) {
        IntStream.range(0, interfacesJeson.size()).forEach(i -> interfaceList.add(interfaceCodec.decode(get(interfacesJeson, i), context)));
    }
    interfaceList.forEach(interf -> {
        names.remove(interf.name());
    });
    String vplsName = names.get(0);
    EncapsulationType encap = json.findValue(ENCAPSULATION_TYPE) == null ? null : EncapsulationType.enumFromString(json.findValue(ENCAPSULATION_TYPE).asText());
    VplsData vplsData = VplsData.of(vplsName, encap);
    vplsData.addInterfaces(interfaceList);
    return vplsData;
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) VplsData(org.onosproject.vpls.api.VplsData) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) Interface(org.onosproject.net.intf.Interface)

Aggregations

Interface (org.onosproject.net.intf.Interface)92 ConnectPoint (org.onosproject.net.ConnectPoint)51 MacAddress (org.onlab.packet.MacAddress)35 VlanId (org.onlab.packet.VlanId)34 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)32 Ethernet (org.onlab.packet.Ethernet)28 IpAddress (org.onlab.packet.IpAddress)28 ArrayList (java.util.ArrayList)26 DeviceId (org.onosproject.net.DeviceId)26 Host (org.onosproject.net.Host)25 InterfaceService (org.onosproject.net.intf.InterfaceService)25 Logger (org.slf4j.Logger)25 Set (java.util.Set)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)23 LoggerFactory (org.slf4j.LoggerFactory)23 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)22 Test (org.junit.Test)21 ApplicationId (org.onosproject.core.ApplicationId)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)20