예제 #1
0
 def setUp(self):
     super(TestCacheBackedPluginApi, self).setUp()
     self._api = rpc.CacheBackedPluginApi(lib_topics.PLUGIN)
     self._api._legacy_interface = mock.Mock()
     self._api.remote_resource_cache = mock.Mock()
     self._network_id = uuidutils.generate_uuid()
     self._segment_id = uuidutils.generate_uuid()
     self._segment = network.NetworkSegment(
         id=self._segment_id,
         network_id=self._network_id,
         network_type=constants.TYPE_FLAT)
     self._port_id = uuidutils.generate_uuid()
     self._network = network.Network(id=self._network_id,
                                     segments=[self._segment])
     self._port = ports.Port(
         id=self._port_id,
         network_id=self._network_id,
         mac_address=netaddr.EUI('fa:16:3e:ec:c7:d9'),
         admin_state_up=True,
         security_group_ids=set([uuidutils.generate_uuid()]),
         fixed_ips=[],
         allowed_address_pairs=[],
         device_owner=constants.DEVICE_OWNER_COMPUTE_PREFIX,
         bindings=[
             ports.PortBinding(port_id=self._port_id,
                               host='host1',
                               status=constants.ACTIVE,
                               profile={})
         ],
         binding_levels=[
             ports.PortBindingLevel(port_id=self._port_id,
                                    host='host1',
                                    level=0,
                                    segment=self._segment)
         ])
예제 #2
0
    def test_initialization_with_default_resources(self, rcache_class):
        rcache_obj = mock.MagicMock()
        rcache_class.return_value = rcache_obj

        rpc.CacheBackedPluginApi(lib_topics.PLUGIN)

        rcache_class.assert_called_once_with(
            rpc.CacheBackedPluginApi.RESOURCE_TYPES)
        rcache_obj.start_watcher.assert_called_once_with()