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");
}
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;
}
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));
}
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));
}
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));
}
Aggregations