From a0d9acec6f3926ef31430a2be0c2737b30eb5ebb Mon Sep 17 00:00:00 2001 From: slavkap <51903378+slavkap@users.noreply.github.com> Date: Tue, 25 May 2021 17:56:43 +0300 Subject: [PATCH] fix: create template with Marvin (#4631) * undefined params * if we define those params, when invoking the functions create_from_volume/create_from_snapshot will be created two templates * according to the API docs createTemplate command does not accept account and domainid --- tools/marvin/marvin/lib/base.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index e0b3772b5f3..5a8db630a50 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -1476,16 +1476,12 @@ class Template: @classmethod def create_from_volume(cls, apiclient, volume, services, - random_name=True): + random_name=True, projectid=None): """Create Template from volume""" # Create template from Volume ID cmd = createTemplate.createTemplateCmd() - Template._set_command(apiclient, cmd, services, random_name) - - cmd.volumeid = volume.id - - return Template(apiclient.createTemplate(cmd).__dict__) + return Template._set_command(apiclient, cmd, services, random_name, projectid = projectid, volume = volume) @classmethod def create_from_snapshot(cls, apiclient, snapshot, services, account=None, @@ -1494,14 +1490,10 @@ class Template: # Create template from Snapshot ID cmd = createTemplate.createTemplateCmd() - Template._set_command(apiclient, cmd, services, random_name) - - cmd.snapshotid = snapshot.id - - return Template(apiclient.createTemplate(cmd).__dict__) + return Template._set_command(apiclient, cmd, services, random_name, snapshot = snapshot, projectid = projectid) @classmethod - def _set_command(cls, apiclient, cmd, services, random_name=True): + def _set_command(cls, apiclient, cmd, services, random_name=True, snapshot=None, volume=None, projectid=None): cmd.displaytext = services["displaytext"] cmd.name = "-".join([ services["name"], @@ -1528,12 +1520,12 @@ class Template: raise Exception( "Unable to find Ostype is required for creating template") - cmd.snapshotid = snapshot.id + if volume: + cmd.volumeid = volume.id + + if snapshot: + cmd.snapshotid = snapshot.id - if account: - cmd.account = account - if domainid: - cmd.domainid = domainid if projectid: cmd.projectid = projectid