This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new a0d9ace fix: create template with Marvin (#4631)
a0d9ace is described below
commit a0d9acec6f3926ef31430a2be0c2737b30eb5ebb
Author: slavkap <[email protected]>
AuthorDate: Tue May 25 17:56:43 2021 +0300
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 e0b3772..5a8db63 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