Revision 202b47e9

View differences:

include/NebulaUtil.h
96 96
     * @param st string to split
97 97
     * @param delim delimiter character
98 98
     * @param result where the result will be saved
99
     * @param clean_empty true to clean empty split parts.
100
     *  Example for st "a::b:c"
101
     *      clean_empty true will return ["a", "b", "c"]
102
     *      clean_empty fase will return ["a", "", "b", "c"]
103 99
     */
104 100
    template <class T>
105
    void split_unique(
106
            const std::string& st,
107
            char delim,
108
            std::set<T>& result,
109
            bool clean_empty=true)
101
    void split_unique(const std::string& st, char delim, std::set<T>& result)
110 102
    {
111 103
        T elem;
112 104
        std::vector<std::string>::const_iterator it;
113 105

  
114
        std::vector<std::string> strings = split(st, delim, clean_empty);
106
        std::vector<std::string> strings = split(st, delim, true);
115 107

  
116 108
        for (it = strings.begin(); it != strings.end(); it++)
117 109
        {
......
128 120
    }
129 121

  
130 122
    /**
123
     * Explicit specialization for strings
124
     */
125
    template <>
126
    void split_unique(const std::string& st, char delim,
127
            std::set<std::string>& result);
128

  
129
    /**
131 130
     * Joins the given element with the delimiter
132 131
     *
133 132
     * @param first iterator
include/PoolObjectSQL.h
91 91
            case VROUTER:        return "VROUTER" ; break;
92 92
            case MARKETPLACE:    return "MARKETPLACE" ; break;
93 93
            case MARKETPLACEAPP: return "MARKETPLACEAPP" ; break;
94
            case VMGROUP:        return "VMGROUP" ; break;
94 95
            default:             return "";
95 96
        }
96 97
    };
include/VMGroup.h
165 165
    // -------------------------------------------------------------------------
166 166
    // VMGroup attributes
167 167
    // -------------------------------------------------------------------------
168
    /**
169
     *  Name of the VM Group
170
     */
171
    std::string name;
172

  
173 168
	/**
174 169
	 *  The role set
175 170
	 */
include/VMGroupRole.h
18 18
#define VMGROUP_ROLE_H_
19 19

  
20 20
#include "PoolObjectSQL.h"
21
#include "NebulaUtil.h"
21 22

  
22 23
class VMGroupPool;
23 24

  
......
186 187

  
187 188
            for ( it = key_set.begin(); it != key_set.end() ; ++it )
188 189
            {
189
                if ( roles.find(*it) == roles.end() )
190
                string rname = one_util::trim(*it);
191

  
192
                if ( roles.find(rname) == roles.end() )
190 193
                {
191 194
                    return false;
192 195
                }
src/cli/etc/onevmgroup.yaml
5 5

  
6 6
:NAME:
7 7
  :desc: Name of the VM Group
8
  :size: 20
8
  :size: 15
9 9
  :left: true
10 10

  
11 11
:USER:
......
18 18
  :size: 15
19 19
  :left: true
20 20

  
21
:ROLES:
22
  :desc: Roles in the VM Group
23
  :size: 31
24
  :left: true
25

  
21 26
:default:
22 27
- :ID
23 28
- :USER
24 29
- :GROUP
25 30
- :NAME
31
- :ROLES
src/cli/one_helper/onevmgroup_helper.rb
33 33
                d["ID"]
34 34
            end
35 35

  
36
            column :NAME, "Name of the VM Group", :left, :size=>20 do |d|
36
            column :NAME, "Name of the VM Group", :left, :size=>15 do |d|
37 37
                d["NAME"]
38 38
            end
39 39

  
......
46 46
                helper.group_name(d, options)
47 47
            end
48 48

  
49
            default :ID, :USER, :GROUP, :NAME
49
            column :ROLES, "Roles in the VM Group", :left, :size=>31 do |d|
50
                roles = d["ROLES"]["ROLE"]
51
                roles_names = ""
52

  
53
                if !roles.nil?
54
                    rnames = roles.collect { |i| i["NAME"] }
55
                    roles_names = rnames.join(", ") if !rnames.empty?
56
                end
57

  
58
                roles_names
59
            end
60

  
61
            default :ID, :USER, :GROUP, :NAME, :ROLES
50 62
        end
51 63

  
52 64
        table
src/common/NebulaUtil.cc
339 339
/* -------------------------------------------------------------------------- */
340 340
/* -------------------------------------------------------------------------- */
341 341

  
342
namespace one_util
343
{
344
template<>
345
void split_unique(const std::string& st, char delim, std::set<std::string>& res)
346
{
347
    std::vector<std::string>::const_iterator it;
348

  
349
    std::vector<std::string> strings = split(st, delim, true);
350

  
351
    for (it = strings.begin(); it != strings.end(); it++)
352
    {
353
        res.insert(*it);
354
    }
355
}
356
}
357

  
358
/* -------------------------------------------------------------------------- */
359
/* -------------------------------------------------------------------------- */
360

  
342 361
/**
343 362
 *  Buffer length for zlib inflate/deflate
344 363
 */
src/oca/ruby/opennebula/vm_group.rb
169 169
        def owner_id
170 170
            self['UID'].to_i
171 171
        end
172

  
173
        # [return] _Array_ with the name of roles
174
        def role_names
175
            self.retrieve_elements('ROLES/ROLE/NAME')
176
        end
172 177
    end
173 178
end
src/rm/Request.cc
63 63
            return "marketplace";
64 64
        case PoolObjectSQL::MARKETPLACEAPP:
65 65
            return "marketplaceapp";
66
        case PoolObjectSQL::VMGROUP:
67
            return "vm group";
66 68
        default:
67 69
            return "-";
68 70
      }

Also available in: Unified diff