Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 6dcb84a

Browse files
authored
Merge pull request #7 from johnmccabe/maint/master/flag_vanagon_frankenbuilder_vms
(maint) allow vm name to be overridden for roles
2 parents 0fdacc8 + 75bfe60 commit 6dcb84a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vmpooler-bitbar.30s.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ def copy_menu_text_params(menu_text)
5050
"bash=/bin/bash param1=-c param2='echo -n #{menu_text} | pbcopy' terminal=false"
5151
end
5252

53+
def get_display_name(vm)
54+
# list of roles which override the vm[:name] displayed
55+
flagged_roles = ['vanagon_target']
56+
if vm[:tags].key?('roles')
57+
flagged_roles.each do | flagged_role |
58+
if vm[:tags]['roles'].include?(flagged_role)
59+
return flagged_role
60+
end
61+
end
62+
end
63+
vm[:name]
64+
end
65+
5366
def ssh_user(vm)
5467
vm[:template].start_with?('win') ? 'Administrator' : 'root'
5568
end
@@ -81,7 +94,7 @@ def ssh_user(vm)
8194
<% if !vms.nil? -%>
8295
<% vms.each do |vm| -%>
8396
<% remaining_time_colour = vm[:remaining] <= warning_timeleft_threshhold ? 'red' : 'green' -%>
84-
<%= vm[:timebar] %><%= vm[:hostname] %> (<%= vm[:name] %>) | <%= fixed_font_header_params %> color=<%= remaining_time_colour %> <%= copy_menu_text_params(vm[:fqdn]) %>
97+
<%= vm[:timebar] %><%= vm[:hostname] %> (<%= get_display_name(vm) %>) | <%= fixed_font_header_params %> color=<%= remaining_time_colour %> <%= copy_menu_text_params(vm[:fqdn]) %>
8598
-- Action | <%= submenu_header_params %>
8699
-- SSH to VM | href='ssh://<%= ssh_user(vm) %>@<%= vm[:fqdn] %>' <%= terminal_action_params %>
87100
-- Delete VM | bash=<%= this_script %> param1=delete param2=<%= vm[:hostname] %> <%= refresh_action_params %>

0 commit comments

Comments
 (0)