1Sys::Virt::Network(3) User Contributed Perl DocumentationSys::Virt::Network(3)
2
3
4
6 Sys::Virt::Network - Represent & manage a libvirt virtual network
7
9 The "Sys::Virt::Network" module represents a virtual network managed by
10 the virtual machine monitor.
11
13 my $uuid = $net->get_uuid()
14 Returns a 16 byte long string containing the raw globally unique
15 identifier (UUID) for the network.
16
17 my $uuid = $net->get_uuid_string()
18 Returns a printable string representation of the raw UUID, in the
19 format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.
20
21 my $name = $net->get_name()
22 Returns a string with a locally unique name of the network
23
24 $net->is_active()
25 Returns a true value if the network is currently running
26
27 $net->is_persistent()
28 Returns a true value if the network has a persistent configuration
29 file defined
30
31 my $xml = $net->get_xml_description()
32 Returns an XML document containing a complete description of the
33 network's configuration
34
35 $net->create()
36 Start a network whose configuration was previously defined using
37 the "define_network" method in Sys::Virt.
38
39 $net->undefine()
40 Remove the configuration associated with a network previously
41 defined with the "define_network" method in Sys::Virt. If the
42 network is running, you probably want to use the "shutdown" or
43 "destroy" methods instead.
44
45 $net->destroy()
46 Immediately terminate the machine, and remove it from the virtual
47 machine monitor. The $net handle is invalid after this call
48 completes and should not be used again.
49
50 $net->update($command, $section, $parentIndex, $xml, $flags=0)
51 Update the network configuration with $xml. The $section parameter,
52 which must be one of the XML SECTION CONSTANTS listed later,
53 indicates what schema is used in $xml. The $command parameter
54 determines what action is taken. Finally, the $flags parameter can
55 be use to control which config is affected.
56
57 $net->get_bridge_name()
58 Return the name of the bridge device associated with the virtual
59 network
60
61 $flag = $net->get_autostart();
62 Return a true value if the virtual network is configured to
63 automatically start upon boot. Return false, otherwise
64
65 $net->set_autostart($flag)
66 Set the state of the autostart flag, which determines whether the
67 virtual network will automatically start upon boot of the host OS.
68
69 @leases = $net->get_dhcp_leases($mac=undef, $flags=0)
70 Get a list of all active DHCP leases. If $mac is undefined than
71 leases for all VMs are returned, otherwise only leases for the
72 matching MAC address are returned. The $flags parameter is
73 currently unused and defaults to zero.
74
75 The elements in the returned array are hash references with the
76 following fields
77
78 "iface"
79 Network interface name
80
81 "expirytime"
82 Seconds since the epoch until the lease expires
83
84 "type"
85 One of the Sys::Virt IP address type constants
86
87 "mac"
88 The MAC address of the lease
89
90 "iaid"
91 The IAID of the client
92
93 "ipaddr"
94 The IP address of the lease
95
96 "prefix"
97 The IP address prefix
98
99 "hostname"
100 The optional hostname associated with the lease
101
102 "clientid"
103 The client ID or DUID
104
105 @port = $net->list_all_ports($flags=0)
106 List all ports associated with the network. The return array
107 elements are instances of the "Sys::Virt::NetworkPort" class.
108
109 $port = $net->create_port($xml, $flags=0)
110 Create a new network port from the given $xml description. The
111 $flags parameter can optionally taken one or more of the network
112 port creation constants. The returned $port object is an instance
113 of the "Sys::Virt::NetworkPort" class.
114
115 $port = $net->get_port_by_uuid($uuid);
116 Lookup a network port from a raw or printable UUID. The returned
117 $port object is an instance of the "Sys::Virt::NetworkPort" class.
118
120 This section documents constants that are used with various APIs
121 described above
122
123 LIST FILTERING
124 The following constants are used to filter object lists
125
126 Sys::Virt::Network::LIST_ACTIVE
127 Include networks which are active
128
129 Sys::Virt::Network::LIST_INACTIVE
130 Include networks which are not active
131
132 Sys::Virt::Network::LIST_AUTOSTART
133 Include networks which are set to autostart
134
135 Sys::Virt::Network::LIST_NO_AUTOSTART
136 Include networks which are not set to autostart
137
138 Sys::Virt::Network::LIST_PERSISTENT
139 Include networks which are persistent
140
141 Sys::Virt::Network::LIST_TRANSIENT
142 Include networks which are transient
143
144 XML CONSTANTS
145 The following constants are used when querying XML
146
147 Sys::Virt::Network::XML_INACTIVE
148 Request the inactive XML, instead of the current possibly live
149 config.
150
152 The following constants are used to refer to sections of the XML
153 document
154
155 Sys::Virt::Network::SECTION_BRIDGE
156 The bridge device element
157
158 Sys::Virt::Network::SECTION_DNS_HOST
159 The DNS host record section
160
161 Sys::Virt::Network::SECTION_DNS_SRV
162 The DNS SRV record section
163
164 Sys::Virt::Network::SECTION_DNS_TXT
165 The DNS TXT record section
166
167 Sys::Virt::Network::SECTION_DOMAIN
168 The domain name section
169
170 Sys::Virt::Network::SECTION_FORWARD
171 The forward device section
172
173 Sys::Virt::Network::SECTION_FORWARD_INTERFACE
174 The forward interface section
175
176 Sys::Virt::Network::SECTION_FORWARD_PF
177 The forward physical function section
178
179 Sys::Virt::Network::SECTION_IP
180 The IP address section
181
182 Sys::Virt::Network::SECTION_IP_DHCP_HOST
183 The IP address DHCP host section
184
185 Sys::Virt::Network::SECTION_IP_DHCP_RANGE
186 The IP address DHCP range section
187
188 Sys::Virt::Network::SECTION_PORTGROUP
189 The port group section
190
191 Sys::Virt::Network::SECTION_NONE
192 The top level domain element
193
194 XML UPDATE FLAGS
195 Sys::Virt::Network::UPDATE_AFFECT_CURRENT
196 Affect whatever the current object state is
197
198 Sys::Virt::Network::UPDATE_AFFECT_CONFIG
199 Always update the config file
200
201 Sys::Virt::Network::UPDATE_AFFECT_LIVE
202 Always update the live config
203
204 XML UPDATE COMMANDS
205 Sys::Virt::Network::UPDATE_COMMAND_NONE
206 No update
207
208 Sys::Virt::Network::UPDATE_COMMAND_DELETE
209 Remove the matching entry
210
211 Sys::Virt::Network::UPDATE_COMMAND_MODIFY
212 Modify the matching entry
213
214 Sys::Virt::Network::UPDATE_COMMAND_ADD_FIRST
215 Insert the matching entry at the start
216
217 Sys::Virt::Network::UPDATE_COMMAND_ADD_LAST
218 Insert the matching entry at the end
219
220 EVENT ID CONSTANTS
221 Sys::Virt::Network::EVENT_ID_LIFECYCLE
222 Network lifecycle events
223
224 LIFECYCLE CHANGE EVENTS
225 The following constants allow network lifecycle change events to be
226 interpreted. The events contain both a state change, and a reason
227 though the reason is currently unused.
228
229 Sys::Virt::Network::EVENT_DEFINED
230 Indicates that a persistent configuration has been defined for the
231 network.
232
233 Sys::Virt::Network::EVENT_STARTED
234 The network has started running
235
236 Sys::Virt::Network::EVENT_STOPPED
237 The network has stopped running
238
239 Sys::Virt::Network::EVENT_UNDEFINED
240 The persistent configuration has gone away
241
243 Daniel P. Berrange <berrange@redhat.com>
244
246 Copyright (C) 2006 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange
247
249 This program is free software; you can redistribute it and/or modify it
250 under the terms of either the GNU General Public License as published
251 by the Free Software Foundation (either version 2 of the License, or at
252 your option any later version), or, the Artistic License, as specified
253 in the Perl README file.
254
256 Sys::Virt, Sys::Virt::Error, "http://libvirt.org"
257
258
259
260perl v5.32.1 2021-03-02 Sys::Virt::Network(3)