From c3e97623004e81be8485727cec826c459d8d09fc Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Fri, 8 Feb 2019 16:54:24 +0100 Subject: [PATCH 1/2] Allow imgadm to recognize docker base images Up until now imgadm assume that docker images were always called account/image:tag, but this is not always the case, e.g. fedora:latest is a valid docker image too. --- salt/modules/smartos_imgadm.py | 3 +-- salt/states/smartos.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/salt/modules/smartos_imgadm.py b/salt/modules/smartos_imgadm.py index 7730678a5515..7d0b1c4ddfd9 100644 --- a/salt/modules/smartos_imgadm.py +++ b/salt/modules/smartos_imgadm.py @@ -110,8 +110,7 @@ def _split_docker_uuid(uuid): if len(uuid) == 2: tag = uuid[1] repo = uuid[0] - if len(repo.split('/')) == 2: - return repo, tag + return repo, tag return None, None diff --git a/salt/states/smartos.py b/salt/states/smartos.py index f28317e55677..15a32989b31e 100644 --- a/salt/states/smartos.py +++ b/salt/states/smartos.py @@ -157,8 +157,7 @@ def _split_docker_uuid(uuid): if len(uuid) == 2: tag = uuid[1] repo = uuid[0] - if len(repo.split('/')) == 2: - return repo, tag + return repo, tag return None, None From 6b7f76f15703fcaaecf903154dfb07bb719011c8 Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Fri, 8 Feb 2019 17:44:00 +0100 Subject: [PATCH 2/2] Also auto_import missing images for disks in smartos state --- salt/states/smartos.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/salt/states/smartos.py b/salt/states/smartos.py index 15a32989b31e..8b5447682b38 100644 --- a/salt/states/smartos.py +++ b/salt/states/smartos.py @@ -809,6 +809,19 @@ def vm_present(name, vmconfig, config=None): ret['result'] = False ret['comment'] = 'image {0} not installed'.format(vmconfig['image_uuid']) + # prepare disk.*.image_uuid + for disk in vmconfig['disks'] if 'disks' in vmconfig else []: + if 'image_uuid' in disk and disk['image_uuid'] not in __salt__['imgadm.list'](): + if config['auto_import']: + if not __opts__['test']: + res = __salt__['imgadm.import'](disk['image_uuid']) + if disk['image_uuid'] not in res: + ret['result'] = False + ret['comment'] = 'failed to import image {0}'.format(disk['image_uuid']) + else: + ret['result'] = False + ret['comment'] = 'image {0} not installed'.format(disk['image_uuid']) + # docker json-array handling if 'internal_metadata' in vmconfig: for var in vmconfig_docker_array: