Search in sources :

Example 6 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class InstancePortCodecTest method testInstancePortDecode.

/**
 * Tests the instance port decoding.
 */
@Test
public void testInstancePortDecode() throws IOException {
    InstancePort port = getInstancePort("InstancePort.json");
    assertThat(port.networkId(), is("net-id-1"));
    assertThat(port.portId(), is("port-id-1"));
    assertThat(port.deviceId(), is(DeviceId.deviceId("of:000000000000000a")));
    assertThat(port.portNumber(), is(PortNumber.portNumber(1, "tap-1")));
    assertThat(port.ipAddress(), is(IpAddress.valueOf("10.10.10.1")));
    assertThat(port.macAddress(), is(MacAddress.valueOf("11:22:33:44:55:66")));
    assertThat(port.state().name(), is("ACTIVE"));
}
Also used : InstancePort(org.onosproject.openstacknetworking.api.InstancePort) DefaultInstancePort(org.onosproject.openstacknetworking.impl.DefaultInstancePort) InstancePortJsonMatcher.matchesInstancePort(org.onosproject.openstacknetworking.codec.InstancePortJsonMatcher.matchesInstancePort) Test(org.junit.Test)

Example 7 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class DefaultInstancePortTest method testConstruction.

/**
 * Test object construction.
 */
@Test
public void testConstruction() {
    InstancePort instancePort = instancePort1;
    assertThat(instancePort.portId(), is(PORT_ID_1));
    assertThat(instancePort.networkId(), is(NETWORK_ID_1));
    assertThat(instancePort.macAddress(), is(MAC_ADDRESS_1));
    assertThat(instancePort.ipAddress(), is(IP_ADDRESS_1));
    assertThat(instancePort.portNumber(), is(PORT_NUM_1));
    assertThat(instancePort.deviceId(), is(DEV_ID_1));
    assertThat(instancePort.state(), is(ACTIVE));
}
Also used : InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Test(org.junit.Test)

Example 8 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class InstancePortManagerTest method testCreateAndUpdateInstancePort.

/**
 * Tests updating an instance port, and checks if it triggers proper events.
 */
@Test
public void testCreateAndUpdateInstancePort() {
    target.createInstancePort(instancePort1);
    assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
    assertEquals("Instance port did not match", PORT_NUM_1, target.instancePort(PORT_ID_1).portNumber());
    HostLocation location = new HostLocation(DEV_ID_2, PORT_NUM_2, TIME_2);
    DefaultAnnotations.Builder annotations = DefaultAnnotations.builder().set(ANNOTATION_NETWORK_ID, NETWORK_ID_2).set(ANNOTATION_PORT_ID, PORT_ID_1).set(ANNOTATION_CREATE_TIME, String.valueOf(TIME_2));
    Host host = new DefaultHost(PROVIDER_ID, HOST_ID_2, MAC_ADDRESS_2, VLAN_ID, location, ImmutableSet.of(IP_ADDRESS_2), annotations.build());
    final InstancePort updated = DefaultInstancePort.from(host, ACTIVE);
    target.updateInstancePort(updated);
    assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
    assertEquals("Instance port did not match", PORT_NUM_2, target.instancePort(PORT_ID_1).portNumber());
    validateEvents(OPENSTACK_INSTANCE_PORT_DETECTED, OPENSTACK_INSTANCE_PORT_UPDATED);
}
Also used : DefaultHost(org.onosproject.net.DefaultHost) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) HostLocation(org.onosproject.net.HostLocation) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Host(org.onosproject.net.Host) DefaultHost(org.onosproject.net.DefaultHost) Test(org.junit.Test)

Example 9 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class InstancePortManagerTest method testGetInstancePortByIpAndNetId.

/**
 * Tests if getting an instance port with IP and network ID returns correct port.
 */
@Test
public void testGetInstancePortByIpAndNetId() {
    createBasicInstancePorts();
    InstancePort port = target.instancePort(IP_ADDRESS_1, NETWORK_ID_1);
    assertEquals("Instance port did not match", port, instancePort1);
}
Also used : InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Test(org.junit.Test)

Example 10 with InstancePort

use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.

the class InstancePortManagerTest method testTerminateInstance.

/**
 * Tests if it triggers the instance termination event.
 */
@Test
public void testTerminateInstance() {
    InstancePort instancePort = instancePort1;
    target.createInstancePort(instancePort);
    InstancePort inactiveInstancePort = instancePort.updateState(INACTIVE);
    target.updateInstancePort(inactiveInstancePort);
    assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
    assertNotNull("Instance port did not match", target.instancePort(PORT_ID_1));
    validateEvents(OPENSTACK_INSTANCE_PORT_DETECTED, OPENSTACK_INSTANCE_TERMINATED);
}
Also used : InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Test(org.junit.Test)

Aggregations

InstancePort (org.onosproject.openstacknetworking.api.InstancePort)36 Test (org.junit.Test)13 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)10 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)9 InstancePortService (org.onosproject.openstacknetworking.api.InstancePortService)9 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)9 Set (java.util.Set)7 Argument (org.apache.karaf.shell.api.action.Argument)7 Command (org.apache.karaf.shell.api.action.Command)7 Service (org.apache.karaf.shell.api.action.lifecycle.Service)7 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)7 PortNumber (org.onosproject.net.PortNumber)7 Port (org.openstack4j.model.network.Port)7 IpAddress (org.onlab.packet.IpAddress)6 ApplicationId (org.onosproject.core.ApplicationId)6 CoreService (org.onosproject.core.CoreService)6 OpenstackNetworkService (org.onosproject.openstacknetworking.api.OpenstackNetworkService)6 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)6