mirror of
https://github.com/puppetlabs/vmpooler-provider-ec2.git
synced 2026-01-26 02:28:40 -05:00
fix lifetime, fix name to use depending on domain set or not
This commit is contained in:
parent
c6f7991aac
commit
df3fc43289
1 changed files with 23 additions and 3 deletions
|
|
@ -192,6 +192,13 @@ module Vmpooler
|
||||||
raise("Instance creation not attempted, #{new_vmname} already exists") if get_vm(pool_name, new_vmname)
|
raise("Instance creation not attempted, #{new_vmname} already exists") if get_vm(pool_name, new_vmname)
|
||||||
|
|
||||||
subnet_id = get_subnet_id(pool_name)
|
subnet_id = get_subnet_id(pool_name)
|
||||||
|
domain_set = domain
|
||||||
|
if domain_set.nil?
|
||||||
|
name_to_use = new_vmname
|
||||||
|
else
|
||||||
|
name_to_use = "#{new_vmname}.#{domain_set}"
|
||||||
|
end
|
||||||
|
|
||||||
tag = [
|
tag = [
|
||||||
{
|
{
|
||||||
resource_type: 'instance', # accepts capacity-reservation, client-vpn-endpoint, customer-gateway, carrier-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, instance-event-window, internet-gateway, ipam, ipam-pool, ipam-scope, ipv4pool-ec2, ipv6pool-ec2, key-pair, launch-template, local-gateway, local-gateway-route-table, local-gateway-virtual-interface, local-gateway-virtual-interface-group, local-gateway-route-table-vpc-association, local-gateway-route-table-virtual-interface-group-association, natgateway, network-acl, network-interface, network-insights-analysis, network-insights-path, network-insights-access-scope, network-insights-access-scope-analysis, placement-group, prefix-list, replace-root-volume-task, reserved-instances, route-table, security-group, security-group-rule, snapshot, spot-fleet-request, spot-instances-request, subnet, subnet-cidr-reservation, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-connect-peer, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-endpoint, vpc-endpoint-service, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
|
resource_type: 'instance', # accepts capacity-reservation, client-vpn-endpoint, customer-gateway, carrier-gateway, dedicated-host, dhcp-options, egress-only-internet-gateway, elastic-ip, elastic-gpu, export-image-task, export-instance-task, fleet, fpga-image, host-reservation, image, import-image-task, import-snapshot-task, instance, instance-event-window, internet-gateway, ipam, ipam-pool, ipam-scope, ipv4pool-ec2, ipv6pool-ec2, key-pair, launch-template, local-gateway, local-gateway-route-table, local-gateway-virtual-interface, local-gateway-virtual-interface-group, local-gateway-route-table-vpc-association, local-gateway-route-table-virtual-interface-group-association, natgateway, network-acl, network-interface, network-insights-analysis, network-insights-path, network-insights-access-scope, network-insights-access-scope-analysis, placement-group, prefix-list, replace-root-volume-task, reserved-instances, route-table, security-group, security-group-rule, snapshot, spot-fleet-request, spot-instances-request, subnet, subnet-cidr-reservation, traffic-mirror-filter, traffic-mirror-session, traffic-mirror-target, transit-gateway, transit-gateway-attachment, transit-gateway-connect-peer, transit-gateway-multicast-domain, transit-gateway-route-table, volume, vpc, vpc-endpoint, vpc-endpoint-service, vpc-peering-connection, vpn-connection, vpn-gateway, vpc-flow-log
|
||||||
|
|
@ -206,7 +213,7 @@ module Vmpooler
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'lifetime', # required by AWS reaper
|
key: 'lifetime', # required by AWS reaper
|
||||||
value: get_current_lifetime(new_vmname)
|
value: get_max_lifetime
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'created_by', # required by AWS reaper
|
key: 'created_by', # required by AWS reaper
|
||||||
|
|
@ -226,7 +233,7 @@ module Vmpooler
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Name',
|
key: 'Name',
|
||||||
value: new_vmname
|
value: name_to_use
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -451,6 +458,12 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns max_lifetime_upper_limit in hours in the format Xh defaults to 12h
|
||||||
|
def get_max_lifetime
|
||||||
|
max_hours = global_config[:config]['max_lifetime_upper_limit'] || '12'
|
||||||
|
"#{max_hours}h"
|
||||||
|
end
|
||||||
|
|
||||||
def get_current_job_url(vm_name)
|
def get_current_job_url(vm_name)
|
||||||
@redis.with_metrics do |redis|
|
@redis.with_metrics do |redis|
|
||||||
job = redis.hget("vmpooler__vm__#{vm_name}", 'tag:jenkins_build_url') || ''
|
job = redis.hget("vmpooler__vm__#{vm_name}", 'tag:jenkins_build_url') || ''
|
||||||
|
|
@ -464,8 +477,15 @@ module Vmpooler
|
||||||
pool_configuration = pool_config(pool_name)
|
pool_configuration = pool_config(pool_name)
|
||||||
return nil if pool_configuration.nil?
|
return nil if pool_configuration.nil?
|
||||||
|
|
||||||
|
domain_set = domain
|
||||||
|
if domain_set.nil?
|
||||||
|
name_to_use = vm_object.private_dns_name
|
||||||
|
else
|
||||||
|
name_to_use = vm_object.tags.detect { |f| f.key == 'Name' }&.value
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
'name' => vm_object.tags.detect { |f| f.key == 'vm_name' }&.value,
|
'name' => name_to_use,
|
||||||
# 'hostname' => vm_object.hostname,
|
# 'hostname' => vm_object.hostname,
|
||||||
'template' => pool_configuration&.key?('template') ? pool_configuration['template'] : nil, # was expecting to get it from API, not from config, but this is what vSphere does too!
|
'template' => pool_configuration&.key?('template') ? pool_configuration['template'] : nil, # was expecting to get it from API, not from config, but this is what vSphere does too!
|
||||||
'poolname' => vm_object.tags.detect { |f| f.key == 'pool' }&.value,
|
'poolname' => vm_object.tags.detect { |f| f.key == 'pool' }&.value,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue