# Path: networking_vsphere/_i18n.py
# _LI = _translators.log_info
# 
# Path: networking_vsphere/common/constants.py
# AGENT_TYPE_OVSVAPP = "OVSvApp Agent"
# AGENT_TYPE_DVS = 'DVS agent'
# OVSVAPP = 'ovsvapp'
# DVS = 'dvs'
# OVSVAPP_PLUGIN = 'ovsvapp_service_plugin'
# DEVICE = 'device'
# VMWARE_HYPERVISOR_TYPE = 'VMware vCenter Server'
# PORT_STATUS_UP = 'UP'
# PORT_STATUS_DOWN = 'DOWN'
# VM_CREATED = 'VM_CREATED'
# VM_UPDATED = 'VM_UPDATED'
# VM_DELETED = 'VM_DELETED'
# DRIVER_IDLE = 'IDLE'
# DRIVER_READY = 'READY'
# DRIVER_RUNNING = 'RUNNING'
# DRIVER_STOPPED = 'STOPPED'
# DEAD_VLAN = 4095
# AGENT_INITIALIZING = "INITIALIZING"
# AGENT_INITIALIZED = "INITIALIZED"
# AGENT_RUNNING = "RUNNING"
# AGENT_STOPPING = "STOPPING"
# AGENT_STOPPED = "STOPPED"
# SEC_TO_INT_PATCH = "patch-integration"
# INT_TO_SEC_PATCH = "patch-security"
# SG_DROPALL_PRI = 0
# SG_DEFAULT_PRI = 1
# SG_LOW_PRI = 5
# SG_RULES_PRI = 10
# SG_TP_PRI = 20
# SG_TCP_FLAG_PRI = 25
# SG_DROP_HIGH_PRI = 50
# SG_DEFAULT_TABLE_ID = 0
# SG_EGRESS_TABLE_ID = 1
# SG_IP_TABLE_ID = 2
# SG_TCP_TABLE_ID = 2
# SG_UDP_TABLE_ID = 2
# SG_ICMP_TABLE_ID = 2
# SG_LEARN_TABLE_ID = 5
# SG_CANARY_TABLE_ID = 23
# ICMP_ECHO_REQ = 8
# ICMP_ECHO_REP = 0
# ICMP_TIME_EXCEEDED = 11
# ICMP_TS_REQ = 13
# ICMP_TS_REP = 14
# ICMP_INFO_REQ = 15
# ICMP_INFO_REP = 16
# ICMP_AM_REQ = 17
# ICMP_AM_REP = 18
# ICMP_DEST_UNREACH = 3
# THREAD_POOL_SIZE = 5
# RPC_BATCH_SIZE = 30
# SG_RPC_BATCH_SIZE = 10
# DIRECTION_IP_PREFIX = {'ingress': 'source_ip_prefix',
#                        'egress': 'dest_ip_prefix'}
# PROTOCOL = {'icmp': 1,
#             'tcp': 6,
#             'udp': 17,
#             'ipv6-icmp': 58}
# DVS_PORTGROUP_NAME_MAXLEN = 80
# LOGIN_RETRIES = 3
# VM_NETWORK_DEVICE_TYPES = [
#     'VirtualE1000', 'VirtualE1000e', 'VirtualPCNet32',
#     'VirtualSriovEthernetCard', 'VirtualVmxnet']
# CONCURRENT_MODIFICATION_TEXT = 'Cannot complete operation due to concurrent '\
#                                'modification by another operation.'
# LOGIN_PROBLEM_TEXT = "Cannot complete login due to an incorrect "\
#                      "user name or password"
# DELETED_TEXT = "The object has already been deleted or has not been "\
#                "completely created"
# DUPLICATE_NAME = "oslo_vmware.exceptions.DuplicateName"
# RESOURCE_IN_USE = "is in use."
# MIN_EPHEMERAL_PORT = 32768
# MAX_EPHEMERAL_PORT = 65535


import eventlet
import oslo_messaging
import netaddr
import threading
import time
from oslo_config import cfg
from oslo_log import log
from oslo_utils import importutils
from networking_vsphere._i18n import _LI
from networking_vsphere.common import constants as ovsvapp_const
from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import rpc as n_rpc
                     len(devices))
            ovsvapplock.acquire()
            self.devices_to_refilter |= set(devices)
            self.firewall.remove_ports_from_provider_cache(devices)
            ovsvapplock.release()

    def add_devices_to_filter(self, devices):
        if not devices:
            return
        self.firewall.add_ports_to_filter(devices)

    def ovsvapp_sg_update(self, port_with_rules):
        for port_id in port_with_rules:
            if port_id in self.firewall.ports:
                self.firewall.prepare_port_filter(port_with_rules[port_id])

    def remove_devices_filter(self, device_id):
        if not device_id:
            return
        self.firewall.clean_port_filters([device_id], True)

    def expand_sg_rules(self, ports_info):
        ips = ports_info.get('member_ips')
        ports = ports_info.get('ports')
        for port in ports.values():
            updated_rule = []
            for rule in port.get('sg_normal_rules'):
                remote_group_id = rule.get('remote_group_id')
                direction = rule.get('direction')
                direction_ip_prefix = (

# Path: networking_vsphere/_i18n.py
# _LI = _translators.log_info
# 
# Path: networking_vsphere/common/constants.py
# AGENT_TYPE_OVSVAPP = "OVSvApp Agent"
# AGENT_TYPE_DVS = 'DVS agent'
# OVSVAPP = 'ovsvapp'
# DVS = 'dvs'
# OVSVAPP_PLUGIN = 'ovsvapp_service_plugin'
# DEVICE = 'device'
# VMWARE_HYPERVISOR_TYPE = 'VMware vCenter Server'
# PORT_STATUS_UP = 'UP'
# PORT_STATUS_DOWN = 'DOWN'
# VM_CREATED = 'VM_CREATED'
# VM_UPDATED = 'VM_UPDATED'
# VM_DELETED = 'VM_DELETED'
# DRIVER_IDLE = 'IDLE'
# DRIVER_READY = 'READY'
# DRIVER_RUNNING = 'RUNNING'
# DRIVER_STOPPED = 'STOPPED'
# DEAD_VLAN = 4095
# AGENT_INITIALIZING = "INITIALIZING"
# AGENT_INITIALIZED = "INITIALIZED"
# AGENT_RUNNING = "RUNNING"
# AGENT_STOPPING = "STOPPING"
# AGENT_STOPPED = "STOPPED"
# SEC_TO_INT_PATCH = "patch-integration"
# INT_TO_SEC_PATCH = "patch-security"
# SG_DROPALL_PRI = 0
# SG_DEFAULT_PRI = 1
# SG_LOW_PRI = 5
# SG_RULES_PRI = 10
# SG_TP_PRI = 20
# SG_TCP_FLAG_PRI = 25
# SG_DROP_HIGH_PRI = 50
# SG_DEFAULT_TABLE_ID = 0
# SG_EGRESS_TABLE_ID = 1
# SG_IP_TABLE_ID = 2
# SG_TCP_TABLE_ID = 2
# SG_UDP_TABLE_ID = 2
# SG_ICMP_TABLE_ID = 2
# SG_LEARN_TABLE_ID = 5
# SG_CANARY_TABLE_ID = 23
# ICMP_ECHO_REQ = 8
# ICMP_ECHO_REP = 0
# ICMP_TIME_EXCEEDED = 11
# ICMP_TS_REQ = 13
# ICMP_TS_REP = 14
# ICMP_INFO_REQ = 15
# ICMP_INFO_REP = 16
# ICMP_AM_REQ = 17
# ICMP_AM_REP = 18
# ICMP_DEST_UNREACH = 3
# THREAD_POOL_SIZE = 5
# RPC_BATCH_SIZE = 30
# SG_RPC_BATCH_SIZE = 10
# DIRECTION_IP_PREFIX = {'ingress': 'source_ip_prefix',
#                        'egress': 'dest_ip_prefix'}
# PROTOCOL = {'icmp': 1,
#             'tcp': 6,
#             'udp': 17,
#             'ipv6-icmp': 58}
# DVS_PORTGROUP_NAME_MAXLEN = 80
# LOGIN_RETRIES = 3
# VM_NETWORK_DEVICE_TYPES = [
#     'VirtualE1000', 'VirtualE1000e', 'VirtualPCNet32',
#     'VirtualSriovEthernetCard', 'VirtualVmxnet']
# CONCURRENT_MODIFICATION_TEXT = 'Cannot complete operation due to concurrent '\
#                                'modification by another operation.'
# LOGIN_PROBLEM_TEXT = "Cannot complete login due to an incorrect "\
#                      "user name or password"
# DELETED_TEXT = "The object has already been deleted or has not been "\
#                "completely created"
# DUPLICATE_NAME = "oslo_vmware.exceptions.DuplicateName"
# RESOURCE_IN_USE = "is in use."
# MIN_EPHEMERAL_PORT = 32768
# MAX_EPHEMERAL_PORT = 65535


# Path: networking_vsphere/agent/ovsvapp_sg_agent.py
import eventlet
import oslo_messaging
import netaddr
import threading
import time
from oslo_config import cfg
from oslo_log import log
from oslo_utils import importutils
from networking_vsphere._i18n import _LI
from networking_vsphere.common import constants as ovsvapp_const
from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import rpc as n_rpc

                     len(devices))
            ovsvapplock.acquire()
            self.devices_to_refilter |= set(devices)
            self.firewall.remove_ports_from_provider_cache(devices)
            ovsvapplock.release()

    def add_devices_to_filter(self, devices):
        if not devices:
            return
        self.firewall.add_ports_to_filter(devices)

    def ovsvapp_sg_update(self, port_with_rules):
        for port_id in port_with_rules:
            if port_id in self.firewall.ports:
                self.firewall.prepare_port_filter(port_with_rules[port_id])

    def remove_devices_filter(self, device_id):
        if not device_id:
            return
        self.firewall.clean_port_filters([device_id], True)

    def expand_sg_rules(self, ports_info):
        ips = ports_info.get('member_ips')
        ports = ports_info.get('ports')
        for port in ports.values():
            updated_rule = []
            for rule in port.get('sg_normal_rules'):
                remote_group_id = rule.get('remote_group_id')
                direction = rule.get('direction')
                direction_ip_prefix = (

                    ovsvapp_const.DIRECTION_IP_PREFIX[direction])