mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
F #2347: Fix bugs. Show role names in vm group output
This commit is contained in:
parent
973aac07fd
commit
202b47e9d8
@ -96,22 +96,14 @@ namespace one_util
|
||||
* @param st string to split
|
||||
* @param delim delimiter character
|
||||
* @param result where the result will be saved
|
||||
* @param clean_empty true to clean empty split parts.
|
||||
* Example for st "a::b:c"
|
||||
* clean_empty true will return ["a", "b", "c"]
|
||||
* clean_empty fase will return ["a", "", "b", "c"]
|
||||
*/
|
||||
template <class T>
|
||||
void split_unique(
|
||||
const std::string& st,
|
||||
char delim,
|
||||
std::set<T>& result,
|
||||
bool clean_empty=true)
|
||||
void split_unique(const std::string& st, char delim, std::set<T>& result)
|
||||
{
|
||||
T elem;
|
||||
std::vector<std::string>::const_iterator it;
|
||||
|
||||
std::vector<std::string> strings = split(st, delim, clean_empty);
|
||||
std::vector<std::string> strings = split(st, delim, true);
|
||||
|
||||
for (it = strings.begin(); it != strings.end(); it++)
|
||||
{
|
||||
@ -127,6 +119,13 @@ namespace one_util
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicit specialization for strings
|
||||
*/
|
||||
template <>
|
||||
void split_unique(const std::string& st, char delim,
|
||||
std::set<std::string>& result);
|
||||
|
||||
/**
|
||||
* Joins the given element with the delimiter
|
||||
*
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
case VROUTER: return "VROUTER" ; break;
|
||||
case MARKETPLACE: return "MARKETPLACE" ; break;
|
||||
case MARKETPLACEAPP: return "MARKETPLACEAPP" ; break;
|
||||
case VMGROUP: return "VMGROUP" ; break;
|
||||
default: return "";
|
||||
}
|
||||
};
|
||||
|
@ -165,11 +165,6 @@ private:
|
||||
// -------------------------------------------------------------------------
|
||||
// VMGroup attributes
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Name of the VM Group
|
||||
*/
|
||||
std::string name;
|
||||
|
||||
/**
|
||||
* The role set
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define VMGROUP_ROLE_H_
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "NebulaUtil.h"
|
||||
|
||||
class VMGroupPool;
|
||||
|
||||
@ -186,7 +187,9 @@ private:
|
||||
|
||||
for ( it = key_set.begin(); it != key_set.end() ; ++it )
|
||||
{
|
||||
if ( roles.find(*it) == roles.end() )
|
||||
string rname = one_util::trim(*it);
|
||||
|
||||
if ( roles.find(rname) == roles.end() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the VM Group
|
||||
:size: 20
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:USER:
|
||||
@ -18,8 +18,14 @@
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:ROLES:
|
||||
:desc: Roles in the VM Group
|
||||
:size: 31
|
||||
:left: true
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
- :ROLES
|
||||
|
@ -33,7 +33,7 @@ class OneVMGroupHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the VM Group", :left, :size=>20 do |d|
|
||||
column :NAME, "Name of the VM Group", :left, :size=>15 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
@ -46,7 +46,19 @@ class OneVMGroupHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME
|
||||
column :ROLES, "Roles in the VM Group", :left, :size=>31 do |d|
|
||||
roles = d["ROLES"]["ROLE"]
|
||||
roles_names = ""
|
||||
|
||||
if !roles.nil?
|
||||
rnames = roles.collect { |i| i["NAME"] }
|
||||
roles_names = rnames.join(", ") if !rnames.empty?
|
||||
end
|
||||
|
||||
roles_names
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :ROLES
|
||||
end
|
||||
|
||||
table
|
||||
|
@ -339,6 +339,25 @@ std::string one_util::gsub(const std::string& st, const std::string& sfind,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
namespace one_util
|
||||
{
|
||||
template<>
|
||||
void split_unique(const std::string& st, char delim, std::set<std::string>& res)
|
||||
{
|
||||
std::vector<std::string>::const_iterator it;
|
||||
|
||||
std::vector<std::string> strings = split(st, delim, true);
|
||||
|
||||
for (it = strings.begin(); it != strings.end(); it++)
|
||||
{
|
||||
res.insert(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Buffer length for zlib inflate/deflate
|
||||
*/
|
||||
|
@ -169,5 +169,10 @@ module OpenNebula
|
||||
def owner_id
|
||||
self['UID'].to_i
|
||||
end
|
||||
|
||||
# [return] _Array_ with the name of roles
|
||||
def role_names
|
||||
self.retrieve_elements('ROLES/ROLE/NAME')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,6 +63,8 @@ string Request::object_name(PoolObjectSQL::ObjectType ob)
|
||||
return "marketplace";
|
||||
case PoolObjectSQL::MARKETPLACEAPP:
|
||||
return "marketplaceapp";
|
||||
case PoolObjectSQL::VMGROUP:
|
||||
return "vm group";
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user