class Libvirt::Network

Constants

IP_ADDR_TYPE_IPV4
IP_ADDR_TYPE_IPV6
NETWORK_SECTION_BRIDGE
NETWORK_SECTION_DNS_HOST
NETWORK_SECTION_DNS_SRV
NETWORK_SECTION_DNS_TXT
NETWORK_SECTION_DOMAIN
NETWORK_SECTION_FORWARD
NETWORK_SECTION_FORWARD_INTERFACE
NETWORK_SECTION_FORWARD_PF
NETWORK_SECTION_IP
NETWORK_SECTION_IP_DHCP_HOST
NETWORK_SECTION_IP_DHCP_RANGE
NETWORK_SECTION_NONE
NETWORK_SECTION_PORTGROUP
NETWORK_UPDATE_AFFECT_CONFIG
NETWORK_UPDATE_AFFECT_CURRENT
NETWORK_UPDATE_AFFECT_LIVE
NETWORK_UPDATE_COMMAND_ADD_FIRST
NETWORK_UPDATE_COMMAND_ADD_LAST
NETWORK_UPDATE_COMMAND_MODIFY
NETWORK_UPDATE_COMMAND_NONE
SECTION_BRIDGE

Ideally we would just have the “SECTION_BRIDGE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_BRIDGE” for backwards compatibility.

SECTION_DNS_HOST

Ideally we would just have the “SECTION_DNS_HOST” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_DNS_HOST” for backwards compatibility.

SECTION_DNS_SRV

Ideally we would just have the “SECTION_DNS_SRV” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_DNS_SRV” for backwards compatibility.

SECTION_DNS_TXT

Ideally we would just have the “SECTION_DNS_TXT” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_DNS_TXT” for backwards compatibility.

SECTION_DOMAIN

Ideally we would just have the “SECTION_DOMAIN” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_DOMAIN” for backwards compatibility.

SECTION_FORWARD

Ideally we would just have the “SECTION_FORWARD” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_FORWARD” for backwards compatibility.

SECTION_FORWARD_INTERFACE

Ideally we would just have the “SECTION_FORWARD_INTERFACE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_FORWARD_INTERFACE” for backwards compatibility.

SECTION_FORWARD_PF

Ideally we would just have the “SECTION_FORWARD_PF” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_FORWARD_PF” for backwards compatibility.

SECTION_IP

Ideally we would just have the “SECTION_IP” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_IP” for backwards compatibility.

SECTION_IP_DHCP_HOST

Ideally we would just have the “SECTION_IP_DHCP_HOST” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_IP_DHCP_HOST” for backwards compatibility.

SECTION_IP_DHCP_RANGE

Ideally we would just have the “SECTION_IP_DHCP_RANGE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_IP_DHCP_RANGE” for backwards compatibility.

SECTION_NONE

Ideally we would just have the “SECTION_NONE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_NONE” for backwards compatibility.

SECTION_PORTGROUP

Ideally we would just have the “SECTION_PORTGROUP” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_SECTION_PORTGROUP” for backwards compatibility.

UPDATE_AFFECT_CONFIG

Ideally we would just have the “UPDATE_AFFECT_CONFIG” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_AFFECT_CONFIG” for backwards compatibility.

UPDATE_AFFECT_CURRENT

Ideally we would just have the “UPDATE_AFFECT_CURRENT” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_AFFECT_CURRENT” for backwards compatibility.

UPDATE_AFFECT_LIVE

Ideally we would just have the “UPDATE_AFFECT_LIVE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_AFFECT_LIVE” for backwards compatibility.

UPDATE_COMMAND_ADD_FIRST

Ideally we would just have the “UPDATE_COMMAND_ADD_FIRST” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_COMMAND_ADD_FIRST” for backwards compatibility.

UPDATE_COMMAND_ADD_LAST

Ideally we would just have the “UPDATE_COMMAND_ADD_LAST” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_COMMAND_ADD_LAST” for backwards compatibility.

UPDATE_COMMAND_DELETE
UPDATE_COMMAND_MODIFY

Ideally we would just have the “UPDATE_COMMAND_MODIFY” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_COMMAND_MODIFY” for backwards compatibility.

UPDATE_COMMAND_NONE

Ideally we would just have the “UPDATE_COMMAND_NONE” constant. Unfortunately we screwed up long ago, and we have to leave “NETWORK_UPDATE_COMMAND_NONE” for backwards compatibility.

XML_INACTIVE

Attributes

connection[R]

Public Instance Methods

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

Call virNetworkIsActive to determine if this network is currently active.

static VALUE libvirt_network_active_p(VALUE n)
{
    ruby_libvirt_generate_call_truefalse(virNetworkIsActive,
                                         ruby_libvirt_connect_get(n),
                                         network_get(n));
}

Call virNetworkGetAutostart to determine if this network will be autostarted when libvirtd starts.

