mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #200 Fixed minor Errors in OCCI
This commit is contained in:
parent
c0149a5bb1
commit
478d5b3b5f
@ -14,14 +14,10 @@ PORT=4567
|
||||
|
||||
# Configuration for the image repository
|
||||
DATABASE=<ONELOCATION>/var/occi.db
|
||||
IMAGE_DIR=<PATH TO EXISTING IMAGE DIRECTORY>
|
||||
|
||||
# Configuration for OpenNebula's Virtual Networks
|
||||
BRIDGE=<NAME OF DEFAULT BRIDGE>
|
||||
|
||||
# Default format for FS
|
||||
FS_FORMAT=ext3
|
||||
|
||||
# VM types allowed and its template file (inside templates directory)
|
||||
VM_TYPE=[NAME=small, TEMPLATE=small.erb]
|
||||
VM_TYPE=[NAME=medium, TEMPLATE=medium.erb]
|
||||
|
@ -7,11 +7,11 @@ NAME = <%= vm_info['NAME'] %>
|
||||
<% vm_info['DISK'].each do |disk| %>
|
||||
<% if disk['STORAGE'] && disk['STORAGE']['href'] %>
|
||||
DISK = [ IMAGE_ID = <%= disk['STORAGE']['href'].split('/').last %>
|
||||
<% if disk['OVERWRITE'] %>
|
||||
OVERWRITE = yes
|
||||
<% if disk.key?('OVERWRITE') %>
|
||||
,OVERWRITE = "yes"
|
||||
<% end %>
|
||||
<% if disk['SAVE_AS'] %>
|
||||
SAVE_AS = "<%= disk['SAVE_AS'] %>"
|
||||
,SAVE_AS = "<%= disk['SAVE_AS'] %>"
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
@ -21,14 +21,13 @@ NAME = <%= vm_info['NAME'] %>
|
||||
<% if vm_info['NIC'] %>
|
||||
<% vm_info['NIC'].each do |nic| %>
|
||||
<% if nic['NETWORK'] && nic['NETWORK']['href'] %>
|
||||
NIC = [ NETWORK_ID = <%= nic['NETWORK']['href'].split('/').last %>,
|
||||
NIC = [ NETWORK_ID = <%= nic['NETWORK']['href'].split('/').last %>
|
||||
<% if nic['IP'] %>
|
||||
IP = <%= nic['IP'] %>
|
||||
,IP = <%= nic['IP'] %>
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
INSTANCE_TYPE = <%= vm_info['INSTANCE_TYPE']%>
|
||||
|
||||
INSTANCE_TYPE = <%= vm_info['INSTANCE_TYPE']%>
|
@ -1,55 +1,33 @@
|
||||
NAME = <%= vm_info['NAME']%>
|
||||
|
||||
CPU = 4
|
||||
MEMORY = 4096
|
||||
|
||||
OS = [ kernel = /vmlinuz,
|
||||
initrd = /initrd.img,
|
||||
root = sda1,
|
||||
kernel_cmd = "ro xencons=tty console=tty1"]
|
||||
|
||||
<% if vm_info['STORAGE']
|
||||
vm_info['STORAGE'].each do |key, image|
|
||||
image=[image].flatten
|
||||
case key
|
||||
when "SWAP"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "swap",
|
||||
size=<%= img['size']%>,
|
||||
target=<%= img['dev']%> ]
|
||||
<%
|
||||
end
|
||||
when "DISK"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "disk",
|
||||
target=<%= img['dev']%>,
|
||||
source=<%= img['source']%>,
|
||||
image_id=<%= img['image']%> ]
|
||||
<%
|
||||
end
|
||||
when "FS"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "fs",
|
||||
target=<%= img['dev']%>,
|
||||
size=<%= img['size']%>,
|
||||
format=<%= @config[:fs_format]||"ext3"%> ]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if vm_info['NETWORK'] and vm_info['NETWORK']['NIC'] %>
|
||||
<% vm_info['NETWORK']['NIC'].each do |nic| %>
|
||||
NIC = [
|
||||
<% if nic['ip'] %>
|
||||
IP=<%= nic['ip'] %>,
|
||||
<% end %>
|
||||
NETWORK="<%= nic['network']%>",
|
||||
NETWORK_ID=<%= nic['network_id'] %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
INSTANCE_TYPE = <%= vm_info[:instance_type ]%>
|
||||
NAME = <%= vm_info['NAME'] %>
|
||||
|
||||
<% if vm_info['DISK'] %>
|
||||
<% vm_info['DISK'].each do |disk| %>
|
||||
<% if disk['STORAGE'] && disk['STORAGE']['href'] %>
|
||||
DISK = [ IMAGE_ID = <%= disk['STORAGE']['href'].split('/').last %>
|
||||
<% if disk.key?('OVERWRITE') %>
|
||||
,OVERWRITE = "yes"
|
||||
<% end %>
|
||||
<% if disk['SAVE_AS'] %>
|
||||
,SAVE_AS = "<%= disk['SAVE_AS'] %>"
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if vm_info['NIC'] %>
|
||||
<% vm_info['NIC'].each do |nic| %>
|
||||
<% if nic['NETWORK'] && nic['NETWORK']['href'] %>
|
||||
NIC = [ NETWORK_ID = <%= nic['NETWORK']['href'].split('/').last %>
|
||||
<% if nic['IP'] %>
|
||||
,IP = <%= nic['IP'] %>
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
INSTANCE_TYPE = <%= vm_info['INSTANCE_TYPE']%>
|
@ -1,55 +1,33 @@
|
||||
NAME = <%= vm_info['NAME']%>
|
||||
|
||||
CPU = 1
|
||||
MEMORY = 1024
|
||||
|
||||
OS = [ kernel = /vmlinuz,
|
||||
initrd = /initrd.img,
|
||||
root = sda1,
|
||||
kernel_cmd = "ro xencons=tty console=tty1"]
|
||||
|
||||
<% if vm_info['STORAGE']
|
||||
vm_info['STORAGE'].each do |key, image|
|
||||
image=[image].flatten
|
||||
case key
|
||||
when "SWAP"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "swap",
|
||||
size=<%= img['size']%>,
|
||||
target=<%= img['dev']%> ]
|
||||
<%
|
||||
end
|
||||
when "DISK"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "disk",
|
||||
target=<%= img['dev']%>,
|
||||
source=<%= img['source']%>,
|
||||
image_id=<%= img['image']%> ]
|
||||
<%
|
||||
end
|
||||
when "FS"
|
||||
image.each do |img|
|
||||
%>
|
||||
DISK = [ type = "fs",
|
||||
target=<%= img['dev']%>,
|
||||
size=<%= img['size']%>,
|
||||
format=<%= @config[:fs_format]||"ext3"%> ]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if vm_info['NETWORK'] and vm_info['NETWORK']['NIC'] %>
|
||||
<% vm_info['NETWORK']['NIC'].each do |nic| %>
|
||||
NIC = [
|
||||
<% if nic['ip'] %>
|
||||
IP=<%= nic['ip'] %>,
|
||||
<% end %>
|
||||
NETWORK="<%= nic['network']%>",
|
||||
NETWORK_ID=<%= nic['network_id'] %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
INSTANCE_TYPE = <%= vm_info[:instance_type ]%>
|
||||
NAME = <%= vm_info['NAME'] %>
|
||||
|
||||
<% if vm_info['DISK'] %>
|
||||
<% vm_info['DISK'].each do |disk| %>
|
||||
<% if disk['STORAGE'] && disk['STORAGE']['href'] %>
|
||||
DISK = [ IMAGE_ID = <%= disk['STORAGE']['href'].split('/').last %>
|
||||
<% if disk.key?('OVERWRITE') %>
|
||||
,OVERWRITE = "yes"
|
||||
<% end %>
|
||||
<% if disk['SAVE_AS'] %>
|
||||
,SAVE_AS = "<%= disk['SAVE_AS'] %>"
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if vm_info['NIC'] %>
|
||||
<% vm_info['NIC'].each do |nic| %>
|
||||
<% if nic['NETWORK'] && nic['NETWORK']['href'] %>
|
||||
NIC = [ NETWORK_ID = <%= nic['NETWORK']['href'].split('/').last %>
|
||||
<% if nic['IP'] %>
|
||||
,IP = <%= nic['IP'] %>
|
||||
<% end %>
|
||||
]
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
INSTANCE_TYPE = <%= vm_info['INSTANCE_TYPE']%>
|
@ -21,22 +21,15 @@ include OpenNebula
|
||||
class ImagePoolOCCI < ImagePool
|
||||
OCCI_IMAGE_POOL = %q{
|
||||
<STORAGE_COLLECTION>
|
||||
<% if pool_hash['IMAGE_POOL'] && pool_hash['IMAGE_POOL']['IMAGE'] %>
|
||||
<% imagelist=[pool_hash['IMAGE_POOL']['IMAGE']].flatten %>
|
||||
<% imagelist.each{ |image| %>
|
||||
<STORAGE href="<%= base_url %>/storage/<%= image['ID'] %>"/>
|
||||
<% self.each{ |im| %>
|
||||
<STORAGE href="<%= base_url %>/storage/<%= im.id.to_s %>" name="<%= im.name %>"/>
|
||||
<% } %>
|
||||
<% end %>
|
||||
</STORAGE_COLLECTION>
|
||||
}
|
||||
|
||||
|
||||
# Creates the OCCI representation of a Virtual Machine Pool
|
||||
def to_occi(base_url)
|
||||
pool_hash = self.to_hash
|
||||
return pool_hash, 500 if OpenNebula.is_error?(pool_hash)
|
||||
|
||||
begin
|
||||
def to_occi(base_url)begin
|
||||
occi = ERB.new(OCCI_IMAGE_POOL)
|
||||
occi_text = occi.result(binding)
|
||||
rescue Exception => e
|
||||
|
@ -30,11 +30,10 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
<% if template['DISK'] %>
|
||||
<% template['DISK'].each do |disk| %>
|
||||
<DISK>
|
||||
<STORAGE href="<%= base_url %>/storage/<%= disk['IMAGE_ID'] %>"/>
|
||||
<NAME><%= disk['NAME'] %></NAME>
|
||||
<STORAGE href="<%= base_url %>/storage/<%= disk['IMAGE_ID'] %>" name="<%= disk['IMAGE'] %>"/>
|
||||
<TYPE><%= disk['TYPE'] %></TYPE>
|
||||
<TARGET><%= disk['TARGET'] %></TARGET>
|
||||
<% if disk['CLONE'] %>
|
||||
<% if disk['CLONE']=='NO' %>
|
||||
<OVERWRITE/>
|
||||
<% end %>
|
||||
<% if disk['SAVE_AS'] %>
|
||||
@ -46,10 +45,13 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
<% if template['NIC'] %>
|
||||
<% template['NIC'].each do |nic| %>
|
||||
<NIC>
|
||||
<NETWORK href="<%= base_url %>/network/<%= nic['NETWORK_ID'] %>"/>
|
||||
<NETWORK href="<%= base_url %>/network/<%= nic['NETWORK_ID'] %>" name="<%= nic['NETWORK'] %>"/>
|
||||
<% if nic['IP'] %>
|
||||
<IP><%= nic['IP'] %></IP>
|
||||
<% end %>
|
||||
<% if nic['MAC'] %>
|
||||
<MAC><%= nic['MAC'] %></MAC>
|
||||
<% end %>
|
||||
</NIC>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -21,21 +21,15 @@ include OpenNebula
|
||||
class VirtualMachinePoolOCCI < VirtualMachinePool
|
||||
OCCI_VM_POOL = %q{
|
||||
<COMPUTE_COLLECTION>
|
||||
<% if pool_hash['VM_POOL'] && pool_hash['VM_POOL']['VM'] %>
|
||||
<% vmlist=[pool_hash['VM_POOL']['VM']].flatten %>
|
||||
<% vmlist.each{ |vm| %>
|
||||
<COMPUTE href="<%= base_url %>/compute/<%= vm['ID'] %>"/>
|
||||
<% self.each{ |vm| %>
|
||||
<COMPUTE href="<%= base_url %>/compute/<%= vm.id.to_s %>" name="<%= vm.name %>"/>
|
||||
<% } %>
|
||||
<% end %>
|
||||
</COMPUTE_COLLECTION>
|
||||
}
|
||||
|
||||
|
||||
# Creates the OCCI representation of a Virtual Machine Pool
|
||||
def to_occi(base_url)
|
||||
pool_hash = self.to_hash
|
||||
return pool_hash, 500 if OpenNebula.is_error?(pool_hash)
|
||||
|
||||
begin
|
||||
occi = ERB.new(OCCI_VM_POOL)
|
||||
occi_text = occi.result(binding)
|
||||
|
@ -21,22 +21,15 @@ include OpenNebula
|
||||
class VirtualNetworkPoolOCCI < VirtualNetworkPool
|
||||
OCCI_NETWORK_POOL = %q{
|
||||
<NETWORK_COLLECTION>
|
||||
<% if pool_hash['VNET_POOL'] && pool_hash['VNET_POOL']['VNET'] %>
|
||||
<% vnlist=[pool_hash['VNET_POOL']['VNET']].flatten %>
|
||||
<% vnlist.each{ |vn| %>
|
||||
<NETWORK href="<%= base_url %>/network/<%= vn['ID'] %>"/>
|
||||
<% self.each{ |vn| %>
|
||||
<NETWORK href="<%= base_url %>/network/<%= vn.id.to_s %>" name="<%= vn.name %>"/>
|
||||
<% } %>
|
||||
<% end %>
|
||||
</NETWORK_COLLECTION>
|
||||
}
|
||||
|
||||
|
||||
# Creates the OCCI representation of a Virtual Machine Pool
|
||||
def to_occi(base_url)
|
||||
pool_hash = self.to_hash
|
||||
return pool_hash, 500 if OpenNebula.is_error?(pool_hash)
|
||||
|
||||
begin
|
||||
def to_occi(base_url)begin
|
||||
occi = ERB.new(OCCI_NETWORK_POOL)
|
||||
occi_text = occi.result(binding)
|
||||
rescue Exception => e
|
||||
|
Loading…
x
Reference in New Issue
Block a user