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   expose
108       Expose a TCP port from the domain
109
110       Arguments:
111        - number of the port
112        - optional name
113
114       Returns: public ip and port
115
116   list_ports
117       List of exposed TCP ports
118
119   post_resume_aux
120       Method after resume
121
122   open_iptables
123       Open iptables for a remote client
124
125       user
126       remote_ip
127
128   is_public
129       Sets or get the domain public
130
131           $domain->is_public(1);
132
133           if ($domain->is_public()) {
134               ...
135           }
136
137   is_volatile
138       Returns if the domain is volatile, so it will be removed on shutdown
139
140   is_persistent
141       Returns true if the virtual machine is persistent. So it is not removed
142       after shut down.
143
144   run_timeout
145       Sets or get the domain run timeout. When it expires it is shut down.
146
147           $domain->run_timeout(60 * 60); # 60 minutes
148
149   clean_swap_volumes
150       Check if the domain has swap volumes defined, and clean them
151
152           $domain->clean_swap_volumes();
153
154   get_controller
155       Calls the method to get the specified controller info
156
157       Attributes:
158           name -> name of the controller type
159
160   get_controllers
161       Returns a hashref of the hardware controllers for this virtual machine
162
163   drivers
164       List the drivers available for a domain. It may filter for a given
165       type.
166
167           my @drivers = $domain->drivers();
168           my @video_drivers = $domain->drivers('video');
169
170   set_driver_id
171       Sets the driver of a domain given it id. The id must be one from the
172       table domain_drivers_options
173
174           $domain->set_driver_id($id_driver);
175
176   last_vm
177       Returns the last virtual machine manager on which this domain was
178       launched.
179
180           my $vm = $domain->last_vm();
181
182   list_requests
183       Returns a list of pending requests from the domain. It won't show those
184       requests scheduled for later.
185
186   list_all_requests
187       Returns a list of pending requests from the domain including those
188       scheduled for later
189
190   get_driver
191       Returns the driver from a domain
192
193       Argument: name of the device [ optional ] Returns all the drivers if
194       not passwed
195
196           my $driver = $domain->get_driver('video');
197
198   get_driver_id
199       Gets the value of a driver
200
201       Argument: name
202
203           my $driver = $domain->get_driver('video');
204
205   set_option
206       Sets a domain option:
207
208       ·   description
209
210       ·   run_timeout
211
212           $domain->set_option(description => 'Virtual Machine for ...');
213
214   type
215       Returns the virtual machine type as a string.
216
217   rsync
218       Synchronizes the volume data to a remote node.
219
220       Arguments: ( node => $node, request => $request, files => \@files )
221
222       ·   node => Ravada::VM
223
224       ·   request => Ravada::Request ( optional )
225
226       ·   files => listref of files ( optional )
227
228       When files is not specified it syncs the volumes and base volumes if
229       any
230
231   set_base_vm
232           Prepares or removes a base in a virtual manager.
233
234           $domain->set_base_vm(
235               id_vm => $id_vm         # you can pass the id_vm
236                 ,vm => $vm            #    or the vm
237               ,user => $user
238              ,value => $value  # if it is 0, it removes the base
239            ,request => $req
240           );
241
242   remove_base_vm
243       Removes a base in a Virtual Machine Manager node.
244
245         $domain->remove_base_vm($vm, $user);
246
247   file_screenshot
248       Returns the file name where the domain screenshot has been stored
249
250   list_vms
251       Returns a list for virtual machine managers where this domain is base
252
253   base_in_vm
254       Returns if this domain has a base prepared in this virtual manager
255
256           if ($domain->base_in_vm($id_vm)) { ...
257
258   is_local
259       Returns wether this domain is in the local host
260
261   internal_id
262       Returns the internal id of this domain as found in its Virtual Manager
263       connection
264
265   volatile_clones
266       Enables or disables a domain volatile clones feature. Volatile clones
267       are removed when shut down
268
269   status
270       Sets or gets the status of a virtual machine
271
272         $machine->status('active');
273
274       Valid values are:
275
276       ·   active
277
278       ·   down
279
280       ·   hibernated
281
282   client_status
283       Returns the status of the viewer connection. The virtual machine must
284       be active, and the remote ip must be known.
285
286       Possible results:
287
288       ·   connecting : set at the start of the virtual machine
289
290       ·   IP : known remote ip from the current connection
291
292       ·   disconnected : the remote client has been closed
293
294       This method is used from higher level commands, for example, you can
295       shut down or hibernate all the disconnected virtual machines like this:
296
297         # rvd_back --hibernate --disconnected
298         # rvd_back --shutdown --disconnected
299
300       You could also set this command on a cron entry to run nightly, hourly
301       or whenever you find suitable.
302
303   needs_restart
304       Returns true or false if the virtual machine needs to be restarted so
305       some hardware change can be applied.
306
307   Access restrictions
308       These methods implement access restrictions to clone a domain
309
310   allow_ldap_attribute
311       If specified, only the LDAP users with that attribute value can clone
312       these virtual machines.
313
314           $base->allow_ldap_attribute( attribute => 'value' );
315
316       Example:
317
318           $base->allow_ldap_attribute( tipology => 'student' );
319
320   deny_ldap_access
321       If specified, only the LDAP users with that attribute value can clone
322       these virtual machines.
323
324           $base->deny_ldap_attribute( attribute => 'value' );
325
326       Example:
327
328           $base->deny_ldap_attribute( tipology => 'student' );
329
330
331
332perl v5.30.0                      2019-08-08                 Ravada::Domain(3)
Impressum