1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Merge remote-tracking branch 'upstream/master' into feature-1112

This commit is contained in:
Hector Sanjuan 2012-03-07 12:55:31 +01:00
commit d2aed68643
34 changed files with 469 additions and 446 deletions

View File

@ -1441,6 +1441,9 @@ if [ "$UNINSTALL" = "no" ] ; then
for d in $MAKE_DIRS; do
mkdir -p $DESTDIR$d
done
# Remove old migrators
rm $LIB_LOCATION/ruby/onedb/*.rb
fi
# --- Install/Uninstall files ---

View File

@ -61,11 +61,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
helper.create_resource(args[0], options)
end
command :show, 'Show information of a particular VDC', :vdcid do
command :show, 'Show information of a particular VDC', :vdcid,
:options => OZonesHelper::JSON do
helper.show_resource(args[0],options)
end
command :list, 'Lists VDCs in the pool' do
command :list, 'Lists VDCs in the pool', :options => OZonesHelper::JSON do
helper.list_pool(options)
end

View File

@ -71,8 +71,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
onezone show 4 host
EOT
command :show, show_desc, :zoneid, [:resource, nil] do
zone=helper.show_resource(args[0],options)[1]
command :show, show_desc, :zoneid, [:resource, nil],
:options => OZonesHelper::JSON do
zone = helper.show_resource(args[0],options)[1]
#manually print here
if options[:json]
puts zone
end
if !args[1] then next 0 end
case args[1]
when "host"
@ -87,35 +95,41 @@ cmd=CommandParser::CmdParser.new(ARGV) do
aux_helper = OneTemplateHelper.new
when "user"
aux_helper = OneUserHelper.new
else
puts "\n:!: Pool #{args[1]} doesn't exist or is not supported\n\n"
next 0
else
puts "\n:!: Pool #{args[1]} doesn't exist or is not supported\n\n"
next 0
end
pool_hash_data = helper.get_resource_pool("zone", zone[:ID], args[1])
pool_hash_data = helper.get_resource_pool("zone", args[0], args[1],
options)
if pool_hash_data[0] != 0
puts "\nError retrieving information for pool #{args[1]}. Reason: " + pool_hash_data[1] + "\n\n"
if pool_hash_data[0] != 0
puts "\nError retrieving information for pool #{args[1]}. Reason: " + pool_hash_data[1] + "\n\n"
next 0
end
end
if !pool_hash_data[1]
next 0
if !pool_hash_data[1]
next 0
end
if options[:json]
puts pool_hash_data[1]
next 0
end
if pool_hash_data[1].is_a?(Hash)
pool_hash_data[1]=[Hash.transform_keys_to_strings(pool_hash_data[1])]
else
pool_hash_data[1].each{|hash| hash.replace(Hash.transform_keys_to_strings(hash))}
else
pool_hash_data[1].each{|hash| hash.replace(Hash.transform_keys_to_strings(hash))}
end
table = aux_helper.format_pool(options)
table.show(pool_hash_data[1])
table.show(pool_hash_data[1])
0
end
command :list, 'Lists Zones in the pool' do
command :list, 'Lists Zones in the pool', :options=>OZonesHelper::JSON do
helper.list_pool(options)
end

View File

@ -18,6 +18,15 @@ require 'zona'
module OZonesHelper
#Specific ozones CLI options
JSON={
:name => "json",
:short => "-j",
:large => "--json",
:description => "Show the resource in JSON format"
}
class OZHelper
def initialize(user=nil, pass=nil, endpoint_str=nil,
timeout=nil, debug_flag=true)
@ -45,8 +54,13 @@ module OZonesHelper
if Zona::is_error?(rc)
[-1, rc.message]
else
pool=Zona::OZonesJSON.parse_json(rc.body, kind.upcase + "_POOL")
format_pool(pool, options)
if options[:json]
[0, rc.body]
else
resource_str = kind.upcase + "_POOL"
pool=Zona::OZonesJSON.parse_json(rc.body, resource_str)
format_pool(pool, options)
end
end
end
@ -56,18 +70,26 @@ module OZonesHelper
if Zona::is_error?(rc)
[-1, rc.message]
else
resource=Zona::OZonesJSON.parse_json(rc.body, kind.upcase)
format_resource(resource, options)
if options[:json]
[0, rc.body]
else
resource=Zona::OZonesJSON.parse_json(rc.body, kind.upcase)
format_resource(resource, options)
end
end
end
def get_resource_pool(kind, id, pool)
def get_resource_pool(kind, id, pool, options)
rc = @client.get_resource_pool(kind, id, pool)
if Zona::is_error?(rc)
[-1, rc.message]
else
[0 , Zona::OZonesJSON.parse_json(rc.body, pool.upcase+"_POOL")[pool.upcase.to_sym]]
if options[:json]
[0, rc.body]
else
[0 , Zona::OZonesJSON.parse_json(rc.body, pool.upcase+"_POOL")[pool.upcase.to_sym]]
end
end
end

View File

@ -282,12 +282,14 @@ function updateVDCInfo(req,vdc_json){
var zone_host = "";
var zone_port = "";
var sun_link = "";
var self_link = "";
var zone_match = zone_endpoint.match(/^https?:\/\/([\w.-]+):(\d+)\/([\W\w]+)$/);
if (zone_match){
zone_host = zone_match[1];
zone_port = zone_match[2];
sun_link = "http://" + zone_host +"/sunstone_"+ vdc.NAME+"/";
self_link = "http://" + zone_host +"/self_"+ vdc.NAME+"/";
};
var info_tab = {
@ -330,6 +332,10 @@ function updateVDCInfo(req,vdc_json){
<td class="key_td">Sunstone public link</td>\
<td class="value_td">'+(sun_link.length? '<a href="'+sun_link+'" target="_blank">'+sun_link+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a>' : "")+'</td>\
</tr>\
<tr>\
<td class="key_td">SelfService public link</td>\
<td class="value_td">'+(self_link.length? '<a href="'+self_link+'" target="_blank">'+self_link+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a>' : "")+'</td>\
</tr>\
<tr>\
<td class="key_td">ONE_XMLPRC (to export for CLI access)</td>\
<td class="value_td"><input type="text" id="one_xmlrpc" value="'+(zone_host.length? "http://" + zone_host +"/"+ vdc.NAME: "--")+'" style="width:100%;"/></td>\
@ -501,12 +507,10 @@ function setupCreateVDCDialog(){
"ZONEID" : zoneid,
"VDCADMINNAME" : vdcadminname,
"VDCADMINPASS" : vdcadminpass,
"FORCE" : force
"FORCE" : force,
"HOSTS" : hosts
}
};
if (hosts.length){
vdc_json["VDC"]["HOSTS"]=hosts;
};
Sunstone.runAction("VDC.create",vdc_json);
dialog.dialog('close');

View File

@ -53,6 +53,12 @@ var create_zone_tmpl =
<input type="text" name="sunsendpoint_port" id="sunsendpoint_port" value="9869" style="width:3em;"/> /\
<input type="text" name="sunsendpoint_path" id="sunsendpoint_path" value="" style="width:4em;"/>\
<br />\
<label for="selfsendpoint">SelfService end point:</label>\
<input type="text" name="selfsendpoint_ptc" id="selfsendpoint_ptc" value="http" style="width:2em;"/> ://\
<input type="text" name="selfsendpoint" id="selfsendpoint" style="width:7em;" value="localhost"/> :\
<input type="text" name="selfsendpoint_port" id="selfsendpoint_port" value="4567" style="width:3em;"/> /\
<input type="text" name="selfsendpoint_path" id="selfsendpoint_path" value="ui" style="width:4em;"/>\
<br />\
</div>\
</fieldset>\
<fieldset>\
@ -310,8 +316,12 @@ function updateZoneInfo(req,zone_json){
<td class="value_td">'+zone.ENDPOINT+'</td>\
</tr>\
<tr>\
<td class="key_td">Sunstone endpoint</td>\
<td class="value_td">'+ (zone.SUNSENDPOINT.length? '<a href="'+zone.SUNSENDPOINT+'" target="_blank">'+zone.SUNSENDPOINT+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a>' : "") +'</td>\
<td class="key_td">Sunstone endpoint</td>\
<td class="value_td">'+ (zone.SUNSENDPOINT.length? '<a href="'+zone.SUNSENDPOINT+'" target="_blank">'+zone.SUNSENDPOINT+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a>' : "") +'</td>\
</tr>\
<tr>\
<td class="key_td">SelfService endpoint</td>\
<td class="value_td">'+ (zone.SELFENDPOINT.length? '<a href="'+zone.SELFENDPOINT+'" target="_blank">'+zone.SELFENDPOINT+'<span class="ui-icon ui-icon-extlink" style="display:inline-block;" /></a>' : "") +'</td>\
</tr>\
<tr>\
<td class="key_td">#VDCs</td>\
@ -557,11 +567,17 @@ function setupCreateZoneDialog(){
var endpoint_port = $('#endpoint_port',this).val();
var onename = $('#onename',this).val();
var onepass = $('#onepass',this).val();
var se = $('#sunsendpoint',this).val();
var se_ptc = $('#sunsendpoint_ptc',this).val();
var se_port = $('#sunsendpoint_port',this).val();
var se_path = $('#sunsendpoint_path',this).val();
var ss = $('#selfsendpoint',this).val();
var ss_ptc = $('#selfsendpoint_ptc',this).val();
var ss_port = $('#selfsendpoint_port',this).val();
var ss_path = $('#selfsendpoint_path',this).val();
if (!name.length || !endpoint.length ||
!onename.length || !onepass.length){
notifyError("Please fill in all fields");
@ -575,13 +591,18 @@ function setupCreateZoneDialog(){
se = se_ptc + "://" + se + ":" + se_port +
"/" + se_path;
if (ss.length)
ss = ss_ptc + "://" + ss + ":" + ss_port +
"/" + ss_path;
var zone_json = {
"ZONE": {
"NAME": name,
"ENDPOINT": endpoint,
"ONENAME": onename,
"ONEPASS": onepass,
"SUNSENDPOINT" : se
"SUNSENDPOINT" : se,
"SELFENDPOINT" : ss,
}
};

View File

@ -1,9 +0,0 @@
require 'rake'
require 'spec/rake/spectask'
desc "Run all tests with RCov"
Spec::Rake::SpecTask.new('test_with_rcov') do |t|
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', '/Library']
end

View File

@ -1,18 +0,0 @@
{
"vdcpool": {
"vdc": [
{
"hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2",
"zones_id": 1,
"name": "testvdc0",
"id": 1
},
{
"hosts": "testhostvdc1n0",
"zones_id": 1,
"name": "testvdc1",
"id": 2
}
]
}
}

View File

@ -1,12 +0,0 @@
{
"vdcpool": {
"vdc": [
{
"hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2",
"zones_id": 1,
"name": "testvdc0",
"id": 1
}
]
}
}

View File

@ -1,22 +0,0 @@
{
"zonepool": {
"zone": [
{
"onename": "oneadmin",
"onepass": "opennebula",
"endpoint": "http://localhost:2633/RPC2",
"numbervdcs": 2,
"name": "testzone0",
"id": 1
},
{
"onename": "testname",
"onepass": "testpass",
"endpoint": "http://remoteserver:2633/RPC2",
"numbervdcs": 0,
"name": "testzone1",
"id": 2
}
]
}
}

View File

@ -1,14 +0,0 @@
{
"zonepool": {
"zone": [
{
"onename": "oneadmin",
"onepass": "opennebula",
"endpoint": "http://localhost:2633/RPC2",
"numbervdcs": 2,
"name": "testzone0",
"id": 1
}
]
}
}

View File

@ -1,8 +0,0 @@
{
"vdc": {
"hosts": "5,7,9",
"zones_id": 1,
"name": "testvdc0",
"id": 1
}
}

View File

@ -1,5 +0,0 @@
NAME=testvdc0
ZONEID=1
HOSTS=5,7,9
VDCADMINNAME=adminname
VDCADMINPASS=adminpass

View File

@ -1,5 +0,0 @@
NAME=testvdc1
HOSTS=8
ZONEID=1
VDCADMINNAME=othername
VDCADMINPASS=otherpass

View File

@ -1,3 +0,0 @@
NAME=testvdcnozone
HOSTS=3,7
ZONEID=5

View File

@ -1,23 +0,0 @@
{
"zone": {
"onename": "oneadmin",
"onepass": "opennebula",
"endpoint": "http://localhost:2633/RPC2",
"name": "testzone0",
"id": 1,
"vdcs": [
{
"hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2",
"zones_id": 1,
"name": "testvdc0",
"id": 1
},
{
"hosts": "testhostvdc1n0",
"zones_id": 1,
"name": "testvdc1",
"id": 2
}
]
}
}

View File

@ -1,4 +0,0 @@
NAME=testzone0
ENDPOINT=http://localhost:2633/RPC2
ONENAME=oneadmin
ONEPASS=opennebula

View File

@ -1,4 +0,0 @@
NAME=testzone1
ENDPOINT=http://remoteserver:2633/RPC2
ONENAME=testname
ONEPASS=testpass

View File

@ -1,133 +0,0 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Load libraries
require 'rubygems'
require 'spec'
require 'json'
require File.dirname(__FILE__) + "/../../../Client/lib/OZonesClient.rb"
EXAMPLES_PATH = File.dirname(__FILE__) + "/../examples/"
describe 'OZones Pool' do
before(:all) do
@client_launched = true
begin
@ozones_client = OZonesClient::Client.new("http://localhost:6121")
rescue Exception => e
@client_launched = false
end
@client_launched.should == true
rc = @ozones_client.post_resource(
"zone",EXAMPLES_PATH + '/zone/zone0.template')
rc.class.should_not eql(OZonesClient::Error)
rc = @ozones_client.post_resource(
"zone",EXAMPLES_PATH + '/zone/zone1.template')
rc.class.should_not eql(OZonesClient::Error)
rc = @ozones_client.post_resource(
"vdc",EXAMPLES_PATH + '/vdc/vdc0.template')
rc.class.should_not eql(OZonesClient::Error)
rc = @ozones_client.post_resource(
"vdc",EXAMPLES_PATH + '/vdc/vdc1.template')
rc.class.should_not eql(OZonesClient::Error)
end
it "should be able to retrieve the zone pool" do
zonepool = @ozones_client.get_pool("zone")
zonepool.class.should eql(Net::HTTPOK)
zonepool.body.should eql(
File.read(EXAMPLES_PATH+'/pool/zonepool0.json'))
end
it "should be able to retrieve the vdc pool" do
vdcpool = @ozones_client.get_pool("vdc")
vdcpool.class.should eql(Net::HTTPOK)
vdcpool.body.should eql(
File.read(EXAMPLES_PATH+'/pool/vdcpool0.json'))
end
it "should be able to retrieve a particular zone" do
zone0 = @ozones_client.get_resource("zone",1)
zone0.class.should eql(Net::HTTPOK)
zone0.body.should eql(
File.read(EXAMPLES_PATH+'/zone/zone0.json'))
end
it "should be able to retrieve a particular vdc" do
vdc0 = @ozones_client.get_resource("vdc",1)
vdc0.class.should eql(Net::HTTPOK)
vdc0.body.should eql(
File.read(EXAMPLES_PATH+'/vdc/vdc0.json'))
end
it "should fail on zone recreation (with the same name)" do
rc = @ozones_client.post_resource(
"zone",EXAMPLES_PATH + '/zone/zone0.template')
rc.class.should eql(OZonesClient::Error)
end
it "should fail on vdc recreation (with the same name)" do
rc = @ozones_client.post_resource(
"vdc",EXAMPLES_PATH + '/vdc/vdc0.template')
rc.class.should eql(OZonesClient::Error)
end
it "should fail on vdc creation with no existing zone" do
rc = @ozones_client.post_resource(
"vdc",EXAMPLES_PATH +
'/vdc/vdc2nozone.template')
rc.class.should eql(OZonesClient::Error)
end
it "should allow deleting a zone" do
rc = @ozones_client.delete_resource("zone",2)
rc.class.should eql(Net::HTTPOK)
# Zone pool shouldn't account for the deleted zone
zonepool = @ozones_client.get_pool("zone")
zonepool.class.should eql(Net::HTTPOK)
zonepool.body.should eql(
File.read(EXAMPLES_PATH+
'/pool/zonepool1deleted.json'))
end
it "should allow deleting a vdc" do
rc = @ozones_client.delete_resource("vdc",2)
rc.class.should eql(Net::HTTPOK)
# Zone pool shouldn't account for the deleted zone
vdcpool = @ozones_client.get_pool("vdc")
vdcpool.class.should eql(Net::HTTPOK)
vdcpool.body.should eql(
File.read(EXAMPLES_PATH+
'/pool/vdcpool1deleted.json'))
end
it "should fail on non existing zone deletion" do
rc = @ozones_client.delete_resource("zone",5)
rc.class.should eql(OZonesClient::Error)
end
it "should fail on non existing vdc deletion" do
rc = @ozones_client.delete_resource("vdc",5)
rc.class.should eql(OZonesClient::Error)
end
end

View File

@ -1,46 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
VAR_LOCATION="$PWD/var"
OZONES_LOCATION="$PWD/../"
mkdir -p $VAR_LOCATION
if [ "$(ls -A $VAR_LOCATION)" ]; then
echo "$VAR_LOCATION is not empty."
exit -1
fi
rm -rf coverage_server
rcov --exclude /Library --exclude /Users/tinova/.gem -o coverage_server `which rackup` -- $OZONES_LOCATION/config.ru -s thin -p 6121 -o localhost &> server.log &
RCOVPID=$!
sleep 5
rake test_with_rcov
CODE=$?
kill $RCOVPID
sleep 2s;
if [ $CODE != 0 ] ; then
exit 1
fi
find $VAR_LOCATION -mindepth 1 -delete

View File

@ -0,0 +1,57 @@
HOST_MONITORING_INTERVAL = 600
#HOST_PER_INTERVAL = 15
VM_POLLING_INTERVAL = 600
#VM_PER_INTERVAL = 5
#VM_DIR=/srv/cloud/one/var
SCRIPTS_REMOTE_DIR=/var/tmp/one
PORT = 2666
DB = [ backend = "sqlite" ]
VNC_BASE_PORT = 5900
DEBUG_LEVEL = 3
NETWORK_SIZE = 254
MAC_PREFIX = "02:00"
DEFAULT_IMAGE_TYPE = "OS"
DEFAULT_DEVICE_PREFIX = "hd"
IM_MAD = [ name="im_dummy", executable="one_im_dummy"]
VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ]
TM_MAD = [
name = "tm_dummy",
executable = "one_tm",
arguments = "tm_dummy/tm_dummy.conf" ]
IMAGE_MAD = [
executable = "one_image",
arguments = "fs -t 15" ]
HM_MAD = [
executable = "one_hm" ]
AUTH_MAD = [
executable = "one_auth_mad",
arguments = "--authn ssh,x509,ldap,server_cipher,server_x509"
# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509"
]
SESSION_EXPIRATION_TIME = 900
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
VM_RESTRICTED_ATTR = "DISK/SOURCE"
VM_RESTRICTED_ATTR = "NIC/MAC"
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
VM_RESTRICTED_ATTR = "RANK"
IMAGE_RESTRICTED_ATTR = "SOURCE"

View File

@ -1,30 +1,57 @@
#*******************************************************************************
# OpenNebula Configuration file
#*******************************************************************************
# General
HOST_MONITORING_INTERVAL = 600
#HOST_PER_INTERVAL = 15
VM_POLLING_INTERVAL = 600
#VM_PER_INTERVAL = 5
#VM_DIR=/srv/cloud/one/var
SCRIPTS_REMOTE_DIR=/var/tmp/one
PORT=2637
PORT = 2667
DB = [ backend = "sqlite" ]
VNC_BASE_PORT = 5900
DEBUG_LEVEL=3
DEBUG_LEVEL = 3
NETWORK_SIZE = 254
MAC_PREFIX = "02:00"
DEFAULT_IMAGE_TYPE = "OS"
DEFAULT_DEVICE_PREFIX = "hd"
# Dummy
IM_MAD = [ name="im_dummy", executable="one_im_dummy"]
VM_MAD = [ name="vmm_dummy",executable="one_vmm_dummy", type="xml" ]
TM_MAD = [ name="tm_dummy", executable="one_tm", arguments ="tm_dummy/tm_dummy.conf" ]
# Image
IMAGE_MAD = [ executable = "one_image", arguments = "fs -t 15" ]
VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ]
# Hook
HM_MAD = [ executable = "one_hm" ]
TM_MAD = [
name = "tm_dummy",
executable = "one_tm",
arguments = "tm_dummy/tm_dummy.conf" ]
IMAGE_MAD = [
executable = "one_image",
arguments = "fs -t 15" ]
HM_MAD = [
executable = "one_hm" ]
AUTH_MAD = [
executable = "one_auth_mad",
arguments = "--authn ssh,x509,ldap,server_cipher,server_x509"
# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509"
]
SESSION_EXPIRATION_TIME = 900
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
VM_RESTRICTED_ATTR = "DISK/SOURCE"
VM_RESTRICTED_ATTR = "NIC/MAC"
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
VM_RESTRICTED_ATTR = "RANK"
IMAGE_RESTRICTED_ATTR = "SOURCE"

View File

@ -0,0 +1,36 @@
{
"VDC_POOL": {
"VDC": [
{
"ID": 1,
"ACLS": "2,3,4,5,6,7",
"HOSTS": "1,2,3",
"NAME": "vdcA",
"ZONES_ID": 1,
"GROUP_ID": 100,
"VDCADMINNAME": "vdcadminA",
"VDCADMIN_ID": 2
},
{
"ID": 2,
"ACLS": "2,3,4,5",
"HOSTS": "1",
"NAME": "vdcB",
"ZONES_ID": 2,
"GROUP_ID": 100,
"VDCADMINNAME": "vdcadminB",
"VDCADMIN_ID": 2
},
{
"ID": 3,
"ACLS": "8,9,10,11",
"HOSTS": "4",
"NAME": "vdcC",
"ZONES_ID": 1,
"GROUP_ID": 101,
"VDCADMINNAME": "vdcadminC",
"VDCADMIN_ID": 3
}
]
}
}

View File

@ -0,0 +1,26 @@
{
"VDC_POOL": {
"VDC": [
{
"ID": 1,
"ACLS": "2,3,4,5,6,7",
"HOSTS": "1,2,3",
"NAME": "vdcA",
"ZONES_ID": 1,
"GROUP_ID": 100,
"VDCADMINNAME": "vdcadminA",
"VDCADMIN_ID": 2
},
{
"ID": 2,
"ACLS": "2,3,4,5",
"HOSTS": "1",
"NAME": "vdcB",
"ZONES_ID": 2,
"GROUP_ID": 100,
"VDCADMINNAME": "vdcadminB",
"VDCADMIN_ID": 2
}
]
}
}

View File

@ -0,0 +1,26 @@
{
"ZONE_POOL": {
"ZONE": [
{
"ID": 1,
"ENDPOINT": "http://localhost:2666/RPC2",
"NUMBERVDCS": 0,
"SUNSENDPOINT": "http://localhost:9869",
"NAME": "zoneA",
"SELFENDPOINT": null,
"ONENAME": "oneadminA",
"ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA=="
},
{
"ID": 2,
"ENDPOINT": "http://localhost:2667/RPC2",
"NUMBERVDCS": 0,
"SUNSENDPOINT": null,
"NAME": "zoneB",
"SELFENDPOINT": null,
"ONENAME": "oneadminB",
"ONEPASS": "8Si8vlo2P3qn5/SNxkMkDg=="
}
]
}
}

View File

@ -0,0 +1,16 @@
{
"ZONE_POOL": {
"ZONE": [
{
"ID": 1,
"ENDPOINT": "http://localhost:2666/RPC2",
"NUMBERVDCS": 0,
"SUNSENDPOINT": "http://localhost:9869",
"NAME": "zoneA",
"SELFENDPOINT": null,
"ONENAME": "oneadminA",
"ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA=="
}
]
}
}

View File

@ -0,0 +1,12 @@
{
"VDC": {
"ID": 1,
"ACLS": "2,3,4,5,6,7",
"HOSTS": "1,2,3",
"NAME": "vdcA",
"ZONES_ID": 1,
"GROUP_ID": 100,
"VDCADMINNAME": "vdcadminA",
"VDCADMIN_ID": 2
}
}

View File

@ -0,0 +1,14 @@
{
"ZONE": {
"ID": 1,
"ENDPOINT": "http://localhost:2666/RPC2",
"SUNSENDPOINT": "http://localhost:9869",
"VDCS": [
],
"NAME": "zoneA",
"SELFENDPOINT": null,
"ONENAME": "oneadminA",
"ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA=="
}
}

View File

@ -29,89 +29,116 @@ require 'command_parser'
require 'ozones_helper/zones_helper.rb'
require 'ozones_helper/vdc_helper.rb'
TESTS_PATH = File.dirname(__FILE__)+"/../"
module OZones
describe "oZones server regarding VDCs" do
before(:all) do
@zonehelper =
@zonehelper =
ZonesHelper.new("zone", "ozonesadmin","ozonespassword")
@vdchelper =
VDCHelper.new("vdc", "ozonesadmin","ozonespassword")
@vdchelper =
VDCHelper.new("vdc", "ozonesadmin","ozonespassword")
@clientA = OpenNebula::Client.new(File.read(
File.dirname(__FILE__)+"/../etc/one_auth_a"),
"http://localhost:2636/RPC2")
TESTS_PATH+"etc/one_auth_a"),
"http://localhost:2666/RPC2")
@clientB = OpenNebula::Client.new(File.read(
File.dirname(__FILE__)+"/../etc/one_auth_b"),
"http://localhost:2637/RPC2")
TESTS_PATH+"etc/one_auth_b"),
"http://localhost:2667/RPC2")
hostA=OpenNebula::Host.new(OpenNebula::Host.build_xml, @clientA)
hostA.allocate("hostA1","im_dummy","vmm_dummy","tm_dummy")
hostA.allocate("hostA2","im_dummy","vmm_dummy","tm_dummy")
hostA.allocate("hostA3","im_dummy","vmm_dummy","tm_dummy")
hostA.allocate("hostA4","im_dummy","vmm_dummy","tm_dummy")
hostA.allocate("hostA1","im_dummy","vmm_dummy","tm_dummy","dummy")
hostA.allocate("hostA2","im_dummy","vmm_dummy","tm_dummy","dummy")
hostA.allocate("hostA3","im_dummy","vmm_dummy","tm_dummy","dummy")
hostA.allocate("hostA4","im_dummy","vmm_dummy","tm_dummy","dummy")
hostB=OpenNebula::Host.new(OpenNebula::Host.build_xml, @clientB)
hostB.allocate("hostB1","im_dummy","vmm_dummy","tm_dummy")
hostB.allocate("hostB2","im_dummy","vmm_dummy","tm_dummy")
hostB.allocate("hostB3","im_dummy","vmm_dummy","tm_dummy")
hostB.allocate("hostB1","im_dummy","vmm_dummy","tm_dummy","dummy")
hostB.allocate("hostB2","im_dummy","vmm_dummy","tm_dummy","dummy")
hostB.allocate("hostB3","im_dummy","vmm_dummy","tm_dummy","dummy")
end
it "should be able to create a couple of zones" do
@zonehelper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneA.template")[0].should eql(0)
@zonehelper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneB.template")[0].should eql(0)
end
it "should be able to create one vdc with the apropiate ONE resources" do
@vdchelper.create_resource(File.dirname(__FILE__)+
"/../templates/vdcA.template")[0].should eql(0)
rc = @zonehelper.create_resource(TESTS_PATH+"templates/zoneA.template")
rc[0].should eql(0)
rc = @zonehelper.create_resource(TESTS_PATH+"templates/zoneB.template")
rc[0].should eql(0)
end
it "should be able to create one vdc with apropiate ONE resources" do
@vdchelper.create_resource(TESTS_PATH+"templates/vdcA.template",
{:force => false})[0].should eql(0)
upool = OpenNebula::UserPool.new(@clientA)
upool.info
userExist=false
upool.each{|user|
upool.each{|user|
if user['NAME'] == "vdcadminA"
userExist=true
end
}
userExist.should eql(true)
gpool = OpenNebula::GroupPool.new(@clientA)
gpool.info
groupExist=false
gpool.each{|group|
gpool.each{|group|
if group['NAME'] == "vdcA"
groupExist=true
end
}
}
groupExist.should eql(true)
apool = OpenNebula::AclPool.new(@clientA)
apool.info
# TODO check ACLs
end
it "should be able to create a couple of VDCs" do
@vdchelper.create_resource(File.dirname(__FILE__)+
"/../templates/vdcB.template")[0].should eql(0)
@vdchelper.create_resource(File.dirname(__FILE__)+
"/../templates/vdcC.template")[0].should eql(0)
end
it "should fail when creating an existing VDC" do
@vdchelper.create_resource(File.dirname(__FILE__)+
"/../templates/vdcA.template")[0].should eql(-1)
end
it "should fail when creating a VDC upon a non existing zone" do
@vdchelper.create_resource(File.dirname(__FILE__)+
"/../templates/vdc.no.zone.template")[0].should eql(-1)
end
it "should be able to create a couple of VDCs" do
@vdchelper.create_resource(TESTS_PATH+"templates/vdcB.template",
{:force => false})[0].should eql(0)
@vdchelper.create_resource(TESTS_PATH+"templates/vdcC.template",
{:force => false})[0].should eql(0)
end
it "should fail when creating an existing VDC" do
@vdchelper.create_resource(TESTS_PATH+"templates/vdcA.template",
{:force => false})[0].should eql(-1)
end
it "should fail when creating a VDC upon a non existing zone" do
@vdchelper.create_resource(TESTS_PATH+"templates/vdc.no.zone.template",
{:force => false})[0].should eql(-1)
end
it "should be able to retrieve the vdc pool" do
vdcpool = @vdchelper.list_pool({:json => true})
vdcpool[0].should eql(0)
vdcpool[1].should eql(File.read(TESTS_PATH+"examples/pool/vdcpool0.json"))
end
it "should be able to retrieve a particular vdc" do
vdc = @vdchelper.show_resource(1, {:json => true})
vdc[0].should eql(0)
vdc[1].should eql(File.read(TESTS_PATH+"examples/vdc/vdc0.json"))
end
it "should allow deleting a vdc" do
rc = @vdchelper.delete_resource(3, {})
rc[0].should eql(0)
rc = @vdchelper.list_pool({:json => true})
rc[0].should eql(0)
rc[1].should eql(File.read(TESTS_PATH+
"examples/pool/vdcpool_deleted.json"))
end
it "should fail on non-existing vdc deletion" do
rc = @vdchelper.delete_resource(7, {})
rc[0].should eql(-1)
end
end
end

View File

@ -28,36 +28,71 @@ $: << RUBY_LIB_LOCATION+"/cli"
require 'command_parser'
require 'ozones_helper/zones_helper.rb'
TESTS_PATH = File.dirname(__FILE__)+"/../"
module OZones
describe "oZones server regarding zones" do
before(:all) do
@helper = ZonesHelper.new("zone", "ozonesadmin","ozonespassword")
@badhelper = ZonesHelper.new("zone", "wronguser","wrongpassword")
@helper = ZonesHelper.new("zone", "ozonesadmin","ozonespassword")
@badhelper = ZonesHelper.new("zone", "wronguser","wrongpassword")
end
it "should be able to create a couple of zones" do
@helper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneA.template")[0].should eql(0)
@helper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneB.template")[0].should eql(0)
end
rc = @helper.create_resource(TESTS_PATH+"templates/zoneA.template")
rc[0].should eql(0)
@helper.create_resource(TESTS_PATH+"templates/zoneB.template")
rc[0].should eql(0)
end
it "should fail with wrong zones templates" do
@helper.create_resource(File.dirname(__FILE__)+
"/../templates/zone.wrong.credentials.template")[0].should eql(-1)
@helper.create_resource(File.dirname(__FILE__)+
"/../templates/zone.wrong.endpoint.template")[0].should eql(-1)
end
templ_path = "templates/zone.wrong.credentials.template"
rc = @helper.create_resource(TESTS_PATH+templ_path)
rc[0].should eql(-1)
templ_path = "templates/zone.wrong.endpoint.template"
rc = @helper.create_resource(TESTS_PATH+templ_path)
rc[0].should eql(-1)
end
it "should fail when creating zones with existing name" do
@helper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneA.template")[0].should eql(-1)
end
rc = @helper.create_resource(TESTS_PATH+"templates/zoneA.template")
rc[0].should eql(-1)
end
it "should refuse unauthorized requests" do
@badhelper.create_resource(File.dirname(__FILE__)+
"/../templates/zoneA.template")[0].should eql(-1)
end
rc = @badhelper.create_resource(TESTS_PATH+
"templates/zoneA.template")
rc[0].should eql(-1)
end
it "should be able to retrieve the zone pool" do
zonepool = @helper.list_pool({:json => true})
zonepool[0].should eql(0)
zonepool[1].should eql(File.read(TESTS_PATH+
"examples/pool/zonepool0.json"))
end
it "should be able to retrieve a particular zone" do
zone = @helper.show_resource(1,{:json => true})
zone[0].should eql(0)
zone[1].should eql(File.read(TESTS_PATH+"examples/zone/zone0.json"))
end
it "should allow deleting a zone" do
rc = @helper.delete_resource(2, {})
rc[0].should eql(0)
rc = @helper.list_pool({:json => true})
rc[0].should eql(0)
rc[1].should eql(File.read(TESTS_PATH+
"examples/pool/zonepool_deleted.json"))
end
it "should fail on non existing zone deletion" do
rc = @helper.delete_resource(7, {})
rc[0].should eql(-1)
end
end
end
end

View File

@ -2,4 +2,4 @@ NAME=vdcC
VDCADMINNAME=vdcadminC
VDCADMINPASS=vdcpassC
ZONEID=1
HOSTS=3
HOSTS=4

View File

@ -1,5 +1,5 @@
NAME=zoneA
ONENAME=oneadminA
ONEPASS=opennebulaA
ENDPOINT=http://localhost:2636/RPC2
SUNSENDPOINT=http://localhost:9869
ENDPOINT=http://localhost:2666/RPC2
SUNSENDPOINT=http://localhost:9869

View File

@ -1,4 +1,4 @@
NAME=zoneB
ONENAME=oneadminB
ONEPASS=opennebulaB
ENDPOINT=http://localhost:2637/RPC2
ENDPOINT=http://localhost:2667/RPC2

View File

@ -35,8 +35,7 @@ for j in `ls ./spec/*_spec.rb` ; do
OZONES_AUTH=$PWD/etc/ozones_auth ONE_LOCATION=$ONE_LOCATION_A oneA/bin/ozones-server start
sleep 5
ONE_LOCATION=$ONE_LOCATION_A spec $j -f s
ONE_LOCATION=$ONE_LOCATION_A rspec $j -f s
CODE=$?
if [ $CODE != 0 ] ; then
@ -52,18 +51,7 @@ for j in `ls ./spec/*_spec.rb` ; do
done
if (($CODE == 0)); then
# Terminate ONEs
ONE_LOCATION=$ONE_LOCATION_A oneA/bin/one stop
ONE_LOCATION=$ONE_LOCATION_B oneB/bin/one stop
# Stop oZones
ONE_LOCATION=$ONE_LOCATION_A oneA/bin/ozones-server stop
# Delete directories
rm -rf oneA
rm -rf oneB
fi
fi