mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
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:
commit
8a32ffb250
2 changed files with 7 additions and 2 deletions
1
Gemfile
1
Gemfile
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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