1Ravada::Domain(3)     User Contributed Perl Documentation    Ravada::Domain(3)
2
3
4

NAME

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 Arguments: id => $id , [ readonly => {0|1} ]
37
38       Returns: Domain object
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   last_vm
165       Returns the last virtual machine manager on which this domain was
166       launched.
167
168           my $vm = $domain->last_vm();
169
170   list_requests
171       Returns a list of pending requests from the domain. It won't show those
172       requests scheduled for later.
173
174   list_all_requests
175       Returns a list of pending requests from the domain including those
176       scheduled for later
177
178   get_driver
179       Returns the driver from a domain
180
181       Argument: name of the device [ optional ] Returns all the drivers if
182       not passwed
183
184           my $driver = $domain->get_driver('video');
185
186   get_driver_id
187       Gets the value of a driver
188
189       Argument: name
190
191           my $driver = $domain->get_driver('video');
192
193   set_option
194       Sets a domain option:
195
196       ·   description
197
198       ·   run_timeout
199
200           $domain->set_option(description => 'Virtual Machine for ...');
201
202   type
203       Returns the virtual machine type as a string.
204
205   rsync
206       Synchronizes the volume data to a remote node.
207
208       Arguments: ( node => $node, request => $request, files => \@files )
209
210       ·   node => Ravada::VM
211
212       ·   request => Ravada::Request ( optional )
213
214       ·   files => listref of files ( optional )
215
216       When files is not specified it syncs the volumes and base volumes if
217       any
218
219   set_base_vm
220           Prepares or removes a base in a virtual manager.
221
222           $domain->set_base_vm(
223               id_vm => $id_vm         # you can pass the id_vm
224                 ,vm => $vm            #    or the vm
225               ,user => $user
226              ,value => $value  # if it is 0, it removes the base
227            ,request => $req
228           );
229
230   remove_base_vm
231       Removes a base in a Virtual Machine Manager node.
232
233         $domain->remove_base_vm($vm, $user);
234
235   file_screenshot
236       Returns the file name where the domain screenshot has been stored
237
238   list_vms
239       Returns a list for virtual machine managers where this domain is base
240
241   base_in_vm
242       Returns if this domain has a base prepared in this virtual manager
243
244           if ($domain->base_in_vm($id_vm)) { ...
245
246   is_local
247       Returns wether this domain is in the local host
248
249   internal_id
250       Returns the internal id of this domain as found in its Virtual Manager
251       connection
252
253   volatile_clones
254       Enables or disables a domain volatile clones feature. Volatile clones
255       are removed when shut down
256
257   status
258       Sets or gets the status of a virtual machine
259
260         $machine->status('active');
261
262       Valid values are:
263
264       ·   active
265
266       ·   down
267
268       ·   hibernated
269
270   client_status
271       Returns the status of the viewer connection. The virtual machine must
272       be active, and the remote ip must be known.
273
274       Possible results:
275
276       ·   connecting : set at the start of the virtual machine
277
278       ·   IP : known remote ip from the current connection
279
280       ·   disconnected : the remote client has been closed
281
282       This method is used from higher level commands, for example, you can
283       shut down or hibernate all the disconnected virtual machines like this:
284
285         # rvd_back --hibernate --disconnected
286         # rvd_back --shutdown --disconnected
287
288       You could also set this command on a cron entry to run nightly, hourly
289       or whenever you find suitable.
290
291   needs_restart
292       Returns true or false if the virtual machine needs to be restarted so
293       some hardware change can be applied.
294
295   Access restrictions
296       These methods implement access restrictions to clone a domain
297
298   allow_ldap_attribute
299       If specified, only the LDAP users with that attribute value can clone
300       these virtual machines.
301
302           $base->allow_ldap_attribute( attribute => 'value' );
303
304       Example:
305
306           $base->allow_ldap_attribute( tipology => 'student' );
307
308   deny_ldap_access
309       If specified, only the LDAP users with that attribute value can clone
310       these virtual machines.
311
312           $base->deny_ldap_attribute( attribute => 'value' );
313
314       Example:
315
316           $base->deny_ldap_attribute( tipology => 'student' );
317
318
319
320perl v5.28.2                      2019-05-29                 Ravada::Domain(3)
Impressum