Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User should be able to change the Roles tag string through config #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/capify-cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def initialize(cloud_config = "config/cloud.yml")

@instances = []
@cloud_providers.each do |cloud_provider|
@cloud_config[cloud_provider.to_sym][:role_tag] ||= "Roles"
config = @cloud_config[cloud_provider.to_sym]
case cloud_provider
when 'Brightbox'
Expand Down Expand Up @@ -52,9 +53,9 @@ def display_instances
desired_instances.each_with_index do |instance, i|
puts sprintf "%02d: %-40s %-20s %-20s %-20s %-25s %-20s (%s) (%s)",
i, (instance.name || "").green, instance.provider.yellow, instance.id.red, instance.flavor_id.cyan,
instance.contact_point.blue, instance.zone_id.magenta, (instance.tags["Roles"] || "").yellow,
instance.contact_point.blue, instance.zone_id.magenta, (instance.tags[@cloud_config[instance.provider.to_sym][:role_tag]] || "").yellow,
(instance.tags["Options"] || "").yellow
end
end
end

def server_names
Expand All @@ -70,7 +71,7 @@ def desired_instances
end

def get_instances_by_role(role)
desired_instances.select {|instance| instance.tags['Roles'].split(%r{,\s*}).include?(role.to_s) rescue false}
desired_instances.select {|instance| instance.tags[@cloud_config[instance.provider.to_sym][:role_tag]].split(%r{,\s*}).include?(role.to_s) rescue false }
end

def get_instances_by_region(roles, region)
Expand Down