mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
96b0de85d3
@ -86,14 +86,6 @@ public:
|
||||
*/
|
||||
Image * acquire_image(int image_id);
|
||||
|
||||
/**
|
||||
* Try to acquire an image from the repository for a VM.
|
||||
* @param name of the image
|
||||
* @param id of owner
|
||||
* @return pointer to the image or 0 if could not be acquired
|
||||
*/
|
||||
Image * acquire_image(const string& name, int uid);
|
||||
|
||||
/**
|
||||
* Releases an image and triggers any needed operations in the repo
|
||||
* @param iid image id of the image to be released
|
||||
|
@ -78,17 +78,6 @@ public:
|
||||
return static_cast<Image *>(PoolSQL::get(oid,lock));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get an Image from the pool using the image name
|
||||
* @param name of the image
|
||||
* @param lock locks the User mutex
|
||||
* @return a pointer to the Image, 0 if the image could not be loaded
|
||||
*/
|
||||
Image * get(const string& name, int uid, bool lock)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get(name,uid,lock));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a particular Image
|
||||
* @param image pointer to Image
|
||||
@ -127,7 +116,10 @@ public:
|
||||
* automatically increased.
|
||||
* @param img_type will be set to the used image's type
|
||||
* @param uid of VM owner (to look for the image id within its images)
|
||||
* @return 0 on success, -1 error, -2 not using the pool
|
||||
* @return 0 on success,
|
||||
* -1 error,
|
||||
* -2 not using the pool,
|
||||
* -3 deprecated NAME found
|
||||
*/
|
||||
int disk_attribute(VectorAttribute * disk,
|
||||
int disk_id,
|
||||
|
@ -62,9 +62,17 @@ module CommandParser
|
||||
@args = args
|
||||
@options = Hash.new
|
||||
|
||||
set :format, :file, "" do |arg| format_file(arg) ; end
|
||||
set :format, :range, "" do |arg| format_range(arg) ; end
|
||||
set :format, :text, "" do |arg| format_text(arg) ; end
|
||||
set :format, :file, "Path to a file" do |arg|
|
||||
format_file(arg)
|
||||
end
|
||||
|
||||
set :format, :range, "List of id's in the form 1,8..15" do |arg|
|
||||
format_range(arg)
|
||||
end
|
||||
|
||||
set :format, :text, "String" do |arg|
|
||||
format_text(arg)
|
||||
end
|
||||
|
||||
instance_eval(&block)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
:ID:
|
||||
:desc: ONE identifier for Virtual Machine
|
||||
:size: 4
|
||||
:size: 6
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Machine
|
||||
|
@ -26,7 +26,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
def self.password_to_str_desc
|
||||
"TBD"
|
||||
"User password"
|
||||
end
|
||||
|
||||
def self.password_to_str(arg, options)
|
||||
|
@ -105,7 +105,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
def format_pool(pool, options, top=false)
|
||||
config_file=self.class.table_conf
|
||||
table=CLIHelper::ShowTable.new(config_file, self) do
|
||||
column :ID, "ONE identifier for Virtual Machine", :size=>4 do |d|
|
||||
column :ID, "ONE identifier for Virtual Machine", :size=>6 do |d|
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
PLAIN={
|
||||
:name => "plain",
|
||||
:short => "-p",
|
||||
:large => "--plain-password",
|
||||
:large => "--plain",
|
||||
:description => "Store plain password"
|
||||
}
|
||||
|
||||
|
@ -46,31 +46,6 @@ Image * ImageManager::acquire_image(int image_id)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
Image * ImageManager::acquire_image(const string& name, int uid)
|
||||
{
|
||||
Image * img;
|
||||
int rc;
|
||||
|
||||
img = ipool->get(name,uid,true);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = acquire_image(img);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
img->unlock();
|
||||
img = 0;
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int ImageManager::acquire_image(Image *img)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -64,7 +64,6 @@ int ImagePool::allocate (
|
||||
string& error_str)
|
||||
{
|
||||
Image * img;
|
||||
Image * img_aux;
|
||||
string name;
|
||||
ostringstream oss;
|
||||
|
||||
@ -78,14 +77,6 @@ int ImagePool::allocate (
|
||||
goto error_name;
|
||||
}
|
||||
|
||||
// Check for duplicates
|
||||
img_aux = get(name,uid,false);
|
||||
|
||||
if( img_aux != 0 )
|
||||
{
|
||||
goto error_duplicated;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Insert the Object in the pool & Register the image in the repository
|
||||
// ---------------------------------------------------------------------
|
||||
@ -108,12 +99,7 @@ int ImagePool::allocate (
|
||||
|
||||
error_name:
|
||||
oss << "NAME cannot be empty.";
|
||||
goto error_common;
|
||||
|
||||
error_duplicated:
|
||||
oss << "NAME is already taken by IMAGE " << img_aux->get_oid() << ".";
|
||||
|
||||
error_common:
|
||||
delete img;
|
||||
|
||||
*oid = -1;
|
||||
@ -140,41 +126,34 @@ int ImagePool::disk_attribute(VectorAttribute * disk,
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImageManager * imagem = nd.get_imagem();
|
||||
|
||||
istringstream is;
|
||||
int image_id;
|
||||
|
||||
source = disk->vector_value("IMAGE");
|
||||
|
||||
if (source.empty())
|
||||
if (!source.empty())
|
||||
{
|
||||
istringstream is;
|
||||
int image_id;
|
||||
return -3;
|
||||
}
|
||||
|
||||
source = disk->vector_value("IMAGE_ID");
|
||||
source = disk->vector_value("IMAGE_ID");
|
||||
|
||||
if (!source.empty())
|
||||
if (!source.empty())
|
||||
{
|
||||
is.str(source);
|
||||
is >> image_id;
|
||||
|
||||
if( !is.fail() )
|
||||
{
|
||||
is.str(source);
|
||||
is >> image_id;
|
||||
img = imagem->acquire_image(image_id);
|
||||
|
||||
if( !is.fail() )
|
||||
if (img == 0)
|
||||
{
|
||||
img = imagem->acquire_image(image_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
img = imagem->acquire_image(source,uid);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
string type = disk->vector_value("TYPE");
|
||||
@ -220,31 +199,22 @@ void ImagePool::authorize_disk(VectorAttribute * disk,int uid, AuthRequest * ar)
|
||||
string source;
|
||||
Image * img = 0;
|
||||
|
||||
source = disk->vector_value("IMAGE");
|
||||
istringstream is;
|
||||
int image_id;
|
||||
|
||||
source = disk->vector_value("IMAGE_ID");
|
||||
|
||||
if (source.empty())
|
||||
{
|
||||
istringstream is;
|
||||
int image_id;
|
||||
|
||||
source = disk->vector_value("IMAGE_ID");
|
||||
|
||||
if (source.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
is.str(source);
|
||||
is >> image_id;
|
||||
|
||||
if( !is.fail() )
|
||||
{
|
||||
img = get(image_id,true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
is.str(source);
|
||||
is >> image_id;
|
||||
|
||||
if( !is.fail() )
|
||||
{
|
||||
img = get(source,uid,true);
|
||||
img = get(image_id,true);
|
||||
}
|
||||
|
||||
if (img == 0)
|
||||
|
@ -139,8 +139,6 @@ class ImagePoolTest : public PoolTest
|
||||
|
||||
CPPUNIT_TEST ( names_initialization );
|
||||
CPPUNIT_TEST ( update );
|
||||
CPPUNIT_TEST ( get_using_name );
|
||||
CPPUNIT_TEST ( wrong_get_name );
|
||||
CPPUNIT_TEST ( duplicates );
|
||||
CPPUNIT_TEST ( extra_attributes );
|
||||
CPPUNIT_TEST ( wrong_templates );
|
||||
@ -244,13 +242,13 @@ public:
|
||||
// allocated images.
|
||||
imp = new ImagePool(db,"OS", "hd");
|
||||
|
||||
img = imp->get(names[0], uids[0], false);
|
||||
img = imp->get(0, false);
|
||||
CPPUNIT_ASSERT( img != 0 );
|
||||
|
||||
img = imp->get(names[1], uids[1], false);
|
||||
img = imp->get(2, false);
|
||||
CPPUNIT_ASSERT( img == 0 );
|
||||
|
||||
img = imp->get(names[2], uids[2], false);
|
||||
img = imp->get(1, false);
|
||||
CPPUNIT_ASSERT( img != 0 );
|
||||
|
||||
|
||||
@ -322,65 +320,6 @@ public:
|
||||
CPPUNIT_ASSERT( no_value == "" );
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void get_using_name()
|
||||
{
|
||||
int oid_0, oid_1;
|
||||
ImagePool * imp = static_cast<ImagePool *>(pool);
|
||||
|
||||
// Allocate two objects
|
||||
oid_0 = allocate(0);
|
||||
oid_1 = allocate(1);
|
||||
|
||||
// ---------------------------------
|
||||
// Get first object and check its integrity
|
||||
obj = pool->get(oid_0, false);
|
||||
CPPUNIT_ASSERT( obj != 0 );
|
||||
check(0, obj);
|
||||
|
||||
// Get using its name
|
||||
obj = imp->get(names[1], uids[1], true);
|
||||
CPPUNIT_ASSERT( obj != 0 );
|
||||
obj->unlock();
|
||||
|
||||
check(1, obj);
|
||||
|
||||
|
||||
// ---------------------------------
|
||||
// Clean the cache, forcing the pool to read the objects from the DB
|
||||
pool->clean();
|
||||
|
||||
// Get first object and check its integrity
|
||||
obj = imp->get(names[0], uids[0], false);
|
||||
check(0, obj);
|
||||
|
||||
// Get using its name
|
||||
obj = imp->get(oid_1, false);
|
||||
check(1, obj);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void wrong_get_name()
|
||||
{
|
||||
ImagePool * imp = static_cast<ImagePool *>(pool);
|
||||
|
||||
// The pool is empty
|
||||
// Non existing name
|
||||
obj = imp->get("Wrong name", 0, true);
|
||||
CPPUNIT_ASSERT( obj == 0 );
|
||||
|
||||
// Allocate an object
|
||||
allocate(0);
|
||||
|
||||
// Ask again for a non-existing name
|
||||
obj = imp->get("Non existing name",uids[0], true);
|
||||
CPPUNIT_ASSERT( obj == 0 );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -394,15 +333,15 @@ public:
|
||||
CPPUNIT_ASSERT( oid == 0 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
|
||||
// Try to allocate twice the same image, should fail
|
||||
// Try to allocate twice the same image, should work
|
||||
rc = imp->allocate(uids[0], templates[0], &oid);
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
CPPUNIT_ASSERT( rc == 1 );
|
||||
CPPUNIT_ASSERT( oid == 1 );
|
||||
|
||||
// Try again, this time with different uid. Should be allowed
|
||||
rc = imp->allocate(uids[1], templates[0], &oid);
|
||||
CPPUNIT_ASSERT( rc >= 0 );
|
||||
CPPUNIT_ASSERT( oid == rc );
|
||||
CPPUNIT_ASSERT( oid == 2 );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -56,22 +56,26 @@ class SunstoneServer
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
def get_pool(kind)
|
||||
user_flag = -2
|
||||
def get_pool(kind,gid)
|
||||
pool = case kind
|
||||
when "group" then GroupPoolJSON.new(@client)
|
||||
when "host" then HostPoolJSON.new(@client)
|
||||
when "image" then ImagePoolJSON.new(@client, user_flag)
|
||||
when "template" then TemplatePoolJSON.new(@client, user_flag)
|
||||
when "vm" then VirtualMachinePoolJSON.new(@client, user_flag)
|
||||
when "vnet" then VirtualNetworkPoolJSON.new(@client, user_flag)
|
||||
when "image" then ImagePoolJSON.new(@client)
|
||||
when "template" then TemplatePoolJSON.new(@client)
|
||||
when "vm" then VirtualMachinePoolJSON.new(@client)
|
||||
when "vnet" then VirtualNetworkPoolJSON.new(@client)
|
||||
when "user" then UserPoolJSON.new(@client)
|
||||
else
|
||||
error = Error.new("Error: #{kind} resource not supported")
|
||||
return [404, error.to_json]
|
||||
end
|
||||
|
||||
rc = pool.info
|
||||
rc = case kind
|
||||
when "group","host","user" then pool.info
|
||||
else
|
||||
gid != "0" ? pool.info_group : pool.info_all
|
||||
end
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return [500, rc.to_json]
|
||||
else
|
||||
|
@ -1645,12 +1645,12 @@ var OpenNebula = {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
"chown": function(params)
|
||||
{
|
||||
OpenNebula.Helper.chown(params,OpenNebula.Group.resource,"group");
|
||||
}
|
||||
|
||||
// "chown": function(params)
|
||||
// {
|
||||
// OpenNebula.Helper.chown(params,OpenNebula.Group.resource,"group");
|
||||
// }
|
||||
},
|
||||
|
||||
"User": {
|
||||
@ -1824,67 +1824,6 @@ var OpenNebula = {
|
||||
var action = OpenNebula.Helper.action(method, {"group_id": gid});
|
||||
var request = OpenNebula.Helper.request(OpenNebula.User.resource,method, [id, gid]);
|
||||
|
||||
$.ajax({
|
||||
url: "user/" + id + "/action",
|
||||
type: "POST",
|
||||
data: JSON.stringify(action),
|
||||
success: function()
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
callback(request);
|
||||
}
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
if (callback_error)
|
||||
{
|
||||
callback_error(request, OpenNebula.Error(response));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
"addgroup" : function(params){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var gid = params.data.extra_param;
|
||||
|
||||
var method = "addgroup";
|
||||
var action = OpenNebula.Helper.action(method, {"group_id": gid});
|
||||
var request = OpenNebula.Helper.request(OpenNebula.User.resource,method, [id, gid]);
|
||||
|
||||
$.ajax({
|
||||
url: "user/" + id + "/action",
|
||||
type: "POST",
|
||||
data: JSON.stringify(action),
|
||||
success: function()
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
callback(request);
|
||||
}
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
if (callback_error)
|
||||
{
|
||||
callback_error(request, OpenNebula.Error(response));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
"delgroup" : function(params){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var gid = params.data.extra_param;
|
||||
|
||||
var method = "delgroup";
|
||||
var action = OpenNebula.Helper.action(method, {"group_id": gid});
|
||||
var request = OpenNebula.Helper.request(OpenNebula.User.resource,method, [id, gid]);
|
||||
|
||||
$.ajax({
|
||||
url: "user/" + id + "/action",
|
||||
type: "POST",
|
||||
@ -1905,6 +1844,67 @@ var OpenNebula = {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// "addgroup" : function(params){
|
||||
// var callback = params.success;
|
||||
// var callback_error = params.error;
|
||||
// var id = params.data.id;
|
||||
// var gid = params.data.extra_param;
|
||||
|
||||
// var method = "addgroup";
|
||||
// var action = OpenNebula.Helper.action(method, {"group_id": gid});
|
||||
// var request = OpenNebula.Helper.request(OpenNebula.User.resource,method, [id, gid]);
|
||||
|
||||
// $.ajax({
|
||||
// url: "user/" + id + "/action",
|
||||
// type: "POST",
|
||||
// data: JSON.stringify(action),
|
||||
// success: function()
|
||||
// {
|
||||
// if (callback)
|
||||
// {
|
||||
// callback(request);
|
||||
// }
|
||||
// },
|
||||
// error: function(response)
|
||||
// {
|
||||
// if (callback_error)
|
||||
// {
|
||||
// callback_error(request, OpenNebula.Error(response));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// "delgroup" : function(params){
|
||||
// var callback = params.success;
|
||||
// var callback_error = params.error;
|
||||
// var id = params.data.id;
|
||||
// var gid = params.data.extra_param;
|
||||
|
||||
// var method = "delgroup";
|
||||
// var action = OpenNebula.Helper.action(method, {"group_id": gid});
|
||||
// var request = OpenNebula.Helper.request(OpenNebula.User.resource,method, [id, gid]);
|
||||
|
||||
// $.ajax({
|
||||
// url: "user/" + id + "/action",
|
||||
// type: "POST",
|
||||
// data: JSON.stringify(action),
|
||||
// success: function()
|
||||
// {
|
||||
// if (callback)
|
||||
// {
|
||||
// callback(request);
|
||||
// }
|
||||
// },
|
||||
// error: function(response)
|
||||
// {
|
||||
// if (callback_error)
|
||||
// {
|
||||
// callback_error(request, OpenNebula.Error(response));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
},
|
||||
|
||||
"Image": {
|
||||
|
@ -99,7 +99,7 @@ var dashboard_tab_content =
|
||||
<h3>Quickstart</h3>\
|
||||
<form id="quickstart_form"><fieldset>\
|
||||
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
|
||||
<label style="font-weight:bold;width:40px;height:7em;">New:</label>\
|
||||
<label style="font-weight:bold;width:40px;height:8em;">New:</label>\
|
||||
<input type="radio" name="quickstart" value="Host.create_dialog">Host</input><br />\
|
||||
<input type="radio" name="quickstart" value="Group.create_dialog">Group</input><br />\
|
||||
<input type="radio" name="quickstart" value="Template.create_dialog">VM Template</input><br />\
|
||||
|
@ -81,7 +81,7 @@ var dashboard_tab_content =
|
||||
<h3>Quickstart</h3>\
|
||||
<form id="quickstart_form"><fieldset>\
|
||||
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
|
||||
<label style="font-weight:bold;width:40px;height:7em;">New:</label>\
|
||||
<label style="font-weight:bold;width:40px;height:4em;">New:</label>\
|
||||
<input type="radio" name="quickstart" value="Template.create_dialog">VM Template</input><br />\
|
||||
<input type="radio" name="quickstart" value="VM.create_dialog">VM Instance</input><br />\
|
||||
<input type="radio" name="quickstart" value="Network.create_dialog">Virtual Network</input><br />\
|
||||
|
@ -107,14 +107,14 @@ var group_actions = {
|
||||
notify:true
|
||||
},
|
||||
|
||||
"Group.chown" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Group.chown,
|
||||
callback : updateGroupElement,
|
||||
elements: function() { return getSelectedNodes(dataTable_groups); },
|
||||
error : onError,
|
||||
notify:true
|
||||
},
|
||||
// "Group.chown" : {
|
||||
// type: "multiple",
|
||||
// call : OpenNebula.Group.chown,
|
||||
// callback : updateGroupElement,
|
||||
// elements: function() { return getSelectedNodes(dataTable_groups); },
|
||||
// error : onError,
|
||||
// notify:true
|
||||
// },
|
||||
|
||||
}
|
||||
|
||||
@ -130,13 +130,13 @@ var group_buttons = {
|
||||
text: "+ New Group",
|
||||
condition : True
|
||||
},
|
||||
"Group.chown" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Change group owner",
|
||||
select: function(){return users_select},
|
||||
tip: "Select the new group owner:",
|
||||
condition : True
|
||||
},
|
||||
// "Group.chown" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Change group owner",
|
||||
// select: function(){return users_select},
|
||||
// tip: "Select the new group owner:",
|
||||
// condition : True
|
||||
// },
|
||||
|
||||
"Group.delete" : {
|
||||
type: "action",
|
||||
|
@ -359,14 +359,14 @@ var image_buttons = {
|
||||
text: "Change owner",
|
||||
select: function() {return users_select;},
|
||||
tip: "Select the new owner:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
"Image.chgrp" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Change group",
|
||||
select: function() {return groups_select;},
|
||||
tip: "Select the new group:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
"action_list" : {
|
||||
type: "select",
|
||||
|
@ -711,14 +711,14 @@ var template_buttons = {
|
||||
text: "Change owner",
|
||||
select: function() {return users_select;},
|
||||
tip: "Select the new owner:",
|
||||
condition: True
|
||||
condition: function(){return gid==0;}
|
||||
},
|
||||
"Template.chgrp" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Change group",
|
||||
select: function() {return groups_select;},
|
||||
tip: "Select the new group:",
|
||||
condition: True
|
||||
condition: function(){return gid==0;}
|
||||
},
|
||||
"action_list" : {
|
||||
type: "select",
|
||||
|
@ -29,7 +29,7 @@ var users_tab_content =
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">All</input></th>\
|
||||
<th>ID</th>\
|
||||
<th>Name</th>\
|
||||
<th>Groups</th>\
|
||||
<th>Group</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyusers">\
|
||||
@ -93,7 +93,7 @@ var user_actions = {
|
||||
error: onError
|
||||
});
|
||||
},
|
||||
condition: function(){ uid == 0 },
|
||||
condition: True,
|
||||
notify: false
|
||||
},
|
||||
|
||||
@ -108,27 +108,27 @@ var user_actions = {
|
||||
notify: true
|
||||
},
|
||||
|
||||
"User.addgroup" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.addgroup,
|
||||
callback : function(req){
|
||||
Sunstone.runAction("User.show",req.request.data[0]);
|
||||
},
|
||||
elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
// "User.addgroup" : {
|
||||
// type: "multiple",
|
||||
// call: OpenNebula.User.addgroup,
|
||||
// callback : function(req){
|
||||
// Sunstone.runAction("User.show",req.request.data[0]);
|
||||
// },
|
||||
// elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
// error: onError,
|
||||
// notify: true
|
||||
// },
|
||||
|
||||
"User.delgroup" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.User.delgroup,
|
||||
callback : function(req){
|
||||
Sunstone.runAction("User.show",req.request.data[0]);
|
||||
},
|
||||
elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
// "User.delgroup" : {
|
||||
// type: "multiple",
|
||||
// call: OpenNebula.User.delgroup,
|
||||
// callback : function(req){
|
||||
// Sunstone.runAction("User.show",req.request.data[0]);
|
||||
// },
|
||||
// elements : function() {return getSelectedNodes(dataTable_users);},
|
||||
// error: onError,
|
||||
// notify: true
|
||||
// },
|
||||
|
||||
"User.show" : {
|
||||
type: "single",
|
||||
@ -161,25 +161,25 @@ var user_buttons = {
|
||||
},
|
||||
"User.chgrp" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Change main group",
|
||||
text: "Change group",
|
||||
select: function(){ return groups_select; },
|
||||
tip: "This will change the main group of the selected users. Select the new group:",
|
||||
condition: True
|
||||
},
|
||||
"User.addgroup" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Add to group",
|
||||
select: function(){ return groups_select; },
|
||||
tip: "Select the new group to add users:",
|
||||
condition: True
|
||||
},
|
||||
"User.delgroup" : {
|
||||
type: "confirm_with_select",
|
||||
text: "Delete from group",
|
||||
select: function(){ return groups_select; },
|
||||
tip: "Select the group from which to delete users:",
|
||||
condition: True
|
||||
},
|
||||
// "User.addgroup" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Add to group",
|
||||
// select: function(){ return groups_select; },
|
||||
// tip: "Select the new group to add users:",
|
||||
// condition: True
|
||||
// },
|
||||
// "User.delgroup" : {
|
||||
// type: "confirm_with_select",
|
||||
// text: "Delete from group",
|
||||
// select: function(){ return groups_select; },
|
||||
// tip: "Select the group from which to delete users:",
|
||||
// condition: True
|
||||
// },
|
||||
"User.delete" : {
|
||||
type: "action",
|
||||
text: "Delete",
|
||||
@ -191,7 +191,7 @@ var users_tab = {
|
||||
title: "Users",
|
||||
content: users_tab_content,
|
||||
buttons: user_buttons,
|
||||
condition: function(){ return uid == 0; }
|
||||
condition: True
|
||||
}
|
||||
|
||||
Sunstone.addActions(user_actions);
|
||||
@ -201,52 +201,12 @@ Sunstone.addMainTab('users_tab',users_tab);
|
||||
// added to the dataTable
|
||||
function userElementArray(user_json){
|
||||
var user = user_json.USER;
|
||||
if (!user.NAME || user.NAME == {}){
|
||||
name = "";
|
||||
} else {
|
||||
name = user.NAME;
|
||||
}
|
||||
|
||||
var groups_str="";
|
||||
if (user.GROUPS.ID.constructor == Array){ //several groups
|
||||
for (var i=0; i< user.GROUPS.ID.length; i++){
|
||||
groups_str+=getGroupName(user.GROUPS.ID[i])+', ';
|
||||
};
|
||||
groups_str = groups_str.slice(0,-2);
|
||||
} else { //one group
|
||||
groups_str = getGroupName(user.GROUPS.ID);
|
||||
};
|
||||
|
||||
// var groups_full_str=getGroupName(user.GID)+", ";
|
||||
// var group_field;
|
||||
|
||||
// if (user.GROUPS.ID){
|
||||
// $.each(user.GROUPS.ID,function() {
|
||||
// if (i<=5) {
|
||||
// groups_str+=getGroupName(this)+", ";
|
||||
// };
|
||||
// groups_full_str+=getGroupName(this)+", ";
|
||||
// i++;
|
||||
// });
|
||||
// if (i>0){
|
||||
// groups_str = groups_str.slice(0, -2);
|
||||
// groups_full_str = groups_str.slice(0, -2);
|
||||
// };
|
||||
// if (i>5){
|
||||
// groups_str+="...";
|
||||
// group_field = '<div class="shortened_info">'+groups_str+'</div><div class="full_info" style="display:none">'+groups_full_str+'</div>';
|
||||
// } else {
|
||||
// group_field=groups_str;
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'<input type="checkbox" id="user_'+user.ID+'" name="selected_items" value="'+user.ID+'"/>',
|
||||
user.ID,
|
||||
name,
|
||||
groups_str
|
||||
user.NAME,
|
||||
user.GNAME
|
||||
]
|
||||
}
|
||||
|
||||
@ -305,7 +265,7 @@ function setupCreateUserDialog(){
|
||||
$('#create_user_form').submit(function(){
|
||||
var user_name=$('#username',this).val();
|
||||
var user_password=$('#pass',this).val();
|
||||
if (!user_name.length && !user_password.length){
|
||||
if (!user_name.length || !user_password.length){
|
||||
notifyError("User name and password must be filled in");
|
||||
return false;
|
||||
}
|
||||
@ -337,30 +297,29 @@ function setUserAutorefresh(){
|
||||
|
||||
$(document).ready(function(){
|
||||
//if we are not oneadmin, our tab will not even be in the DOM.
|
||||
if (uid==0) {
|
||||
dataTable_users = $("#datatable_users").dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bAutoWidth":false,
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] }
|
||||
]
|
||||
});
|
||||
dataTable_users.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','',''],dataTable_users);
|
||||
dataTable_users = $("#datatable_users").dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bAutoWidth":false,
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] }
|
||||
]
|
||||
});
|
||||
dataTable_users.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','',''],dataTable_users);
|
||||
|
||||
Sunstone.runAction("User.list");
|
||||
Sunstone.runAction("User.list");
|
||||
|
||||
setupCreateUserDialog();
|
||||
setUserAutorefresh();
|
||||
setupCreateUserDialog();
|
||||
setUserAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_users);
|
||||
tableCheckboxesListener(dataTable_users);
|
||||
shortenedInfoFields('#datatable_users');
|
||||
|
||||
initCheckAllBoxes(dataTable_users);
|
||||
tableCheckboxesListener(dataTable_users);
|
||||
shortenedInfoFields('#datatable_users');
|
||||
}
|
||||
})
|
||||
|
@ -419,7 +419,7 @@ var vm_buttons = {
|
||||
text: "Change owner",
|
||||
select: function() {return users_select;},
|
||||
tip: "Select the new owner:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
|
||||
"VM.chgrp" : {
|
||||
@ -427,7 +427,7 @@ var vm_buttons = {
|
||||
text: "Change group",
|
||||
select: function() {return groups_select;},
|
||||
tip: "Select the new group:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
|
||||
"VM.shutdown" : {
|
||||
|
@ -264,7 +264,7 @@ var vnet_buttons = {
|
||||
text: "Change owner",
|
||||
select: function() {return users_select;},
|
||||
tip: "Select the new owner:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
|
||||
"Network.chgrp" : {
|
||||
@ -272,7 +272,7 @@ var vnet_buttons = {
|
||||
text: "Change group",
|
||||
select: function() {return groups_select;},
|
||||
tip: "Select the new group:",
|
||||
condition: True
|
||||
condition: function() { return gid == 0; }
|
||||
},
|
||||
|
||||
"Network.delete" : {
|
||||
|
@ -374,9 +374,10 @@ function readCookie(){
|
||||
//sets the user info in the top bar and creates a listner in the
|
||||
//signout button
|
||||
function setLogin(){
|
||||
//This two variables can be used anywhere
|
||||
//This variables can be used anywhere
|
||||
username = cookie["one-user"];
|
||||
uid = cookie["one-user_id"];
|
||||
gid = cookie["one-user_gid"];
|
||||
|
||||
$("#user").html(username);
|
||||
$("#logout").click(function(){
|
||||
|
@ -137,6 +137,9 @@ get '/' do
|
||||
response.set_cookie("one-user_id",
|
||||
:value=>"#{session[:user_id]}",
|
||||
:expires=>time)
|
||||
response.set_cookie("one-user_gid",
|
||||
:value=>"#{session[:user_gid]}",
|
||||
:expires=>time)
|
||||
|
||||
p = SunstonePlugins.new
|
||||
@plugins = p.authorized_plugins(session[:user], session[:user_gname])
|
||||
@ -187,7 +190,7 @@ end
|
||||
# GET Pool information
|
||||
##############################################################################
|
||||
get '/:pool' do
|
||||
@SunstoneServer.get_pool(params[:pool])
|
||||
@SunstoneServer.get_pool(params[:pool],session[:user_gid])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
@ -725,6 +725,10 @@ int VirtualMachine::get_disk_images(string& error_str)
|
||||
{
|
||||
goto error_image;
|
||||
}
|
||||
else if ( rc == -3)
|
||||
{
|
||||
goto error_name;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -744,6 +748,9 @@ error_max_db:
|
||||
error_image:
|
||||
error_str = "Could not get disk image for VM.";
|
||||
|
||||
error_name:
|
||||
error_str = "NAME is not supported for DISK. Use IMAGE_ID instead.";
|
||||
|
||||
error_common:
|
||||
NebulaLog::log("ONE",Log::ERROR, error_str);
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user