Ejemplo n.º 1
0
def create_cache_for_l2_agent():
    """Create a push-notifications cache for L2 agent related resources."""

    objects.register_objects()
    resource_types = [
        resources.PORT, resources.SECURITYGROUP, resources.SECURITYGROUPRULE,
        resources.NETWORK, resources.SUBNET
    ]
    rcache = resource_cache.RemoteResourceCache(resource_types)
    rcache.start_watcher()
    return rcache
Ejemplo n.º 2
0
 def setUp(self):
     super(TestObjectVersions, self).setUp()
     # NOTE(davidsha): Neutron Classifier OvO's need to be seeded,
     # There also appears to be some versioned objects leaking in from
     # Neutron from dependencies.
     # Because of this I've included all Neutron OvO's and added them
     # to the local object_data variable.
     # This dependency will prevent upgrades to a neutron OvO from breaking
     # this test if they were stored statically here.
     objects.register_objects()
     n_obj.register_objects()
Ejemplo n.º 3
0
 def setUp(self):
     super(SecurityGroupServerAPIShimTestCase, self).setUp()
     objects.register_objects()
     resource_types = [resources.PORT, resources.SECURITYGROUP,
                       resources.SECURITYGROUPRULE]
     self.rcache = resource_cache.RemoteResourceCache(resource_types)
     # prevent any server lookup attempts
     mock.patch.object(self.rcache, '_flood_cache_for_query').start()
     self.shim = securitygroups_rpc.SecurityGroupServerAPIShim(self.rcache)
     self.sg_agent = mock.Mock()
     self.shim.register_legacy_sg_notification_callbacks(self.sg_agent)
     self.ctx = context.get_admin_context()
Ejemplo n.º 4
0
 def setUp(self):
     super(SecurityGroupServerAPIShimTestCase, self).setUp()
     objects.register_objects()
     resource_types = [resources.PORT, resources.SECURITYGROUP,
                       resources.SECURITYGROUPRULE]
     self.rcache = resource_cache.RemoteResourceCache(resource_types)
     # prevent any server lookup attempts
     mock.patch.object(self.rcache, '_flood_cache_for_query').start()
     self.shim = securitygroups_rpc.SecurityGroupServerAPIShim(self.rcache)
     self.sg_agent = mock.Mock()
     self.shim.register_legacy_sg_notification_callbacks(self.sg_agent)
     self.ctx = context.get_admin_context()
Ejemplo n.º 5
0
def create_cache_for_l2_agent():
    """Create a push-notifications cache for L2 agent related resources."""

    objects.register_objects()
    resource_types = [
        resources.PORT,
        resources.SECURITYGROUP,
        resources.SECURITYGROUPRULE,
        resources.NETWORK,
        resources.SUBNET
    ]
    rcache = resource_cache.RemoteResourceCache(resource_types)
    rcache.start_watcher()
    return rcache
Ejemplo n.º 6
0
def create_cache_for_l2_agent():
    """Create a push-notifications cache for L2 agent related resources."""

    objects.register_objects()
    resource_types = [
        resources.PORT, resources.SECURITYGROUP, resources.SECURITYGROUPRULE,
        resources.NETWORK, resources.SUBNET
    ]
    rcache = resource_cache.RemoteResourceCache(resource_types)
    rcache.start_watcher()
    # TODO(kevinbenton): ensure flood uses filters or that this has a long
    # timeout before Pike release.
    rcache.bulk_flood_cache()
    return rcache
Ejemplo n.º 7
0
 def setUp(self):
     super(TestObjectVersions, self).setUp()
     # NOTE(ihrachys): seed registry with all objects under neutron.objects
     # before validating the hashes
     objects.register_objects()
Ejemplo n.º 8
0
#    License for the specific language governing permissions and limitations
#    under the License.

from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib import context as n_ctx
from oslo_log import log as logging

from neutron.api.rpc.callbacks.consumer import registry as registry_rpc
from neutron.api.rpc.callbacks import events as events_rpc
from neutron.api.rpc.handlers import resources_rpc
from neutron.common import rpc as n_rpc
from neutron import objects

LOG = logging.getLogger(__name__)
objects.register_objects()


class RemoteResourceCache(object):
    """Retrieves and stashes logical resources in their OVO format.

    This is currently only compatible with OVO objects that have an ID.
    """
    def __init__(self, resource_types):
        self.resource_types = resource_types
        self._cache_by_type_and_id = {rt: {} for rt in self.resource_types}
        self._deleted_ids_by_type = {rt: set() for rt in self.resource_types}
        # track everything we've asked the server so we don't ask again
        self._satisfied_server_queries = set()
        self._puller = resources_rpc.ResourcesPullRpcApi()
Ejemplo n.º 9
0
from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib import context as n_ctx
from neutron_lib import rpc as n_rpc
from oslo_log import log as logging

from neutron._i18n import _
from neutron.api.rpc.callbacks.consumer import registry as registry_rpc
from neutron.api.rpc.callbacks import events as events_rpc
from neutron.api.rpc.handlers import resources_rpc
from neutron import objects
from neutron.common import utils
from neutron.common import log_utils

LOG = logging.getLogger(__name__)
objects.register_objects()


class RemoteResourceCache(object):
    LOG.info('%s(): caller(): %s', log_utils.get_fname(1),
             log_utils.get_fname(2))
    """Retrieves and stashes logical resources in their OVO format.

    This is currently only compatible with OVO objects that have an ID.
    """
    def __init__(self, resource_types):
        LOG.info('%s(): caller(): %s', log_utils.get_fname(1),
                 log_utils.get_fname(2))
        self.resource_types = resource_types
        self._cache_by_type_and_id = {rt: {} for rt in self.resource_types}
        self._deleted_ids_by_type = {rt: set() for rt in self.resource_types}
Ejemplo n.º 10
0
 def setUp(self):
     super(TestObjectVersions, self).setUp()
     # NOTE(ihrachys): seed registry with all objects under neutron.objects
     # before validating the hashes
     objects.register_objects()
Ejemplo n.º 11
0
 def _create_cache_for_l2_agent(self):
     """Create a push-notifications cache for L2 agent related resources."""
     objects.register_objects()
     rcache = resource_cache.RemoteResourceCache(self.RESOURCE_TYPES)
     rcache.start_watcher()
     self.remote_resource_cache = rcache