Download Template
(self, apiclient, retries=300, interval=5)
| 1706 | apiclient.deleteTemplate(cmd) |
| 1707 | |
| 1708 | def download(self, apiclient, retries=300, interval=5): |
| 1709 | """Download Template""" |
| 1710 | while retries > -1: |
| 1711 | time.sleep(interval) |
| 1712 | template_response = Template.list( |
| 1713 | apiclient, |
| 1714 | id=self.id, |
| 1715 | zoneid=self.zoneid, |
| 1716 | templatefilter='self' |
| 1717 | ) |
| 1718 | |
| 1719 | if isinstance(template_response, list): |
| 1720 | template = template_response[0] |
| 1721 | if not hasattr(template, 'status') or not template or not template.status: |
| 1722 | retries = retries - 1 |
| 1723 | continue |
| 1724 | |
| 1725 | # If template is ready, |
| 1726 | # template.status = Download Complete |
| 1727 | # Downloading - x% Downloaded |
| 1728 | # Processing - Initial status |
| 1729 | # Error - Any other string |
| 1730 | if template.status == 'Download Complete' and template.isready: |
| 1731 | return |
| 1732 | |
| 1733 | elif 'Downloaded' in template.status or template.status == 'Processing': |
| 1734 | retries = retries - 1 |
| 1735 | continue |
| 1736 | |
| 1737 | elif 'Installing' not in template.status: |
| 1738 | if retries >= 0: |
| 1739 | retries = retries - 1 |
| 1740 | continue |
| 1741 | raise Exception( |
| 1742 | "Error in downloading template: status - %s" % |
| 1743 | template.status) |
| 1744 | |
| 1745 | else: |
| 1746 | retries = retries - 1 |
| 1747 | raise Exception("Template download failed exception") |
| 1748 | |
| 1749 | def updatePermissions(self, apiclient, **kwargs): |
| 1750 | """Updates the template permissions""" |
no test coverage detected