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..8b5447682b38 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 @@ -810,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: