#
# This template is processed by the OCCI Server to include specific data for the
# instance, you should not need to modify the ruby code.
# You can add common attributes for your cloud templates (e.g. OS)
#

<% if @vm_info['NAME'] %>
    NAME   = "<%= @vm_info['NAME'] %>"
<% end %>

<% @vm_info.each('DISK') do |disk| %>
    <% if disk.attr('STORAGE','href') %>
      DISK = [ IMAGE_ID = <%= disk.attr('STORAGE','href').split('/').last %>
           ]
    <% end %>
<% end %>

<% @vm_info.each('NIC') do |nic| %>
    <% if nic.attr('NETWORK','href') %>
      NIC = [ NETWORK_ID = <%= nic.attr('NETWORK','href').split('/').last %>
          <% if nic['IP'] %>
              ,IP = <%= nic['IP'] %>
          <% end %>
          ]
    <% end %>
<% end %>

<% if @vm_info.has_elements?('CONTEXT') %>
	CONTEXT = [
	<% first = true %>
	<% @vm_info.each('CONTEXT/*') do |cont| %>
	    <% if cont.text %>
    	    <% if first %>
    		    <%= cont.name %> = "<%= cont.text %>"
    		    <% first = false %>
    		<% else %>
    		    ,<%= cont.name %> = "<%= cont.text %>"
    		<% end %>
		<% end %>
	<% end %>
	]
<% end %>

INSTANCE_TYPE = <%= @itype %>