1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-11 04:58:16 +03:00

Merge branch 'master' into feature-523

This commit is contained in:
Daniel Molina 2011-03-30 16:26:56 +02:00
commit 20d29f14ac
16 changed files with 130 additions and 185 deletions

View File

View File

@ -598,7 +598,6 @@ AUTH_ETC_FILES="src/authm_mad/auth_mad \
#-------------------------------------------------------------------------------
EXAMPLE_SHARE_FILES="share/examples/vm.template \
share/examples/vm.schema \
share/examples/private.net \
share/examples/public.net"

View File

@ -382,7 +382,7 @@ VM_HOOK = [
# on = "ERROR",
# command = "host_error.rb",
# arguments = "$HID -r n",
# remote = no ]
# remote = "no" ]
#-------------------------------------------------------------------------------
# This two hooks can be used to automatically delete or resubmit VMs that reach
# the "failed" state. This way, the administrator doesn't have to interact
@ -393,14 +393,14 @@ VM_HOOK = [
#
#VM_HOOK = [
# name = "on_failure_delete",
# on = "FAILURE",
# command = "onevm delete",
# on = "FAILED",
# command = "/usr/bin/env onevm delete",
# arguments = "$VMID" ]
#
#VM_HOOK = [
# name = "on_failure_resubmit",
# on = "FAILURE",
# command = "onevm resubmit",
# on = "FAILED",
# command = "/usr/bin/env onevm resubmit",
# arguments = "$VMID" ]
#-------------------------------------------------------------------------------

View File

@ -1,113 +0,0 @@
# ----------------------------------------------------------------------
# VM ATTRIBUTES
# Each attribute is labeled as Optional or Mandatory, also if it
# can be defined in the driver conf file is tagged with default. Finally
# the hypervisors that support the attribute are listed.
# ----------------------------------------------------------------------
#---------------------------------------
# Name of the VM
#---------------------------------------
NAME = "vm-example" # Optional, Default: one-$VMID, XEN, KVM
#---------------------------------------
# Capacity
#---------------------------------------
CPU = "amount_of_requested_CPU" # Mandatory, XEN, KVM
MEMORY = "amount_of_requested_MEM" # Mandatory, XEN, KVM
VCPU = "number of virtual cpus" # Optional, default, KVM, XEN
#---------------------------------------
# OS and boot options
#---------------------------------------
OS = [
kernel = "path_to_os_kernel", # XEN: Mandatory,default. KVM: Optional
initrd = "path_to_initrd_image", # XEN: Mandatory,default. KVM: Optional
kernel_cmd = "kernel_command_line", # Optional, default, KVM, XEN
root = "device to be mounted as root" # XEN: Mandatory,default. KVM: Optional
boot = "device to boot from" ] # KVM: Mandatory,default XEN: Optional
#---------------------------------------
# Features of the hypervisor
#---------------------------------------
FEATURES = [
pae = "yes|no", # Optional, KVM
acpi = "yes|no" ] # Optional, KVM
#---------------------------------------
# VM Disks
#---------------------------------------
DISK = [
type = "floppy|disk|cdrom|swap", #Optional, KVM ,XEN(only swap)
source = "path_to_disk_image_file|physical_dev", #Mandatory, XEN, KVM
size = "size_in_GB", #Optional, KVM, XEN (only for swap, defaults 1G)
target = "device_to_map_disk", #Mandatory, XEN, KVM
bus = "ide|scsi|virtio|xen", #Optional, KVM
readonly = "yes|no", #Optional, XEN, KVM
clone = "yes|no", #Optional, XEN, KVM
save = "path_to_disk_image_file" ] #Optional, XEN, KVM
#---------------------------------------
# Network Interfaces
#---------------------------------------
NIC = [
network = "name_of_the_virtual_network", #Optional, XEN, KVM
ip = "ip_address", #Optional, XEN, KVM
bridge = "name_of_bridge_to_bind_if", #Optional, XEN, KVM
target = "device_name_to_map_if", #Optional, KVM
mac = "HW_address", #Optional, XEN, KVM
script = "path_to_script_to_bring_up_if"] #Optional, KVM
#---------------------------------------
# I/O Interfaces
#---------------------------------------
INPUT = [ #Optional, KVM
type = "mouse|tablet",
bus = "usb|ps2|xen" ]
GRAPHICS = [ #Optional, XEN, KVM
type = "vnc|sdl",
listen = "IP-to-listen-on",
port = "port_for_VNC_server",
passwd = "passwor_for_VNC_server" ]
#---------------------------------------
# Raw Hypervisor attributes
#---------------------------------------
RAW = [ # Optional, KVM, XEN
type = "xen|kvm",
data = "raw_domain_configutarion"]
#---------------------------------------
# Context for the VM
# values can use:
# $<template_variable>
# $<template_variable>[<attribute>]
# $<template_variable>[<attribute>, <attribute2>=<value2>]
# $NETWORK[<vnet_attribute>, NAME=<vnet_name>]
#---------------------------------------
CONTEXT = [ # Optional, KVM, XEN
var_1 = "value_1",
var_n = "value_n",
files = "space-separated list of paths to include in context device",
target= "device to attach the context device" ]
#---------------------------------------
# Scheduler
# Requirements expressions can use:
# $<template_variable>
# $<template_variable>[<attribute>]
# $<template_variable>[<attribute>, <attribute2>=<value2>]
#---------------------------------------
REQUIREMENTS = "Bool_expression_for_reqs" #Optional
RANK = "Arith_expression_to_rank_hosts" #Optional

View File

@ -151,7 +151,7 @@ EOT
end
end
oneup_opts=OneUPParse.new([:list])
oneup_opts=OneUPParse.new([:list, :xml])
oneup_opts.parse(ARGV)
ops=oneup_opts.options

View File

@ -20,7 +20,6 @@ require 'erb'
require 'time'
require 'AWS'
require 'base64'
require 'CloudServer'
require 'ImageEC2'
@ -74,7 +73,7 @@ class EC2QueryServer < CloudServer
@server_host=@config[:server]
end
@server_port=@config[:port]
@server_port=@config[:port]
print_configuration
end
@ -89,20 +88,32 @@ class EC2QueryServer < CloudServer
def authenticate(params,env)
password = get_user_password(params['AWSAccessKeyId'])
return nil if !password
signature = case params['SignatureVersion']
when "1" then signature_version_1(params.clone, password)
when "2" then signature_version_2(params,
password,
env,
false)
end
signature = case params['SignatureVersion']
when "1" then signature_version_1(params.clone, password)
when "2" then signature_version_2(params,
password,
env,
true,
false)
end
if params['Signature']==signature
return one_client_user(params['AWSAccessKeyId'], password)
else
return nil
else
if params['SignatureVersion']=="2"
signature = signature_version_2(params,
password,
env,
false,
false)
if params['Signature']==signature
return one_client_user(params['AWSAccessKeyId'], password)
end
end
end
return nil
end
@ -143,7 +154,7 @@ class EC2QueryServer < CloudServer
image.enable
erb_version = params['Version']
erb_version = params['Version']
response = ERB.new(File.read(@config[:views]+"/register_image.erb"))
return response.result(binding), 200
@ -155,7 +166,7 @@ class EC2QueryServer < CloudServer
impool.info
erb_user_name = params['AWSAccessKeyId']
erb_version = params['Version']
erb_version = params['Version']
response = ERB.new(File.read(@config[:views]+"/describe_images.erb"))
return response.result(binding), 200
@ -177,7 +188,7 @@ class EC2QueryServer < CloudServer
end
# Get the image
tmp, img=params['ImageId'].split('-')
tmp, img=params['ImageId'].split('-')
# Build the VM
erb_vm_info=Hash.new
@ -203,19 +214,18 @@ class EC2QueryServer < CloudServer
erb_vm_info[:vm_id]=vm.id
erb_vm_info[:vm]=vm
erb_user_name = params['AWSAccessKeyId']
erb_version = params['Version']
erb_version = params['Version']
response = ERB.new(File.read(@config[:views]+"/run_instances.erb"))
return response.result(binding), 200
end
def describe_instances(params, one_client)
user_flag=-1
vmpool = VirtualMachinePool.new(one_client, user_flag)
vmpool.info
erb_version = params['Version']
erb_version = params['Version']
erb_user_name = params['AWSAccessKeyId']
response = ERB.new(File.read(@config[:views]+"/describe_instances.erb"))
@ -227,7 +237,7 @@ class EC2QueryServer < CloudServer
vmid=params['InstanceId.1']
vmid=params['InstanceId.01'] if !vmid
tmp, vmid=vmid.split('-') if vmid[0]==?i
tmp, vmid=vmid.split('-') if vmid[0]==?i
vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client)
rc = vm.info
@ -242,7 +252,7 @@ class EC2QueryServer < CloudServer
return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc)
erb_version = params['Version']
erb_version = params['Version']
response =ERB.new(File.read(@config[:views]+"/terminate_instances.erb"))
return response.result(binding), 200
@ -264,18 +274,19 @@ private
end
# Calculates signature version 2
def signature_version_2(params, secret_key, env, urlencode=true)
def signature_version_2(params, secret_key, env, includeport=true, urlencode=true)
signature_params = params.reject { |key,value|
key=='Signature' or key=='file' }
server_str = @server_host
server_str = server_str + ":" + @server_port unless %w{2008-12-01 2009-11-30}.include? params["Version"]
if includeport
server_str = @server_host + ':' + @server_port
else
server_str = @server_host
end
canonical_str = AWS.canonical_string(signature_params,
server_str,
env['REQUEST_METHOD'])
server_str,
env['REQUEST_METHOD'])
# Use the correct signature strength
sha_strength = case params['SignatureMethod']
@ -286,13 +297,13 @@ private
digest = OpenSSL::Digest::Digest.new(sha_strength)
b64hmac =
Base64.encode64(
Base64.encode64(
OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","")
if urlencode
return CGI::escape(b64hmac)
return CGI::escape(b64hmac)
else
return b64hmac
return b64hmac
end
end

View File

@ -97,6 +97,8 @@ void RequestManager::VirtualMachineAllocate::execute(
VirtualMachineAllocate::ipool->authorize_disk(vector,uid,&ar);
}
vectors.clear();
num = vm_template->get("NIC",vectors);
for(int i=0; i<num; i++)

View File

@ -20,13 +20,13 @@ module OpenNebulaJSON
class ClusterJSON < OpenNebula::Cluster
include JSONUtils
def allocate(template_json)
def create(template_json)
cluster_hash = parse_json(template_json,'cluster')
if OpenNebula.is_error?(cluster_hash)
return cluster_hash
end
super(cluster_hash['name'])
self.allocate(cluster_hash['name'])
end
def perform_action(template_json)

View File

@ -20,14 +20,16 @@ module OpenNebulaJSON
class HostJSON < OpenNebula::Host
include JSONUtils
def allocate(template_json)
def create(template_json)
host_hash = parse_json(template_json, 'host')
if OpenNebula.is_error?(host_hash)
return host_hash
end
super(host_hash['name'], host_hash['im_mad'], host_hash['vm_mad'],
host_hash['tm_mad'])
self.allocate(host_hash['name'],
host_hash['im_mad'],
host_hash['vm_mad'],
host_hash['tm_mad'])
end
def delete

View File

@ -20,18 +20,19 @@ module OpenNebulaJSON
class ImageJSON < OpenNebula::Image
include JSONUtils
def allocate(template_json)
def create(template_json)
image_hash = parse_json(template_json, 'image')
if OpenNebula.is_error?(image_hash)
return image_hash
end
if image_hash['image_raw']
super(image_hash['image_raw'])
template = image_hash['image_raw']
else
template = template_to_str(image_hash)
super(template)
end
OpenNebula::ImageRepository.new.create(self, template)
end
def perform_action(template_json)

View File

@ -20,14 +20,14 @@ module OpenNebulaJSON
class UserJSON < OpenNebula::User
include JSONUtils
def allocate(template_json)
def create(template_json)
user_hash = parse_json(template_json, 'user')
if OpenNebula.is_error?(user_hash)
return user_hash
end
password = Digest::SHA1.hexdigest(user_hash['password'])
super(user_hash['name'], password)
self.allocate(user_hash['name'], password)
end
def perform_action(template_json)

View File

@ -20,18 +20,19 @@ module OpenNebulaJSON
class VirtualMachineJSON < OpenNebula::VirtualMachine
include JSONUtils
def allocate(template_json)
def create(template_json)
vm_hash = parse_json(template_json, 'vm')
if OpenNebula.is_error?(vm_hash)
return vm_hash
end
if vm_hash['vm_raw']
super(vm_hash['vm_raw'])
template = vm_hash['vm_raw']
else
template = template_to_str(vm_hash)
super(template)
end
self.allocate(template)
end
def perform_action(template_json)

View File

@ -20,18 +20,19 @@ module OpenNebulaJSON
class VirtualNetworkJSON < OpenNebula::VirtualNetwork
include JSONUtils
def allocate(template_json)
def create(template_json)
vnet_hash = parse_json(template_json, 'vnet')
if OpenNebula.is_error?(vnet_hash)
return vnet_hash
end
if vnet_hash['vnet_raw']
super(vnet_hash['vnet_raw'])
template = vnet_hash['vnet_raw']
else
template = template_to_str(vnet_hash)
super(template)
end
self.allocate(template)
end
def perform_action(template_json)

View File

@ -115,7 +115,7 @@ class SunstoneServer
return [404, error.to_json]
end
rc = resource.allocate(template)
rc = resource.create(template)
if OpenNebula.is_error?(rc)
return [500, rc.to_json]
else

View File

@ -1258,6 +1258,9 @@ function createVMachineDialog(){
$('select#boot_method option').removeAttr("selected");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
$('div#disks select#BUS').append(
'<option id="virtio" value="virtio">virtio</option>');
$('input#TYPE', section_raw).val("kvm");
$(section_inputs).show();
@ -1281,8 +1284,9 @@ function createVMachineDialog(){
$('select#boot_method option#no_boot').html("Please choose");
$('.kernel, .bootloader', $('div#os_boot_opts')).hide();
$('div#disks select#BUS option#virtio').remove();
$('input#TYPE', section_raw).val("kvm");
$('input#TYPE', section_raw).val("xen");
$(section_inputs).hide(); //not present for xen
update_dynamic_css();
};
@ -1714,6 +1718,25 @@ function createVMachineDialog(){
$('fieldset',section_context).toggle();
return false;
});
$('#add_context_button', section_context).click(function(){
var name = $('#var_name',section_context).val();
var value = $('#var_value',section_context).val();
if (!name.length || !value.length) {
notifyError("Context variable name and value must be filled in");
return false;
}
option= '<option value=\''+value+'\' name=\''+name+'\'>'+
name+'='+value+
'</option>';
$('select#context_box',section_context).append(option);
return false;
});
$('#remove_context_button', section_context).click(function(){
box_remove_element(section_context,'#context_box');
return false;
});
};
@ -1852,7 +1875,8 @@ function createVMachineDialog(){
notifyError("There are mandatory fields missing in the OS Boot options section");
return false;
};
addSectionJSON(vm_json,scope);
vm_json["OS"] = {};
addSectionJSON(vm_json["OS"],scope);
//process disks
scope = section_disks;
@ -1874,11 +1898,15 @@ function createVMachineDialog(){
vm_json["GRAPHICS"] = {};
addSectionJSON(vm_json["GRAPHICS"],scope);
//context -> include
//context
scope = section_context;
var context = $('#CONTEXT',scope).val();
if (context)
vm_json["CONTEXT"] = context;
vm_json["CONTEXT"] = {};
var pair;
$('#context_box option',scope).each(function(){
name = $(this).attr("name");
value = $(this).val();
vm_json["CONTEXT"][name]=value;
});
//placement -> fetch with value
scope = section_placement;
@ -2102,7 +2130,7 @@ function createImageDialog(){
$('#create_image_form_manual').submit(function(){
template=$('#template',this).val();
OpenNebula.Image.create({data: template,success: addImageElement,error: onError});
OpenNebula.Image.register({data: template,success: addImageElement,error: onError});
$create_image_dialog.dialog('close');
return false;
});
@ -2446,7 +2474,7 @@ function imageElementArray(image_json){
return [
'<input type="checkbox" id="image_'+image.ID+'" name="selected_items" value="'+image.ID+'"/>',
image.ID,
image.USERNAME ? image.USERNAME : getUserName(image.ID),
image.USERNAME ? image.USERNAME : getUserName(image.UID),
image.NAME,
OpenNebula.Helper.image_type(image.TYPE),
pretty_time(image.REGTIME),

View File

@ -392,7 +392,7 @@ var create_vm_tmpl =
<label for="ARCH">Architecture:</label>\
<select id="ARCH" name="arch">\
<option value="i686">i686</option>\
<option value="x86-64">x86-64</option>\
<option value="x86_64">x86_64</option>\
</select>\
<div class="tip">CPU architecture to virtualization</div>\
</div>\
@ -436,9 +436,9 @@ var create_vm_tmpl =
<label for="BOOT">Boot:</label>\
<select id="BOOT" name="boot">\
<option value="hd">hd</option>\
<option value="hd">fd</option>\
<option value="hd">cdrom</option>\
<option value="hd">network</option>\
<option value="fd">fd</option>\
<option value="cdrom">cdrom</option>\
<option value="network">network</option>\
</select>\
<div class="tip">Boot device type</div>\
</div>\
@ -693,14 +693,27 @@ var create_vm_tmpl =
<!--context textarea? -->\
<div class="vm_section" id="context">\
<div class="show_hide" id="add_context_cb">\
<h3>Add context <a id="add_context" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
<h3>Add context variables <a id="add_context" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
</div>\
<fieldset><legend>Context</legend>\
<div class="vm_param kvm_opt xen_opt">\
<label for="CONTEXT">Context:</label>\
<input type="text" id="CONTEXT" name="context" />\
<!--<textarea id="CONTEXT" style="width:320px;height:15em;"></textarea>-->\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<label for="var_name">Name:</label>\
<input type="text" id="var_name" name="var_name" />\
<div class="tip">Name for the context variable</div>\
</div>\
<div class="vm_param kvm_opt xen_opt">\
<label for="var_value">Value:</label>\
<input type="text" id="var_value" name="var_value" />\
<div class="tip">Value of the context variable</div>\
</div>\
<div class="">\
<button class="add_remove_button add_button" id="add_context_button" value="add_context">Add</button>\
<button class="add_remove_button" id="remove_context_button" value="remove_input">Remove selected</button>\
<div class="clear"></div>\
<label for="context_box">Current variables:</label>\
<select id="context_box" name="context_box" style="width:150px;height:100px;" multiple>\
</select>\
</div>\
</fieldset>\
</div>\
\