Statistics
| Branch: | Tag: | Revision:

one / include / RequestManager.h @ ae53d437

History | View | Annotate | Download (42.9 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             */
3
/*                                                                            */
4
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
5
/* not use this file except in compliance with the License. You may obtain    */
6
/* a copy of the License at                                                   */
7
/*                                                                            */
8
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
9
/*                                                                            */
10
/* Unless required by applicable law or agreed to in writing, software        */
11
/* distributed under the License is distributed on an "AS IS" BASIS,          */
12
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
13
/* See the License for the specific language governing permissions and        */
14
/* limitations under the License.                                             */
15
/* -------------------------------------------------------------------------- */
16

    
17
#ifndef REQUEST_MANAGER_H_
18
#define REQUEST_MANAGER_H_
19

    
20
#include "ActionManager.h"
21
#include "VirtualMachinePool.h"
22
#include "HostPool.h"
23
#include "UserPool.h"
24
#include "VirtualNetworkPool.h"
25
#include "ImagePool.h"
26
#include "ClusterPool.h"
27
#include "VMTemplatePool.h"
28
#include "GroupPool.h"
29

    
30
#include <xmlrpc-c/base.hpp>
31
#include <xmlrpc-c/registry.hpp>
32
#include <xmlrpc-c/server_abyss.hpp>
33

    
34
using namespace std;
35

    
36
extern "C" void * rm_action_loop(void *arg);
37

    
38
extern "C" void * rm_xml_server_loop(void *arg);
39

    
40
class RequestManager : public ActionListener
41
{
42
public:
43

    
44
    RequestManager(
45
        VirtualMachinePool *    _vmpool,
46
        HostPool *              _hpool,
47
        VirtualNetworkPool *    _vnpool,
48
        UserPool           *    _upool,
49
        ImagePool          *    _ipool,
50
        ClusterPool        *    _cpool,
51
        VMTemplatePool     *    _tpool,
52
        GroupPool          *    _gpool,
53
        int                     _port,
54
        string                  _xml_log_file)
55
            :vmpool(_vmpool),hpool(_hpool),vnpool(_vnpool),upool(_upool),
56
            ipool(_ipool),cpool(_cpool),tpool(_tpool),gpool(_gpool),port(_port),
57
            socket_fd(-1),xml_log_file(_xml_log_file)
58
    {
59
        am.addListener(this);
60
    };
61

    
62
    ~RequestManager()
63
    {}
64
    ;
65

    
66
    /**
67
     *  This functions starts the associated listener thread (XML server), and
68
     *  creates a new thread for the Request Manager. This thread will wait in
69
     *  an action loop till it receives ACTION_FINALIZE.
70
     *    @return 0 on success.
71
     */
72
    int start();
73

    
74
    /**
75
     *  Gets the thread identification.
76
     *    @return pthread_t for the manager thread (that in the action loop).
77
     */
78
    pthread_t get_thread_id() const
79
    {
80
        return rm_thread;
81
    };
82

    
83
    /**
84
     *
85
     */
86
    void finalize()
87
    {
88
        am.trigger(ACTION_FINALIZE,0);
89
    };
90

    
91
private:
92

    
93
    //--------------------------------------------------------------------------
94
    // Friends, thread functions require C-linkage
95
    //--------------------------------------------------------------------------
96

    
97
    friend void * rm_xml_server_loop(void *arg);
98

    
99
    friend void * rm_action_loop(void *arg);
100

    
101
    /**
102
     *  Thread id for the RequestManager
103
     */
104
    pthread_t               rm_thread;
105

    
106
    /**
107
     *  Thread id for the XML Server
108
     */
109
    pthread_t               rm_xml_server_thread;
110

    
111
    /**
112
     *  Pointer to the VM Pool, to access Virtual Machines
113
     */
114
    VirtualMachinePool *    vmpool;
115

    
116
    /**
117
     *  Pointer to the Host Pool, to access hosts
118
     */
119
    HostPool           *    hpool;
120

    
121
    /**
122
     *  Pointer to the VN Pool, to access Virtual Netowrks
123
     */
124
    VirtualNetworkPool *    vnpool;
125

    
126
    /**
127
     *  Pointer to the User Pool, to access users
128
     */
129
    UserPool           *    upool;
130

    
131
    /**
132
     *  Pointer to the Image Pool, to access images
133
     */
134
    ImagePool          *    ipool;
135

    
136
    /**
137
     *  Pointer to the Cluster Pool, to access clusters
138
     */
139
    ClusterPool        *    cpool;
140

    
141
    /**
142
     *  Pointer to the Template Pool, to access templates
143
     */
144
    VMTemplatePool     *    tpool;
145

    
146
    /**
147
     *  Pointer to the Group Pool, to access groups
148
     */
149
    GroupPool          *    gpool;
150

    
151
    /**
152
     *  Port number where the connection will be open
153
     */
154
    int port;
155

    
156
    /*
157
     *  FD for the XML server socket
158
     */
159
    int socket_fd;
160

    
161
    /**
162
     *  Filename for the log of the xmlrpc server that listens
163
     */
164
    string xml_log_file;
165

    
166
    /**
167
     *  Action engine for the Manager
168
     */
169
    ActionManager   am;
170

    
171
    /**
172
     *  To register XML-RPC methods
173
     */
174
    xmlrpc_c::registry RequestManagerRegistry;
175

    
176
    /**
177
     *  The XML-RPC server
178
     */
179
    xmlrpc_c::serverAbyss *  AbyssServer;
180

    
181
    /**
182
     *  The action function executed when an action is triggered.
183
     *    @param action the name of the action
184
     *    @param arg arguments for the action function
185
     */
186
    void do_action(const string & action, void * arg);
187

    
188
    void register_xml_methods();
189

    
190
    int setup_socket();
191

    
192
    // ----------------------------------------------------------------------
193
    // ----------------------------------------------------------------------
194
    //                          Error Messages
195
    // ----------------------------------------------------------------------
196
    // ----------------------------------------------------------------------
197

    
198

    
199
    /**
200
     *  Logs authorization errors
201
     *    @param method name of the RM method where the error arose
202
     *    @param action authorization action
203
     *    @param object object that needs to be authorized
204
     *    @param uid user that is authorized
205
     *    @param id id of the object, -1 for Pool
206
     *    @returns string for logging
207
     */
208
    static string authorization_error (const string& method,
209
                                       const string &action,
210
                                       const string &object,
211
                                       int   uid,
212
                                       int   id)
213
    {
214
        ostringstream oss;
215
        oss << "[" << method << "]" << " User [" << uid << "] not authorized"
216
            << " to perform " << action << " on " << object;
217

    
218

    
219
        if ( id != -1 )
220
        {
221
            oss << " [" << id << "].";
222
        }
223
        else
224
        {
225
            oss << " Pool";
226
        }
227

    
228
        return oss.str();
229
    }
230

    
231
    /**
232
     *  Logs authenticate errors
233
     *    @param method name of the RM method where the error arose
234
     *    @returns string for logging
235
     */
236
    static string authenticate_error (const string& method)
237
    {
238
        ostringstream oss;
239

    
240
        oss << "[" << method << "]" << " User couldn't be authenticated," <<
241
               " aborting call.";
242

    
243
        return oss.str();
244
    }
245

    
246
    /**
247
     *  Logs get object errors
248
     *    @param method name of the RM method where the error arose
249
     *    @param object over which the get failed
250
     *    @param id of the object over which the get failed
251
     *    @returns string for logging
252
     */
253
    static string get_error (const string& method,
254
                             const string &object,
255
                             int id)
256
    {
257
        ostringstream oss;
258

    
259
        oss << "[" << method << "]" << " Error getting " <<
260
               object;
261

    
262
       if ( id != -1 )
263
       {
264
           oss << " [" << id << "].";
265
       }
266
       else
267
       {
268
          oss << " Pool.";
269
       }
270

    
271
       return oss.str();
272
    }
273

    
274
    /**
275
     *  Logs action errors
276
     *    @param method name of the RM method where the error arose
277
     *    @param action that triggered the error
278
     *    @param object over which the action was applied
279
     *    @param id id of the object, -1 for Pool, -2 for no-id objects
280
     *              (allocate error, parse error)
281
     *    @param rc returned error code (NULL to ignore)
282
     *    @returns string for logging
283
     */
284
    static string action_error (const string& method,
285
                                const string &action,
286
                                const string &object,
287
                                int id,
288
                                int rc)
289
    {
290
        ostringstream oss;
291

    
292
        oss << "[" << method << "]" << " Error trying to " << action << " "
293
            << object;
294

    
295
        switch(id)
296
        {
297
            case -2:
298
                break;
299
            case -1:
300
                oss << "Pool.";
301
                break;
302
            default:
303
                oss << " [" << id << "].";
304
                break;
305
        }
306

    
307
        if ( rc != 0 )
308
        {
309
            oss << " Returned error code [" << rc << "].";
310
        }
311

    
312
        return oss.str();
313
    }
314

    
315
    // ----------------------------------------------------------------------
316
    // ----------------------------------------------------------------------
317
    //                          XML-RPC Methods
318
    // ----------------------------------------------------------------------
319
    // ----------------------------------------------------------------------
320

    
321
    /* ---------------------------------------------------------------------- */
322
    /*                     Virtual Machine Interface                          */
323
    /* ---------------------------------------------------------------------- */
324
    class VirtualMachineAllocate: public xmlrpc_c::method
325
    {
326
    public:
327
        VirtualMachineAllocate(
328
            VirtualMachinePool * _vmpool,
329
            VirtualNetworkPool * _vnpool,
330
            ImagePool          * _ipool,
331
            VMTemplatePool     * _tpool,
332
            UserPool           * _upool):
333
        vmpool(_vmpool),
334
        vnpool(_vnpool),
335
        ipool(_ipool),
336
        tpool(_tpool),
337
        upool(_upool)
338
        {
339
            _signature="A:ss";
340
            _help="Allocates a virtual machine in the pool";
341
        };
342

    
343
        ~VirtualMachineAllocate(){};
344

    
345
        void execute(
346
            xmlrpc_c::paramList const& paramList,
347
            xmlrpc_c::value *   const  retval);
348
    private:
349
        VirtualMachinePool * vmpool;
350
        VirtualNetworkPool * vnpool;
351
        ImagePool          * ipool;
352
        VMTemplatePool     * tpool;
353
        UserPool           * upool;
354
    };
355

    
356
    /* ---------------------------------------------------------------------- */
357

    
358
    class VirtualMachineDeploy: public xmlrpc_c::method
359
    {
360
    public:
361
        VirtualMachineDeploy(
362
            VirtualMachinePool * _vmpool,
363
            HostPool           * _hpool,
364
            UserPool           * _upool):
365
                vmpool(_vmpool),
366
                hpool(_hpool),
367
                upool(_upool)
368
        {
369
            _signature="A:sii";
370
            _help="Deploys a virtual machine";
371
        };
372

    
373
        ~VirtualMachineDeploy(){};
374

    
375
        void execute(
376
            xmlrpc_c::paramList const& paramList,
377
            xmlrpc_c::value *   const  retval);
378

    
379
    private:
380
        VirtualMachinePool * vmpool;
381
        HostPool           * hpool;
382
        UserPool           * upool;
383
    };
384

    
385
    /* ---------------------------------------------------------------------- */
386

    
387
    class VirtualMachineAction: public xmlrpc_c::method
388
    {
389
    public:
390
        VirtualMachineAction(
391
            VirtualMachinePool * _vmpool,
392
            UserPool * _upool):
393
                vmpool(_vmpool),
394
                upool(_upool)
395
        {
396
            _signature="A:ssi";
397
            _help="Performs an action on a virtual machine";
398
        };
399

    
400
        ~VirtualMachineAction(){};
401

    
402
        void execute(
403
            xmlrpc_c::paramList const& paramList,
404
            xmlrpc_c::value *   const  retval);
405

    
406
    private:
407
        VirtualMachinePool * vmpool;
408
        UserPool *           upool;
409
    };
410

    
411
    /* ---------------------------------------------------------------------- */
412

    
413
    class VirtualMachineMigrate: public xmlrpc_c::method
414
    {
415
    public:
416
        VirtualMachineMigrate(
417
            VirtualMachinePool * _vmpool,
418
            HostPool *           _hpool,
419
            UserPool *           _upool):
420
                vmpool(_vmpool),
421
                hpool(_hpool),
422
                upool(_upool)
423
        {
424
            _signature="A:siib";
425
            _help="Migrates a virtual machine";
426
        };
427

    
428
        ~VirtualMachineMigrate(){};
429

    
430
        void execute(
431
            xmlrpc_c::paramList const& paramList,
432
            xmlrpc_c::value *   const  retval);
433

    
434
    private:
435
        VirtualMachinePool * vmpool;
436
        HostPool *           hpool;
437
        UserPool *           upool;
438
    };
439

    
440
    /* ---------------------------------------------------------------------- */
441

    
442
    class VirtualMachineInfo: public xmlrpc_c::method
443
    {
444
    public:
445
        VirtualMachineInfo(
446
            VirtualMachinePool * _vmpool,
447
            UserPool           * _upool):
448
                vmpool(_vmpool),
449
                upool(_upool)
450
        {
451
            _signature="A:si";
452
            _help="Returns virtual machine information";
453
        };
454

    
455
        ~VirtualMachineInfo(){};
456

    
457
        void execute(
458
            xmlrpc_c::paramList const& paramList,
459
            xmlrpc_c::value *   const  retval);
460

    
461
    private:
462
        VirtualMachinePool * vmpool;
463
        UserPool           * upool;
464
    };
465

    
466
    /* ---------------------------------------------------------------------- */
467

    
468
    class VirtualMachineSaveDisk: public xmlrpc_c::method
469
    {
470
    public:
471
        VirtualMachineSaveDisk(
472
            VirtualMachinePool * _vmpool,
473
            UserPool           * _upool,
474
            ImagePool          * _ipool):
475
                vmpool(_vmpool),
476
                upool(_upool),
477
                ipool(_ipool)
478
        {
479
            _signature="A:siis";
480
            _help = "Sets the disk to be saved in a new Image with the given "
481
                    "name.";
482
        };
483

    
484
        ~VirtualMachineSaveDisk(){};
485

    
486
        void execute(
487
            xmlrpc_c::paramList const& paramList,
488
            xmlrpc_c::value *   const  retval);
489

    
490
    private:
491
        VirtualMachinePool * vmpool;
492
        UserPool           * upool;
493
        ImagePool          * ipool;
494
    };
495

    
496
    /* ---------------------------------------------------------------------- */
497

    
498
    class VirtualMachinePoolInfo: public xmlrpc_c::method
499
    {
500
    public:
501
        VirtualMachinePoolInfo(
502
            VirtualMachinePool * _vmpool,
503
            UserPool           * _upool):
504
                vmpool(_vmpool),
505
                upool(_upool)
506
        {
507
            _signature="A:sii";
508
            _help="Returns the virtual machine pool";
509
        };
510

    
511
        ~VirtualMachinePoolInfo(){};
512

    
513
        void execute(
514
            xmlrpc_c::paramList const& paramList,
515
            xmlrpc_c::value *   const  retval);
516

    
517
    private:
518
        VirtualMachinePool * vmpool;
519
        UserPool           *  upool;
520
    };
521

    
522
    /* ---------------------------------------------------------------------- */
523
    /*                            Template Interface                          */
524
    /* ---------------------------------------------------------------------- */
525

    
526
    class TemplateAllocate: public xmlrpc_c::method
527
    {
528
    public:
529
        TemplateAllocate(
530
            VMTemplatePool * _tpool,
531
            UserPool * _upool):
532
                tpool(_tpool),
533
                upool(_upool)
534
        {
535
            _signature="A:ss";
536
            _help="Allocates a template in the pool";
537
        };
538

    
539
        ~TemplateAllocate(){};
540

    
541
        void execute(
542
            xmlrpc_c::paramList const& paramList,
543
            xmlrpc_c::value *   const  retvalP);
544

    
545
    private:
546
        VMTemplatePool * tpool;
547
        UserPool *       upool;
548
    };
549

    
550
    /* ---------------------------------------------------------------------- */
551

    
552
    class TemplateDelete: public xmlrpc_c::method
553
    {
554
    public:
555
        TemplateDelete(VMTemplatePool * _tpool,
556
                       UserPool *       _upool):
557
                            tpool(_tpool),
558
                            upool(_upool)
559
        {
560
            _signature="A:si";
561
            _help="Deletes a Template";
562
        };
563

    
564
        ~TemplateDelete(){};
565

    
566
        void execute(
567
            xmlrpc_c::paramList const& paramList,
568
            xmlrpc_c::value *   const  retvalP);
569

    
570
    private:
571
        VMTemplatePool * tpool;
572
        UserPool  *      upool;
573
    };
574

    
575
    /* ---------------------------------------------------------------------- */
576

    
577
    class TemplateInfo: public xmlrpc_c::method
578
    {
579
    public:
580
        TemplateInfo(VMTemplatePool * _tpool,
581
                     UserPool *       _upool):
582
                      tpool(_tpool),
583
                      upool(_upool)
584
        {
585
            _signature="A:si";
586
            _help="Returns information for a Template";
587
        };
588

    
589
        ~TemplateInfo(){};
590

    
591
        void execute(
592
            xmlrpc_c::paramList const& paramList,
593
            xmlrpc_c::value *   const  retvalP);
594

    
595
    private:
596
        VMTemplatePool * tpool;
597
        UserPool  *      upool;
598
    };
599

    
600
    /* ---------------------------------------------------------------------- */
601

    
602
    class TemplateUpdate: public xmlrpc_c::method
603
    {
604
    public:
605
        TemplateUpdate(VMTemplatePool * _tpool,
606
                       UserPool *       _upool):
607
                        tpool(_tpool),
608
                        upool(_upool)
609
        {
610
            _signature="A:siss";
611
            _help="Modifies Template attribute";
612
        };
613

    
614
        ~TemplateUpdate(){};
615

    
616
        void execute(
617
            xmlrpc_c::paramList const& paramList,
618
            xmlrpc_c::value *   const  retvalP);
619

    
620
    private:
621
        VMTemplatePool * tpool;
622
        UserPool  *      upool;
623
    };
624

    
625
    /* ---------------------------------------------------------------------- */
626

    
627
    class TemplateRemoveAttribute: public xmlrpc_c::method
628
    {
629
    public:
630
        TemplateRemoveAttribute(VMTemplatePool * _tpool,
631
                             UserPool *          _upool):
632
                        tpool(_tpool),
633
                        upool(_upool)
634
        {
635
            _signature="A:sis";
636
            _help="Removes Template attribute";
637
        };
638

    
639
        ~TemplateRemoveAttribute(){};
640

    
641
        void execute(
642
            xmlrpc_c::paramList const& paramList,
643
            xmlrpc_c::value *   const  retvalP);
644

    
645
    private:
646
        VMTemplatePool * tpool;
647
        UserPool  *      upool;
648
    };
649

    
650
    /* ---------------------------------------------------------------------- */
651

    
652
    class TemplatePublish: public xmlrpc_c::method
653
    {
654
    public:
655
        TemplatePublish(VMTemplatePool * _tpool,
656
                     UserPool *          _upool):
657
                        tpool(_tpool),
658
                        upool(_upool)
659
        {
660
            _signature="A:sib";
661
            _help="Publish/Unpublish the Template";
662
        };
663

    
664
        ~TemplatePublish(){};
665

    
666
        void execute(
667
            xmlrpc_c::paramList const& paramList,
668
            xmlrpc_c::value *   const  retvalP);
669

    
670
    private:
671
        VMTemplatePool * tpool;
672
        UserPool  *      upool;
673
    };
674

    
675
    /* ---------------------------------------------------------------------- */
676

    
677
    class TemplatePoolInfo: public xmlrpc_c::method
678
    {
679
    public:
680
        TemplatePoolInfo(
681
            VMTemplatePool * _tpool,
682
            UserPool * _upool):
683
                tpool(_tpool),
684
                upool(_upool)
685
        {
686
            _signature="A:sii";
687
            _help="Returns the template pool";
688
        };
689

    
690
        ~TemplatePoolInfo(){};
691

    
692
        void execute(
693
            xmlrpc_c::paramList const& paramList,
694
            xmlrpc_c::value *   const  retvalP);
695

    
696
    private:
697
        VMTemplatePool * tpool;
698
        UserPool *       upool;
699
    };
700

    
701
    /* ---------------------------------------------------------------------- */
702
    /*                            Host Interface                              */
703
    /* ---------------------------------------------------------------------- */
704

    
705
    class HostAllocate: public xmlrpc_c::method
706
    {
707
    public:
708
        HostAllocate(
709
            HostPool * _hpool,
710
            UserPool * _upool):
711
                hpool(_hpool),
712
                upool(_upool)
713
        {
714
            _signature="A:sssss";
715
            _help="Allocates a host in the pool";
716
        };
717

    
718
        ~HostAllocate(){};
719

    
720
        void execute(
721
            xmlrpc_c::paramList const& paramList,
722
            xmlrpc_c::value *   const  retvalP);
723

    
724
    private:
725
        HostPool * hpool;
726
        UserPool * upool;
727
    };
728

    
729
    /* ---------------------------------------------------------------------- */
730

    
731
    class HostInfo: public xmlrpc_c::method
732
    {
733
    public:
734
        HostInfo(
735
            HostPool * _hpool,
736
            UserPool * _upool):
737
                hpool(_hpool),
738
                upool(_upool)
739
        {
740
            _signature="A:si";
741
            _help="Returns host information";
742
        };
743

    
744
        ~HostInfo(){};
745

    
746
        void execute(
747
            xmlrpc_c::paramList const& paramList,
748
            xmlrpc_c::value *   const  retvalP);
749

    
750
    private:
751
        HostPool * hpool;
752
        UserPool * upool;
753
    };
754

    
755
    /* ---------------------------------------------------------------------- */
756

    
757
    class HostPoolInfo: public xmlrpc_c::method
758
    {
759
    public:
760
        HostPoolInfo(HostPool * _hpool,
761
                     UserPool * _upool):
762
            hpool(_hpool),
763
            upool(_upool)
764
        {
765
            _signature="A:s";
766
            _help="Returns the host pool information";
767
        };
768

    
769
        ~HostPoolInfo(){};
770

    
771
        void execute(
772
            xmlrpc_c::paramList const& paramList,
773
            xmlrpc_c::value *   const  retvalP);
774

    
775
    private:
776
        HostPool * hpool;
777
        UserPool * upool;
778
    };
779

    
780
    /* ---------------------------------------------------------------------- */
781

    
782
    class HostDelete: public xmlrpc_c::method
783
    {
784
    public:
785
        HostDelete(
786
            HostPool * _hpool,
787
            UserPool * _upool):
788
                hpool(_hpool),
789
                upool(_upool)
790
        {
791
            _signature="A:si";
792
            _help="Deletes a host from the pool";
793
        };
794

    
795
        ~HostDelete(){};
796

    
797
        void execute(
798
            xmlrpc_c::paramList const& paramList,
799
            xmlrpc_c::value *   const  retvalP);
800

    
801
    private:
802
        HostPool * hpool;
803
        UserPool * upool;
804
    };
805

    
806
    /* ---------------------------------------------------------------------- */
807

    
808
    class HostEnable: public xmlrpc_c::method
809
    {
810
    public:
811
        HostEnable(
812
            HostPool * _hpool,
813
            UserPool * _upool):
814
                hpool(_hpool),
815
                upool(_upool)
816
        {
817
            _signature="A:sib";
818
            _help="Enables or disables a host";
819
        };
820

    
821
        ~HostEnable(){};
822

    
823
        void execute(
824
            xmlrpc_c::paramList const& paramList,
825
            xmlrpc_c::value *   const  retvalP);
826

    
827
    private:
828
        HostPool * hpool;
829
        UserPool * upool;
830
    };
831

    
832
    /* ---------------------------------------------------------------------- */
833
    /*                      Cluster Interface                                 */
834
    /* ---------------------------------------------------------------------- */
835

    
836
    class ClusterAllocate: public xmlrpc_c::method
837
    {
838
    public:
839
        ClusterAllocate(
840
            UserPool *      _upool,
841
            ClusterPool *   _cpool):
842
                upool(_upool),
843
                cpool(_cpool)
844
        {
845
            _signature="A:ss";
846
            _help="Allocates a cluster in the pool";
847
        };
848

    
849
        ~ClusterAllocate(){};
850

    
851
        void execute(
852
            xmlrpc_c::paramList const& paramList,
853
            xmlrpc_c::value *   const  retvalP);
854

    
855
    private:
856
        UserPool *      upool;
857
        ClusterPool *   cpool;
858
    };
859

    
860
    /* ---------------------------------------------------------------------- */
861

    
862
    class ClusterInfo: public xmlrpc_c::method
863
    {
864
    public:
865
        ClusterInfo(
866
            UserPool *      _upool,
867
            ClusterPool *   _cpool):
868
                upool(_upool),
869
                cpool(_cpool)
870
        {
871
            _signature="A:si";
872
            _help="Returns cluster information";
873
        };
874

    
875
        ~ClusterInfo(){};
876

    
877
        void execute(
878
            xmlrpc_c::paramList const& paramList,
879
            xmlrpc_c::value *   const  retvalP);
880

    
881
    private:
882
        UserPool *      upool;
883
        ClusterPool *   cpool;
884
    };
885

    
886
    /* ---------------------------------------------------------------------- */
887

    
888
    class ClusterDelete: public xmlrpc_c::method
889
    {
890
    public:
891
        ClusterDelete(
892
            UserPool *      _upool,
893
            ClusterPool *   _cpool):
894
                upool(_upool),
895
                cpool(_cpool)
896
        {
897
            _signature="A:si";
898
            _help="Deletes a cluster from the pool";
899
        };
900

    
901
        ~ClusterDelete(){};
902

    
903
        void execute(
904
            xmlrpc_c::paramList const& paramList,
905
            xmlrpc_c::value *   const  retvalP);
906

    
907
    private:
908
        UserPool *      upool;
909
        ClusterPool *   cpool;
910
    };
911

    
912
    /* ---------------------------------------------------------------------- */
913

    
914
    class ClusterAdd: public xmlrpc_c::method
915
    {
916
    public:
917
        ClusterAdd(
918
            HostPool *      _hpool,
919
            UserPool *      _upool,
920
            ClusterPool *   _cpool):
921
                hpool(_hpool),
922
                upool(_upool),
923
                cpool(_cpool)
924
        {
925
            _signature="A:sii";
926
            _help="Adds a host to a cluster";
927
        };
928

    
929
        ~ClusterAdd(){};
930

    
931
        void execute(
932
            xmlrpc_c::paramList const& paramList,
933
            xmlrpc_c::value *   const  retvalP);
934

    
935
    private:
936
        HostPool *      hpool;
937
        UserPool *      upool;
938
        ClusterPool *   cpool;
939
    };
940

    
941
    /* ---------------------------------------------------------------------- */
942

    
943
    class ClusterRemove: public xmlrpc_c::method
944
    {
945
    public:
946
        ClusterRemove(
947
            HostPool *      _hpool,
948
            UserPool *      _upool,
949
            ClusterPool *   _cpool):
950
                hpool(_hpool),
951
                upool(_upool),
952
                cpool(_cpool)
953
        {
954
            _signature="A:si";
955
            _help="Removes a host from its cluster";
956
        };
957

    
958
        ~ClusterRemove(){};
959

    
960
        void execute(
961
            xmlrpc_c::paramList const& paramList,
962
            xmlrpc_c::value *   const  retvalP);
963

    
964
    private:
965
        HostPool *      hpool;
966
        UserPool *      upool;
967
        ClusterPool *   cpool;
968
    };
969

    
970
    /* ---------------------------------------------------------------------- */
971

    
972
    class ClusterPoolInfo: public xmlrpc_c::method
973
    {
974
    public:
975
        ClusterPoolInfo(
976
            UserPool *      _upool,
977
            ClusterPool *   _cpool):
978
                upool(_upool),
979
                cpool(_cpool)
980
        {
981
            _signature="A:s";
982
            _help="Returns the cluster pool information";
983
        };
984

    
985
        ~ClusterPoolInfo(){};
986

    
987
        void execute(
988
            xmlrpc_c::paramList const& paramList,
989
            xmlrpc_c::value *   const  retvalP);
990

    
991
    private:
992
        UserPool *      upool;
993
        ClusterPool *   cpool;
994
    };
995

    
996

    
997
    /* ---------------------------------------------------------------------- */
998
    /*                      Group Interface                                   */
999
    /* ---------------------------------------------------------------------- */
1000

    
1001
    class GroupAllocate: public xmlrpc_c::method
1002
    {
1003
    public:
1004
        GroupAllocate(
1005
            UserPool *      _upool,
1006
            GroupPool *     _gpool):
1007
                upool(_upool),
1008
                gpool(_gpool)
1009
        {
1010
            _signature="A:ss";
1011
            _help="Allocates a group in the pool";
1012
        };
1013

    
1014
        ~GroupAllocate(){};
1015

    
1016
        void execute(
1017
            xmlrpc_c::paramList const& paramList,
1018
            xmlrpc_c::value *   const  retvalP);
1019

    
1020
    private:
1021
        UserPool *      upool;
1022
        GroupPool *     gpool;
1023
    };
1024

    
1025
    /* ---------------------------------------------------------------------- */
1026

    
1027
    class GroupInfo: public xmlrpc_c::method
1028
    {
1029
    public:
1030
        GroupInfo(
1031
            UserPool *      _upool,
1032
            GroupPool *     _gpool):
1033
                upool(_upool),
1034
                gpool(_gpool)
1035
        {
1036
            _signature="A:si";
1037
            _help="Returns group information";
1038
        };
1039

    
1040
        ~GroupInfo(){};
1041

    
1042
        void execute(
1043
            xmlrpc_c::paramList const& paramList,
1044
            xmlrpc_c::value *   const  retvalP);
1045

    
1046
    private:
1047
        UserPool *      upool;
1048
        GroupPool *     gpool;
1049
    };
1050

    
1051
    /* ---------------------------------------------------------------------- */
1052

    
1053
    class GroupDelete: public xmlrpc_c::method
1054
    {
1055
    public:
1056
        GroupDelete(
1057
            UserPool *      _upool,
1058
            GroupPool *     _gpool):
1059
                upool(_upool),
1060
                gpool(_gpool)
1061
        {
1062
            _signature="A:si";
1063
            _help="Deletes a group from the pool";
1064
        };
1065

    
1066
        ~GroupDelete(){};
1067

    
1068
        void execute(
1069
            xmlrpc_c::paramList const& paramList,
1070
            xmlrpc_c::value *   const  retvalP);
1071

    
1072
    private:
1073
        UserPool *      upool;
1074
        GroupPool *     gpool;
1075
    };
1076

    
1077
    /* ---------------------------------------------------------------------- */
1078

    
1079
    class GroupPoolInfo: public xmlrpc_c::method
1080
    {
1081
    public:
1082
        GroupPoolInfo(
1083
            UserPool *      _upool,
1084
            GroupPool *     _gpool):
1085
                upool(_upool),
1086
                gpool(_gpool)
1087
        {
1088
            _signature="A:s";
1089
            _help="Returns the group pool information";
1090
        };
1091

    
1092
        ~GroupPoolInfo(){};
1093

    
1094
        void execute(
1095
            xmlrpc_c::paramList const& paramList,
1096
            xmlrpc_c::value *   const  retvalP);
1097

    
1098
    private:
1099
        UserPool *      upool;
1100
        GroupPool *     gpool;
1101
    };
1102

    
1103

    
1104
    /* ---------------------------------------------------------------------- */
1105
    /*                      Virtual Network Interface                         */
1106
    /* ---------------------------------------------------------------------- */
1107

    
1108

    
1109
    class VirtualNetworkAllocate: public xmlrpc_c::method
1110
    {
1111
    public:
1112
        VirtualNetworkAllocate(
1113
            VirtualNetworkPool * _vnpool,
1114
            UserPool *           _upool):
1115
                vnpool(_vnpool),
1116
                upool(_upool)
1117
        {
1118
            _signature="A:ss";
1119
            _help="Creates a virtual network";
1120
        };
1121

    
1122
        ~VirtualNetworkAllocate(){};
1123

    
1124
        void execute(
1125
            xmlrpc_c::paramList const& paramList,
1126
            xmlrpc_c::value *   const  retvalP);
1127

    
1128
    private:
1129
        VirtualNetworkPool * vnpool;
1130
        UserPool           * upool;
1131
    };
1132

    
1133
    /* ---------------------------------------------------------------------- */
1134

    
1135
    class VirtualNetworkInfo: public xmlrpc_c::method
1136
    {
1137
    public:
1138
        VirtualNetworkInfo(
1139
            VirtualNetworkPool * _vnpool,
1140
            UserPool           * _upool):
1141
                 vnpool(_vnpool),
1142
                 upool(_upool)
1143
        {
1144
            _signature="A:si";
1145
            _help="Returns virtual network information";
1146
        };
1147

    
1148
        ~VirtualNetworkInfo(){};
1149

    
1150
        void execute(
1151
            xmlrpc_c::paramList const& paramList,
1152
            xmlrpc_c::value *   const  retvalP);
1153

    
1154
    private:
1155
        VirtualNetworkPool * vnpool;
1156
        UserPool           * upool;
1157
    };
1158

    
1159
    /* ---------------------------------------------------------------------- */
1160

    
1161
    class VirtualNetworkPoolInfo: public xmlrpc_c::method
1162
    {
1163
    public:
1164
        VirtualNetworkPoolInfo(VirtualNetworkPool * _vnpool,
1165
                               UserPool           * _upool):
1166
            vnpool(_vnpool),
1167
            upool(_upool)
1168
        {
1169
            _signature="A:si";
1170
            _help="Returns the virtual network pool information";
1171
        };
1172

    
1173
        ~VirtualNetworkPoolInfo(){};
1174

    
1175
        void execute(
1176
            xmlrpc_c::paramList const& paramList,
1177
            xmlrpc_c::value *   const  retvalP);
1178

    
1179
    private:
1180
        VirtualNetworkPool * vnpool;
1181
        UserPool           * upool;
1182
    };
1183

    
1184
    /* ---------------------------------------------------------------------- */
1185

    
1186
    class VirtualNetworkPublish: public xmlrpc_c::method
1187
    {
1188
    public:
1189
        VirtualNetworkPublish(
1190
            VirtualNetworkPool * _vnpool,
1191
            UserPool           * _upool):
1192
                vnpool(_vnpool),
1193
                upool(_upool)
1194
        {
1195
            _signature="A:sib";
1196
            _help="Enables/Disables a virtual network";
1197
        };
1198

    
1199
        ~VirtualNetworkPublish(){};
1200

    
1201
        void execute(
1202
            xmlrpc_c::paramList const& paramList,
1203
            xmlrpc_c::value *   const  retvalP);
1204

    
1205
    private:
1206
        VirtualNetworkPool * vnpool;
1207
        UserPool           * upool;
1208
    };
1209

    
1210
    /* ---------------------------------------------------------------------- */
1211

    
1212
    class VirtualNetworkDelete: public xmlrpc_c::method
1213
    {
1214
    public:
1215
        VirtualNetworkDelete(
1216
            VirtualNetworkPool * _vnpool,
1217
            UserPool           * _upool):
1218
                vnpool(_vnpool),
1219
                upool(_upool)
1220
        {
1221
            _signature="A:si";
1222
            _help="Deletes a virtual network";
1223
        };
1224

    
1225
        ~VirtualNetworkDelete(){};
1226

    
1227
        void execute(
1228
            xmlrpc_c::paramList const& paramList,
1229
            xmlrpc_c::value *   const  retvalP);
1230

    
1231
    private:
1232
        VirtualNetworkPool * vnpool;
1233
        UserPool           * upool;
1234
    };
1235

    
1236
    /* ---------------------------------------------------------------------- */
1237

    
1238
    class VirtualNetworkAddLeases: public xmlrpc_c::method
1239
    {
1240
    public:
1241
        VirtualNetworkAddLeases(
1242
            VirtualNetworkPool * _vnpool,
1243
            UserPool           * _upool):
1244
                vnpool(_vnpool),
1245
                upool(_upool)
1246
        {
1247
            _signature="A:sis";
1248
            _help="Adds leases to a virtual network";
1249
        };
1250

    
1251
        ~VirtualNetworkAddLeases(){};
1252

    
1253
        void execute(
1254
            xmlrpc_c::paramList const& paramList,
1255
            xmlrpc_c::value *   const  retvalP);
1256

    
1257
    private:
1258
        VirtualNetworkPool * vnpool;
1259
        UserPool           * upool;
1260
    };
1261

    
1262
    /* ---------------------------------------------------------------------- */
1263

    
1264
    class VirtualNetworkRemoveLeases: public xmlrpc_c::method
1265
    {
1266
    public:
1267
        VirtualNetworkRemoveLeases(
1268
            VirtualNetworkPool * _vnpool,
1269
            UserPool           * _upool):
1270
                vnpool(_vnpool),
1271
                upool(_upool)
1272
        {
1273
            _signature="A:sis";
1274
            _help="Removes leases from a virtual network";
1275
        };
1276

    
1277
        ~VirtualNetworkRemoveLeases(){};
1278

    
1279
        void execute(
1280
            xmlrpc_c::paramList const& paramList,
1281
            xmlrpc_c::value *   const  retvalP);
1282

    
1283
    private:
1284
        VirtualNetworkPool * vnpool;
1285
        UserPool           * upool;
1286
    };
1287
    /* ---------------------------------------------------------------------- */
1288
    /*                      User Management Interface                         */
1289
    /* ---------------------------------------------------------------------- */
1290

    
1291

    
1292
    class UserAllocate: public xmlrpc_c::method
1293
    {
1294
    public:
1295
        UserAllocate(UserPool * _upool):upool(_upool)
1296
        {
1297
            _signature="A:sss";
1298
            _help="Creates a new user";
1299
        };
1300

    
1301
        ~UserAllocate(){};
1302

    
1303
        void execute(
1304
            xmlrpc_c::paramList const& paramList,
1305
            xmlrpc_c::value *   const  retvalP);
1306

    
1307
    private:
1308
        UserPool * upool;
1309
    };
1310

    
1311
    /* ---------------------------------------------------------------------- */
1312

    
1313
    class UserDelete: public xmlrpc_c::method
1314
    {
1315
    public:
1316
        UserDelete(UserPool * _upool):upool(_upool)
1317
        {
1318
            _signature="A:si";
1319
            _help="Deletes a user account";
1320
        };
1321

    
1322
        ~UserDelete(){};
1323

    
1324
        void execute(
1325
            xmlrpc_c::paramList const& paramList,
1326
            xmlrpc_c::value *   const  retvalP);
1327

    
1328
    private:
1329
        UserPool * upool;
1330
    };
1331

    
1332
    /* ---------------------------------------------------------------------- */
1333

    
1334
    class UserChangePassword: public xmlrpc_c::method
1335
    {
1336
    public:
1337
        UserChangePassword(UserPool * _upool):upool(_upool)
1338
        {
1339
            _signature="A:sis";
1340
            _help="Changes the password for the given user.";
1341
        };
1342

    
1343
        ~UserChangePassword(){};
1344

    
1345
        void execute(
1346
            xmlrpc_c::paramList const& paramList,
1347
            xmlrpc_c::value *   const  retvalP);
1348

    
1349
    private:
1350
        UserPool * upool;
1351
    };
1352

    
1353
    /* ---------------------------------------------------------------------- */
1354

    
1355
    class UserInfo: public xmlrpc_c::method                                   
1356
    {
1357
    public:                                                                   
1358
        UserInfo(UserPool * _upool):upool(_upool)
1359
        {
1360
            _signature="A:si";
1361
            _help="Returns the information for a user";
1362
        };
1363

    
1364
        ~UserInfo(){};
1365

    
1366
        void execute(
1367
            xmlrpc_c::paramList const& paramList,
1368
            xmlrpc_c::value *   const  retvalP);
1369

    
1370
    private:
1371
        UserPool * upool;
1372
    };
1373

    
1374
    /* ---------------------------------------------------------------------- */
1375

    
1376
    class UserPoolInfo: public xmlrpc_c::method
1377
    {
1378
    public:
1379
        UserPoolInfo(UserPool * _upool):upool(_upool)
1380
        {
1381
            _signature="A:s";
1382
            _help="Returns content of the user pool";
1383
        };
1384

    
1385
        ~UserPoolInfo(){};
1386

    
1387
        void execute(
1388
            xmlrpc_c::paramList const& paramList,
1389
            xmlrpc_c::value *   const  retvalP);
1390

    
1391
    private:
1392
        UserPool * upool;
1393
    };
1394

    
1395
    /* ---------------------------------------------------------------------- */
1396
    /*                      Image Pool Interface                              */
1397
    /* ---------------------------------------------------------------------- */
1398

    
1399
    class ImageAllocate: public xmlrpc_c::method
1400
    {
1401
    public:
1402
        ImageAllocate(ImagePool * _ipool,
1403
                      UserPool * _upool):
1404
                            ipool(_ipool),
1405
                            upool(_upool)
1406
        {
1407
            _signature="A:ss";
1408
            _help="Creates a new image";
1409
        };
1410

    
1411
        ~ImageAllocate(){};
1412

    
1413
        void execute(
1414
            xmlrpc_c::paramList const& paramList,
1415
            xmlrpc_c::value *   const  retvalP);
1416

    
1417
    private:
1418
        ImagePool * ipool;
1419
        UserPool  * upool;
1420
    };
1421

    
1422
    /* ---------------------------------------------------------------------- */
1423

    
1424
    class ImageDelete: public xmlrpc_c::method
1425
    {
1426
    public:
1427
        ImageDelete(ImagePool * _ipool,
1428
                      UserPool * _upool):
1429
                            ipool(_ipool),
1430
                            upool(_upool)
1431
        {
1432
            _signature="A:si";
1433
            _help="Deletes an image";
1434
        };
1435

    
1436
        ~ImageDelete(){};
1437

    
1438
        void execute(
1439
            xmlrpc_c::paramList const& paramList,
1440
            xmlrpc_c::value *   const  retvalP);
1441

    
1442
    private:
1443
        ImagePool * ipool;
1444
        UserPool  * upool;
1445
    };
1446

    
1447
    /* ---------------------------------------------------------------------- */
1448

    
1449
    class ImageInfo: public xmlrpc_c::method
1450
    {
1451
    public:
1452
        ImageInfo(ImagePool * _ipool,
1453
                  UserPool  * _upool):
1454
                      ipool(_ipool),
1455
                      upool(_upool)
1456
        {
1457
            _signature="A:si";
1458
            _help="Returns information for an image";
1459
        };
1460

    
1461
        ~ImageInfo(){};
1462

    
1463
        void execute(
1464
            xmlrpc_c::paramList const& paramList,
1465
            xmlrpc_c::value *   const  retvalP);
1466

    
1467
    private:
1468
        ImagePool * ipool;
1469
        UserPool  * upool;
1470
    };
1471

    
1472
    /* ---------------------------------------------------------------------- */
1473

    
1474
    class ImageUpdate: public xmlrpc_c::method
1475
    {
1476
    public:
1477
        ImageUpdate(ImagePool * _ipool,
1478
                    UserPool  * _upool):
1479
                        ipool(_ipool),
1480
                        upool(_upool)
1481
        {
1482
            _signature="A:siss";
1483
            _help="Modifies image attribute";
1484
        };
1485

    
1486
        ~ImageUpdate(){};
1487

    
1488
        void execute(
1489
            xmlrpc_c::paramList const& paramList,
1490
            xmlrpc_c::value *   const  retvalP);
1491

    
1492
    private:
1493
        ImagePool * ipool;
1494
        UserPool  * upool;
1495
    };
1496

    
1497
    /* ---------------------------------------------------------------------- */
1498

    
1499
    class ImageRemoveAttribute: public xmlrpc_c::method
1500
    {
1501
    public:
1502
        ImageRemoveAttribute(ImagePool * _ipool,
1503
                             UserPool  * _upool):
1504
                        ipool(_ipool),
1505
                        upool(_upool)
1506
        {
1507
            _signature="A:sis";
1508
            _help="Removes image attribute";
1509
        };
1510

    
1511
        ~ImageRemoveAttribute(){};
1512

    
1513
        void execute(
1514
            xmlrpc_c::paramList const& paramList,
1515
            xmlrpc_c::value *   const  retvalP);
1516

    
1517
    private:
1518
        ImagePool * ipool;
1519
        UserPool  * upool;
1520
    };
1521

    
1522
    /* ---------------------------------------------------------------------- */
1523

    
1524
    class ImagePublish: public xmlrpc_c::method
1525
    {
1526
    public:
1527
        ImagePublish(ImagePool * _ipool,
1528
                     UserPool  * _upool):
1529
                        ipool(_ipool),
1530
                        upool(_upool)
1531
        {
1532
            _signature="A:sib";
1533
            _help="Publish/Unpublish the Image";
1534
        };
1535

    
1536
        ~ImagePublish(){};
1537

    
1538
        void execute(
1539
            xmlrpc_c::paramList const& paramList,
1540
            xmlrpc_c::value *   const  retvalP);
1541

    
1542
    private:
1543
        ImagePool * ipool;
1544
        UserPool  * upool;
1545
    };
1546

    
1547
    /* ---------------------------------------------------------------------- */
1548

    
1549
    class ImagePersistent: public xmlrpc_c::method
1550
    {
1551
    public:
1552
        ImagePersistent(ImagePool * _ipool,
1553
                     UserPool  * _upool):
1554
                        ipool(_ipool),
1555
                        upool(_upool)
1556
        {
1557
            _signature="A:sib";
1558
            _help="Make an Image (non)persistent";
1559
        };
1560

    
1561
        ~ImagePersistent(){};
1562

    
1563
        void execute(
1564
            xmlrpc_c::paramList const& paramList,
1565
            xmlrpc_c::value *   const  retvalP);
1566

    
1567
    private:
1568
        ImagePool * ipool;
1569
        UserPool  * upool;
1570
    };
1571

    
1572
    /* ---------------------------------------------------------------------- */
1573

    
1574
    class ImageEnable: public xmlrpc_c::method
1575
    {
1576
    public:
1577
        ImageEnable(ImagePool * _ipool,
1578
                     UserPool  * _upool):
1579
                        ipool(_ipool),
1580
                        upool(_upool)
1581
        {
1582
            _signature="A:sib";
1583
            _help="Enables/Disables the Image";
1584
        };
1585

    
1586
        ~ImageEnable(){};
1587

    
1588
        void execute(
1589
            xmlrpc_c::paramList const& paramList,
1590
            xmlrpc_c::value *   const  retvalP);
1591

    
1592
    private:
1593
        ImagePool * ipool;
1594
        UserPool  * upool;
1595
    };
1596

    
1597
    /* ---------------------------------------------------------------------- */
1598

    
1599
    class ImagePoolInfo: public xmlrpc_c::method
1600
    {
1601
    public:
1602
        ImagePoolInfo(ImagePool * _ipool,
1603
                      UserPool  * _upool):
1604
                            ipool(_ipool),
1605
                            upool(_upool)
1606
        {
1607
            _signature="A:si";
1608
            _help="Returns content of image pool attending to the filter flag";
1609
        };
1610

    
1611
        ~ImagePoolInfo(){};
1612

    
1613
        void execute(
1614
            xmlrpc_c::paramList const& paramList,
1615
            xmlrpc_c::value *   const  retvalP);
1616

    
1617
    private:
1618
        ImagePool * ipool;
1619
        UserPool  * upool;
1620
    };
1621

    
1622
};
1623

    
1624

    
1625
/* -------------------------------------------------------------------------- */
1626
/* -------------------------------------------------------------------------- */
1627
/* -------------------------------------------------------------------------- */
1628

    
1629
#endif
1630