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

Method create

tools/marvin/marvin/lib/base.py:1492–1545  ·  view source on GitHub ↗

Create template from Volume

(cls, apiclient, services, volumeid=None,
               account=None, domainid=None, projectid=None, randomise=True, snapshotid=None, zoneid=None)

Source from the content-addressed store, hash-verified

1490
1491 @classmethod
1492 def create(cls, apiclient, services, volumeid=None,
1493 account=None, domainid=None, projectid=None, randomise=True, snapshotid=None, zoneid=None):
1494 """Create template from Volume"""
1495 # Create template from Virtual machine and Volume ID
1496 cmd = createTemplate.createTemplateCmd()
1497 cmd.displaytext = services["displaytext"]
1498 if randomise:
1499 cmd.name = "-".join([services["name"], random_gen()])
1500 else:
1501 cmd.name = services["name"]
1502 if "ostypeid" in services:
1503 cmd.ostypeid = services["ostypeid"]
1504 elif "ostype" in services:
1505 # Find OSTypeId from Os type
1506 sub_cmd = listOsTypes.listOsTypesCmd()
1507 sub_cmd.description = services["ostype"]
1508 ostypes = apiclient.listOsTypes(sub_cmd)
1509
1510 if not isinstance(ostypes, list):
1511 raise Exception(
1512 "Unable to find Ostype id with desc: %s" %
1513 services["ostype"])
1514 cmd.ostypeid = ostypes[0].id
1515 else:
1516 raise Exception(
1517 "Unable to find Ostype is required for creating template")
1518
1519 cmd.isfeatured = services[
1520 "isfeatured"] if "isfeatured" in services else False
1521 cmd.ispublic = services[
1522 "ispublic"] if "ispublic" in services else False
1523 cmd.isextractable = services[
1524 "isextractable"] if "isextractable" in services else False
1525 cmd.passwordenabled = services[
1526 "passwordenabled"] if "passwordenabled" in services else False
1527
1528 if volumeid:
1529 cmd.volumeid = volumeid
1530
1531 if account:
1532 cmd.account = account
1533
1534 if domainid:
1535 cmd.domainid = domainid
1536
1537 if projectid:
1538 cmd.projectid = projectid
1539
1540 if snapshotid:
1541 cmd.snapshotid = snapshotid
1542
1543 if zoneid:
1544 cmd.zoneid = zoneid
1545 return Template(apiclient.createTemplate(cmd).__dict__)
1546
1547 @classmethod
1548 def register(cls, apiclient, services, zoneid=None,

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected