Revision 5bde303f

View differences:

include/Request.h
128 128
    void failure_response(ErrorCode ec, const string& val);
129 129

  
130 130
    /**
131
     *  Gets a string representation for the Auth object in the
132
     *  request.
133
     *    @param ob object for the auth operation
134
     *    @returns string equivalent of the object
135
     */
136
    static string object_name(AuthRequest::Object ob);
137

  
138
    /**
131 139
     *  Logs authorization errors
132 140
     *    @param action authorization action
133 141
     *    @param object object that needs to be authorized
src/rm/Request.cc
147 147
/* -------------------------------------------------------------------------- */
148 148
/* -------------------------------------------------------------------------- */
149 149

  
150
string Request::object_name(AuthRequest::Object ob)
151
{
152
    switch (ob)
153
    {
154
        case AuthRequest::VM:
155
            return "virtual machine";
156
        case AuthRequest::HOST:
157
            return "host";
158
        case AuthRequest::NET:
159
            return "virtual network";
160
        case AuthRequest::IMAGE:
161
            return "image";
162
        case AuthRequest::USER:
163
            return "user";
164
        case AuthRequest::CLUSTER:
165
            return "cluster";
166
        case AuthRequest::TEMPLATE:
167
            return "virtual machine template";
168
        case AuthRequest::GROUP:
169
            return "group";
170
        default:
171
            return "-";
172
      }
173
};
174

  
175
/* -------------------------------------------------------------------------- */
176
/* -------------------------------------------------------------------------- */
177

  
150 178
string Request::authorization_error (const string &action,
151 179
                                     const string &object,
152 180
                                     int   uid,
src/rm/RequestManagerAllocate.cc
27 27
    ostringstream oss;
28 28

  
29 29
    oss << "[" << method_name << "]" << " Error allocating a new "
30
        << AuthRequest::object_name(auth_object) << ".";
30
        << object_name(auth_object) << ".";
31 31

  
32 32
    if (!error.empty())
33 33
    {
......
45 45
    ostringstream oss;
46 46

  
47 47
    oss << "[" << method_name << "]" << " Error allocating a new "
48
        << AuthRequest::object_name(auth_object) << ". Parse error";
48
        << object_name(auth_object) << ". Parse error";
49 49

  
50 50
    if ( error != 0 )
51 51
    {
......
147 147
                                          string& error_str)
148 148
{
149 149
    VirtualNetworkPool * vpool = static_cast<VirtualNetworkPool *>(pool);
150
    VirtualNetworkTemplate * vtmpl = static_cast<VirtualNetworkTemplate *>(tmpl);
150
    VirtualNetworkTemplate * vtmpl=static_cast<VirtualNetworkTemplate *>(tmpl);
151 151

  
152 152
    return vpool->allocate(uid, gid, vtmpl, &id, error_str);
153 153
}
......
175 175
                                    string& error_str)
176 176
{
177 177
    VMTemplatePool * tpool = static_cast<VMTemplatePool *>(pool);
178
    VirtualMachineTemplate * ttmpl = static_cast<VirtualMachineTemplate *>(tmpl);
178

  
179
    VirtualMachineTemplate * ttmpl=static_cast<VirtualMachineTemplate *>(tmpl);
179 180

  
180 181
    return tpool->allocate(uid, gid, ttmpl, &id, error_str);
181 182
}
......
238 239
                                 string& error_str)
239 240
{
240 241
    string gname = xmlrpc_c::value_string(paramList.getString(1));
242

  
241 243
    GroupPool * gpool = static_cast<GroupPool *>(pool);
242 244

  
243 245
    return gpool->allocate(uid, gname, &id, error_str);

Also available in: Unified diff