Search in sources :

Example 1 with COMPLETE

use of org.onosproject.openstacknode.api.NodeState.COMPLETE in project onos by opennetworkinglab.

the class OpenstackNodeWebResource method initIncompleteNodes.

/**
 * Initializes openstack nodes which are in the stats other than COMPLETE.
 *
 * @return 200 OK with init result, 500 server error
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("init/incomplete")
public Response initIncompleteNodes() {
    log.debug(String.format(MESSAGE_NODE, INIT));
    osNodeService.nodes().stream().filter(n -> n.state() != COMPLETE).forEach(n -> {
        log.info("Node {} isn't COMPLETE state so performs initialization again.", n.hostname());
        OpenstackNode updated = n.updateState(NodeState.INIT);
        osNodeAdminService.updateNode(updated);
    });
    return ok(mapper().createObjectNode()).build();
}
Also used : PathParam(javax.ws.rs.PathParam) AbstractWebResource(org.onosproject.rest.AbstractWebResource) Produces(javax.ws.rs.Produces) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) COMPLETE(org.onosproject.openstacknode.api.NodeState.COMPLETE) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) INDENT_OUTPUT(com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) JsonNode(com.fasterxml.jackson.databind.JsonNode) UriBuilder(javax.ws.rs.core.UriBuilder) Tools.nullIsIllegal(org.onlab.util.Tools.nullIsIllegal) DELETE(javax.ws.rs.DELETE) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) Context(javax.ws.rs.core.Context) Set(java.util.Set) Sets(com.google.common.collect.Sets) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Response(javax.ws.rs.core.Response) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) Tools.readTreeFromStream(org.onlab.util.Tools.readTreeFromStream) NodeState(org.onosproject.openstacknode.api.NodeState) InputStream(java.io.InputStream) Response.created(javax.ws.rs.core.Response.created) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with COMPLETE

use of org.onosproject.openstacknode.api.NodeState.COMPLETE 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

Sets (com.google.common.collect.Sets)2 Set (java.util.Set)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 INDENT_OUTPUT (com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)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 InputStream (java.io.InputStream)1 Dictionary (java.util.Dictionary)1 List (java.util.List)1 Objects (java.util.Objects)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 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1