use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class OpenstackResetPortsCommand method doExecute.
@Override
protected void doExecute() {
InstancePortAdminService service = get(InstancePortAdminService.class);
if ((!isAll && !isInactive && portIds == null) || (isAll && isInactive) || (isInactive && portIds != null) || (portIds != null && isAll)) {
print("Please specify one of portIds, --all, and --inactive options.");
return;
}
if (isAll) {
portIds = service.instancePorts().stream().map(InstancePort::portId).toArray(String[]::new);
} else if (isInactive) {
portIds = service.instancePorts().stream().filter(p -> p.state() == INACTIVE).map(InstancePort::portId).toArray(String[]::new);
}
for (String portId : portIds) {
resetPort(service, portId);
print("Successfully requested re-installing flow rules for port %s!", portId);
}
print("Done.");
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortCodecTest method testInstancePortEncode.
/**
* Tests the instance port encoding.
*/
@Test
public void testInstancePortEncode() {
InstancePort port = DefaultInstancePort.builder().networkId("net-id-1").portId("port-id-1").deviceId(DeviceId.deviceId("of:000000000000000a")).portNumber(PortNumber.portNumber(1, "tap-1")).ipAddress(IpAddress.valueOf("10.10.10.1")).macAddress(MacAddress.valueOf("11:22:33:44:55:66")).state(InstancePort.State.valueOf("ACTIVE")).build();
ObjectNode portJson = instancePortCodec.encode(port, context);
assertThat(portJson, matchesInstancePort(port));
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortCodecTest method getInstancePort.
/**
* Reads in an instance port from the given resource and decodes it.
*
* @param resourceName resource to use to read the JSON for the rule
* @return decoded instance port
* @throws IOException if processing the resource fails
*/
private InstancePort getInstancePort(String resourceName) throws IOException {
InputStream jsonStream = InstancePortCodecTest.class.getResourceAsStream(resourceName);
JsonNode json = context.mapper().readTree(jsonStream);
MatcherAssert.assertThat(json, notNullValue());
InstancePort port = instancePortCodec.decode((ObjectNode) json, context);
assertThat(port, notNullValue());
return port;
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortManagerTest method testMigrateInstanceEnd.
/**
* Tests if it triggers the instance migration end event.
*/
@Test
public void testMigrateInstanceEnd() {
InstancePort instancePort = instancePort1;
InstancePort migratingPort = instancePort.updateState(MIGRATING);
target.createInstancePort(migratingPort);
InstancePort migratedPort = instancePort.updateState(MIGRATED);
target.updateInstancePort(migratedPort);
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_MIGRATION_ENDED);
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortManagerTest method testRestartInstance.
/**
* Tests if it triggers the instance restart event.
*/
@Test
public void testRestartInstance() {
InstancePort instancePort = instancePort1;
InstancePort inactiveInstancePort = instancePort.updateState(INACTIVE);
target.createInstancePort(inactiveInstancePort);
target.updateInstancePort(instancePort);
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_RESTARTED);
}
Aggregations