servers info for stack

This commit is contained in:
amartynov 2015-08-18 20:01:17 +03:00
parent c55f69bd75
commit 15b66e116b
4 changed files with 17 additions and 19 deletions

View File

@ -20,9 +20,10 @@ module StackCommands
out.flush out.flush
break break
end end
out << "Next try...\n" out << "."
out.flush out.flush
end end
out << "\n"
rescue StandardError => e rescue StandardError => e
logger.error e.message logger.error e.message
out << "Error: #{e.message}\n" out << "Error: #{e.message}\n"

View File

@ -21,7 +21,7 @@ module Connectors
def stack(name, options={}) def stack(name, options={})
query = {'name' => name}.merge(options) query = {'name' => name}.merge(options)
bson = collection.find(query).to_a.first bson = collection.find(query).to_a.first
raise RecordNotFound.new("'#{id}' not found") unless bson raise RecordNotFound.new("'#{name}' not found") unless bson
model_from_bson(bson) model_from_bson(bson)
end end

View File

@ -255,21 +255,17 @@ module Provider
end end
def stack_servers(stack) def stack_servers(stack)
=begin
r = cloud_formation.list_stack_resources({'StackName' => stack.name}).body['StackResourceSummaries'] #stack_resources(stack)
pp r
s = r.map{|r| pp r; compute.servers.get(r['PhysicalResourceId'])}
pp s
s
=end
list = compute.describe_instances({'tag-key' => 'aws:cloudformation:stack-id', 'tag-value' => stack.id}).body["reservationSet"] list = compute.describe_instances({'tag-key' => 'aws:cloudformation:stack-id', 'tag-value' => stack.id}).body["reservationSet"]
pp list list.map do |l|
list.map{|l| pp l; convert_server(l["instancesSet"][0])} i = l["instancesSet"][0]
=begin {
list.select{|l| l["instancesSet"][0]["instanceState"]["name"].to_s != "terminated"}.map do |server| 'name' => i["tagSet"]["Name"],
'_id' => i["instanceId"],
'key_name' => i["keyName"],
'private_ip' => i["privateIpAddress"],
'public_ip' => i["ipAddress"],
}
end end
=end
end end
def create_default_stack_name s def create_default_stack_name s

View File

@ -55,10 +55,11 @@ class StackBootstrapWorker < Worker
'project' => project.id, 'project' => project.id,
'deploy_env' => deploy_env.identifier, 'deploy_env' => deploy_env.identifier,
'remote_user' => mongo.image(deploy_env.image).remote_user, 'remote_user' => mongo.image(deploy_env.image).remote_user,
'key' => extended_info.key_name || provider.ssh_key, 'key' => extended_info["key_name"] || provider.ssh_key,
'_id' => extended_info.id, '_id' => extended_info["id"],
'chef_node_name' => extended_info.name, 'chef_node_name' => extended_info["name"],
'private_ip' => extended_info.addresses.values.first.first['addr'], 'private_ip' => extended_info["private_ip"],
'public_ip' => extended_info["public_ip"],
'created_by' => stack.owner, 'created_by' => stack.owner,
'run_list' => stack.run_list || [], 'run_list' => stack.run_list || [],
'stack' => stack.id 'stack' => stack.id