Project

General

Profile

« Previous | Next » 

Revision b43fa642

Added by Ohad Levy about 12 years ago

  • ID b43fa642613aaedb59e5b76e3d3ed4a26d53c679

added basic ovirt vm show page, minor fixes in compute resource level

View differences:

app/views/compute_resources/vms/index/_ovirt.html.erb
</tr>
<% @compute_resource.vms.each do |vm| -%>
<tr>
<td><%= vm.name %></td>
<td><%= link_to vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity) %></td>
<td><%= vm.cores %></td>
<td> <%= number_to_human_size vm.memory %> </td>
<td <%= vm_power_class(vm.ready?) %>> <%= vm_state(!vm.ready?) %> </td>
app/views/compute_resources/vms/show/_ovirt.html.erb
<% title @vm.name %>
<div class='row'>
<div class='span16'>
<table class="list zebra-striped">
<tr><th colspan="2">Properties</th></tr>
<tr>
<td>Name</td>
<td><%= @vm.name %></td>
</tr>
<tr>
<td>VCPU(s)</td>
<td><%= @vm.cores %></td>
</tr>
<tr>
<td>UUID</td>
<td><%= @vm.identity %></td>
</tr>
<tr>
<td>Memory</td>
<td><%= number_to_human_size @vm.memory %> </td>
</tr>
<tr>
<td>Display</td>
<td><%= @vm.display[:type] %> (<%= @vm.display[:port] %>)</td>
</tr>
<% @vm.interfaces.each do |nic| -%>
<tr>
<td>NIC</td>
<td><%= "#{nic.name} - #{nic.mac}" %></td>
</tr>
<% end -%>
<% @vm.volumes.each do |vol| -%>
<tr>
<td>Disk</td>
<td><%= "using #{number_to_human_size vol.size}" %></td>
</tr>
<% end -%>
<tr>
<td>Running on</td>
<td><%= link_to @compute_resource, compute_resource_path(@compute_resource) %></td>
</tr>
</table>
</div>
</div>
<% title_actions display_link_if_authorized("Power#{state(@vm.ready?)}", hash_for_power_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => @vm.identity), :confirm => 'Are you sure?', :method => :put, :class=>'btn ' + (@vm.ready? ? "danger" : "success")),
display_link_if_authorized("Delete", hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => @vm.identity).merge(:auth_action => :destroy), :confirm => 'Are you sure?', :method => :delete, :class=>'btn danger'),
display_link_if_authorized("Other VMs on #{@compute_resource}", hash_for_compute_resource_vms_path(:compute_resource_id => @compute_resource), :class=>'btn') %>
lib/foreman/model/libvirt.rb
def client
# WARNING potential connection leak
Thread.current[id] ||= ::Fog::Compute.new(:provider => "Libvirt", :libvirt_uri => url)
Thread.current[url] ||= ::Fog::Compute.new(:provider => "Libvirt", :libvirt_uri => url)
end
def disconnect
lib/foreman/model/ovirt.rb
true
end
def console(uuid)
vm = find_vm_by_uuid(uuid)
raise "VM is not running!" if vm.status == "down"
raise "Spice display is not supported at the moment" if vm.display[:type] =~ /spice/i
VNCProxy.start(:host => vm.display[:address], :host_port => vm.display[:port], :password => vm.ticket)
end
protected
def bootstrap(args)
......
false
end
def console(uuid)
vm = find_vm_by_uuid(uuid)
raise "VM is not running!" if vm.status == "down"
raise "Spice display is not supported at the moment" if vm.display[:type] =~ /spice/i
VNCProxy.start(:host => vm.display[:address], :host_port => vm.display[:port], :password => vm.ticket)
end
private
def create_interfaces(vm, attrs)

Also available in: Unified diff