<commit_before># -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Metaswitch Networks
# Copyright (c) 2013 OpenStack Foundation
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

#*****************************************************************************#
#* Calico/OpenStack Plugin                                                   *#
#*                                                                           *#
#* This module is the OpenStack-specific implementation of the Plugin        *#
#* component of the new Calico architecture (described by the "Felix, the    *#
#* Calico Plugin and the Calico ACL Manager" wiki page at                    *#
#* https://github.com/Metaswitch/calico-docs/wiki).                          *#
#*                                                                           *#
#* It is implemented as a Neutron/ML2 mechanism driver.                      *#
#*****************************************************************************#

from neutron.common import constants
from neutron.extensions import portbindings
from neutron.openstack.common import log
from neutron.plugins.ml2 import driver_api as api
from neutron.plugins.ml2.drivers import mech_agent
import eventlet
from eventlet.green import zmq
import json
import time
from neutron import context as ctx
from neutron import manager

LOG = log.getLogger(__name__)

#*****************************************************************************#
#* TCP port numbers used by the 0MQ sockets that connect the Calico plugin,  *#
#* Felix and ACL Manager components, as shown by the following diagram.      *#
#*                                                                           *#
#*                                                                           *#
#*                ROUTER #1 +------------+ #3 ROUTER                         *#
#*          ,-------------->|            |<-------------------.              *#
#*          |               |   Plugin   |                    |              *#
#*          |   ,-----------|            |<---------------.   |              *#
#*          |   |     REQ   +------------+ #4 PUB         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*      REQ |   | REP                                 SUB |   | REQ          *#
#*          |   V #2                                      |   |              *#
#*     +------------+ SUB                  PUB #6 +-----------------+        *#
#*     |            |---------------------------->|                 |        *#
#*     |   Felix    |                             |   ACL Manager   |        *#
#*     |            |---------------------------->|                 |        *#
#*     +------------+ REQ               ROUTER #5 +-----------------+        *#
#*                                                                           *#
#*                                                                           *#
#*  #1: tcp://controller:PLUGIN_ENDPOINT_PORT                                *#
#*                                                                           *#
#*  #2: tcp://felix_host:FELIX_ENDPOINT_PORT                                 *#
#*                                                                           *#
#*  #3: tcp://controller:PLUGIN_ACLGET_PORT                                  *#
#*                                                                           *#
#*  #4: tcp://controller:PLUGIN_ACLPUB_PORT                                  *#
#*                                                                           *#
#*  #5: tcp://acl_host:MANAGER_ACLGET_PORT                                   *#
#*                                                                           *#
#*  #6: tcp://acl_host:MANAGER_ACLPUB_PORT                                   *#
#*                                                                           *#
#*****************************************************************************#
PLUGIN_ENDPOINT_PORT = 9901
FELIX_ENDPOINT_PORT = 9902
PLUGIN_ACLGET_PORT = 9903
PLUGIN_ACLPUB_PORT = 9904

#*****************************************************************************#
#* Time (ms) to allow for Felix to send us an ENDPOINT* response.            *#
#*****************************************************************************#
ENDPOINT_RESPONSE_TIMEOUT = 2000

#*****************************************************************************#
#* Time (ms) to allow for Felix to send us a HEARTBEAT response.             *#
#*****************************************************************************#
HEARTBEAT_RESPONSE_TIMEOUT = 2000

#*****************************************************************************#
#* Time between heartbeats, in seconds.                                      *#
#*****************************************************************************#
HEARTBEAT_SEND_INTERVAL_SECS = 10

#*****************************************************************************#
#* An OpenStack agent type name for Felix, the Calico agent component in the *#
#* new architecture.                                                         *#
#*****************************************************************************#
AGENT_TYPE_FELIX = 'Felix (Calico agent)'

