Module: Kontena::Plugin::Aws::Prompts
- Included in:
- Master::CreateCommand, Master::TerminateCommand, Nodes::CreateCommand, Nodes::RestartCommand, Nodes::TerminateCommand
- Defined in:
- lib/kontena/plugin/aws/prompts.rb
Defined Under Namespace
Modules: Common
Instance Method Summary collapse
Instance Method Details
#ask_node ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/kontena/plugin/aws/prompts.rb', line 153 def ask_node if self.name.nil? nodes = client.get("grids/#{current_grid}/nodes") nodes = nodes['nodes'].select{ |n| n['labels'] && n['labels'].include?('provider=aws'.freeze) } raise "Did not find any nodes with label provider=aws" if nodes.size == 0 prompt.select("Select node:") do || nodes.sort_by{ |n| n['node_number'] }.reverse.each do |node| initial = node['initial_member'] ? '(initial) ' : '' .choice "#{node['name']} #{initial}", node['name'] end end else self.name end end |
#aws_client ⇒ Object
4 5 6 |
# File 'lib/kontena/plugin/aws/prompts.rb', line 4 def aws_client @aws_client ||= Aws::EC2::Client.new(access_key_id: access_key, secret_access_key: secret_key, region: region) end |
#resolve_region(node) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/kontena/plugin/aws/prompts.rb', line 171 def resolve_region(node) return nil if node.nil? || node['labels'].nil? node['labels'].each do |label| tag, value = label.split('=', 2) return value if tag == 'region' end end |