code: def image_mapped(name):
      
      try:
          out = check_output(['rbd', 'showmapped'])
          if six.PY3:
              out = out.decode('UTF-8')
      except CalledProcessError:
          return False
  
      return name in out
docs: Determine whether a RADOS block device is mapped locally.