From 5ed0f74a9c8ad702c58c7f06a99fe211668efb55 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Wed, 6 Apr 2016 17:21:46 +0300 Subject: [PATCH] Initial implementation of strategies There should be a way to declaratively describe each space type and strategy of its allocation. Implements blueprint: dynamic-allocation Change-Id: I66c2f0b90fb94b0496b5d341817688a042161318 --- bareon_allocator/parsers/dynamic_schema_parser.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bareon_allocator/parsers/dynamic_schema_parser.py b/bareon_allocator/parsers/dynamic_schema_parser.py index 5e6c1f0..b687b7d 100644 --- a/bareon_allocator/parsers/dynamic_schema_parser.py +++ b/bareon_allocator/parsers/dynamic_schema_parser.py @@ -31,6 +31,12 @@ class DynamicSchemaParser(object): self.rendered_spaces = [] self.disks = [] self.spaces = [] + # TODO(eli): In the future should be moved into config. + self.strategies = { + 'vg': {'strategy': 'container'}, + 'lv': {'strategy': 'elastic'}, + 'partitions': {'strategy': 'elastic'} + } self.parse() self.post_parse() @@ -42,9 +48,12 @@ class DynamicSchemaParser(object): Disk(**disk) for disk in self.raw_disks] - self.spaces = [ - Space(**space) - for space in self.rendered_spaces if space['type'] != 'vg'] + for s in self.rendered_spaces: + strategy = self.strategies.get(s['type'], {}).get('strategy') + if strategy == 'elastic': + self.spaces.append(Space(**s)) + elif strategy is None: + LOG.warn('There is not strategy for space %s', s) def post_parse(self): # Add fake volume Unallocated, in order to be able