Search in sources :

Example 96 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class InterfaceAddCommand method doExecute.

@Override
protected void doExecute() {
    InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
    List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
    if (ips != null) {
        for (String strIp : ips) {
            ipAddresses.add(InterfaceIpAddress.valueOf(strIp));
        }
    }
    MacAddress macAddr = mac == null ? null : MacAddress.valueOf(mac);
    VlanId vlanId = vlan == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(vlan));
    Interface intf = new Interface(name, ConnectPoint.deviceConnectPoint(connectPoint), ipAddresses, macAddr, vlanId);
    interfaceService.add(intf);
    print("Interface added");
}
Also used : InterfaceAdminService(org.onosproject.net.intf.InterfaceAdminService) MacAddress(org.onlab.packet.MacAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Example 97 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class InterfaceConfig method getInterfaces.

/**
 * Retrieves all interfaces configured on this port.
 *
 * @return set of interfaces
 * @throws ConfigException if there is any error in the JSON config
 */
public Set<Interface> getInterfaces() throws ConfigException {
    Set<Interface> interfaces = Sets.newHashSet();
    try {
        for (JsonNode intfNode : array) {
            String name = intfNode.path(NAME).asText(null);
            List<InterfaceIpAddress> ips = getIps(intfNode);
            String mac = intfNode.path(MAC).asText();
            MacAddress macAddr = mac.isEmpty() ? null : MacAddress.valueOf(mac);
            VlanId vlan = getVlan(intfNode, VLAN);
            VlanId vlanUntagged = getVlan(intfNode, VLAN_UNTAGGED);
            Set<VlanId> vlanTagged = getVlans(intfNode, VLAN_TAGGED);
            VlanId vlanNative = getVlan(intfNode, VLAN_NATIVE);
            interfaces.add(new Interface(name, subject, ips, macAddr, vlan, vlanUntagged, vlanTagged, vlanNative));
        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }
    return interfaces;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ConfigException(org.onosproject.net.config.ConfigException) MacAddress(org.onlab.packet.MacAddress) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId)

Example 98 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class McastConfigTest method setEgressVlan.

/**
 * Tests egress VLAN setter.
 *
 * @throws Exception
 */
@Test
public void setEgressVlan() throws Exception {
    config.setEgressVlan(EGRESS_VLAN_2);
    VlanId egressVlan = config.egressVlan();
    assertNotNull("egressVlan should not be null", egressVlan);
    assertThat(egressVlan, is(EGRESS_VLAN_2));
}
Also used : VlanId(org.onlab.packet.VlanId) Test(org.junit.Test)

Example 99 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class McastConfigTest method ingressVlan.

/**
 * Tests ingress VLAN getter.
 *
 * @throws Exception
 */
@Test
public void ingressVlan() throws Exception {
    VlanId ingressVlan = config.ingressVlan();
    assertNotNull("ingressVlan should not be null", ingressVlan);
    assertThat(ingressVlan, is(INGRESS_VLAN_1));
}
Also used : VlanId(org.onlab.packet.VlanId) Test(org.junit.Test)

Example 100 with VlanId

use of org.onlab.packet.VlanId in project onos by opennetworkinglab.

the class McastConfigTest method setIngressVlan.

/**
 * Tests ingress VLAN setter.
 *
 * @throws Exception
 */
@Test
public void setIngressVlan() throws Exception {
    config.setIngressVlan(INGRESS_VLAN_2);
    VlanId ingressVlan = config.ingressVlan();
    assertNotNull("ingressVlan should not be null", ingressVlan);
    assertThat(ingressVlan, is(INGRESS_VLAN_2));
}
Also used : VlanId(org.onlab.packet.VlanId) Test(org.junit.Test)

Aggregations

VlanId (org.onlab.packet.VlanId)147 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)60 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)56 DeviceId (org.onosproject.net.DeviceId)55 List (java.util.List)53 Test (org.junit.Test)53 MacAddress (org.onlab.packet.MacAddress)49 Collection (java.util.Collection)45 Ethernet (org.onlab.packet.Ethernet)44 CoreService (org.onosproject.core.CoreService)43 FlowRule (org.onosproject.net.flow.FlowRule)43 Collections (java.util.Collections)41 Collectors (java.util.stream.Collectors)41 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)41 TrafficSelector (org.onosproject.net.flow.TrafficSelector)38 ImmutableSet (com.google.common.collect.ImmutableSet)37 ConnectPoint (org.onosproject.net.ConnectPoint)37 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)37 MplsLabel (org.onlab.packet.MplsLabel)35 Intent (org.onosproject.net.intent.Intent)34