예제 #1
0
    def test_pull_does_not_raise_on_none(self):
        def _none_cb(*args, **kwargs):
            pass

        registry.provide(_none_cb, resources.QOS_POLICY)

        obj = registry.pull(resources.QOS_POLICY, 'fake_id')
        self.assertIsNone(obj)
예제 #2
0
    def test_pull_does_not_raise_on_none(self):
        def _none_cb(*args, **kwargs):
            pass

        registry.provide(_none_cb, resources.QOS_POLICY)

        obj = registry.pull(resources.QOS_POLICY, 'fake_id')
        self.assertIsNone(obj)
예제 #3
0
 def pull(self, context, resource_type, version, resource_id):
     obj = prod_registry.pull(resource_type, resource_id, context=context)
     if obj:
         #TODO(QoS): Remove in the future with new version of
         #           versionedobjects containing
         #           https://review.openstack.org/#/c/207998/
         if version == obj.VERSION:
             version = None
         return obj.obj_to_primitive(target_version=version)
예제 #4
0
 def pull(self, context, resource_type, version, resource_id):
     obj = prod_registry.pull(resource_type, resource_id, context=context)
     if obj:
         #TODO(QoS): Remove in the future with new version of
         #           versionedobjects containing
         #           https://review.openstack.org/#/c/207998/
         if version == obj.VERSION:
             version = None
         return obj.obj_to_primitive(target_version=version)
예제 #5
0
    def test_pull_returns_callback_result(self):
        policy_obj = policy.QosPolicy(context=None)

        def _fake_policy_cb(*args, **kwargs):
            return policy_obj

        registry.provide(_fake_policy_cb, resources.QOS_POLICY)

        self.assertEqual(policy_obj,
                         registry.pull(resources.QOS_POLICY, 'fake_id'))
예제 #6
0
    def test_pull_returns_callback_result(self):
        policy_obj = policy.QosPolicy(context=None)

        def _fake_policy_cb(*args, **kwargs):
            return policy_obj

        registry.provide(_fake_policy_cb, resources.QOS_POLICY)

        self.assertEqual(
            policy_obj,
            registry.pull(resources.QOS_POLICY, 'fake_id'))
예제 #7
0
 def pull(self, context, resource_type, version, resource_id):
     obj = prod_registry.pull(resource_type, resource_id, context=context)
     if obj:
         return obj.obj_to_primitive(target_version=version)
예제 #8
0
 def pull(self, context, resource_type, version, resource_id):
     obj = prod_registry.pull(resource_type, resource_id, context=context)
     if obj:
         return obj.obj_to_primitive(target_version=version)