1Ravada::Domain(3) User Contributed Perl Documentation Ravada::Domain(3)
2
3
4
6 Ravada::Domain - Domains ( Virtual Machines ) library for Ravada
7
8 sub _check_disk_modified {
9 my $self = shift;
10
11 if ( !$self->is_base() ) {
12 return;
13 }
14
15 my $last_stat_base = 0;
16 for my $file_base ( $self->list_files_base ) {
17 my @stat_base = stat($file_base);
18 $last_stat_base = $stat_base[9] if$stat_base[9] > $last_stat_base;
19 # warn $last_stat_base;
20 }
21
22 my $files_updated = 0;
23 for my $file ( $self->disk_device ) {
24 my @stat = stat($file) or next;
25 $files_updated++ if $stat[9] > $last_stat_base;
26 # warn "\ncheck\t$file ".$stat[9]."\n vs \tfile_base $last_stat_base $files_updated\n";
27 }
28 die "Base already created and no disk images updated"
29 if !$files_updated;
30 }
31
32 id Returns the id of the domain my $id = $domain->id();
33 open
34 Open a domain
35
36 Argument: id
37
38 Returns: Domain object read only
39
40 is_known
41 Returns if the domain is known in Ravada.
42
43 is_known_extra
44 Returns if the domain has extra fields information known in Ravada.
45
46 start_time
47 Returns the last time (epoch format in seconds) the domain was started.
48
49 spice_password
50 Returns the password defined for the spice viewers
51
52 display_file
53 Returns a file with the display information. Defaults to spice.
54
55 info
56 Return information about the domain.
57
58 pre_remove
59 Code to run before removing the domain. It can be implemented in each
60 domain. It is not expected to run by itself, the remove function calls
61 it before proceeding.
62
63 $domain->pre_remove(); # This isn't likely to be necessary
64 $domain->remove(); # Automatically calls the domain pre_remove method
65
66 is_base Returns true or false if the domain is a prepared base
67 is_locked Shows if the domain has running or pending requests. It could be
68 considered too as the domain is busy doing something like starting,
69 shutdown or prepare base. Returns true if locked.
70 id_owner Returns the id of the user that created this domain
71 id_base Returns the id from the base this domain is based on, if any.
72 vm Returns a string with the name of the VM ( Virtual Machine ) this domain
73 was created on
74 clones Returns a list of clones from this virtual machine my @clones =
75 $domain->clones
76 has_clones Returns the number of clones from this virtual machine my
77 $has_clones = $domain->has_clones
78 list_files_base Returns a list of the filenames of this base-type domain
79 list_files_base_target
80 Returns a list of the filenames and targets of this base-type domain
81
82 can_screenshot Returns wether this domain can take an screenshot.
83 remove_base Makes the domain a regular, non-base virtual machine and
84 removes the base files.
85 clone
86 Clones a domain
87
88 arguments
89
90 user => $user : The user that owns the clone
91 name => $name : Name of the new clone
92
93 can_hybernate
94 Returns wether a domain supports hybernation
95
96 can_hibernate
97 Returns wether a domain supports hibernation
98
99 add_volume_swap
100 Adds a swap volume to the virtual machine
101
102 Arguments:
103
104 size => $kb
105 name => $name (optional)
106
107 post_resume_aux
108 Method after resume
109
110 open_iptables
111 Open iptables for a remote client
112
113 user
114 remote_ip
115
116 is_public
117 Sets or get the domain public
118
119 $domain->is_public(1);
120
121 if ($domain->is_public()) {
122 ...
123 }
124
125 is_volatile
126 Returns if the domain is volatile, so it will be removed on shutdown
127
128 is_persistent
129 Returns true if the virtual machine is persistent. So it is not removed
130 after shut down.
131
132 run_timeout
133 Sets or get the domain run timeout. When it expires it is shut down.
134
135 $domain->run_timeout(60 * 60); # 60 minutes
136
137 clean_swap_volumes
138 Check if the domain has swap volumes defined, and clean them
139
140 $domain->clean_swap_volumes();
141
142 get_controller
143 Calls the method to get the specified controller info
144
145 Attributes:
146 name -> name of the controller type
147
148 get_controllers
149 Returns a hashref of the hardware controllers for this virtual machine
150
151 drivers
152 List the drivers available for a domain. It may filter for a given
153 type.
154
155 my @drivers = $domain->drivers();
156 my @video_drivers = $domain->drivers('video');
157
158 set_driver_id
159 Sets the driver of a domain given it id. The id must be one from the
160 table domain_drivers_options
161
162 $domain->set_driver_id($id_driver);
163
164 list_requests
165 Returns a list of pending requests from the domain. It won't show those
166 requests scheduled for later.
167
168 list_all_requests
169 Returns a list of pending requests from the domain including those
170 scheduled for later
171
172 get_driver
173 Returns the driver from a domain
174
175 Argument: name of the device [ optional ] Returns all the drivers if
176 not passwed
177
178 my $driver = $domain->get_driver('video');
179
180 get_driver_id
181 Gets the value of a driver
182
183 Argument: name
184
185 my $driver = $domain->get_driver('video');
186
187 set_option
188 Sets a domain option:
189
190 · description
191
192 · run_timeout
193
194 $domain->set_option(description => 'Virtual Machine for ...');
195
196 type
197 Returns the virtual machine type as a string.
198
199 file_screenshot
200 Returns the name of the file where the virtual machine screenshot is
201 stored
202
203 internal_id
204 Returns the internal id of this domain as found in its Virtual Manager
205 connection
206
207 volatile_clones
208 Enables or disables a domain volatile clones feature. Volatile clones
209 are removed when shut down
210
211 status
212 Sets or gets the status of a virtual machine
213
214 $machine->status('active');
215
216 Valid values are:
217
218 · active
219
220 · down
221
222 · hibernated
223
224 client_status
225 Returns the status of the viewer connection. The virtual machine must
226 be active, and the remote ip must be known.
227
228 Possible results:
229
230 · connecting : set at the start of the virtual machine
231
232 · IP : known remote ip from the current connection
233
234 · disconnected : the remote client has been closed
235
236 This method is used from higher level commands, for example, you can
237 shut down or hibernate all the disconnected virtual machines like this:
238
239 # rvd_back --hibernate --disconnected
240 # rvd_back --shutdown --disconnected
241
242 You could also set this command on a cron entry to run nightly, hourly
243 or whenever you find suitable.
244
245 needs_restart
246 Returns true or false if the virtual machine needs to be restarted so
247 some hardware change can be applied.
248
249 Access restrictions
250 These methods implement access restrictions to clone a domain
251
252 allow_ldap_access
253 If specified, only the LDAP users with that attribute value can clone
254 these virtual machines.
255
256 $base->allow_ldap_access( attribute => 'value' );
257
258 Example:
259
260 $base->allow_ldap_access( tipology => 'student' );
261
262 delete_ldap_access
263 Given an id ldap access, remove it from the permissions:
264
265 $base->delete_ldap_access( $id_access );
266
267 The id_access can be obtained through list_ldap_access method.
268
269 list_ldap_access
270 Returns a list of all the ldap access restrictions as a list. Each
271 value of the list is a hashref with all the fields of the restriction.
272
273 deny_ldap_access
274 If specified, only the LDAP users with that attribute value can clone
275 these virtual machines.
276
277 $base->deny_ldap_attribute( attribute => 'value' );
278
279 Example:
280
281 $base->deny_ldap_attribute( tipology => 'student' );
282
283 move_ldap_access
284 Moves a LDAP attribute access restriction up or down in the list. You
285 have to supply the id_access that can be found from list_ldap_access
286 and a +1 or -1 value. This restrictions will be moved up or down
287 according to the position change requested.
288
289 $domain->move_ldap_access($id_access, $position)
290
291 set_ldap_access
292 Change the LDAP access restriction values. Actually only the allowed
293 and last fields can be modified:
294
295 $domain->set_ldap_access( $id_access, $allowed, $last);
296
297
298
299perl v5.28.1 2019-04-12 Ravada::Domain(3)