mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
parent
7a9a6f87b6
commit
6b11d98f3f
@ -193,6 +193,35 @@ class OneFlowTemplateHelper < OpenNebulaHelper::OneHelper
|
||||
ret
|
||||
end
|
||||
|
||||
# Get custom role attributes values from user
|
||||
#
|
||||
# @param role [Hash] Service role with custom attributes
|
||||
#
|
||||
# @return [Hash] Role with custom attributes values
|
||||
def custom_role_attrs(roles)
|
||||
return if roles.nil? || roles.empty?
|
||||
|
||||
ret = {}
|
||||
role_with_custom_attrs = false
|
||||
|
||||
roles.each do |role|
|
||||
next unless role.key?('custom_attrs')
|
||||
|
||||
####################################################################
|
||||
# Display Role Information
|
||||
####################################################################
|
||||
header = "> Please insert the user inputs for the role \"#{role['name']}\""
|
||||
puts header
|
||||
|
||||
role.merge!(custom_attrs(role['custom_attrs']))
|
||||
role_with_custom_attrs = true
|
||||
end
|
||||
|
||||
ret['roles'] = roles if role_with_custom_attrs
|
||||
|
||||
ret
|
||||
end
|
||||
|
||||
def networks(vnets)
|
||||
return unless vnets
|
||||
|
||||
|
@ -61,6 +61,7 @@ require 'command_parser'
|
||||
require 'opennebula/oneflow_client'
|
||||
require 'cli_helper'
|
||||
require 'one_helper/oneflowtemplate_helper'
|
||||
require 'one_helper/onetemplate_helper'
|
||||
|
||||
USER_AGENT = 'CLI'
|
||||
|
||||
@ -253,14 +254,18 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
break
|
||||
end
|
||||
|
||||
params['merge_template'] = {}
|
||||
body = JSON.parse(response.body)['DOCUMENT']['TEMPLATE']['BODY']
|
||||
|
||||
params['merge_template'] = helper.custom_attrs(
|
||||
body['custom_attrs']
|
||||
)
|
||||
# Check global custom attributes
|
||||
custom_attrs = helper.custom_attrs(body['custom_attrs'])
|
||||
params['merge_template'].merge!(custom_attrs) unless custom_attrs.nil?
|
||||
|
||||
params['merge_template'] = {} unless params['merge_template']
|
||||
# Check role level custom attributes
|
||||
custom_role_attrs = helper.custom_role_attrs(body['roles'])
|
||||
params['merge_template'].merge!(custom_role_attrs) unless custom_role_attrs.nil?
|
||||
|
||||
# Check vnets attributes
|
||||
vnets = helper.networks(body['networks'])
|
||||
params['merge_template'].merge!(vnets) unless vnets.nil?
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user