properly set chef node name for instances
This commit is contained in:
parent
9c21fc0fe4
commit
0dd550c37e
@ -254,21 +254,29 @@ module Provider
|
|||||||
cloud_formation.describe_stack_resources({'StackName' => stack.name}).body['StackResources']
|
cloud_formation.describe_stack_resources({'StackName' => stack.name}).body['StackResources']
|
||||||
end
|
end
|
||||||
|
|
||||||
def stack_resource(stack, resource_id)
|
# не работает, не используется
|
||||||
physical_id = fog_stack(stack).resources.get(resource_id).physical_resource_id
|
# def stack_resource(stack, resource_id)
|
||||||
compute.servers.get(physical_id)
|
# physical_id = fog_stack(stack).resources.get(resource_id).physical_resource_id
|
||||||
end
|
# compute.servers.get(physical_id)
|
||||||
|
# end
|
||||||
|
|
||||||
def stack_servers(stack)
|
def stack_servers(stack)
|
||||||
list = compute.describe_instances({'tag-key' => 'aws:cloudformation:stack-id', 'tag-value' => stack.id}).body["reservationSet"]
|
# orchestration.describe_stack_resources возвращает мало информации
|
||||||
list.map do |l|
|
list = compute.describe_instances(
|
||||||
i = l["instancesSet"][0]
|
'tag-key' => 'aws:cloudformation:stack-id',
|
||||||
|
'tag-value' => stack.id
|
||||||
|
).body["reservationSet"]
|
||||||
|
|
||||||
|
list.map do |instance|
|
||||||
|
info = instance["instancesSet"][0]
|
||||||
|
instance_logical_name = info["tagSet"]["Name"] || info['tagSet']['aws:cloudformation:logical-id']
|
||||||
{
|
{
|
||||||
'name' => i["tagSet"]["Name"],
|
# 'name' => info["tagSet"]["Name"],
|
||||||
'id' => i["instanceId"],
|
'name' => [stack.name, instance_logical_name].join('-'),
|
||||||
'key_name' => i["keyName"],
|
'id' => info["instanceId"],
|
||||||
'private_ip' => i["privateIpAddress"],
|
'key_name' => info["keyName"],
|
||||||
'public_ip' => i["ipAddress"],
|
'private_ip' => info["privateIpAddress"],
|
||||||
|
'public_ip' => info["ipAddress"],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -277,6 +285,7 @@ module Provider
|
|||||||
"stack-#{self.ssh_key}-#{s.project}-#{s.deploy_env}-#{Time.now.to_i}".gsub('_', '-')
|
"stack-#{self.ssh_key}-#{s.project}-#{s.deploy_env}-#{Time.now.to_i}".gsub('_', '-')
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
|
|
||||||
def convert_groups list
|
def convert_groups list
|
||||||
res = {}
|
res = {}
|
||||||
list.each do |g|
|
list.each do |g|
|
||||||
@ -327,5 +336,9 @@ module Provider
|
|||||||
r
|
r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def orchestration
|
||||||
|
@orchestration ||= Fog::AWS::CloudFormation.new(connection_options)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -246,6 +246,7 @@ module Provider
|
|||||||
end
|
end
|
||||||
|
|
||||||
def stack_resource(stack, resource_id)
|
def stack_resource(stack, resource_id)
|
||||||
|
fog_stack = orchestration.stacks.get(stack.name, stack.id)
|
||||||
physical_id = fog_stack(stack).resources.get(resource_id).physical_resource_id
|
physical_id = fog_stack(stack).resources.get(resource_id).physical_resource_id
|
||||||
compute.servers.get(physical_id)
|
compute.servers.get(physical_id)
|
||||||
end
|
end
|
||||||
@ -287,7 +288,7 @@ module Provider
|
|||||||
end
|
end
|
||||||
|
|
||||||
def orchestration
|
def orchestration
|
||||||
@connection ||= Fog::Orchestration.new(connection_options)
|
@orchestration ||= Fog::Orchestration.new(connection_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user