class Libvirt::NodeDevice

Attributes

connection[R]

Public Instance Methods

destroy → nil click to toggle source

Call virNodeDeviceDestroy to shutdown the node device.

static VALUE libvirt_nodedevice_destroy(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNodeDeviceDestroy,
                                   ruby_libvirt_connect_get(n),
                                   nodedevice_get(n));
}
detach(driver=nil, flags=0) → nil click to toggle source

Call virNodeDeviceDettach to detach the node device from the node.

static VALUE libvirt_nodedevice_detach(int argc, VALUE *argv, VALUE n)
{
    VALUE driver = RUBY_Qnil, flags = RUBY_Qnil;

    rb_scan_args(argc, argv, "02", &driver, &flags);

    if (ruby_libvirt_value_to_uint(flags) != 0 ||
        ruby_libvirt_get_cstring_or_null(driver) != NULL) {
        ruby_libvirt_generate_call_nil(virNodeDeviceDetachFlags,
                                       ruby_libvirt_connect_get(n),
                                       nodedevice_get(n),
                                       ruby_libvirt_get_cstring_or_null(driver),
                                       ruby_libvirt_value_to_uint(flags));
    } else {
        ruby_libvirt_generate_call_nil(virNodeDeviceDettach,
                                       ruby_libvirt_connect_get(n),
                                       nodedevice_get(n));
    }
}
free → nil click to toggle source

Call virNodeDeviceFree to free the node device object. After this call the node device object is no longer valid.

static VALUE libvirt_nodedevice_free(VALUE n)
{
    ruby_libvirt_generate_call_free(NodeDevice, n);
}
list_caps → list click to toggle source

Call virNodeDeviceListCaps to retrieve a list of capabilities of the node device.

static VALUE libvirt_nodedevice_list_caps(VALUE c)
{
    int r, num;
    char **names;

    num = virNodeDeviceNumOfCaps(nodedevice_get(c));
    ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
                                "virNodeDeviceNumOfCaps",
                                ruby_libvirt_connect_get(c));
    if (num == 0) {
        /* if num is 0, don't call virNodeDeviceListCaps function */
        return rb_ary_new2(num);
    }

    names = alloca(sizeof(char *) * num);
    r = virNodeDeviceListCaps(nodedevice_get(c), names, num);
    ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
                                "virNodeDeviceListCaps",
                                ruby_libvirt_connect_get(c));

    return ruby_libvirt_generate_list(r, names);
}
lookup_scsi_host_by_wwn(wwnn, wwpn, flags=0) → Libvirt::NodeDevice click to toggle source

Call virNodeDeviceLookupSCSIHostByWWN to look up a SCSI host by its WWNN and WWPN.

static VALUE libvirt_nodedevice_lookup_scsi_host_by_wwn(int argc, VALUE *argv,
                                                        VALUE n)
{
    VALUE wwnn, wwpn, flags = RUBY_Qnil;
    virNodeDevicePtr nd;

    rb_scan_args(argc, argv, "21", &wwnn, &wwpn, &flags);

    nd = virNodeDeviceLookupSCSIHostByWWN(ruby_libvirt_connect_get(n),
                                          StringValueCStr(wwnn),
                                          StringValueCStr(wwpn),
                                          ruby_libvirt_value_to_uint(flags));
    if (nd == NULL) {
        return Qnil;
    }

    return ruby_libvirt_nodedevice_new(nd, ruby_libvirt_conn_attr(n));
}
name → String click to toggle source

Call virNodeDeviceGetName to retrieve the name of the node device.

static VALUE libvirt_nodedevice_name(VALUE c)
{
    ruby_libvirt_generate_call_string(virNodeDeviceGetName,
                                      ruby_libvirt_connect_get(c), 0,
                                      nodedevice_get(c));
}
num_of_caps → Fixnum click to toggle source

Call virNodeDeviceNumOfCaps to retrieve the number of capabilities of the node device.

static VALUE libvirt_nodedevice_num_of_caps(VALUE c)
{
    ruby_libvirt_generate_call_int(virNodeDeviceNumOfCaps,
                                   ruby_libvirt_connect_get(c),
                                   nodedevice_get(c));
}
parent → String click to toggle source

Call virNodeDeviceGetParent to retrieve the parent of the node device.

static VALUE libvirt_nodedevice_parent(VALUE c)
{
    /* unfortunately we can't use ruby_libvirt_generate_call_string() here
     * because virNodeDeviceGetParent() returns NULL as a valid value (when this
     * device has no parent).  Hand-code it instead
     */

    const char *str;

    str = virNodeDeviceGetParent(nodedevice_get(c));
    if (str == NULL) {
        return Qnil;
    }
    else {
        return rb_str_new2(str);
    }
}
reattach → nil click to toggle source

Call virNodeDeviceReAttach to reattach the node device to the node.

static VALUE libvirt_nodedevice_reattach(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNodeDeviceReAttach,
                                   ruby_libvirt_connect_get(n),
                                   nodedevice_get(n));
}
reset → nil click to toggle source

Call virNodeDeviceReset to reset the node device.

static VALUE libvirt_nodedevice_reset(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNodeDeviceReset,
                                   ruby_libvirt_connect_get(n),
                                   nodedevice_get(n));
}
xml_desc(flags=0) → String click to toggle source

Call virNodeDeviceGetXMLDesc to retrieve the XML for the node device.

static VALUE libvirt_nodedevice_xml_desc(int argc, VALUE *argv, VALUE n)
{
    VALUE flags = RUBY_Qnil;

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

    ruby_libvirt_generate_call_string(virNodeDeviceGetXMLDesc,
                                      ruby_libvirt_connect_get(n),
                                      1, nodedevice_get(n),
                                      ruby_libvirt_value_to_uint(flags));
}