proper names for instances in groups
This commit is contained in:
parent
a9ad1ca8de
commit
0ce0207fdf
@ -267,13 +267,14 @@ module Provider
|
|||||||
'tag-value' => stack.id
|
'tag-value' => stack.id
|
||||||
).body["reservationSet"]
|
).body["reservationSet"]
|
||||||
|
|
||||||
|
# В ресурсах могут лежать не только конкретные инстансы, но и MasterNodesGroup, которые управляют
|
||||||
|
# несколькими инстансами. Обрабатываем эту ситуацию.
|
||||||
instances = resources.map { |resource| resource["instancesSet"] }.flatten
|
instances = resources.map { |resource| resource["instancesSet"] }.flatten
|
||||||
|
|
||||||
instances.map do |instance|
|
instances.map do |instance|
|
||||||
logical_name = instance["tagSet"]["Name"] || instance['tagSet']['aws:cloudformation:logical-id']
|
|
||||||
{
|
{
|
||||||
# 'name' => instance["tagSet"]["Name"],
|
# 'name' => instance["tagSet"]["Name"],
|
||||||
'name' => [stack.name, logical_name].join('-'),
|
'name' => [stack.name, instance_name(instance)].join('-'),
|
||||||
'id' => instance["instanceId"],
|
'id' => instance["instanceId"],
|
||||||
'key_name' => instance["keyName"],
|
'key_name' => instance["keyName"],
|
||||||
'private_ip' => instance["privateIpAddress"],
|
'private_ip' => instance["privateIpAddress"],
|
||||||
@ -341,5 +342,14 @@ module Provider
|
|||||||
@orchestration ||= Fog::AWS::CloudFormation.new(connection_options)
|
@orchestration ||= Fog::AWS::CloudFormation.new(connection_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def instance_name(instance)
|
||||||
|
return instance["tagSet"]["Name"] if instance["tagSet"]["Name"]
|
||||||
|
if instance['tagSet']['aws:autoscaling:groupName']
|
||||||
|
instance["instanceId"]
|
||||||
|
else
|
||||||
|
instance['tagSet']['aws:cloudformation:logical-id']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user