From c4700778e838cc54231ccfe5b45a5486de674c49 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Fri, 1 Dec 2017 11:28:51 +0100 Subject: [PATCH] B #1554: Fix EC2 deployment failure with custom USERDATA (#1556) (cherry picked from commit 59665e9f81132be4b3ee9fc64b3d4d81d20c0840) --- src/vmm_mad/remotes/ec2/ec2_driver.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index 83fc098a41..b9f88e81a0 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -321,22 +321,22 @@ class EC2Driver if !ec2_value(ec2_info, 'USERDATA') xml = OpenNebula::XMLElement.new xml.initialize_xml(xml_text, 'VM') - end - if xml.has_elements?('TEMPLATE/CONTEXT') - # Since there is only 1 level ',' will not be added - context_str = xml.template_like_str('TEMPLATE/CONTEXT') + if xml.has_elements?('TEMPLATE/CONTEXT') + # Since there is only 1 level ',' will not be added + context_str = xml.template_like_str('TEMPLATE/CONTEXT') - if xml['TEMPLATE/CONTEXT/TOKEN'] == 'YES' - # TODO use OneGate library - token_str = generate_onegate_token(xml) - if token_str - context_str << "\nONEGATE_TOKEN=\"#{token_str}\"" + if xml['TEMPLATE/CONTEXT/TOKEN'] == 'YES' + # TODO use OneGate library + token_str = generate_onegate_token(xml) + if token_str + context_str << "\nONEGATE_TOKEN=\"#{token_str}\"" + end end - end - userdata_key = EC2[:run][:args]["USERDATA"][:opt] - opts[userdata_key] = Base64.encode64(context_str) + userdata_key = EC2[:run][:args]["USERDATA"][:opt] + opts[userdata_key] = Base64.encode64(context_str) + end end instances = @ec2.create_instances(opts)