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   pre_prepare_base
9       Run this before preparing the base. By default does nothing and may be
10       implemented in the object.
11
12       This is executed automatically so it shouldn't been called.
13
14   prepare_base
15       Prepares the virtual machine as a base:
16
17       •   shuts it down
18
19       •   creates read only volumes based on this base
20
21       •   locks it so it won't get started
22
23       •   stores the virtual machine template for the clones
24
25   post_prepare_base
26       Placeholder for optional method implemented in subclasses. This will
27       run after preparing the base files.
28
29   spinoff
30       Makes volumes indpendent from base
31
32       sub _check_disk_modified {
33           my $self = shift;
34
35           if ( !$self->is_base() ) {
36               return;
37           }
38
39           my $last_stat_base = 0;
40           for my $file_base ( $self->list_files_base ) {
41               my @stat_base = stat($file_base);
42               $last_stat_base = $stat_base[9] if$stat_base[9] > $last_stat_base;
43       #        warn $last_stat_base;
44           }
45
46           my $files_updated = 0;
47           for my $file ( $self->disk_device ) {
48               my @stat = stat($file) or next;
49               $files_updated++ if $stat[9] > $last_stat_base;
50       #        warn "\ncheck\t$file ".$stat[9]."\n vs \tfile_base $last_stat_base $files_updated\n";
51           }
52           die "Base already created and no disk images updated"
53               if !$files_updated;
54       }
55
56   id Returns the id of  the domain my $id = $domain->id();
57   open
58       Open a domain
59
60       Argument: id Arguments: id => $id , [ readonly => {0|1} ]
61
62       Returns: Domain object
63
64   check_status
65       Checks if a virtual machine known status is in sync.
66
67       •   Checks it is already started
68
69       •   Performs shutdown cleaning procedures if down
70
71   is_known
72       Returns if the domain is known in Ravada.
73
74   is_known_extra
75       Returns if the domain has extra fields information known in Ravada.
76
77   start_time
78       Returns the last time (epoch format in seconds) the domain was started.
79
80   spice_password
81       Returns the password defined for the spice viewers
82
83   display_file
84       Returns a file with the display information. Defaults to spice.
85
86   display_file_tls
87       Returns a file with the display information in TLS connections.
88       Defaults to spice.
89
90   display
91       Returns the display information.
92
93   info
94       Return information about the domain.
95
96   pre_remove
97       Code to run before removing the domain. It can be implemented in each
98       domain.  It is not expected to run by itself, the remove function calls
99       it before proceeding.
100
101           $domain->pre_remove();  # This isn't likely to be necessary
102           $domain->remove();      # Automatically calls the domain pre_remove method
103
104   restore
105       Returns the clone to an initial state.
106
107       Depending of the type of volumes added to the virtual machines all the
108       information stored there is removed. Only data volumes are kept
109       untouched.
110
111       •   system : cleaned to the initial state
112
113       •   tmp/swap : cleaned to the initial state
114
115       •   data : nothing gets removed
116
117   is_base Returns true or  false if the domain is a prepared base
118   is_locked Shows if the domain has running or pending requests. It could be
119       considered too as the domain is busy doing something like starting,
120       shutdown or prepare base. Returns true if locked.
121   id_owner Returns the id of the user that created this domain
122   id_base Returns the id from the base this domain is based on, if any.
123   vm Returns a string with the name of the VM ( Virtual Machine ) this domain
124       was created on
125   clones Returns a list of clones from this virtual machine my @clones =
126       $domain->clones
127   has_clones Returns the number of clones from this virtual machine my
128       $has_clones = $domain->has_clones
129   list_files_base Returns a list of the filenames of this base-type domain
130   list_files_base_target
131       Returns a list of the filenames and targets of this base-type domain
132
133   can_screenshot Returns wether this domain can take an screenshot.
134   remove_base Makes the domain a regular, non-base virtual machine and
135       removes the base files.
136   clone
137       Clones a domain
138
139       arguments
140
141       user => $user : The user that owns the clone
142       name => $name : Name of the new clone
143
144   can_hybernate
145       Returns wether a domain supports hybernation
146
147   can_hibernate
148       Returns wether a domain supports hibernation
149
150   add_volume_swap
151       Adds a swap volume to the virtual machine
152
153       Arguments:
154
155           size => $kb
156           name => $name (optional)
157
158   expose
159       Expose a TCP port from the domain
160
161       Arguments:
162        - number of the port
163        - optional name
164
165       Returns: public ip and port
166
167   exposed_port
168       Returns all the data from an exposed port.
169
170       Argument: number or name description of the port permission.
171
172           my $port_data = $domain->exposed_port(80);
173
174           my $port_data = $domain->exposed_port('web');
175
176   open_exposed_ports
177       Performs an iptables open of all the exposed ports of the domain
178
179   remove_expose
180       Remove exposed port
181
182       Argument: virtual machine exposed port [ optional ]
183
184       If no port is passed all the exposed ports are removed.
185
186   list_ports
187       List of exposed TCP ports
188
189   post_resume_aux
190       Method after resume
191
192   open_iptables
193       Open iptables for a remote client
194
195       user
196       remote_ip
197
198   is_public
199       Sets or get the domain public
200
201           $domain->is_public(1);
202
203           if ($domain->is_public()) {
204               ...
205           }
206
207   is_volatile
208       Returns if the domain is volatile, so it will be removed on shutdown
209
210   is_persistent
211       Returns true if the virtual machine is persistent. So it is not removed
212       after shut down.
213
214   run_timeout
215       Sets or get the domain run timeout. When it expires it is shut down.
216
217           $domain->run_timeout(60 * 60); # 60 minutes
218
219   clean_swap_volumes
220       Check if the domain has swap volumes defined, and clean them
221
222           $domain->clean_swap_volumes();
223
224   get_controller
225       Calls the method to get the specified controller info
226
227       Attributes:
228           name -> name of the controller type
229
230   get_controllers
231       Returns a hashref of the hardware controllers for this virtual machine
232
233   drivers
234       List the drivers available for a domain. It may filter for a given
235       type.
236
237           my @drivers = $domain->drivers();
238           my @video_drivers = $domain->drivers('video');
239
240   set_driver_id
241       Sets the driver of a domain given it id. The id must be one from the
242       table domain_drivers_options
243
244           $domain->set_driver_id($id_driver);
245
246   last_vm
247       Returns the last virtual machine manager on which this domain was
248       launched.
249
250           my $vm = $domain->last_vm();
251
252   list_requests
253       Returns a list of pending requests from the domain. It won't show those
254       requests scheduled for later.
255
256   list_all_requests
257       Returns a list of pending requests from the domain including those
258       scheduled for later
259
260   get_driver
261       Returns the driver from a domain
262
263       Argument: name of the device [ optional ] Returns all the drivers if
264       not passwed
265
266           my $driver = $domain->get_driver('video');
267
268   get_driver_id
269       Gets the value of a driver
270
271       Argument: name
272
273           my $driver = $domain->get_driver('video');
274
275   set_option
276       Sets a domain option:
277
278       •   description
279
280       •   run_timeout
281
282           $domain->set_option(description => 'Virtual Machine for ...');
283
284   type
285       Returns the virtual machine type as a string.
286
287   rsync
288       Synchronizes the volume data to a remote node.
289
290       Arguments: ( node => $node, request => $request, files => \@files )
291
292       •   node => Ravada::VM
293
294       •   request => Ravada::Request ( optional )
295
296       •   files => listref of files ( optional )
297
298       When files is not specified it syncs the volumes and base volumes if
299       any
300
301   set_base_vm
302           Prepares or removes a base in a virtual manager.
303
304           $domain->set_base_vm(
305               id_vm => $id_vm         # you can pass the id_vm
306                 ,vm => $vm            #    or the vm
307               ,user => $user
308              ,value => $value  # if it is 0, it removes the base
309            ,request => $req
310           );
311
312   migrate_base
313       Migrates a base to a virtual manager node.
314
315       Alias for set_base_vm.
316
317   remove_base_vm
318       Removes a base in a Virtual Machine Manager node.
319
320         $domain->remove_base_vm($vm, $user);
321
322   file_screenshot
323       Returns the file name where the domain screenshot has been stored
324
325   list_vms
326       Returns a list for virtual machine managers where this domain is base
327
328   base_in_vm
329       Returns if this domain has a base prepared in this virtual manager
330
331           if ($domain->base_in_vm($id_vm)) { ...
332
333   base_files_in_vm
334       arguments
335
336       vm : The virtual manager to check
337
338       Returns true if all te base files exist in the virtual manager o node
339
340         $domain->base_files_in_vm($node);
341
342   is_local
343       Returns wether this domain is in the local host
344
345   pools
346       Enables or disables pools of clones for this virtual machine
347
348   pool_clones
349       Number of clones of this virtual machine that belong to the pool
350
351   pool_start
352       Number of clones of this virtual machine that are pre-started
353
354   is_pool
355       Return if the virtual machine belongs to a pool of clones
356
357   internal_id
358       Returns the internal id of this domain as found in its Virtual Manager
359       connection
360
361   volatile_clones
362       Enables or disables a domain volatile clones feature. Volatile clones
363       are removed when shut down
364
365   status
366       Sets or gets the status of a virtual machine
367
368         $machine->status('active');
369
370       Valid values are:
371
372       •   active
373
374       •   down
375
376       •   hibernated
377
378   client_status
379       Returns the status of the viewer connection. The virtual machine must
380       be active, and the remote ip must be known.
381
382       Possible results:
383
384       •   connecting : set at the start of the virtual machine
385
386       •   IP : known remote ip from the current connection
387
388       •   disconnected : the remote client has been closed
389
390       This method is used from higher level commands, for example, you can
391       shut down or hibernate all the disconnected virtual machines like this:
392
393         # rvd_back --hibernate --disconnected
394         # rvd_back --shutdown --disconnected
395
396       You could also set this command on a cron entry to run nightly, hourly
397       or whenever you find suitable.
398
399   needs_restart
400       Returns true or false if the virtual machine needs to be restarted so
401       some hardware change can be applied.
402
403   Access restrictions
404       These methods implement access restrictions to clone a domain
405
406   allow_ldap_access
407       If specified, only the LDAP users with that attribute value can clone
408       these virtual machines.
409
410           $base->allow_ldap_attribute( attribute => 'value' );
411
412       Example:
413
414           $base->allow_ldap_attribute( tipology => 'student' );
415
416   default_access
417       Sets the default access value
418
419   grant_access
420       Grant access to a virtual machine
421
422       Arguments is a named list
423
424       •   attribute
425
426       •   value
427
428       •   type
429
430       •   allowed ( true / false ) defaults to true
431
432       •   last : if this grant matches it stops looking
433
434   access_allowed
435       Returns if a client is granted access to a virtual machine
436
437       Arguments: expects a named vars list of client attributes retrieved
438       from the web connection.
439
440   list_access
441       Returns a list of access grants
442
443       Argument: optionally pass the type of grant.
444
445   delete_access
446       Deletes a list of access grants from the database
447
448   delete_ldap_access
449       Deletes a granted ldap access setting
450
451       Argument: id of the access from the table access_ldap_attribute
452
453   list_ldap_access
454       List granted ldap access settings
455
456   deny_ldap_access
457       If specified, only the LDAP users with that attribute value can clone
458       these virtual machines.
459
460           $base->deny_ldap_attribute( attribute => 'value' );
461
462       Example:
463
464           $base->deny_ldap_attribute( tipology => 'student' );
465
466   move_ldap_access
467       Moves an access access grant up or down
468
469       Arguments:
470
471       •   id_ldap_access
472
473       •   position: +1/-1
474
475   move_access
476       Moves an access access grant up or down
477
478       Arguments:
479
480       •   id_access
481
482       •   position: +1/-1
483
484   set_ldap_access
485       Changes access grant allowed and last states
486
487       Arguments:
488
489       •   id_access
490
491       •   allowed
492
493       •   last
494
495   set_access
496       Changes access grant allowed and last states
497
498       •   id_access
499
500       •   allowed
501
502       •   last
503
504   rebase
505       Rebases the virtual machine to another one
506
507       If it is a base it rebases all the clones.
508
509   list_instances
510       Returns a list of instances of the virtual machine in all the physical
511       nodes
512
513   has_non_shared_storage
514       Return wether this virtual machine has non shared storage volumes
515
516   compact
517       Compacts virtual machine volumes
518
519   purge
520       Removes backups from virtual machine volumes
521

POD ERRORS

523       Hey! The above document had some coding errors, which are explained
524       below:
525
526       Around line 814:
527           You forgot a '=back' before '=head2'
528
529       Around line 1986:
530           You forgot a '=back' before '=head2'
531
532       Around line 4922:
533           You forgot a '=back' before '=head2'
534
535
536
537perl v5.32.1                      2021-05-24                 Ravada::Domain(3)
Impressum