class Libvirt::StoragePool

Constants

BUILDING
BUILD_NEW

virStoragePoolBuildFlags

BUILD_NO_OVERWRITE
BUILD_OVERWRITE
BUILD_REPAIR
BUILD_RESIZE
CREATE_NORMAL
CREATE_PREALLOC_METADATA
CREATE_WITH_BUILD
CREATE_WITH_BUILD_NO_OVERWRITE
CREATE_WITH_BUILD_OVERWRITE
DEGRADED
DELETE_NORMAL

virStorageVolDeleteFlags

DELETE_ZEROED
INACCESSIBLE
INACTIVE

virStoragePoolState

RUNNING
XML_INACTIVE

Attributes

connection[R]

Public Instance Methods

active? → [true|false] click to toggle source

Call virStoragePoolIsActive to determine if this storage pool is active.

static VALUE libvirt_storage_pool_active_p(VALUE p)
{
    ruby_libvirt_generate_call_truefalse(virStoragePoolIsActive,
                                         ruby_libvirt_connect_get(p),
                                         pool_get(p));
}

Call virStoragePoolGetAutostart to determine whether this storage pool will autostart when libvirtd starts.

static VALUE libvirt_storage_pool_autostart(VALUE p)
{
    int r, autostart;

    r = virStoragePoolGetAutostart(pool_get(p), &autostart);
    ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
                                "virStoragePoolGetAutostart",
                                ruby_libvirt_connect_get(p));

    return autostart ? Qtrue : Qfalse;
}
Also aliased as: autostart?
autostart = [true|false] click to toggle source

Call virStoragePoolSetAutostart to make this storage pool start when libvirtd starts.

static VALUE libvirt_storage_pool_autostart_equal(VALUE p, VALUE autostart)
{
    if (autostart != Qtrue && autostart != Qfalse) {
                rb_raise(rb_eTypeError,
                 "wrong argument type (expected TrueClass or FalseClass)");
    }

    ruby_libvirt_generate_call_nil(virStoragePoolSetAutostart,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p), RTEST(autostart) ? 1 : 0);
}

Call virStoragePoolGetAutostart to determine whether this storage pool will autostart when libvirtd starts.

Alias for: autostart
build(flags=0) → nil click to toggle source

Call virStoragePoolBuild to build this storage pool.

static VALUE libvirt_storage_pool_build(int argc, VALUE *argv, VALUE p)
{
    VALUE flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "01", &flags);

    ruby_libvirt_generate_call_nil(virStoragePoolBuild,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p),
                                   ruby_libvirt_value_to_uint(flags));
}
create(flags=0) → nil click to toggle source

Call virStoragePoolCreate to start this storage pool.

static VALUE libvirt_storage_pool_create(int argc, VALUE *argv, VALUE p)
{
    VALUE flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "01", &flags);

    ruby_libvirt_generate_call_nil(virStoragePoolCreate,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p),
                                   ruby_libvirt_value_to_uint(flags));
}

Call virStorageVolCreateXML to create a new storage volume from xml.

Alias for: create_volume_xml

Call virStorageVolCreateXMLFrom to clone a volume from an existing volume with the properties specified in xml.

create_volume_xml(xml, flags=0) → Libvirt::StorageVol click to toggle source

Call virStorageVolCreateXML to create a new storage volume from xml.

static VALUE libvirt_storage_pool_create_volume_xml(int argc, VALUE *argv,
                                                    VALUE p)
{
    virStorageVolPtr vol;
    VALUE xml, flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "11", &xml, &flags);

    vol = virStorageVolCreateXML(pool_get(p), StringValueCStr(xml),
                                 ruby_libvirt_value_to_uint(flags));
    ruby_libvirt_raise_error_if(vol == NULL, e_Error, "virStorageVolCreateXML",
                                ruby_libvirt_connect_get(p));

    return vol_new(vol, ruby_libvirt_conn_attr(p));
}
Also aliased as: create_vol_xml
create_volume_xml_from(xml, clonevol, flags=0) → Libvirt::StorageVol click to toggle source

Call virStorageVolCreateXMLFrom to clone a volume from an existing volume with the properties specified in xml.

