Bug #1058

userid and vmid not available in EC2 templates

Added by olivier sallou over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:01/12/2012
Priority:NormalDue date:
Assignee:Daniel Molina% Done:

100%

Category:-
Target version:Release 3.4 - Beta
Resolution:worksforme Pull request:
Affected Versions:OpenNebula 3.0

Description

EC2QueryServer.rb sets erb_vm_info[:vm_id] and erb_user_name variable in run_instances but those variables are not in EC2 templates.

I tried using those variables in small.template.erb like:

<% if erb_vm_info[:user_data] >
CONTEXT = [
EC2_USER_DATA="<%= erb_vm_info[:user_data] %>",
TARGET="hdc",
HOSTNAME="VM-<%= erb_vm_info[:vm_id] %>",
USERNAME="<%= erb_user_name %>"
]
<
end %>

but variables remains empty.

History

#1 Updated by olivier sallou over 9 years ago

Just a fix on template, I had the <%= in my template but don't know why it is not in previous post. Here is my EC2 template that "fails".
erb_vm_info[:user_data] is set correctly, only vm_id and user_name fail (empty).

<% if erb_vm_info[:user_data] >
CONTEXT = [
EC2_USER_DATA="<%= erb_vm_info[:user_data] %>",
TARGET="hdb",
HOSTNAME="VM-<%= erb_vm_info[:vm_id] %>",
USERNAME="<%= erb_user_name %>"
]
<
end %>

In sunstone, here what appears in CONTEXT of generated VM:
EC2_USER_DATA bXl2YXIxPW15dmFsdWUxCm15dmFyMj1teXZhbHVlMgo=
USERNAME ""
TARGET hdb
HOSTNAME VM-

#2 Updated by Daniel Molina over 9 years ago

Those variables are defined after creating the VM, if you want to add this kind of information you have to use the OpenNebula CONTEXT syntax:
http://www.opennebula.org/documentation:rel3.2:template#context_section

FYI, Using User template variables are only available in the last OpenNebula 3.2 release.

Therefore your CONTEXT section should look like this

<% if erb_vm_info[:user_data] %>
  CONTEXT = [ 
    EC2_USER_DATA="<%= erb_vm_info[:user_data] %>",
    TARGET="hdb",
    HOSTNAME="VM-$VMID",
    USERNAME=$UID
  ]
<% end %>

#3 Updated by Ruben S. Montero over 9 years ago

  • Category set to 11
  • Status changed from New to Assigned
  • Assignee set to Daniel Molina
  • Target version set to Release 3.4 - Beta

#4 Updated by Daniel Molina over 9 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
  • Resolution set to worksforme

Also available in: Atom PDF