mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
(QENG-7530) Make VM names more human readable
Prior to this commit hostnames for VMs provisioned by vmpooler were 15 random characters. This is difficult for humans to tell apart. This commit updates the naming to use the `spicy-proton` gem to generate adjective noun pair names for the VMs, which I think would be easier for humans to tell apart, as well as fun and memorable to say. The random name should not exceed 15 characters in order to prevent issues with NETBIOS, etc as discussed in the attached ticket.
This commit is contained in:
parent
6cbc16cd80
commit
2ca6d49aeb
2 changed files with 7 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
require 'vmpooler/providers'
|
||||
require 'spicy-proton'
|
||||
|
||||
module Vmpooler
|
||||
class PoolManager
|
||||
|
|
@ -29,6 +30,9 @@ module Vmpooler
|
|||
|
||||
@vm_mutex = {}
|
||||
|
||||
# Name generator for generating host names
|
||||
@name_generator = Spicy::Proton.new
|
||||
|
||||
# load specified providers from config file
|
||||
load_used_providers
|
||||
end
|
||||
|
|
@ -265,8 +269,8 @@ module Vmpooler
|
|||
|
||||
def _clone_vm(pool_name, provider)
|
||||
# Generate a randomized hostname
|
||||
o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten
|
||||
new_vmname = $config[:config]['prefix'] + o[rand(25)] + (0...14).map { o[rand(o.length)] }.join
|
||||
random_name = [@name_generator.adjective(max: 7), @name_generator.noun(max: 7)].join('-')
|
||||
new_vmname = $config[:config]['prefix'] + random_name
|
||||
|
||||
# Add VM to Redis inventory ('pending' pool)
|
||||
$redis.sadd('vmpooler__pending__' + pool_name, new_vmname)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue