diff --git a/config.yml b/config.yml index 5cb645101811a827c418781365224fb85f2e1a67..9b054f740d9b6d7cfc9637863a8f88709d28a430 100644 --- a/config.yml +++ b/config.yml @@ -1,25 +1,82 @@ images: debian8: - name: Debian 8 + name: Debian 8 - GARR url: https://cdimage.debian.org/cdimage/openstack/current-8/debian-8-openstack-amd64.qcow2 disk_format: qcow2 + tags: + - "os_distro=debian" + - "os_type=linux" + - "os_version=8" + - "architecture=amd64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" debian9: - name: Debian 9 + name: Debian 9 - GARR url: https://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2 disk_format: qcow2 + tags: + - "os_distro=debian" + - "os_type=linux" + - "os_version=9" + - "architecture=amd64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" + - "hw_vif_multiqueue_enabled=true" centos7: - name: CentOS 7 + name: CentOS 7 - GARR url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 disk_format: qcow2 + tags: + - "os_distro=centos" + - "os_type=linux" + - "os_version=7.X" + - "architecture=x86_64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" + - "hw_vif_multiqueue_enabled=true" centos6: - name: CentOS 6 + name: CentOS 6 - GARR url: http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud.qcow2 disk_format: qcow2 + tags: + - "os_distro=centos" + - "os_type=linux" + - "os_version=6.X" + - "architecture=x86_64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" ubuntu-14.04: - name: Ubuntu 14.04 + name: Ubuntu 14.04 - GARR url: https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img disk_format: qcow2 + tags: + - "os_distro=ubuntu" + - "os_type=linux" + - "os_version=14.04" + - "architecture=amd64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" ubuntu-16.04: - name: Ubuntu 16.04 + name: Ubuntu 16.04 - GARR url: https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img disk_format: qcow2 + tags: + - "os_distro=ubuntu" + - "os_type=linux" + - "os_version=16.04" + - "architecture=amd64" + - "os_require_quiesce=yes" + - "hw_qemu_guest_agent=yes" + - "hw_scsi_model=virtio-scsi" + - "hw_disk_bus=scsi" + - "hw_vif_multiqueue_enabled=true" diff --git a/update-images.py b/update-images.py old mode 100644 new mode 100755 index d550a2cc842b1ab1c869ac4bc172ec07033200c3..8907388baa6c93f1efac1bcbfbbc1980210819d5 --- a/update-images.py +++ b/update-images.py @@ -3,6 +3,7 @@ import yaml import requests import datetime +import time import os from pprint import pprint import shade @@ -37,6 +38,7 @@ if not os.path.isdir(download_dir): openstack_cloud_connection = shade.openstack_cloud() for image_key in sorted(config['images'].keys()): + print("=== Image name: {}".format(image_key)) url = config['images'][image_key]['url'] request_response = requests_session.head(url, allow_redirects=True) request_response.raise_for_status() @@ -79,13 +81,22 @@ for image_key in sorted(config['images'].keys()): print("From: {}".format(url)) print("To: {}".format(download_image_file)) download_from_url(url, download_image_file) + else: + print("Already available: {}".format(download_image_file)) new_image_name = image_name + " " + str(last_modified_time) + tagDict = {} + tagDict["last_modified"] = str(last_modified_time) + if config['images'][image_key]['tags']: + tagDict = dict(tag_desc.split('=',1) for tag_desc in sorted(config['images'][image_key]['tags'])) + print("Tag dictionary: {}".format(tagDict)) + + time0 = int(time.time()) openstack_cloud_connection.create_image(image_name, filename=download_image_file, disk_format=config['images'][image_key]['disk_format'], - meta={ - "last_modified":str(last_modified_time), - }, - wait=True,is_public=True) \ No newline at end of file + meta=tagDict, + wait=True,is_public=True) + time1 = int(time.time()) + print("Uploaded to Glance in {} seconds".format(time1-time0))