Exemple #1
0
def resource_type_versioned_topic(resource_type):
    _validate_resource_type(resource_type)
    cls = resources.get_resource_cls(resource_type)
    return topics.RESOURCE_TOPIC_PATTERN % {
        'resource_type': resource_type,
        'version': cls.VERSION
    }
Exemple #2
0
def resource_type_versioned_topic(resource_type, version=None):
    """Return the topic for a resource type.

    If no version is provided, the latest version of the object will
    be used.
    """
    _validate_resource_type(resource_type)
    cls = resources.get_resource_cls(resource_type)
    return topics.RESOURCE_TOPIC_PATTERN % {'resource_type': resource_type,
                                            'version': version or cls.VERSION}
Exemple #3
0
def resource_type_versioned_topic(resource_type, version=None):
    """Return the topic for a resource type.

    If no version is provided, the latest version of the object will
    be used.
    """
    _validate_resource_type(resource_type)
    cls = resources.get_resource_cls(resource_type)
    return topics.RESOURCE_TOPIC_PATTERN % {'resource_type': resource_type,
                                            'version': version or cls.VERSION}
Exemple #4
0
    def pull(self, context, resource_type, resource_id):
        _validate_resource_type(resource_type)

        # we've already validated the resource type, so we are pretty sure the
        # class is there => no need to validate it specifically
        resource_type_cls = resources.get_resource_cls(resource_type)

        cctxt = self.client.prepare()
        primitive = cctxt.call(context, 'pull',
            resource_type=resource_type,
            version=resource_type_cls.VERSION, resource_id=resource_id)

        if primitive is None:
            raise ResourceNotFound(resource_type=resource_type,
                                   resource_id=resource_id)

        return resource_type_cls.clean_obj_from_primitive(primitive)
Exemple #5
0
    def pull(self, context, resource_type, resource_id):
        _validate_resource_type(resource_type)

        # we've already validated the resource type, so we are pretty sure the
        # class is there => no need to validate it specifically
        resource_type_cls = resources.get_resource_cls(resource_type)

        cctxt = self.client.prepare()
        primitive = cctxt.call(context, 'pull',
            resource_type=resource_type,
            version=resource_type_cls.VERSION, resource_id=resource_id)

        if primitive is None:
            raise ResourceNotFound(resource_type=resource_type,
                                   resource_id=resource_id)

        return resource_type_cls.clean_obj_from_primitive(primitive)
Exemple #6
0
def _resource_to_class(resource_type):
    _validate_resource_type(resource_type)

    # we've already validated the resource type, so we are pretty sure the
    # class is there => no need to validate it specifically
    return resources.get_resource_cls(resource_type)
Exemple #7
0
 def test_unknown_type(self):
     self.assertIsNone(resources.get_resource_cls('unknown-resource-type'))
Exemple #8
0
 def test_known_type(self):
     # it could be any other NeutronObject, assuming it's known to RPC
     # callbacks
     self.assertEqual(policy.QosPolicy,
                      resources.get_resource_cls(resources.QOS_POLICY))
 def test_unknown_type(self):
     self.assertIsNone(resources.get_resource_cls('unknown-resource-type'))
Exemple #10
0
 def test_known_type(self):
     # it could be any other NeutronObject, assuming it's known to RPC
     # callbacks
     self.assertEqual(policy.QosPolicy,
                      resources.get_resource_cls(resources.QOS_POLICY))
Exemple #11
0
def resource_type_versioned_topic(resource_type):
    _validate_resource_type(resource_type)
    cls = resources.get_resource_cls(resource_type)
    return topics.RESOURCE_TOPIC_PATTERN % {'resource_type': resource_type,
                                            'version': cls.VERSION}
Exemple #12
0
def _resource_to_class(resource_type):
    _validate_resource_type(resource_type)

    # we've already validated the resource type, so we are pretty sure the
    # class is there => no need to validate it specifically
    return resources.get_resource_cls(resource_type)