After setup wait till builtin templates are downloaded
(apiclient, zoneid, hypervisor, host,
linklocalip, interval=60)
| 651 | |
| 652 | |
| 653 | def download_builtin_templates(apiclient, zoneid, hypervisor, host, |
| 654 | linklocalip, interval=60): |
| 655 | """After setup wait till builtin templates are downloaded""" |
| 656 | |
| 657 | # Change IPTABLES Rules |
| 658 | get_process_status( |
| 659 | host["ipaddress"], |
| 660 | host["port"], |
| 661 | host["username"], |
| 662 | host["password"], |
| 663 | linklocalip, |
| 664 | "iptables -P INPUT ACCEPT" |
| 665 | ) |
| 666 | time.sleep(interval) |
| 667 | # Find the BUILTIN Templates for given Zone, Hypervisor |
| 668 | list_template_response = list_templates( |
| 669 | apiclient, |
| 670 | hypervisor=hypervisor, |
| 671 | zoneid=zoneid, |
| 672 | templatefilter='self' |
| 673 | ) |
| 674 | |
| 675 | if not isinstance(list_template_response, list): |
| 676 | raise Exception("Failed to download BUILTIN templates") |
| 677 | |
| 678 | # Ensure all BUILTIN templates are downloaded |
| 679 | templateid = None |
| 680 | for template in list_template_response: |
| 681 | if template.templatetype == "BUILTIN": |
| 682 | templateid = template.id |
| 683 | |
| 684 | # Sleep to ensure that template is in downloading state after adding |
| 685 | # Sec storage |
| 686 | time.sleep(interval) |
| 687 | while True: |
| 688 | template_response = list_templates( |
| 689 | apiclient, |
| 690 | id=templateid, |
| 691 | zoneid=zoneid, |
| 692 | templatefilter='self' |
| 693 | ) |
| 694 | template = template_response[0] |
| 695 | # If template is ready, |
| 696 | # template.status = Download Complete |
| 697 | # Downloading - x% Downloaded |
| 698 | # Error - Any other string |
| 699 | if template.status == 'Download Complete': |
| 700 | break |
| 701 | |
| 702 | elif 'Downloaded' in template.status: |
| 703 | time.sleep(interval) |
| 704 | |
| 705 | elif 'Installing' not in template.status: |
| 706 | raise Exception("ErrorInDownload") |
| 707 | |
| 708 | return |
| 709 | |
| 710 |
nothing calls this directly
no test coverage detected