use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkListCommand method doExecute.
@Override
protected void doExecute() {
OpenstackVtapNetwork vtapNetwork = osVtapAdminService.getVtapNetwork();
if (vtapNetwork != null) {
print(FORMAT, vtapNetwork.mode().toString(), vtapNetwork.networkId() != null ? vtapNetwork.networkId() : "N/A", vtapNetwork.serverIp().toString());
print(FORMAT_NODES, osNodeNames(osVtapAdminService.getVtapNetworkDevices()));
}
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkWebResource method createNetwork.
/**
* Creates a openstack vtap network from the JSON input stream.
*
* @param input openstack vtap network JSON input stream
* @return 200 OK on creating success
* 400 BAD_REQUEST if the JSON is malformed
* 409 CONFLICT if already the openstack vtap network exists
* @onos.rsModel OpenstackVtapNetwork
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createNetwork(InputStream input) {
log.info(MESSAGE_NETWORK, CREATE);
OpenstackVtapNetwork vtapNetwork = readNetworkConfiguration(input);
if (vtapNetwork == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
if (vtapService.createVtapNetwork(vtapNetwork.mode(), vtapNetwork.networkId(), vtapNetwork.serverIp()) == null) {
log.warn(ERROR_DUPLICATE, vtapNetwork);
return Response.status(Response.Status.CONFLICT).build();
}
return Response.ok().build();
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkWebResource method getNetwork.
/**
* Get openstack vtap network.
*
* @return 200 OK with openstack vtap network
* 404 NOT_FOUND if openstack vtap network is not exists
* @onos.rsModel OpenstackVtapNetwork
*/
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getNetwork() {
log.info(MESSAGE_NETWORK, READ);
OpenstackVtapNetwork vtapNetwork = vtapService.getVtapNetwork();
if (vtapNetwork == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
JsonNode jsonNode = codec(OpenstackVtapNetwork.class).encode(vtapNetwork, this);
return Response.ok(jsonNode, MediaType.APPLICATION_JSON_TYPE).build();
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class DefaultOpenstackVtapNetworkTest method testConstruction.
/**
* Tests object construction.
*/
@Test
public void testConstruction() {
OpenstackVtapNetwork vtapNetwork = vtapNetwork1;
assertThat(vtapNetwork.mode(), is(VTAP_NETWORK_MODE_1));
assertThat(vtapNetwork.networkId(), is(VTAP_NETWORK_NETWORK_ID_1));
assertThat(vtapNetwork.serverIp(), is(SERVER_IP_1));
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapManager method purgeVtap.
/**
* Purges all flow rules and group tables, tunneling interface for openstack vtap.
*/
@Override
public void purgeVtap() {
// Remove all flow rules
flowRuleService.removeFlowRulesById(appId);
// Remove all groups and tunnel interfaces
osNodeService.completeNodes(COMPUTE).stream().filter(osNode -> osNode.state() == COMPLETE).forEach(osNode -> {
groupService.getGroups(osNode.intgBridge(), appId).forEach(group -> groupService.removeGroup(osNode.intgBridge(), group.appCookie(), appId));
OpenstackVtapNetwork vtapNetwork = getVtapNetwork();
setTunnelInterface(osNode, vtapNetwork, false);
});
log.trace("{} all flow rules, groups, tunnel interface are purged", appId.name());
}
Aggregations