Create template from URL
(cls, apiclient, services, zoneid=None,
account=None, domainid=None, hypervisor=None,
projectid=None, details=None, randomize_name=True, templatetag=None)
| 1546 | |
| 1547 | @classmethod |
| 1548 | def register(cls, apiclient, services, zoneid=None, |
| 1549 | account=None, domainid=None, hypervisor=None, |
| 1550 | projectid=None, details=None, randomize_name=True, templatetag=None): |
| 1551 | """Create template from URL""" |
| 1552 | |
| 1553 | # Create template from Virtual machine and Volume ID |
| 1554 | cmd = registerTemplate.registerTemplateCmd() |
| 1555 | cmd.displaytext = services["displaytext"] |
| 1556 | if randomize_name: |
| 1557 | cmd.name = "-".join([services["name"], random_gen()]) |
| 1558 | else: |
| 1559 | cmd.name = services["name"] |
| 1560 | cmd.format = services["format"] |
| 1561 | if hypervisor: |
| 1562 | cmd.hypervisor = hypervisor |
| 1563 | elif "hypervisor" in services: |
| 1564 | cmd.hypervisor = services["hypervisor"] |
| 1565 | |
| 1566 | if "ostypeid" in services: |
| 1567 | cmd.ostypeid = services["ostypeid"] |
| 1568 | elif "ostype" in services: |
| 1569 | # Find OSTypeId from Os type |
| 1570 | sub_cmd = listOsTypes.listOsTypesCmd() |
| 1571 | sub_cmd.description = services["ostype"] |
| 1572 | ostypes = apiclient.listOsTypes(sub_cmd) |
| 1573 | |
| 1574 | if not isinstance(ostypes, list): |
| 1575 | raise Exception( |
| 1576 | "Unable to find Ostype id with desc: %s" % |
| 1577 | services["ostype"]) |
| 1578 | cmd.ostypeid = ostypes[0].id |
| 1579 | else: |
| 1580 | raise Exception( |
| 1581 | "Unable to find Ostype is required for registering template") |
| 1582 | |
| 1583 | cmd.url = services["url"] |
| 1584 | |
| 1585 | if zoneid: |
| 1586 | cmd.zoneid = zoneid |
| 1587 | else: |
| 1588 | cmd.zoneid = services["zoneid"] |
| 1589 | |
| 1590 | cmd.isfeatured = services[ |
| 1591 | "isfeatured"] if "isfeatured" in services else False |
| 1592 | cmd.ispublic = services[ |
| 1593 | "ispublic"] if "ispublic" in services else False |
| 1594 | cmd.isextractable = services[ |
| 1595 | "isextractable"] if "isextractable" in services else False |
| 1596 | cmd.isdynamicallyscalable = services["isdynamicallyscalable"] if "isdynamicallyscalable" in services else False |
| 1597 | cmd.passwordenabled = services[ |
| 1598 | "passwordenabled"] if "passwordenabled" in services else False |
| 1599 | cmd.deployasis = services["deployasis"] if "deployasis" in services else False |
| 1600 | |
| 1601 | if account: |
| 1602 | cmd.account = account |
| 1603 | |
| 1604 | if domainid: |
| 1605 | cmd.domainid = domainid |
nothing calls this directly
no test coverage detected