示例#1
0
class ClusterCreateRequestBody(base.SenlinObject):

    # VERSION 1.0: initial version
    # VERSION 1.1: added field 'config'
    VERSION = '1.1'
    VERSION_MAP = {
        '1.7': '1.1',
    }

    fields = {
        'name': fields.NameField(),
        'profile_id': fields.StringField(),
        'min_size': fields.CapacityField(
            nullable=True, minimum=0,
            default=consts.CLUSTER_DEFAULT_MIN_SIZE),
        'max_size': fields.CapacityField(
            nullable=True, minimum=-1,
            default=consts.CLUSTER_DEFAULT_MAX_SIZE),
        'desired_capacity': fields.CapacityField(
            nullable=True, minimum=0),
        'metadata': fields.JsonField(nullable=True, default={}),
        'timeout': fields.NonNegativeIntegerField(
            nullable=True, default=CONF.default_action_timeout),
        'config': fields.JsonField(nullable=True, default={}),
    }

    def obj_make_compatible(self, primitive, target_version):
        super(ClusterCreateRequest, self).obj_make_compatible(
            primitive, target_version)
        target_version = versionutils.convert_version_to_tuple(target_version)
        if target_version < (1, 1):
            if 'config' in primitive['senlin_object.data']:
                del primitive['senlin_object.data']['config']
示例#2
0
class ClusterCreateRequestBody(base.SenlinObject):

    fields = {
        'name':
        fields.NameField(),
        'profile_id':
        fields.StringField(),
        'min_size':
        fields.CapacityField(nullable=True,
                             minimum=0,
                             default=consts.CLUSTER_DEFAULT_MIN_SIZE),
        'max_size':
        fields.CapacityField(nullable=True,
                             minimum=-1,
                             default=consts.CLUSTER_DEFAULT_MAX_SIZE),
        'desired_capacity':
        fields.CapacityField(nullable=True,
                             minimum=0,
                             default=consts.CLUSTER_DEFAULT_MIN_SIZE),
        'metadata':
        fields.JsonField(nullable=True, default={}),
        'timeout':
        fields.NonNegativeIntegerField(nullable=True,
                                       default=CONF.default_action_timeout),
    }
示例#3
0
class ClusterResizeRequest(base.SenlinObject):

    fields = {
        'identity': fields.StringField(),
        'adjustment_type': fields.AdjustmentTypeField(nullable=True),
        'number': fields.FloatField(nullable=True),
        'min_size': fields.CapacityField(nullable=True, minimum=0),
        'max_size': fields.CapacityField(nullable=True, minimum=-1),
        'min_step': fields.NonNegativeIntegerField(nullable=True),
        'strict': fields.BooleanField(nullable=True, default=True),
    }
示例#4
0
    def setUp(self):
        super(TestCapacity, self).setUp()

        self.field = senlin_fields.CapacityField()
        self.coerce_good_values = [
            (100, 100),  # plain integer
            ('100', 100),  # string of integer
            ('0123', 123),  # leading zeros ignored
        ]
        self.coerce_bad_values = [
            -1,  # less than 0
            'strval',  # illegal value
        ]
        self.to_primitive_values = self.coerce_good_values[0:1]
        self.from_primitive_values = self.coerce_good_values[0:1]