[PATCH] [Kimchi 0/2] Add graphics merging to template update

Lucio Correia (2): Add graphics settings merge to template update Update tests model/templates.py | 7 +++++++ tests/test_template.py | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) -- 1.9.1

Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- model/templates.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/model/templates.py b/model/templates.py index 053942a..8a29e02 100644 --- a/model/templates.py +++ b/model/templates.py @@ -166,6 +166,13 @@ class TemplateModel(object): old_t = self.lookup(name) new_t = copy.copy(old_t) + # Merge graphics settings + graph_args = params.get('graphics') + if graph_args: + graphics = dict(new_t['graphics']) + graphics.update(graph_args) + params['graphics'] = graphics + # Merge cpu_info settings new_cpu_info = params.get('cpu_info') if new_cpu_info: -- 1.9.1

Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- tests/test_template.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_template.py b/tests/test_template.py index 3b9f26a..da0037e 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -275,14 +275,23 @@ class TemplateTests(unittest.TestCase): update_tmpl = json.loads(resp.read()) self.assertEquals(update_tmpl['folder'], folder_data['folder']) - # Update graphics + # Test graphics merge req = json.dumps({'graphics': {'type': 'spice'}}) resp = self.request(new_tmpl_uri, req, 'PUT') self.assertEquals(200, resp.status) update_tmpl = json.loads(resp.read()) self.assertEquals('spice', update_tmpl['graphics']['type']) - req = json.dumps({'graphics': {'type': 'vnc', 'listen': 'fe00::0'}}) + # update only listen (type does not reset to default 'vnc') + req = json.dumps({'graphics': {'listen': 'fe00::0'}}) + resp = self.request(new_tmpl_uri, req, 'PUT') + self.assertEquals(200, resp.status) + update_tmpl = json.loads(resp.read()) + self.assertEquals('spice', update_tmpl['graphics']['type']) + self.assertEquals('fe00::0', update_tmpl['graphics']['listen']) + + # update only type (listen does not reset to default '127.0.0.1') + req = json.dumps({'graphics': {'type': 'vnc'}}) resp = self.request(new_tmpl_uri, req, 'PUT') self.assertEquals(200, resp.status) update_tmpl = json.loads(resp.read()) -- 1.9.1
participants (2)
-
Aline Manera
-
Lucio Correia