static VALUE libvirt_storage_pool_create_volume_xml_from(int argc, VALUE *argv,
                                                         VALUE p)
{
    virStorageVolPtr vol;
    VALUE xml, flags = RUBY_Qnil, cloneval = RUBY_Qnil;

    rb_scan_args(argc, argv, "21", &xml, &cloneval, &flags);

    vol = virStorageVolCreateXMLFrom(pool_get(p), StringValueCStr(xml),
                                     vol_get(cloneval),
                                     ruby_libvirt_value_to_uint(flags));
    ruby_libvirt_raise_error_if(vol == NULL, e_Error,
                                "virStorageVolCreateXMLFrom",
                                ruby_libvirt_connect_get(p));

    return vol_new(vol, ruby_libvirt_conn_attr(p));
}
Also aliased as: create_vol_xml_from
delete(flags=0) → nil click to toggle source

Call virStoragePoolDelete to delete the data corresponding to this data pool. This is a destructive operation.

static VALUE libvirt_storage_pool_delete(int argc, VALUE *argv, VALUE p)
{
    VALUE flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "01", &flags);

    ruby_libvirt_generate_call_nil(virStoragePoolDelete,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p),
                                   ruby_libvirt_value_to_uint(flags));
}
destroy → nil click to toggle source

Call virStoragePoolDestroy to shutdown this storage pool.

static VALUE libvirt_storage_pool_destroy(VALUE p)
{
    ruby_libvirt_generate_call_nil(virStoragePoolDestroy,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p));
}
free → nil click to toggle source

Call virStoragePoolFree to free this storage pool object. After this call the storage pool object is no longer valid.

static VALUE libvirt_storage_pool_free(VALUE p)
{
    ruby_libvirt_generate_call_free(StoragePool, p);
}
info → Libvirt::StoragePoolInfo click to toggle source

Call virStoragePoolGetInfo to retrieve information about this storage pool.

static VALUE libvirt_storage_pool_info(VALUE p)
{
    virStoragePoolInfo info;
    int r;
    VALUE result;

    r = virStoragePoolGetInfo(pool_get(p), &info);
    ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
                                "virStoragePoolGetInfo",
                                ruby_libvirt_connect_get(p));

    result = rb_class_new_instance(0, NULL, c_storage_pool_info);
    rb_iv_set(result, "@state", INT2NUM(info.state));
    rb_iv_set(result, "@capacity", ULL2NUM(info.capacity));
    rb_iv_set(result, "@allocation", ULL2NUM(info.allocation));
    rb_iv_set(result, "@available", ULL2NUM(info.available));

    return result;
}
list_all_volumes(flags=0) → Array click to toggle source

Call virStoragePoolListAllVolumes to get an array of volume objects for all volumes.

static VALUE libvirt_storage_pool_list_all_volumes(int argc, VALUE *argv,
                                                   VALUE p)
{
    ruby_libvirt_generate_call_list_all(virStorageVolPtr, argc, argv,
                                        virStoragePoolListAllVolumes,
                                        pool_get(p), ruby_libvirt_conn_attr(p),
                                        vol_new, virStorageVolFree);
}
list_volumes → list click to toggle source

Call virStoragePoolListVolumes to retrieve a list of volume names in this storage pools.

static VALUE libvirt_storage_pool_list_volumes(VALUE p)
{
    int r, num;
    char **names;

    num = virStoragePoolNumOfVolumes(pool_get(p));
    ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
                                "virStoragePoolNumOfVolumes",
                                ruby_libvirt_connect_get(p));
    if (num == 0) {
        return rb_ary_new2(num);
    }

    names = alloca(sizeof(char *) * num);
    r = virStoragePoolListVolumes(pool_get(p), names, num);
    ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
                                "virStoragePoolListVolumes",
                                ruby_libvirt_connect_get(p));

    return ruby_libvirt_generate_list(r, names);
}
lookup_volume_by_key(key) → Libvirt::StorageVol click to toggle source

Call virStorageVolLookupByKey to retrieve a storage volume object by key.

static VALUE libvirt_storage_pool_lookup_vol_by_key(VALUE p, VALUE key)
{
    virStorageVolPtr vol;

    /* FIXME: Why does this take a connection, not a pool? */
    vol = virStorageVolLookupByKey(ruby_libvirt_connect_get(p),
                                   StringValueCStr(key));
    ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
                                "virStorageVolLookupByKey",
                                ruby_libvirt_connect_get(p));

    return vol_new(vol, ruby_libvirt_conn_attr(p));
}
lookup_volume_by_name(name) → Libvirt::StorageVol click to toggle source

Call virStorageVolLookupByName to retrieve a storage volume object by name.

static VALUE libvirt_storage_pool_lookup_vol_by_name(VALUE p, VALUE name)
{
    virStorageVolPtr vol;

    vol = virStorageVolLookupByName(pool_get(p), StringValueCStr(name));
    ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
                                "virStorageVolLookupByName",
                                ruby_libvirt_connect_get(p));

    return vol_new(vol, ruby_libvirt_conn_attr(p));
}
lookup_volume_by_path(path) → Libvirt::StorageVol click to toggle source

Call virStorageVolLookupByPath to retrieve a storage volume object by path.

static VALUE libvirt_storage_pool_lookup_vol_by_path(VALUE p, VALUE path)
{
    virStorageVolPtr vol;

    /* FIXME: Why does this take a connection, not a pool? */
    vol = virStorageVolLookupByPath(ruby_libvirt_connect_get(p),
                                    StringValueCStr(path));
    ruby_libvirt_raise_error_if(vol == NULL, e_RetrieveError,
                                "virStorageVolLookupByPath",
                                ruby_libvirt_connect_get(p));

    return vol_new(vol, ruby_libvirt_conn_attr(p));
}
name → String click to toggle source

Call virStoragePoolGetName to retrieve the name of this storage pool.

static VALUE libvirt_storage_pool_name(VALUE p)
{
    ruby_libvirt_generate_call_string(virStoragePoolGetName,
                                      ruby_libvirt_connect_get(p), 0,
                                      pool_get(p));
}
num_of_volumes → Fixnum click to toggle source

Call virStoragePoolNumOfVolumes to retrieve the number of volumes in this storage pool.

static VALUE libvirt_storage_pool_num_of_volumes(VALUE p)
{
    int n;

    n = virStoragePoolNumOfVolumes(pool_get(p));
    ruby_libvirt_raise_error_if(n < 0, e_RetrieveError,
                                "virStoragePoolNumOfVolumes",
                                ruby_libvirt_connect_get(p));

    return INT2NUM(n);
}
persistent? → [true|false] click to toggle source

Call virStoragePoolIsPersistent to determine if this storage pool is persistent.

static VALUE libvirt_storage_pool_persistent_p(VALUE p)
{
    ruby_libvirt_generate_call_truefalse(virStoragePoolIsPersistent,
                                         ruby_libvirt_connect_get(p),
                                         pool_get(p));
}
refresh(flags=0) → nil click to toggle source

Call virStoragePoolRefresh to refresh the list of volumes in this storage pool.

static VALUE libvirt_storage_pool_refresh(int argc, VALUE *argv, VALUE p)
{
    VALUE flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "01", &flags);

    ruby_libvirt_generate_call_nil(virStoragePoolRefresh,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p),
                                   ruby_libvirt_value_to_uint(flags));
}
undefine → nil click to toggle source

Call virStoragePoolUndefine to undefine this storage pool.

static VALUE libvirt_storage_pool_undefine(VALUE p)
{
    ruby_libvirt_generate_call_nil(virStoragePoolUndefine,
                                   ruby_libvirt_connect_get(p),
                                   pool_get(p));
}
uuid → String click to toggle source

Call virStoragePoolGetUUIDString to retrieve the UUID of this storage pool.

static VALUE libvirt_storage_pool_uuid(VALUE p)
{
    ruby_libvirt_generate_uuid(virStoragePoolGetUUIDString,
                               ruby_libvirt_connect_get(p), pool_get(p));
}
xml_desc(flags=0) → String click to toggle source

Call virStoragePoolGetXMLDesc to retrieve the XML for this storage pool.

static VALUE libvirt_storage_pool_xml_desc(int argc, VALUE *argv, VALUE p)
{
    VALUE flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "01", &flags);

    ruby_libvirt_generate_call_string(virStoragePoolGetXMLDesc,
                                      ruby_libvirt_connect_get(p),
                                      1, pool_get(p),
                                      ruby_libvirt_value_to_uint(flags));
}