Search in sources :

Example 1 with OpenstackVtapNetwork

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()));
    }
}
Also used : OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork)

Example 2 with OpenstackVtapNetwork

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();
}
Also used : OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 3 with OpenstackVtapNetwork

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();
}
Also used : OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) JsonNode(com.fasterxml.jackson.databind.JsonNode) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with OpenstackVtapNetwork

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));
}
Also used : OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) Test(org.junit.Test)

Example 5 with OpenstackVtapNetwork

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());
}
Also used : DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) OpenstackVtapUtil.getTunnelName(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelName) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) VTAP_INBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_MIRROR_TABLE) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) FlowRuleService(org.onosproject.net.flow.FlowRuleService) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) PROTOCOL_UDP(org.onlab.packet.IPv4.PROTOCOL_UDP) OpenstackVtapUtil.isValidHost(org.onosproject.openstackvtap.util.OpenstackVtapUtil.isValidHost) VTAP_INBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_GROUP_TABLE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackVtapUtil.getGroupKey(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getGroupKey) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Type(org.onosproject.openstackvtap.api.OpenstackVtap.Type) VTAP_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_MIRROR_TABLE) GroupBuckets(org.onosproject.net.group.GroupBuckets) DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceId(org.onosproject.net.DeviceId) GroupDescription(org.onosproject.net.group.GroupDescription) Dictionary(java.util.Dictionary) VTAP_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_GROUP_TABLE) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackVtap(org.onosproject.openstackvtap.api.OpenstackVtap) ComponentContext(org.osgi.service.component.ComponentContext) PORT_NAME(org.onosproject.net.AnnotationKeys.PORT_NAME) HostListener(org.onosproject.net.host.HostListener) TUNNEL_NICIRA(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICIRA) HostService(org.onosproject.net.host.HostService) VTAP_INBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_INBOUND_TABLE) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpenstackVtapEvent(org.onosproject.openstackvtap.api.OpenstackVtapEvent) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OpenstackVtapStore(org.onosproject.openstackvtap.api.OpenstackVtapStore) StreamSupport(java.util.stream.StreamSupport) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ExtensionTreatmentResolver(org.onosproject.net.behaviour.ExtensionTreatmentResolver) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) DeviceListener(org.onosproject.net.device.DeviceListener) PROTOCOL_ICMP(org.onlab.packet.IPv4.PROTOCOL_ICMP) GroupService(org.onosproject.net.group.GroupService) GroupId(org.onosproject.core.GroupId) LeadershipService(org.onosproject.cluster.LeadershipService) OpenstackVtapUtil.hostCompareIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.hostCompareIp) HostLocation(org.onosproject.net.HostLocation) CoreService(org.onosproject.core.CoreService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) VTAP_FLAT_OUTBOUND_GROUP_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_GROUP_TABLE) INTEGRATION_BRIDGE(org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE) OpenstackNodeListener(org.onosproject.openstacknode.api.OpenstackNodeListener) Mode(org.onosproject.openstackvtap.api.OpenstackVtapNetwork.Mode) OpenstackVtapUtil.dumpStackTrace(org.onosproject.openstackvtap.util.OpenstackVtapUtil.dumpStackTrace) TYPE_IPV4(org.onlab.packet.Ethernet.TYPE_IPV4) TUNNEL_NICRA_DEFAULT(org.onosproject.openstackvtap.impl.OsgiPropertyConstants.TUNNEL_NICRA_DEFAULT) NodeId(org.onosproject.cluster.NodeId) ImmutableSet(com.google.common.collect.ImmutableSet) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Device(org.onosproject.net.Device) DHCP_TABLE(org.onosproject.openstacknetworking.api.Constants.DHCP_TABLE) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) NICIRA_RESUBMIT_TABLE(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE) VTAP_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_OUTBOUND_TABLE) Objects(java.util.Objects) NICIRA_SET_TUNNEL_DST(org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST) List(java.util.List) TunnelEndPoints(org.onosproject.net.behaviour.TunnelEndPoints) OpenstackVtapUtil.containsIp(org.onosproject.openstackvtap.util.OpenstackVtapUtil.containsIp) FLAT_TABLE(org.onosproject.openstacknetworking.api.Constants.FLAT_TABLE) FlowRule(org.onosproject.net.flow.FlowRule) ClusterService(org.onosproject.cluster.ClusterService) OpenstackVtapId(org.onosproject.openstackvtap.api.OpenstackVtapId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) IpPrefix(org.onlab.packet.IpPrefix) InterfaceConfig(org.onosproject.net.behaviour.InterfaceConfig) OpenstackVtapListener(org.onosproject.openstackvtap.api.OpenstackVtapListener) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) TunnelKey(org.onosproject.net.behaviour.TunnelKey) GroupBucket(org.onosproject.net.group.GroupBucket) VTAP_FLAT_OUTBOUND_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_TABLE) ExtensionPropertyException(org.onosproject.net.flow.instructions.ExtensionPropertyException) DefaultTunnelDescription(org.onosproject.net.behaviour.DefaultTunnelDescription) OpenstackVtapStoreDelegate(org.onosproject.openstackvtap.api.OpenstackVtapStoreDelegate) ImmutableList(com.google.common.collect.ImmutableList) OpenstackVtapAdminService(org.onosproject.openstackvtap.api.OpenstackVtapAdminService) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) VTAP_FLAT_OUTBOUND_MIRROR_TABLE(org.onosproject.openstacknetworking.api.Constants.VTAP_FLAT_OUTBOUND_MIRROR_TABLE) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FORWARDING_TABLE(org.onosproject.openstacknetworking.api.Constants.FORWARDING_TABLE) Logger(org.slf4j.Logger) OpenstackVtapService(org.onosproject.openstackvtap.api.OpenstackVtapService) TunnelDescription(org.onosproject.net.behaviour.TunnelDescription) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OpenstackNodeEvent(org.onosproject.openstacknode.api.OpenstackNodeEvent) OpenstackVtapCriterion(org.onosproject.openstackvtap.api.OpenstackVtapCriterion) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) PROTOCOL_TCP(org.onlab.packet.IPv4.PROTOCOL_TCP) Reference(org.osgi.service.component.annotations.Reference) OpenstackVtapUtil.getTunnelType(org.onosproject.openstackvtap.util.OpenstackVtapUtil.getTunnelType) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork)

Aggregations

OpenstackVtapNetwork (org.onosproject.openstackvtap.api.OpenstackVtapNetwork)8 Consumes (javax.ws.rs.Consumes)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Test (org.junit.Test)2 INDENT_OUTPUT (com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Dictionary (java.util.Dictionary)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Executors.newSingleThreadScheduledExecutor (java.util.concurrent.Executors.newSingleThreadScheduledExecutor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 GET (javax.ws.rs.GET)1