MCPcopy Create free account
hub / github.com/apache/cloudstack / _set_command

Method _set_command

tools/marvin/marvin/lib/base.py:1661–1697  ·  view source on GitHub ↗
(cls, apiclient, cmd, services, random_name=True, snapshot=None, volume=None, projectid=None)

Source from the content-addressed store, hash-verified

1659
1660 @classmethod
1661 def _set_command(cls, apiclient, cmd, services, random_name=True, snapshot=None, volume=None, projectid=None):
1662 cmd.displaytext = services["displaytext"]
1663 cmd.name = "-".join([
1664 services["name"],
1665 random_gen()
1666 ]) if random_name else services["name"]
1667
1668 if "ispublic" in services:
1669 cmd.ispublic = services["ispublic"]
1670
1671 if "ostypeid" in services:
1672 cmd.ostypeid = services["ostypeid"]
1673 elif "ostype" in services:
1674 # Find OSTypeId from Os type
1675 sub_cmd = listOsTypes.listOsTypesCmd()
1676 sub_cmd.description = services["ostype"]
1677 ostypes = apiclient.listOsTypes(sub_cmd)
1678
1679 if not isinstance(ostypes, list):
1680 raise Exception(
1681 "Unable to find Ostype id with desc: %s" %
1682 services["ostype"])
1683 cmd.ostypeid = ostypes[0].id
1684 else:
1685 raise Exception(
1686 "Unable to find Ostype is required for creating template")
1687
1688 if volume:
1689 cmd.volumeid = volume.id
1690
1691 if snapshot:
1692 cmd.snapshotid = snapshot.id
1693
1694 if projectid:
1695 cmd.projectid = projectid
1696
1697 return Template(apiclient.createTemplate(cmd).__dict__)
1698
1699 def delete(self, apiclient, zoneid=None):
1700 """Delete Template"""

Callers 2

create_from_volumeMethod · 0.80
create_from_snapshotMethod · 0.80

Calls 4

random_genFunction · 0.90
TemplateClass · 0.70
joinMethod · 0.45
createTemplateMethod · 0.45

Tested by

no test coverage detected