mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #2765: Configurable setting to render names assigned to VMs with oneflow
This commit is contained in:
parent
3442350cb2
commit
f3564f715e
@ -46,6 +46,15 @@
|
||||
:action_number: 1
|
||||
:action_period: 60
|
||||
|
||||
# Default name for the Virtual Machines created by oneflow. You can use any
|
||||
# of the following placeholders:
|
||||
# $SERVICE_ID
|
||||
# $SERVICE_NAME
|
||||
# $ROLE_NAME
|
||||
# $VM_NUMBER
|
||||
|
||||
:vm_name_template: '$ROLE_NAME_$VM_NUMBER_(service_$SERVICE_ID)'
|
||||
|
||||
#############################################################
|
||||
# Auth
|
||||
#############################################################
|
||||
|
@ -239,7 +239,12 @@ module OpenNebula
|
||||
@body['last_vmname'] ||= 0
|
||||
|
||||
n_nodes.times { |i|
|
||||
vm_name = "#{@body['name']}_#{@body['last_vmname']}_(service_#{@service.id()})"
|
||||
vm_name = @@vm_name_template
|
||||
.gsub("$SERVICE_ID", @service.id().to_s)
|
||||
.gsub("$SERVICE_NAME", @service.name().to_s)
|
||||
.gsub("$ROLE_NAME", name().to_s)
|
||||
.gsub("$VM_NUMBER", @body['last_vmname'].to_s)
|
||||
|
||||
@body['last_vmname'] += 1
|
||||
|
||||
template_id = @body['vm_template']
|
||||
@ -543,6 +548,10 @@ module OpenNebula
|
||||
@@default_shutdown = shutdown_action
|
||||
end
|
||||
|
||||
def self.init_default_vm_name_template(vm_name_template)
|
||||
@@vm_name_template = vm_name_template
|
||||
end
|
||||
|
||||
# Updates the role
|
||||
# @param [Hash] template
|
||||
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
||||
|
@ -49,6 +49,8 @@ require 'CloudServer'
|
||||
require 'models'
|
||||
require 'log'
|
||||
|
||||
DEFAULT_VM_NAME_TEMPLATE = '$ROLE_NAME_$VM_NUMBER_(service_$SERVICE_ID)'
|
||||
|
||||
##############################################################################
|
||||
# Configuration
|
||||
##############################################################################
|
||||
@ -123,6 +125,9 @@ end
|
||||
Role.init_default_cooldown(conf[:default_cooldown])
|
||||
Role.init_default_shutdown(conf[:shutdown_action])
|
||||
|
||||
conf[:vm_name_template] ||= DEFAULT_VM_NAME_TEMPLATE
|
||||
Role.init_default_vm_name_template(conf[:vm_name_template])
|
||||
|
||||
##############################################################################
|
||||
# LCM thread
|
||||
##############################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user