From 1bc8aa188896fc7668427f19a4ffd89ca5f6fa3c Mon Sep 17 00:00:00 2001 From: Dan Firth Date: Fri, 27 Sep 2013 09:51:31 +0000 Subject: Dropped support for 'disk-size' from system morphology files' --- morphlib/morph2.py | 20 +---------------- morphlib/morph2_tests.py | 35 ----------------------------- morphlib/morphloader.py | 1 - morphlib/morphloader_tests.py | 1 - morphlib/plugins/branch_and_merge_plugin.py | 2 -- 5 files changed, 1 insertion(+), 58 deletions(-) (limited to 'morphlib') diff --git a/morphlib/morph2.py b/morphlib/morph2.py index a733ce77..ec4f2e9a 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -169,10 +169,6 @@ class Morphology(object): self._set_default_value(self._dict, 'max-jobs', int(self['max-jobs'])) - if 'disk-size' in self: - self._set_default_value(self._dict, 'disk-size', - self._parse_size(self['disk-size'])) - for name, value in self.static_defaults[self['kind']]: if name not in self._dict: self._set_default_value(self._dict, name, value) @@ -207,17 +203,6 @@ class Morphology(object): 'deploy', dict()) - def _parse_size(self, size): - if isinstance(size, basestring): - size = size.lower() - if size.endswith('g'): - return int(size[:-1]) * 1024 ** 3 - elif size.endswith('m'): # pragma: no cover - return int(size[:-1]) * 1024 ** 2 - elif size.endswith('k'): # pragma: no cover - return int(size[:-1]) * 1024 - return int(size) # pragma: no cover - def lookup_child_by_name(self, name): '''Find child reference by its name. @@ -284,10 +269,7 @@ class Morphology(object): # Simple values. Use original value unless it has been changed from # the default in memmory. if live_dict[key] == live_dict.get('_orig_' + key, None): - if key in original_dict: - result = original_dict[key] - else: - result = None + result = original_dict.get(key, None) else: result = live_dict[key] return result diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index bf32d3c2..c11d7058 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -96,29 +96,16 @@ class MorphologyTests(unittest.TestCase): self.assertEqual(m['chunks'][0]['morph'], 'le-chunk') self.assertEqual(m['chunks'][0]['build-depends'], None) - def test_parses_system_disk_size(self): - m = Morphology(''' - { - "name": "foo", - "kind": "system", - "disk-size": "1g" - } - ''') - - self.assertEqual(m['disk-size'], 1024 ** 3) - def test_returns_dict_keys(self): m = Morphology(''' { "name": "foo", "kind": "system", - "disk-size": "1g" } ''') self.assertTrue('name' in m.keys()) self.assertTrue('kind' in m.keys()) - self.assertTrue('disk-size' in m.keys()) def test_system_indexes_strata(self): m = Morphology(''' @@ -307,32 +294,10 @@ class MorphologyTests(unittest.TestCase): system_text = '''{ "kind": "system", - "disk-size": "1g", "arch": "x86_64", "system-kind": "rootfs-tarball" }''' - def test_writing_preserves_disk_size(self): - text_lines = self.system_text.splitlines() - morphology = Morphology(self.system_text) - - output = StringIO.StringIO() - morphology.update_text(self.system_text, output) - output_lines = output.getvalue().splitlines() - self.assertEqual(text_lines, output_lines) - - def test_writing_updates_disk_size(self): - text_lines = self.system_text.splitlines() - text_lines[2] = ' "disk-size": 512,' - - morphology = Morphology(self.system_text) - morphology._dict['disk-size'] = 512 - - output = StringIO.StringIO() - morphology.update_text(self.system_text, output) - output_lines = output.getvalue().splitlines() - self.assertEqual(text_lines, output_lines) - def test_nested_dict(self): # Real morphologies don't trigger this code path, so we test manually original_dict = { diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index c94078f9..9b134509 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -146,7 +146,6 @@ class MorphologyLoader(object): 'arch': None, 'system-kind': 'rootfs-tarball', 'configuration-extensions': [], - 'disk-size': '1G', }, 'cluster': {}, } diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py index ac0fef53..d302551e 100644 --- a/morphlib/morphloader_tests.py +++ b/morphlib/morphloader_tests.py @@ -474,7 +474,6 @@ name: foo 'arch': 'x86_64', 'strata': [], 'configuration-extensions': [], - 'disk-size': '1G', }) def test_unsets_defaults_for_system(self): diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 37d5e40c..3be61297 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -360,8 +360,6 @@ class BranchAndMergePlugin(cliapp.Plugin): 'system': [ 'kind', 'description', - 'disk-size', - '_disk-size', 'configuration-extensions', ], 'stratum': [ -- cgit v1.2.1