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