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

Merge branch 'feature-1112' of git.opennebula.org:one into feature-1112

This commit is contained in:
Ruben S. Montero 2012-03-16 18:27:52 +01:00
commit 739128baa8
13 changed files with 51 additions and 41 deletions

View File

@ -87,16 +87,6 @@ AclManager::AclManager(SqlDB * _db) : db(_db), lastOID(-1)
PoolObjectSQL::HOST,
AuthRequest::MANAGE,
error_str);
// Users in USERS can use the default DATASTORE
// @1 DATASTORE/#1 USE
add_rule(AclRule::GROUP_ID |
1,
AclRule::INDIVIDUAL_ID |
1 | // TODO: use DatastorePool::DEFAULT_DS_ID
PoolObjectSQL::DATASTORE,
AuthRequest::USE,
error_str);
}
}

View File

@ -399,6 +399,18 @@ EOT
end
end
# If the cluster name is empty, returns a '-' char.
#
# @param str [String || Hash] Cluster name, or empty Hash (when <CLUSTER/>)
# @return [String] the same Cluster name, or '-' if it is empty
def OpenNebulaHelper.cluster_str(str)
if str != nil && !str.empty?
str
else
"-"
end
end
def OpenNebulaHelper.update_template(id, resource)
require 'tempfile'

View File

@ -57,11 +57,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
end
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
if d["CLUSTER"] == "none"
"-"
else
d["CLUSTER"]
end
OpenNebulaHelper.cluster_str(d["CLUSTER"])
end
column :IMAGES, "Number of Images", :left, :size=>6 do |d|
@ -111,8 +107,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
puts str % ["NAME", datastore.name]
puts str % ["USER", datastore['UNAME']]
puts str % ["GROUP", datastore['GNAME']]
puts str % ["CLUSTER", datastore['CLUSTER']]
puts str % ["CLUSTER_ID", datastore['CLUSTER_ID']]
puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(datastore['CLUSTER'])]
puts str % ["DS_MAD", datastore['DS_MAD']]
puts str % ["TM_MAD", datastore['TM_MAD']]

View File

@ -44,11 +44,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
end
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
if d["CLUSTER"] == "none"
"-"
else
d["CLUSTER"]
end
OpenNebulaHelper.cluster_str(d["CLUSTER"])
end
column :RVM, "Number of Virtual Machines running", :size=>6 do |d|
@ -126,7 +122,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
puts str % ["ID", host.id.to_s]
puts str % ["NAME", host.name]
puts str % ["CLUSTER", host['CLUSTER']]
puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(host['CLUSTER'])]
puts str % ["STATE", host.state_str]
puts str % ["IM_MAD", host['IM_MAD']]
puts str % ["VM_MAD", host['VM_MAD']]

View File

@ -55,11 +55,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
end
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
if d["CLUSTER"] == "none"
"-"
else
d["CLUSTER"]
end
OpenNebulaHelper.cluster_str(d["CLUSTER"])
end
column :TYPE, "Type of Virtual Network", :size=>6 do |d|
@ -111,7 +107,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
puts str % ["NAME", vn['NAME']]
puts str % ["USER", vn['UNAME']]
puts str % ["GROUP", vn['GNAME']]
puts str % ["CLUSTER", vn['CLUSTER']]
puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(vn['CLUSTER'])]
puts str % ["TYPE", vn.type_str]
puts str % ["BRIDGE", vn["BRIDGE"]]
puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])]

View File

@ -37,6 +37,9 @@
# 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
:debug_level: 3
:cluster_id:
:datastore_id:
# VM types allowed and its template file (inside templates directory)
:instance_types:
:m1.small:

View File

@ -79,7 +79,7 @@ class EC2QueryServer < CloudServer
return OpenNebula::Error.new('Unsupported'), 400
end
rc = image.allocate(template)
rc = image.allocate(template, @config[:datastore_id]||1)
if OpenNebula.is_error?(rc)
return OpenNebula::Error.new('Unsupported'), 400
end

View File

@ -37,6 +37,9 @@
# 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
:debug_level: 3
:cluster_id:
:datastore_id:
# VM types allowed and its template file (inside templates directory)
:instance_types:
:small:

View File

@ -342,7 +342,7 @@ class OCCIServer < CloudServer
template = network.to_one_template
return template, 500 if OpenNebula.is_error?(template)
rc = network.allocate(template)
rc = network.allocate(template, @config[:cluster_id]||ClusterPool::NONE_CLUSTER_ID)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
@ -446,7 +446,7 @@ class OCCIServer < CloudServer
template = image.to_one_template
return template, 500 if OpenNebula.is_error?(template)
rc = image.allocate(template)
rc = image.allocate(template, @config[:datastore_id]||1t)
if OpenNebula.is_error?(rc)
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end

View File

@ -26,7 +26,7 @@
/* Regular ones start from ID 100 */
/* -------------------------------------------------------------------------- */
const string ClusterPool::NONE_CLUSTER_NAME = "none";
const string ClusterPool::NONE_CLUSTER_NAME = "";
const int ClusterPool::NONE_CLUSTER_ID = -1;
/* -------------------------------------------------------------------------- */

View File

@ -49,6 +49,8 @@ Datastore::Datastore(
tm_mad(""),
base_path("")
{
group_u = 1;
if (ds_template != 0)
{
obj_template = ds_template;

View File

@ -44,6 +44,7 @@ DatastorePool::DatastorePool(SqlDB * db):
if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb
{
DatastoreTemplate * ds_tmpl;
Datastore * ds;
int rc;
@ -110,6 +111,18 @@ DatastorePool::DatastorePool(SqlDB * db):
goto error_bootstrap;
}
ds = get(rc, true);
ds->set_permissions(
-1,-1,-1,
-1,-1,-1,
1,-1,-1,
error_str);
update(ds);
ds->unlock();
// User created datastores will start from ID 100
set_update_lastOID(99);
}

View File

@ -115,7 +115,7 @@ module Migrator
" <OWNER_U>1</OWNER_U>" <<
" <OWNER_M>1</OWNER_M>" <<
" <OWNER_A>0</OWNER_A>" <<
" <GROUP_U>0</GROUP_U>" <<
" <GROUP_U>1</GROUP_U>" <<
" <GROUP_M>0</GROUP_M>" <<
" <GROUP_A>0</GROUP_A>" <<
" <OTHER_U>0</OTHER_U>" <<
@ -126,7 +126,7 @@ module Migrator
" <TM_MAD>shared</TM_MAD>" <<
" <BASE_PATH>#{var_location}/datastores/0</BASE_PATH>" <<
" <CLUSTER_ID>-1</CLUSTER_ID>" <<
" <CLUSTER>none</CLUSTER>" <<
" <CLUSTER/>" <<
" <IMAGES/>" <<
" <TEMPLATE>" <<
" <DS_MAD><![CDATA[-]]></DS_MAD>" <<
@ -141,7 +141,7 @@ module Migrator
:uid => 0,
:gid => 0,
:owner_u => 1,
:group_u => 0,
:group_u => 1,
:other_u => 0)
# Last oid for cluster_pool and datastore_pool
@ -169,7 +169,7 @@ module Migrator
# Add Cluster elements
doc.root.add_element("CLUSTER_ID").text = "-1"
doc.root.add_element("CLUSTER").text = "none"
doc.root.add_element("CLUSTER").text = ""
@db[:host_pool].insert(
:oid => row[:oid],
@ -198,7 +198,7 @@ module Migrator
# Add Cluster elements
doc.root.add_element("CLUSTER_ID").text = "-1"
doc.root.add_element("CLUSTER").text = "none"
doc.root.add_element("CLUSTER").text = ""
@db[:network_pool].insert(
:oid => row[:oid],
@ -272,7 +272,7 @@ module Migrator
" <OWNER_U>1</OWNER_U>" <<
" <OWNER_M>1</OWNER_M>" <<
" <OWNER_A>0</OWNER_A>" <<
" <GROUP_U>0</GROUP_U>" <<
" <GROUP_U>1</GROUP_U>" <<
" <GROUP_M>0</GROUP_M>" <<
" <GROUP_A>0</GROUP_A>" <<
" <OTHER_U>0</OTHER_U>" <<
@ -283,7 +283,7 @@ module Migrator
" <TM_MAD>shared</TM_MAD>" <<
" <BASE_PATH>#{var_location}/datastores/1</BASE_PATH>" <<
" <CLUSTER_ID>-1</CLUSTER_ID>" <<
" <CLUSTER>none</CLUSTER>" <<
" <CLUSTER/>" <<
images_element <<
" <TEMPLATE>" <<
" <DS_MAD><![CDATA[fs]]></DS_MAD>" <<
@ -298,7 +298,7 @@ module Migrator
:uid => 0,
:gid => 0,
:owner_u => 1,
:group_u => 0,
:group_u => 1,
:other_u => 0)
return true