Merge pull request #341 from highb/imp/master/QENG-7530_human_readable_names

(QENG-7530) Make VM names more human readable
This commit is contained in:
mattkirby 2019-10-24 16:59:04 -07:00 committed by GitHub
commit 8a32ffb250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -12,6 +12,7 @@ gem 'net-ldap', '~> 0.16'
gem 'statsd-ruby', '~> 1.4.0', :require => 'statsd'
gem 'connection_pool', '~> 2.2'
gem 'nokogiri', '~> 1.8'
gem 'spicy-proton', '2.1.1'
group :development do
gem 'pry'

View file

@ -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)