class FelixUnavailable(Exception):
    """
    Exception raised when a Felix instance cannot be contacted.
    """
    def __init__(self, op, port, hostname):
        action = {'CREATED': "create",
                  'UPDATED': "update",<commit_msg>mech_calico: Send heartbeats every 30 seconds, not every 10<commit_after># -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Metaswitch Networks
# Copyright (c) 2013 OpenStack Foundation
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

#*****************************************************************************#
#* Calico/OpenStack Plugin                                                   *#
#*                                                                           *#
#* This module is the OpenStack-specific implementation of the Plugin        *#
#* component of the new Calico architecture (described by the "Felix, the    *#
#* Calico Plugin and the Calico ACL Manager" wiki page at                    *#
#* https://github.com/Metaswitch/calico-docs/wiki).                          *#
#*                                                                           *#
#* It is implemented as a Neutron/ML2 mechanism driver.                      *#
#*****************************************************************************#

from neutron.common import constants
from neutron.extensions import portbindings
from neutron.openstack.common import log
from neutron.plugins.ml2 import driver_api as api
from neutron.plugins.ml2.drivers import mech_agent
import eventlet
from eventlet.green import zmq
import json
import time
from neutron import context as ctx
from neutron import manager

LOG = log.getLogger(__name__)

#*****************************************************************************#
#* TCP port numbers used by the 0MQ sockets that connect the Calico plugin,  *#
#* Felix and ACL Manager components, as shown by the following diagram.      *#
#*                                                                           *#
#*                                                                           *#
#*                ROUTER #1 +------------+ #3 ROUTER                         *#
#*          ,-------------->|            |<-------------------.              *#
#*          |               |   Plugin   |                    |              *#
#*          |   ,-----------|            |<---------------.   |              *#
#*          |   |     REQ   +------------+ #4 PUB         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*          |   |                                         |   |              *#
#*      REQ |   | REP                                 SUB |   | REQ          *#
#*          |   V #2                                      |   |              *#
#*     +------------+ SUB                  PUB #6 +-----------------+        *#
#*     |            |---------------------------->|                 |        *#
#*     |   Felix    |                             |   ACL Manager   |        *#
#*     |            |---------------------------->|                 |        *#
#*     +------------+ REQ               ROUTER #5 +-----------------+        *#
#*                                                                           *#
#*                                                                           *#
#*  #1: tcp://controller:PLUGIN_ENDPOINT_PORT                                *#
#*                                                                           *#
#*  #2: tcp://felix_host:FELIX_ENDPOINT_PORT                                 *#
#*                                                                           *#
#*  #3: tcp://controller:PLUGIN_ACLGET_PORT                                  *#
#*                                                                           *#
#*  #4: tcp://controller:PLUGIN_ACLPUB_PORT                                  *#
#*                                                                           *#
#*  #5: tcp://acl_host:MANAGER_ACLGET_PORT                                   *#
#*                                                                           *#
#*  #6: tcp://acl_host:MANAGER_ACLPUB_PORT                                   *#
#*                                                                           *#
#*****************************************************************************#
PLUGIN_ENDPOINT_PORT = 9901
FELIX_ENDPOINT_PORT = 9902
PLUGIN_ACLGET_PORT = 9903
PLUGIN_ACLPUB_PORT = 9904

#*****************************************************************************#
#* Time (ms) to allow for Felix to send us an ENDPOINT* response.            *#
#*****************************************************************************#
ENDPOINT_RESPONSE_TIMEOUT = 2000

#*****************************************************************************#
#* Time (ms) to allow for Felix to send us a HEARTBEAT response.             *#
#*****************************************************************************#
HEARTBEAT_RESPONSE_TIMEOUT = 2000

#*****************************************************************************#
#* Time between heartbeats, in seconds.                                      *#
#*****************************************************************************#
HEARTBEAT_SEND_INTERVAL_SECS = 30

#*****************************************************************************#
#* An OpenStack agent type name for Felix, the Calico agent component in the *#
#* new architecture.                                                         *#
#*****************************************************************************#
AGENT_TYPE_FELIX = 'Felix (Calico agent)'

class FelixUnavailable(Exception):
    """
    Exception raised when a Felix instance cannot be contacted.
    """
    def __init__(self, op, port, hostname):
        action = {'CREATED': "create",
                  'UPDATED': "update",
{'fraction_non_alphanumeric': 0.24477114277053652, 'fraction_numerical': 0.008638981509548348, 'mean_word_length': 1.081217473584608, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 148, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5807799', 'n_tokens_mistral': 2835, 'n_tokens_neox': 2600, 'n_words': 651}