def attach(zpool, device, new_device, force=False):
 ret = {}
 dlist = []
 if (not exists(zpool)):
  ret[zpool] = 'storage pool does not exist'
  return ret
 ret[zpool] = {}
 if (not os.path.exists(device)):
  ret[zpool][device] = 'not present on filesystem'
 else:
  mode = os.stat(device).st_mode
  if ((not stat.S_ISBLK(mode)) and (not stat.S_ISREG(mode))):
   ret[zpool][device] = 'not a block device, a file vdev or character special device'
 if (not os.path.exists(new_device)):
  ret[zpool][new_device] = 'not present on filesystem'
 else:
  mode = os.stat(new_device).st_mode
  if ((not stat.S_ISBLK(mode)) and (not stat.S_ISREG(mode))):
   ret[zpool][new_device] = 'not a block device, a file vdev or character special device'
 if (len(ret[zpool]) > 0):
  return ret
 zpool_cmd = _check_zpool()
 cmd = '{zpool_cmd} attach {force}{zpool} {device} {new_device}'.format(zpool_cmd=zpool_cmd, force=('-f ' if force else ''), zpool=zpool, device=device, new_device=new_device)
 res = __salt__['cmd.run_all'](cmd, python_shell=False)
 if (res['retcode'] != 0):
  ret[zpool] = (res['stderr'] if ('stderr' in res) else res['stdout'])
 else:
  ret[zpool] = {}
  ret[zpool][new_device] = 'attached'
 return ret

def attach ( zpool , device , new_device , force = False ) : ret = { } dlist = [ ] if ( not exists ( zpool ) ) : ret [ zpool ] = 'storage pool does not exist' return ret ret [ zpool ] = { } if ( not os . path . exists ( device ) ) : ret [ zpool ] [ device ] = 'not present on filesystem' else : mode = os . stat ( device ) . st_mode if ( ( not stat . S_ISBLK ( mode ) ) and ( not stat . S_ISREG ( mode ) ) ) : ret [ zpool ] [ device ] = 'not a block device, a file vdev or character special device' if ( not os . path . exists ( new_device ) ) : ret [ zpool ] [ new_device ] = 'not present on filesystem' else : mode = os . stat ( new_device ) . st_mode if ( ( not stat . S_ISBLK ( mode ) ) and ( not stat . S_ISREG ( mode ) ) ) : ret [ zpool ] [ new_device ] = 'not a block device, a file vdev or character special device' if ( len ( ret [ zpool ] ) > 0 ) : return ret zpool_cmd = _check_zpool ( ) cmd = '{zpool_cmd} attach {force}{zpool} {device} {new_device}' . format ( zpool_cmd = zpool_cmd , force = ( '-f ' if force else '' ) , zpool = zpool , device = device , new_device = new_device ) res = __salt__ [ 'cmd.run_all' ] ( cmd , python_shell = False ) if ( res [ 'retcode' ] != 0 ) : ret [ zpool ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else res [ 'stdout' ] ) else : ret [ zpool ] = { } ret [ zpool ] [ new_device ] = 'attached' return ret
recursively attach hass to all template instances in list and dict .