Exemplo n.º 1
0
class RequestGroup(base.ZunPersistentObject, base.ZunObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'use_same_provider': fields.BooleanField(default=True),
        'resources': fields.DictOfIntegersField(default={}),
        'required_traits': zun_fields.SetOfStringsField(default=set()),
        'forbidden_traits': zun_fields.SetOfStringsField(default=set()),
        # The aggregates field has a form of
        #     [[aggregate_UUID1],
        #      [aggregate_UUID2, aggregate_UUID3]]
        # meaning that the request should be fulfilled from an RP that is a
        # member of the aggregate aggregate_UUID1 and member of the aggregate
        # aggregate_UUID2 or aggregate_UUID3 .
        'aggregates': zun_fields.ListOfListsOfStringsField(default=[]),
        # The entity the request is coming from (e.g. the Neutron port uuid)
        # which may not always be a UUID.
        'requester_id': fields.StringField(nullable=True, default=None),
        # The resource provider UUIDs that together fulfill the request
        # NOTE(gibi): this can be more than one if this is the unnumbered
        # request group (i.e. use_same_provider=False)
        'provider_uuids': fields.ListOfUUIDField(default=[]),
        'in_tree': fields.UUIDField(nullable=True, default=None),
    }

    def __init__(self, context=None, **kwargs):
        super(RequestGroup, self).__init__(context=context, **kwargs)
        self.obj_set_defaults()
 def setUp(self):
     super(TestDictOfIntegers, self).setUp()
     self.field = fields.DictOfIntegersField()
     self.coerce_good_values = [({'foo': '42'}, {'foo': 42}),
                                ({'foo': 4.2}, {'foo': 4})]
     self.coerce_bad_values = [{1: 'bar'}, {'foo': 'boo'},
                               'foo', {'foo': None}]
     self.to_primitive_values = [({'foo': 42}, {'foo': 42})]
     self.from_primitive_values = [({'foo': 42}, {'foo': 42})]