Skip to content

Commit a0d9ace

Browse files
authored
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
1 parent 06744c1 commit a0d9ace

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

tools/marvin/marvin/lib/base.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,16 +1476,12 @@ def extract(cls, apiclient, id, mode, zoneid=None):
14761476

14771477
@classmethod
14781478
def create_from_volume(cls, apiclient, volume, services,
1479-
random_name=True):
1479+
random_name=True, projectid=None):
14801480
"""Create Template from volume"""
14811481
# Create template from Volume ID
14821482
cmd = createTemplate.createTemplateCmd()
14831483

1484-
Template._set_command(apiclient, cmd, services, random_name)
1485-
1486-
cmd.volumeid = volume.id
1487-
1488-
return Template(apiclient.createTemplate(cmd).__dict__)
1484+
return Template._set_command(apiclient, cmd, services, random_name, projectid = projectid, volume = volume)
14891485

14901486
@classmethod
14911487
def create_from_snapshot(cls, apiclient, snapshot, services, account=None,
@@ -1494,14 +1490,10 @@ def create_from_snapshot(cls, apiclient, snapshot, services, account=None,
14941490
# Create template from Snapshot ID
14951491
cmd = createTemplate.createTemplateCmd()
14961492

1497-
Template._set_command(apiclient, cmd, services, random_name)
1498-
1499-
cmd.snapshotid = snapshot.id
1500-
1501-
return Template(apiclient.createTemplate(cmd).__dict__)
1493+
return Template._set_command(apiclient, cmd, services, random_name, snapshot = snapshot, projectid = projectid)
15021494

15031495
@classmethod
1504-
def _set_command(cls, apiclient, cmd, services, random_name=True):
1496+
def _set_command(cls, apiclient, cmd, services, random_name=True, snapshot=None, volume=None, projectid=None):
15051497
cmd.displaytext = services["displaytext"]
15061498
cmd.name = "-".join([
15071499
services["name"],
@@ -1528,12 +1520,12 @@ def _set_command(cls, apiclient, cmd, services, random_name=True):
15281520
raise Exception(
15291521
"Unable to find Ostype is required for creating template")
15301522

1531-
cmd.snapshotid = snapshot.id
1523+
if volume:
1524+
cmd.volumeid = volume.id
1525+
1526+
if snapshot:
1527+
cmd.snapshotid = snapshot.id
15321528

1533-
if account:
1534-
cmd.account = account
1535-
if domainid:
1536-
cmd.domainid = domainid
15371529
if projectid:
15381530
cmd.projectid = projectid
15391531

0 commit comments

Comments
 (0)