Revision 1035fe77 src/vm/VirtualMachine.cc

View differences:

src/vm/VirtualMachine.cc
26 26
#include "VirtualMachine.h"
27 27
#include "VirtualNetworkPool.h"
28 28
#include "NebulaLog.h"
29
#include "AuthManager.h"
30 29

  
31 30
#include "Nebula.h"
32 31

  
......
268 267
    string              value;
269 268
    ostringstream       oss;
270 269

  
271
    AuthRequest ar(uid);
272

  
273 270
    // -----------------------------------------------------------------------
274 271
    // Set a template ID if it wasn't already assigned
275 272
    // ------------------------------------------------------------------------
......
306 303
    // Get network leases
307 304
    // ------------------------------------------------------------------------
308 305

  
309
    rc = get_network_leases(&ar);
306
    rc = get_network_leases();
310 307

  
311 308
    if ( rc != 0 )
312 309
    {
......
317 314
    // Get disk images
318 315
    // ------------------------------------------------------------------------
319 316

  
320
    rc = get_disk_images(&ar);
317
    rc = get_disk_images();
321 318

  
322 319
    if ( rc != 0 )
323 320
    {
......
345 342
    parse_graphics();
346 343

  
347 344
    // ------------------------------------------------------------------------
348
    // Authorize this request
349
    // ------------------------------------------------------------------------
350

  
351
    if ( uid != 0 ) // uid == 0 means oneadmin
352
    {
353
        string t64;
354

  
355
        ar.add_auth(AuthRequest::VM,
356
                    vm_template.to_xml(t64),
357
                    AuthRequest::CREATE,
358
                    uid,
359
                    false);
360

  
361
        if (UserPool::authorize(ar) == -1)
362
        {
363
            goto error_authorize;
364
        }
365
    }
366

  
367
    // ------------------------------------------------------------------------
368 345
    // Insert the template first, so we get a valid template ID. Then the VM
369 346
    // ------------------------------------------------------------------------
370 347

  
......
410 387
    NebulaLog::log("ONE",Log::ERROR, "Could not parse REQUIREMENTS for VM");
411 388
    goto error_common;
412 389

  
413
error_authorize:
414
    NebulaLog::log("ONE",Log::ERROR, "Error authorizing VM creation");
415

  
416 390
error_common:
417 391
    release_network_leases();
418 392
    release_disk_images();
......
819 793
/* -------------------------------------------------------------------------- */
820 794
/* -------------------------------------------------------------------------- */
821 795

  
822
int VirtualMachine::get_disk_images(AuthRequest *ar)
796
int VirtualMachine::get_disk_images()
823 797
{
824 798
    int                   num_disks, rc;
825 799
    vector<Attribute  * > disks;
......
841 815
            continue;
842 816
        }
843 817

  
844
        rc = ipool->disk_attribute(disk, &index, ar);
818
        rc = ipool->disk_attribute(disk, &index);
845 819

  
846 820
        if (rc == -1) // 0 OK, -2 not using the Image pool
847 821
        {
......
879 853
            continue;
880 854
        }
881 855

  
882
        iid = disk->vector_value("IID");
856
        iid = disk->vector_value("IMAGE_ID");
883 857

  
884 858
        if ( iid.empty() )
885 859
        {
......
902 876
/* -------------------------------------------------------------------------- */
903 877
/* -------------------------------------------------------------------------- */
904 878

  
905
int VirtualMachine::get_network_leases(AuthRequest *ar)
879
int VirtualMachine::get_network_leases()
906 880
{
907 881
    int                   num_nics, rc;
908 882
    vector<Attribute  * > nics;
......
923 897
            continue;
924 898
        }
925 899

  
926
        rc = vnpool->nic_attribute(nic, oid, ar);
900
        rc = vnpool->nic_attribute(nic, oid);
927 901

  
928 902
        if (rc == -1)
929 903
        {
......
962 936
            continue;
963 937
        }
964 938

  
965
        vnid = nic->vector_value("VNID");
939
        vnid = nic->vector_value("NETWORK_ID");
966 940

  
967 941
        if ( vnid.empty() )
968 942
        {

Also available in: Unified diff