Пример #1
0
def host_disk_space(conn):
    pool = util.get_default_pool(conn)
    path = util.get_default_dir(conn)

    avail = 0
    if pool and pool.is_active():
        # FIXME: make sure not inactive?
        # FIXME: use a conn specific function after we send pool-added
        pool.refresh()
        avail = int(util.xpath(pool.get_xml(), "/pool/available"))

    elif not conn.is_remote() and os.path.exists(path):
        vfs = os.statvfs(os.path.dirname(path))
        avail = vfs[statvfs.F_FRSIZE] * vfs[statvfs.F_BAVAIL]

    return float(avail / 1024.0 / 1024.0 / 1024.0)
Пример #2
0
def check_default_pool_active(topwin, conn):
    default_pool = util.get_default_pool(conn)
    if default_pool and not default_pool.is_active():
        res = err_dial.yes_no(_("Default pool is not active."),
                              _("Storage pool '%s' is not active. "
                                "Would you like to start the pool "
                                "now?") % default_pool.get_name())
        if not res:
            return False

        # Try to start the pool
        try:
            default_pool.start()
            logging.info("Started pool '%s'", default_pool.get_name())
        except Exception, e:
            return topwin.err.show_err(_("Could not start storage_pool "
                                         "'%s': %s") %
                                         (default_pool.get_name(), str(e)))