diff --git a/lib/vmpooler.rb b/lib/vmpooler.rb index a9eb4eb..70bb819 100644 --- a/lib/vmpooler.rb +++ b/lib/vmpooler.rb @@ -32,6 +32,7 @@ module Vmpooler parsed_config[:config]['task_limit'] ||= 10 parsed_config[:config]['vm_checktime'] ||= 15 parsed_config[:config]['vm_lifetime'] ||= 24 + parsed_config[:config]['prefix'] ||= '' # Create an index of pool aliases parsed_config[:pools].each do |pool| diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index eb9504f..7a2c7b5 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -189,7 +189,7 @@ module Vmpooler # Generate a randomized hostname o = [('a'..'z'), ('0'..'9')].map(&:to_a).flatten - vm['hostname'] = o[rand(25)] + (0...14).map { o[rand(o.length)] }.join + vm['hostname'] = $config[:config]['prefix'] + o[rand(25)] + (0...14).map { o[rand(o.length)] }.join # Add VM to Redis inventory ('pending' pool) $redis.sadd('vmpooler__pending__' + vm['template'], vm['hostname']) diff --git a/vmpooler.yaml.example b/vmpooler.yaml.example index 6e1c5d4..4c6ef24 100644 --- a/vmpooler.yaml.example +++ b/vmpooler.yaml.example @@ -161,6 +161,9 @@ # # - domain # If set, returns a top-level 'domain' JSON key in POST requests +# +# - prefix +# If set, prefixes all created VMs with this string. # Example: @@ -176,6 +179,7 @@ - 'created_by' - 'project' domain: 'company.com' + prefix: '' # :pools: #