class CrushRuleSerializer(serializers.Serializer): class Meta: fields = ('id', 'name', 'ruleset', 'type', 'min_size', 'max_size', 'steps', 'osd_count') id = serializers.IntegerField(source='rule_id') name = serializers.CharField(source='rule_name', help_text="Human readable name") ruleset = serializers.IntegerField( help_text="ID of the CRUSH ruleset of which this rule is a member") type = fields.EnumField( { CRUSH_RULE_TYPE_REPLICATED: 'replicated', CRUSH_RULE_TYPE_ERASURE: 'erasure' }, help_text="Data redundancy type") min_size = serializers.IntegerField( help_text= "If a pool makes more replicas than this number, CRUSH will NOT select this rule" ) max_size = serializers.IntegerField( help_text= "If a pool makes fewer replicas than this number, CRUSH will NOT select this rule" ) steps = serializers.Field( help_text="List of operations used to select OSDs") osd_count = serializers.IntegerField( help_text="Number of OSDs which are used for data placement")
class CrushRuleSerializer(ValidatingSerializer): class Meta: fields = ('id', 'name', 'ruleset', 'type', 'min_size', 'max_size', 'steps', 'osd_count') create_allowed = ('name', 'ruleset', 'type', 'min_size', 'max_size', 'steps') create_required = ('name', 'type', 'min_size', 'max_size', 'steps') modify_allowed = ('name', 'ruleset', 'min_size', 'max_size', 'steps') modify_required = () id = serializers.IntegerField(source='rule_id', required=False) name = serializers.CharField(source='rule_name', help_text="Human readable name", required=False) ruleset = serializers.IntegerField( help_text="ID of the CRUSH ruleset of which this rule is a member", required=False, validators=[ less_than(255), ]) type = fields.EnumField( { CRUSH_RULE_TYPE_REPLICATED: 'replicated', CRUSH_RULE_TYPE_ERASURE: 'erasure' }, help_text="Data redundancy type", required=False) min_size = serializers.IntegerField( help_text= "If a pool makes more replicas than this number, CRUSH will NOT select this rule", required=False) max_size = serializers.IntegerField( help_text= "If a pool makes fewer replicas than this number, CRUSH will NOT select this rule", required=False) steps = StepItemSerializer( required=True, many=True, help_text= "A bucket may have one or more items. The items may consist of node buckets or leaves. Items may have a weight that reflects the relative weight of the item." ) osd_count = serializers.IntegerField( help_text="Number of OSDs which are used for data placement", required=False)
class PoolSerializer(ValidatingSerializer): class Meta: fields = ('name', 'id', 'size', 'pg_num', 'crush_ruleset', 'min_size', 'crash_replay_interval', 'crush_ruleset', 'pgp_num', 'hashpspool', 'full', 'quota_max_objects', 'quota_max_bytes', 'type', 'erasure_code_profile') create_allowed = ('name', 'pg_num', 'pgp_num', 'crush_ruleset', 'size', 'min_size', 'crash_replay_interval', 'crush_ruleset', 'quota_max_objects', 'quota_max_bytes', 'hashpspool', 'type', 'erasure_code_profile') create_required = ('name', 'pg_num') modify_allowed = ('name', 'pg_num', 'pgp_num', 'size', 'min_size', 'crash_replay_interval', 'crush_ruleset', 'quota_max_objects', 'quota_max_bytes', 'hashpspool') modify_required = () # Required in creation name = serializers.CharField( required=False, source='pool_name', help_text="Human readable name of the pool, may" "change over the pools lifetime at user request.") pg_num = serializers.IntegerField( required=False, help_text="Number of placement groups in this pool") # Not required in creation, immutable id = serializers.CharField(source='pool', required=False, help_text="Unique numeric ID") # May be set in creation or updates size = serializers.IntegerField(required=False, help_text="Replication factor") min_size = serializers.IntegerField( required=False, help_text= "Minimum number of replicas required for I/O; clamped to 'size' if greater; 0 defaults to 'size - int(size/2)'" ) crash_replay_interval = serializers.IntegerField( required=False, help_text="Number of seconds to allow clients to " "replay acknowledged, but uncommitted requests") crush_ruleset = serializers.IntegerField(required=False, help_text="CRUSH ruleset in use") # In 'ceph osd pool set' it's called pgp_num, but in 'ceph osd dump' it's called # pg_placement_num :-/ pgp_num = serializers.IntegerField( source='pg_placement_num', required=False, help_text="Effective number of placement groups to use when calculating " "data placement") # This is settable by 'ceph osd pool set' but in 'ceph osd dump' it only appears # within the 'flags' integer. We synthesize a boolean from the flags. hashpspool = serializers.BooleanField(required=False, help_text="Enable HASHPSPOOL flag") # This is synthesized from ceph's 'flags' attribute, read only. full = serializers.BooleanField(required=False, help_text="True if the pool is full") quota_max_objects = serializers.IntegerField( required=False, help_text="Quota limit on object count (0 is unlimited)") quota_max_bytes = serializers.IntegerField( required=False, help_text="Quota limit on usage in bytes (0 is unlimited)") type = fields.EnumField( { CRUSH_RULE_TYPE_REPLICATED: 'replicated', CRUSH_RULE_TYPE_ERASURE: 'erasure' }, help_text="Data redundancy type", required=False) erasure_code_profile = serializers.CharField( required=False, help_text= "This profile configures how to split data in K pieces and create M coding chunks. names can include these characters [A-Za-z0-9-_.]" )