Revision f3fc078b

View differences:

include/RequestManager.h
173 173
    // ----------------------------------------------------------------------
174 174
    // ----------------------------------------------------------------------   
175 175
    
176
    
177
    /**
178
     *  Logs authorization errors
179
     *    @param method name of the RM method where the error arose
180
     *    @param action authorization action
181
     *    @param object object that needs to be authorized
182
     *    @param uid user that is authorized
183
     *    @param id id of the object, -1 for Pool
184
     *    @returns string for logging
185
     */
176 186
    static string authorization_error (const string& method, 
177 187
                                       const string &action, 
178 188
                                       const string &object, 
......
180 190
                                       int   id)
181 191
    {
182 192
        ostringstream oss;
183
        oss << "[" << method << "]" << " User [" << uid << "] not authorized "               
193
        oss << "[" << method << "]" << " User [" << uid << "] not authorized"               
184 194
            << " to perform " << action << " on " << object; 
185 195
            
186 196
        
......
196 206
        return oss.str();
197 207
    }
198 208
    
209
    /**
210
     *  Logs authenticate errors
211
     *    @param method name of the RM method where the error arose
212
     *    @returns string for logging
213
     */   
199 214
    static string authenticate_error (const string& method)
200 215
    {
201 216
        ostringstream oss;
......
205 220
      
206 221
        return oss.str();
207 222
    }
208

  
223
    
224
    /**
225
     *  Logs get object errors
226
     *    @param method name of the RM method where the error arose
227
     *    @param object over which the get failed
228
     *    @param id of the object over which the get failed
229
     *    @returns string for logging
230
     */
209 231
    static string get_error (const string& method, 
210 232
                             const string &object, 
211 233
                             int id)
......
227 249
       return oss.str();
228 250
    }
229 251
    
252
    /**
253
     *  Logs action errors
254
     *    @param method name of the RM method where the error arose
255
     *    @param action that triggered the error
256
     *    @param object over which the action was applied
257
     *    @param id id of the object, -1 for Pool, -2 for no-id objects   
258
     *              (allocate error, parse error)
259
     *    @param rc returned error code (NULL to ignore)
260
     *    @returns string for logging
261
     */
230 262
    static string action_error (const string& method,
231 263
                                const string &action, 
232 264
                                const string &object, 
......
271 303
    {
272 304
    public:
273 305
        VirtualMachineAllocate(
274
            UserPool * _upool):
275
		upool(_upool)
306
            VirtualMachinePool * _vmpool,
307
            VirtualNetworkPool * _vnpool,
308
            ImagePool          * _ipool,
309
            UserPool           * _upool):
310
        vmpool(_vmpool),
311
        vnpool(_vnpool),
312
        ipool(_ipool),
313
        upool(_upool)
276 314
        {
277 315
            _signature="A:ss";
278 316
            _help="Allocates a virtual machine in the pool";
......
284 322
            xmlrpc_c::paramList const& paramList,
285 323
            xmlrpc_c::value *   const  retval);
286 324
    private:
325
        VirtualMachinePool * vmpool;
326
        VirtualNetworkPool * vnpool;
327
        ImagePool          * ipool;
287 328
        UserPool           * upool;
288 329
    };
289 330
    
......
294 335
    public:
295 336
        VirtualMachineDeploy(
296 337
            VirtualMachinePool * _vmpool,
297
            HostPool *           _hpool,
298
            UserPool *           _upool):
338
            HostPool           * _hpool,
339
            UserPool           * _upool):
299 340
                vmpool(_vmpool),
300 341
                hpool(_hpool),
301 342
                upool(_upool)
src/rm/RequestManager.cc
214 214
void RequestManager::register_xml_methods()
215 215
{
216 216
    xmlrpc_c::methodPtr vm_allocate(new 
217
        RequestManager::VirtualMachineAllocate(upool));
217
        RequestManager::VirtualMachineAllocate(vmpool, vnpool, ipool, upool));
218 218
        
219 219
    xmlrpc_c::methodPtr vm_deploy(new 
220 220
        RequestManager::VirtualMachineDeploy(vmpool,hpool,upool));
src/rm/RequestManagerAllocate.cc
34 34
    int                 vid, uid;
35 35
    int                 rc;
36 36

  
37
    Nebula&             nd    = Nebula::instance();
38
    ImagePool *         ipool = nd.get_ipool();
39
    VirtualNetworkPool* vnpool= nd.get_vnpool();
40
    VirtualMachinePool* vmpool= nd.get_vmpool();
41

  
42 37
    ostringstream       oss;
43 38

  
44 39
    vector<xmlrpc_c::value> arrayData;
......
96 91
                continue;
97 92
            }
98 93

  
99
            ipool->authorize_disk(vector,&ar);
94
            VirtualMachineAllocate::ipool->authorize_disk(vector,&ar);
100 95
        }
101 96

  
102 97
        num = vm_template->get("NIC",vectors);
......
110 105
                continue;
111 106
            }
112 107

  
113
            vnpool->authorize_nic(vector,&ar);
108
            VirtualMachineAllocate::vnpool->authorize_nic(vector,&ar);
114 109
        }
115 110

  
116 111
        ar.add_auth(AuthRequest::VM,
......
128 123
    //--------------------------------------------------------------------------
129 124
    //   Allocate the VirtualMAchine
130 125
    //--------------------------------------------------------------------------
131
    rc = vmpool->allocate(uid,vm_template,&vid,false);
126
    rc = VirtualMachineAllocate::vmpool->allocate(uid,vm_template,&vid,false);
132 127

  
133 128
    if ( rc < 0 )
134 129
    {
......
157 152
    goto error_common;
158 153

  
159 154
error_parse:
160
    oss.str(action_error(method_name, "PARSE", "VM TEMPLATE",-2,rc));
155
    oss << action_error(method_name, "PARSE", "VM TEMPLATE",-2,rc);
161 156
    if (error_msg != 0)
162 157
    {
163
        oss << "Reason: " << error_msg;
158
        oss << ". Reason: " << error_msg;
164 159
        free(error_msg);
165 160
    }
166 161

  
src/rm/RequestManagerImageAllocate.cc
127 127
    goto error_common;
128 128

  
129 129
error_parse:
130
    oss.str(action_error(method_name, "PARSE", "IMAGE TEMPLATE",-2,rc));
130
    oss << action_error(method_name, "PARSE", "IMAGE TEMPLATE",-2,rc);
131 131
    if (error_msg != 0)
132 132
    {
133
        oss << "Reason: " << error_msg;
133
        oss << ". Reason: " << error_msg;
134 134
        free(error_msg);
135 135
    }
136 136

  
src/rm/RequestManagerVirtualNetworkAllocate.cc
127 127
    goto error_common;
128 128

  
129 129
error_parse:
130
    oss.str(action_error(method_name, "PARSE", "VNET TEMPLATE",-2,rc));
130
    oss << action_error(method_name, "PARSE", "VNET TEMPLATE",-2,rc);
131 131
    if (error_msg != 0)
132 132
    {
133
        oss << "Reason: " << error_msg;
133
        oss << ". Reason: " << error_msg;
134 134
        free(error_msg);
135 135
    }
136 136

  

Also available in: Unified diff