Commit b6969695 authored by Fernando Verdugo's avatar Fernando Verdugo Committed by Francesc Guasch
Browse files

Feature/1093 isos (#1097)

* feat(isos): from backend
* wip(isos): xml more heterogeneous definition

It's not necessary to indicate an exact topology of cpu or detail apparmor, etc ...
This generated errors in other environments, e.g. with docker.

Issue #1093
parent 2bf59c85
......@@ -15,12 +15,6 @@
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>Penryn</model>
<feature policy='require' name='vme'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='hypervisor'/>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
......@@ -138,12 +132,4 @@
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-a289e5a7-77c8-4447-b21e-177105598ec6</label>
<imagelabel>libvirt-a289e5a7-77c8-4447-b21e-177105598ec6</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+64055:+130</label>
<imagelabel>+64055:+130</imagelabel>
</seclabel>
</domain>
......@@ -12,9 +12,6 @@
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Penryn</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
......
......@@ -12,9 +12,6 @@
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Penryn</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
......
......@@ -12,9 +12,6 @@
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Penryn</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
......
......@@ -12,9 +12,6 @@
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Penryn</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
......
......@@ -145,12 +145,4 @@
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-7358e9e4-7472-416e-a2d2-c831491814e9</label>
<imagelabel>libvirt-7358e9e4-7472-416e-a2d2-c831491814e9</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+123:+131</label>
<imagelabel>+123:+131</imagelabel>
</seclabel>
</domain>
......@@ -3055,6 +3055,15 @@ sub _cmd_list_network_interfaces($self, $request) {
$request->output(encode_json(\@ifs));
}
sub _cmd_list_isos($self, $request){
my $vm_type = $request->args('vm_type');
my $vm = Ravada::VM->open( type => $vm_type );
my @isos = sort { "\L$a" cmp "\L$b" } $vm->search_volume_path_re(qr(.*\.iso$));
$request->output(encode_json(\@isos));
}
sub _clean_requests($self, $command, $request=undef) {
my $query = "DELETE FROM requests "
." WHERE command=? "
......@@ -3317,6 +3326,9 @@ sub _req_method {
#networks
,list_network_interfaces => \&_cmd_list_network_interfaces
#isos
,list_isos => \&_cmd_list_isos
);
return $methods{$cmd};
}
......
......@@ -580,12 +580,16 @@ Returns a reference to a list of the ISOs known by the system
=cut
sub iso_file {
my $self = shift;
my $vm = $self->search_vm('KVM');
my @isos = sort { "\L$a" cmp "\L$b" } $vm->search_volume_path_re(qr(.*\.iso$));
#TODO remove path from device
return \@isos;
sub iso_file ($self, $vm_type) {
my $req = Ravada::Request->list_isos(
vm_type => $vm_type
);
$self->wait_request($req);
return [] if $req->status ne 'done';
my $isos = decode_json($req->output());
return $isos;
}
=head2 list_lxc_templates
......@@ -884,6 +888,7 @@ sub list_requests($self, $id_domain_req=undef, $seconds=60) {
|| $command eq 'connect_node'
|| $command eq 'post_login'
|| $command eq 'list_network_interfaces'
|| $command eq 'list_isos'
;
next if ( $command eq 'force_shutdown'
|| $command eq 'start'
......
......@@ -101,6 +101,9 @@ our %VALID_ARG = (
#networks
,list_network_interfaces => { uid => 1, vm_type => 1, type => 2 }
#isos
,list_isos => { vm_type => 1 }
,ping_backend => {}
);
......@@ -137,7 +140,7 @@ our %COMMAND = (
,important=> {
limit => 20
,priority => 1
,commands => ['clone','start','start_clones','create','open_iptables','list_network_interfaces']
,commands => ['clone','start','start_clones','create','open_iptables','list_network_interfaces','list_isos']
}
,secondary => {
limit => 50
......
......@@ -396,7 +396,7 @@ get '/iso_file.json' => sub {
return access_denied($c) unless _logged_in($c)
&& $USER->can_create_machine();
my @isos =('<NONE>');
push @isos,(@{$RAVADA->iso_file});
push @isos,(@{$RAVADA->iso_file('KVM')});
$c->render(json => \@isos);
};
......@@ -1852,7 +1852,7 @@ sub manage_machine {
$c->stash(errors => \@errors);
return $c->render(template => 'main/settings_machine'
, nodes => [$RAVADA->list_vms($domain->type)]
, isos => $RAVADA->iso_file()
, isos => $RAVADA->iso_file($domain->type)
, list_clones => [map { $_->{name} } $domain->clones]
, action => $c->req->url->to_abs->path
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment