Skip to content

Commit

Permalink
Add VMs path to the VMs show page
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMatthes committed Mar 16, 2019
1 parent ceeea72 commit a3662f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/api/v_sphere/folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ def initialize(rbvmomi_folder)
@folder = rbvmomi_folder
end

def subfolders
@folder.children.select { |folder_entry| folder_entry.is_a? RbVmomi::VIM::Folder }.map do |each|
def parent
@folder.parent
end

def subfolders(recursive: false)
folders = @folder.children.select { |folder_entry| folder_entry.is_a? RbVmomi::VIM::Folder }.map do |each|
Folder.new each
end

folders += folders.flat_map { |each| each.subfolders recursive: true } if recursive
folders
end

def vms(recursive: true)
Expand Down
16 changes: 16 additions & 0 deletions app/api/v_sphere/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ def name
@vm.name
end

def full_path
path = [name]
parent = parent_folder
until parent.nil?
path << parent.name
parent = parent.parent
end
path.reverse
end

def parent_folder
root_folder.subfolders(recursive: true).find do |folder|
folder.vms(recursive: false).include? self
end
end

# Guest OS communication
def vm_ware_tools?
tool_status = @vm&.guest&.toolsStatus
Expand Down
2 changes: 1 addition & 1 deletion app/views/vms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end %>

@hardware = {'IP Address' => @vm.ip,
'DNS' => @vm.dns,
'Heartbeat Status' => @vm.guest_heartbeat_status }
'Heartbeat Status' => @vm.guest_heartbeat_status}
%>

<div class ="table-active container pt-3 pb-3 mb-3 text-center" style="width: 100%">
Expand Down

0 comments on commit a3662f3

Please sign in to comment.