static VALUE libvirt_network_autostart(VALUE n)
{
    int r, autostart;

    r = virNetworkGetAutostart(network_get(n), &autostart);
    ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNetworkAutostart",
                                ruby_libvirt_connect_get(n));

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

Call virNetworkSetAutostart to set this network to be autostarted when libvirtd starts.

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

    ruby_libvirt_generate_call_nil(virNetworkSetAutostart,
                                   ruby_libvirt_connect_get(n),
                                   network_get(n), RTEST(autostart) ? 1 : 0);
}

Call virNetworkGetAutostart to determine if this network will be autostarted when libvirtd starts.

Alias for: autostart
bridge_name → String click to toggle source

Call virNetworkGetBridgeName to retrieve the bridge name for this network.

static VALUE libvirt_network_bridge_name(VALUE n)
{
    ruby_libvirt_generate_call_string(virNetworkGetBridgeName,
                                      ruby_libvirt_connect_get(n),
                                      1, network_get(n));
}
create → nil click to toggle source

Call virNetworkCreate to start this network.

static VALUE libvirt_network_create(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNetworkCreate,
                                   ruby_libvirt_connect_get(n),
                                   network_get(n));
}
destroy → nil click to toggle source

Call virNetworkDestroy to shutdown this network.

static VALUE libvirt_network_destroy(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNetworkDestroy,
                                   ruby_libvirt_connect_get(n),
                                   network_get(n));
}
dhcp_leases(mac=nil, flags=0) → Hash click to toggle source

Call virNetworkGetDHCPLeases to retrieve the leases for this network.

static VALUE libvirt_network_get_dhcp_leases(int argc, VALUE *argv, VALUE n)
{
    VALUE mac = RUBY_Qnil, flags = RUBY_Qnil, result;
    int nleases, i = 0, exception = 0;
    virNetworkDHCPLeasePtr *leases = NULL;
    struct leases_arg args;

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

    nleases = virNetworkGetDHCPLeases(network_get(n),
                                      ruby_libvirt_get_cstring_or_null(mac),
                                      &leases,
                                      ruby_libvirt_value_to_uint(flags));
    ruby_libvirt_raise_error_if(nleases < 0, e_Error, "virNetworkGetDHCPLeases",
                                ruby_libvirt_connect_get(n));

    args.leases = leases;
    args.nleases = nleases;
    result = rb_protect(leases_wrap, (VALUE)&args, &exception);

    for (i = 0; i < nleases; i++) {
        virNetworkDHCPLeaseFree(leases[i]);
    }
    free(leases);

    if (exception) {
        rb_jump_tag(exception);
    }

    return result;
}
free → nil click to toggle source

Call virNetworkFree to free this network. The object will no longer be valid after this call.

static VALUE libvirt_network_free(VALUE n)
{
    ruby_libvirt_generate_call_free(Network, n);
}
name → String click to toggle source

Call virNetworkGetName to retrieve the name of this network.

static VALUE libvirt_network_name(VALUE n)
{
    ruby_libvirt_generate_call_string(virNetworkGetName,
                                      ruby_libvirt_connect_get(n), 0,
                                      network_get(n));
}
persistent? → [true|false] click to toggle source

Call virNetworkIsPersistent to determine if this network is persistent.

static VALUE libvirt_network_persistent_p(VALUE n)
{
    ruby_libvirt_generate_call_truefalse(virNetworkIsPersistent,
                                         ruby_libvirt_connect_get(n),
                                         network_get(n));
}
undefine → nil click to toggle source

Call virNetworkUndefine to undefine this network.

static VALUE libvirt_network_undefine(VALUE n)
{
    ruby_libvirt_generate_call_nil(virNetworkUndefine,
                                   ruby_libvirt_connect_get(n),
                                   network_get(n));
}
update → nil click to toggle source

Call virNetworkUpdate to update this network.

static VALUE libvirt_network_update(VALUE n, VALUE command, VALUE section,
                                    VALUE index, VALUE xml, VALUE flags)
{
    ruby_libvirt_generate_call_nil(virNetworkUpdate,
                                   ruby_libvirt_connect_get(n),
                                   network_get(n), NUM2UINT(command),
                                   NUM2UINT(section), NUM2INT(index),
                                   StringValuePtr(xml), NUM2UINT(flags));
}
uuid → String click to toggle source

Call virNetworkGetUUIDString to retrieve the UUID of this network.

static VALUE libvirt_network_uuid(VALUE n)
{
    ruby_libvirt_generate_uuid(virNetworkGetUUIDString,
                               ruby_libvirt_connect_get(n), network_get(n));
}
xml_desc(flags=0) → String click to toggle source

Call virNetworkGetXMLDesc to retrieve the XML for this network.

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

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

    ruby_libvirt_generate_call_string(virNetworkGetXMLDesc,
                                      ruby_libvirt_connect_get(n), 1,
                                      network_get(n),
                                      ruby_libvirt_value_to_uint(flags));
}