Statistics
| Branch: | Tag: | Revision:

one / include / Nebula.h @ 27e61bae

History | View | Annotate | Download (23.1 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2017, OpenNebula Project, OpenNebula Systems                */
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 NEBULA_H_
18
#define NEBULA_H_
19

    
20
#include "LogDB.h"
21
#include "SystemDB.h"
22

    
23
#include "NebulaTemplate.h"
24

    
25
#include "VirtualMachinePool.h"
26
#include "VirtualNetworkPool.h"
27
#include "HostPool.h"
28
#include "UserPool.h"
29
#include "VMTemplatePool.h"
30
#include "GroupPool.h"
31
#include "DatastorePool.h"
32
#include "ClusterPool.h"
33
#include "DocumentPool.h"
34
#include "ZonePool.h"
35
#include "SecurityGroupPool.h"
36
#include "VdcPool.h"
37
#include "VirtualRouterPool.h"
38
#include "MarketPlacePool.h"
39
#include "MarketPlaceAppPool.h"
40
#include "VMGroupPool.h"
41

    
42
#include "VirtualMachineManager.h"
43
#include "LifeCycleManager.h"
44
#include "InformationManager.h"
45
#include "TransferManager.h"
46
#include "DispatchManager.h"
47
#include "RequestManager.h"
48
#include "HookManager.h"
49
#include "AuthManager.h"
50
#include "AclManager.h"
51
#include "ImageManager.h"
52
#include "MarketPlaceManager.h"
53
#include "IPAMManager.h"
54
#include "RaftManager.h"
55
#include "FedReplicaManager.h"
56

    
57
#include "DefaultQuotas.h"
58

    
59
#include "Callbackable.h"
60

    
61

    
62
/**
63
 *  This is the main class for the OpenNebula daemon oned. It stores references
64
 *  to the main modules and data pools. It also includes functions to bootstrap
65
 *  the system and start all its components.
66
 */
67
class Nebula
68
{
69
public:
70

    
71
    static Nebula& instance()
72
    {
73
        static Nebula nebulad;
74

    
75
        return nebulad;
76
    };
77

    
78
    // --------------------------------------------------------------
79
    // Pool Accessors
80
    // --------------------------------------------------------------
81
    LogDB * get_logdb()
82
    {
83
        return logdb;
84
    };
85

    
86
    VirtualMachinePool * get_vmpool()
87
    {
88
        return vmpool;
89
    };
90

    
91
    HostPool * get_hpool()
92
    {
93
        return hpool;
94
    };
95

    
96
    VirtualNetworkPool * get_vnpool()
97
    {
98
        return vnpool;
99
    };
100

    
101
    UserPool * get_upool()
102
    {
103
        return upool;
104
    };
105

    
106
    ImagePool * get_ipool()
107
    {
108
        return ipool;
109
    };
110

    
111
    GroupPool * get_gpool()
112
    {
113
        return gpool;
114
    };
115

    
116
    VMTemplatePool * get_tpool()
117
    {
118
        return tpool;
119
    };
120

    
121
    DatastorePool * get_dspool()
122
    {
123
        return dspool;
124
    };
125

    
126
    ClusterPool * get_clpool()
127
    {
128
        return clpool;
129
    };
130

    
131
    DocumentPool * get_docpool()
132
    {
133
        return docpool;
134
    };
135

    
136
    ZonePool * get_zonepool()
137
    {
138
        return zonepool;
139
    };
140

    
141
    SecurityGroupPool * get_secgrouppool()
142
    {
143
        return secgrouppool;
144
    };
145

    
146
    VdcPool * get_vdcpool()
147
    {
148
        return vdcpool;
149
    };
150

    
151
    VirtualRouterPool * get_vrouterpool()
152
    {
153
        return vrouterpool;
154
    };
155

    
156
    MarketPlacePool * get_marketpool()
157
    {
158
        return marketpool;
159
    };
160

    
161
    MarketPlaceAppPool * get_apppool()
162
    {
163
        return apppool;
164
    };
165

    
166
    VMGroupPool * get_vmgrouppool()
167
    {
168
        return vmgrouppool;
169
    };
170

    
171
    // --------------------------------------------------------------
172
    // Manager Accessors
173
    // --------------------------------------------------------------
174

    
175
    VirtualMachineManager * get_vmm()
176
    {
177
        return vmm;
178
    };
179

    
180
    LifeCycleManager * get_lcm()
181
    {
182
        return lcm;
183
    };
184

    
185
    InformationManager * get_im()
186
    {
187
        return im;
188
    };
189

    
190
    TransferManager * get_tm()
191
    {
192
        return tm;
193
    };
194

    
195
    DispatchManager * get_dm()
196
    {
197
        return dm;
198
    };
199

    
200
    HookManager * get_hm()
201
    {
202
        return hm;
203
    };
204

    
205
    AuthManager * get_authm()
206
    {
207
        return authm;
208
    };
209

    
210
    ImageManager * get_imagem()
211
    {
212
        return imagem;
213
    };
214

    
215
    AclManager * get_aclm()
216
    {
217
        return aclm;
218
    };
219

    
220
    MarketPlaceManager * get_marketm()
221
    {
222
        return marketm;
223
    };
224

    
225
    IPAMManager * get_ipamm()
226
    {
227
        return ipamm;
228
    };
229

    
230
    RaftManager * get_raftm()
231
    {
232
        return raftm;
233
    };
234

    
235
    FedReplicaManager * get_frm()
236
    {
237
        return frm;
238
    };
239

    
240
    // --------------------------------------------------------------
241
    // Environment & Configuration
242
    // --------------------------------------------------------------
243

    
244
    /**
245
     *  Returns the value of LOG->DEBUG_LEVEL in oned.conf file
246
     *      @return the debug level, to instantiate Log'ers
247
     */
248
    Log::MessageType get_debug_level() const;
249

    
250
    /**
251
     *  Returns the value of LOG->SYSTEM in oned.conf file
252
     *      @return the logging system CERR, FILE_TS or SYSLOG
253
     */
254
    NebulaLog::LogType get_log_system() const;
255

    
256
    /**
257
     *  Returns the value of ONE_LOCATION env variable. When this variable is
258
     *  not defined the nebula location is "/".
259
     *      @return the nebula location.
260
     */
261
    const string& get_nebula_location()
262
    {
263
        return nebula_location;
264
    };
265

    
266
    /**
267
     *  Returns the path where mad executables are stored, if ONE_LOCATION is
268
     *  defined this path points to $ONE_LOCATION/bin, otherwise it is
269
     *  /usr/lib/one/mads.
270
     *      @return the mad execs location.
271
     */
272
    const string& get_mad_location()
273
    {
274
        return mad_location;
275
    };
276

    
277
    /**
278
     *  Returns the path where defaults for mads are stored, if ONE_LOCATION is
279
     *  defined this path points to $ONE_LOCATION/etc, otherwise it is /etc/one
280
     *      @return the mad defaults location.
281
     */
282
    const string& get_defaults_location()
283
    {
284
        return etc_location;
285
    };
286

    
287
    /**
288
     *  Returns the path where logs (oned.log, schedd.log,...) are generated
289
     *  if ONE_LOCATION is defined this path points to $ONE_LOCATION/var,
290
     *  otherwise it is /var/log/one.
291
     *      @return the log location.
292
     */
293
    const string& get_log_location()
294
    {
295
        return log_location;
296
    };
297

    
298
    /**
299
     *  Returns the default var location. When ONE_LOCATION is defined this path
300
     *  points to $ONE_LOCATION/var, otherwise it is /var/lib/one.
301
     *      @return the log location.
302
     */
303
    const string& get_var_location()
304
    {
305
        return var_location;
306
    };
307

    
308
    /**
309
     *
310
     *
311
     */
312
    void get_ds_location(string& dsloc);
313

    
314
    /**
315
     *  Returns the default vms location. When ONE_LOCATION is defined this path
316
     *  points to $ONE_LOCATION/var/vms, otherwise it is /var/lib/one/vms. This
317
     *  location stores vm related files: deployment, transfer, context, and
318
     *  logs (in self-contained mode only)
319
     *      @return the vms location.
320
     */
321
    const string& get_vms_location()
322
    {
323
        return vms_location;
324
    };
325

    
326
    /**
327
     *  Returns the path of the log file for a VM, depending where OpenNebula is
328
     *  installed,
329
     *     $ONE_LOCATION/var/$VM_ID/vm.log
330
     *  or
331
     *     /var/log/one/$VM_ID.log
332
     *  @return the log location for the VM.
333
     */
334
    string get_vm_log_filename(int oid);
335

    
336
    /**
337
     *  Returns the name of the host running oned
338
     *    @return the name
339
     */
340
    const string& get_nebula_hostname()
341
    {
342
        return hostname;
343
    };
344

    
345
    /**
346
     *  Returns the version of oned
347
     *    @return the version
348
     */
349
    static string version()
350
    {
351
        return "OpenNebula " + code_version();
352
    };
353

    
354
    /**
355
     *  Returns the version of oned
356
     * @return
357
     */
358
    static string code_version()
359
    {
360
        return "5.4.0"; // bump version
361
    }
362

    
363
    /**
364
     * Version needed for the DB, shared tables
365
     * @return
366
     */
367
    static string shared_db_version()
368
    {
369
        return "5.4.0";
370
    }
371

    
372
    /**
373
     * Version needed for the DB, local tables
374
     * @return
375
     */
376
    static string local_db_version()
377
    {
378
        return "5.4.0";
379
    }
380

    
381
    /**
382
     *  Starts all the modules and services for OpenNebula
383
     */
384
    void start(bool bootstrap_only=false);
385

    
386
    /**
387
     *  Initialize the database
388
     */
389
    void bootstrap_db()
390
    {
391
        start(true);
392
    }
393

    
394
    // --------------------------------------------------------------
395
    // Federation
396
    // --------------------------------------------------------------
397

    
398
    bool is_federation_enabled()
399
    {
400
        return federation_enabled;
401
    };
402

    
403
    bool is_federation_master()
404
    {
405
        return federation_master;
406

    
407
    };
408

    
409
    bool is_federation_slave()
410
    {
411
        return federation_enabled && !federation_master;
412
    };
413

    
414
    int get_zone_id()
415
    {
416
        return zone_id;
417
    };
418

    
419
    int get_server_id()
420
    {
421
        return server_id;
422
    };
423

    
424
    const string& get_master_oned()
425
    {
426
        return master_oned;
427
    };
428

    
429
    // -----------------------------------------------------------------------
430
    // Configuration attributes (read from oned.conf)
431
    // -----------------------------------------------------------------------
432

    
433
    /**
434
     *  Gets a configuration attribute for oned
435
     *    @param name of the attribute
436
     *    @param value of the attribute
437
     */
438
    template<typename T>
439
    void get_configuration_attribute(const string& name, T& value) const
440
    {
441
        nebula_configuration->get(name, value);
442
    };
443

    
444
    /**
445
     *  Gets a user-configurable attribute for oned. Users (and groups) may
446
     *  store oned attributes in the "OPENNEBULA" vector. This function gets
447
     *  the value querying first the user, then the group and finally oned.conf
448
     *    @param uid of the user, if -1 the user template is not considered
449
     *    @param gid of the group
450
     *    @param name of the attribute
451
     *    @param value of the attribute
452
     *
453
     *    @return 0 on success -1 otherwise
454
     */
455
    template<typename T>
456
    int get_configuration_attribute(int uid, int gid, const std::string& name,
457
            T& value) const
458
    {
459
        if ( uid != -1 )
460
        {
461
            User * user = upool->get(uid, true);
462

    
463
            if ( user == 0 )
464
            {
465
                return -1;
466
            }
467

    
468
            const VectorAttribute * uconf;
469

    
470
            uconf = user->get_template_attribute("OPENNEBULA");
471

    
472
            if ( uconf != 0 )
473
            {
474
                if ( uconf->vector_value(name, value) == 0 )
475
                {
476
                    user->unlock();
477
                    return 0;
478
                }
479
            }
480

    
481
            user->unlock();
482
        }
483

    
484
        Group * group = gpool->get(gid, true);
485

    
486
        if ( group == 0 )
487
        {
488
            return -1;
489
        }
490

    
491
        const VectorAttribute * gconf;
492

    
493
        gconf = group->get_template_attribute("OPENNEBULA");
494

    
495
        if ( gconf != 0 )
496
        {
497
            if ( gconf->vector_value(name, value) == 0 )
498
            {
499
                group->unlock();
500
                return 0;
501
            }
502
        }
503

    
504
        group->unlock();
505

    
506
        nebula_configuration->get(name, value);
507

    
508
        return 0;
509
    }
510

    
511
    /**
512
     *  Gets a DS configuration attribute
513
     */
514
    int get_ds_conf_attribute(const std::string& ds_name,
515
        const VectorAttribute* &value) const
516
    {
517
        return get_conf_attribute("DS_MAD_CONF", ds_name, value);
518
    };
519

    
520
    /**
521
     *  Gets a TM configuration attribute
522
     */
523
    int get_tm_conf_attribute(const string& tm_name,
524
        const VectorAttribute* &value) const
525
    {
526
        return get_conf_attribute("TM_MAD_CONF", tm_name, value);
527
    };
528

    
529
    /**
530
     *  Gets a Market configuration attribute
531
     */
532
    int get_market_conf_attribute( const string& mk_name,
533
        const VectorAttribute* &value) const
534
    {
535
        return get_conf_attribute("MARKET_MAD_CONF", mk_name, value);
536
    };
537

    
538
    /**
539
     *  Gets an Auth driver configuration attribute
540
     */
541
    template<typename T>
542
    int get_auth_conf_attribute(const string& driver, const string& attribute,
543
        T& value) const
544
    {
545
        return get_conf_attribute("AUTH_MAD_CONF", driver, attribute, value);
546
    };
547

    
548
    /**
549
     *  Return the Authorization operation for a VM action
550
     *
551
     */
552
    AuthRequest::Operation get_vm_auth_op(History::VMAction action)
553
    {
554
        return nebula_configuration->get_vm_auth_op(action);
555
    }
556

    
557
    /**
558
     *  Gets an XML document with all of the configuration attributes
559
     *    @return the XML
560
     */
561
    string get_configuration_xml() const
562
    {
563
        string xml;
564
        return nebula_configuration->to_xml(xml);
565
    };
566

    
567
    // -----------------------------------------------------------------------
568
    // Default Quotas
569
    // -----------------------------------------------------------------------
570

    
571
    /**
572
     *  Get the default quotas for OpenNebula users
573
     *    @return the default quotas
574
     */
575
    const DefaultQuotas& get_default_user_quota()
576
    {
577
        return default_user_quota;
578
    };
579

    
580
    /**
581
     *  Set the default quotas for OpenNebula users
582
     *    @param tmpl template with the default quotas
583
     *    @param error describes the error if any
584
     *
585
     *    @return 0 if success
586
     */
587
    int set_default_user_quota(Template *tmpl, string& error)
588
    {
589
        int rc = default_user_quota.set(tmpl, error);
590

    
591
        if ( rc == 0 )
592
        {
593
            rc = default_user_quota.update();
594
        }
595

    
596
        return rc;
597
    };
598

    
599
    /**
600
     *  Get the default quotas for OpenNebula for groups
601
     *    @return the default quotas
602
     */
603
    const DefaultQuotas& get_default_group_quota()
604
    {
605
        return default_group_quota;
606
    };
607

    
608
    /**
609
     *  Set the default quotas for OpenNebula groups
610
     *    @param tmpl template with the default quotas
611
     *    @param error describes the error if any
612
     *
613
     *    @return 0 if success
614
     */
615
    int set_default_group_quota(Template *tmpl, string& error)
616
    {
617
        int rc = default_group_quota.set(tmpl, error);
618

    
619
        if ( rc == 0 )
620
        {
621
            rc = default_group_quota.update();
622
        }
623

    
624
        return rc;
625
    };
626

    
627
    // -----------------------------------------------------------------------
628
    // System attributes
629
    // -----------------------------------------------------------------------
630
    /**
631
     *  Reads a System attribute from the DB
632
     *    @param attr_name name of the attribute
633
     *    @param cb Callback that will receive the attribute in XML
634
     *    @return 0 on success
635
     */
636
    int select_sys_attribute(const string& attr_name, string& attr_xml)
637
    {
638
        return system_db->select_sys_attribute(attr_name, attr_xml);
639
    };
640

    
641
    /**
642
     *  Writes a system attribute in the database.
643
     *    @param db pointer to the db
644
     *    @return 0 on success
645
     */
646
    int insert_sys_attribute(
647
        const string& attr_name,
648
        const string& xml_attr,
649
        string&       error_str)
650
    {
651
        return system_db->insert_sys_attribute(attr_name, xml_attr, error_str);
652
    };
653

    
654
    /**
655
     *  Updates the system attribute in the database.
656
     *    @param db pointer to the db
657
     *    @return 0 on success
658
     */
659
    int update_sys_attribute(
660
        const string& attr_name,
661
        const string& xml_attr,
662
        string&       error_str)
663
    {
664
        return system_db->update_sys_attribute(attr_name, xml_attr, error_str);
665
    };
666

    
667
private:
668

    
669
    // -----------------------------------------------------------------------
670
    //Constructors and = are private to only access the class through instance
671
    // -----------------------------------------------------------------------
672

    
673
    Nebula():nebula_configuration(0),
674
        default_user_quota( "DEFAULT_USER_QUOTAS",
675
                            "/DEFAULT_USER_QUOTAS/DATASTORE_QUOTA",
676
                            "/DEFAULT_USER_QUOTAS/NETWORK_QUOTA",
677
                            "/DEFAULT_USER_QUOTAS/IMAGE_QUOTA",
678
                            "/DEFAULT_USER_QUOTAS/VM_QUOTA"),
679
        default_group_quota("DEFAULT_GROUP_QUOTAS",
680
                            "/DEFAULT_GROUP_QUOTAS/DATASTORE_QUOTA",
681
                            "/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA",
682
                            "/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA",
683
                            "/DEFAULT_GROUP_QUOTAS/VM_QUOTA"),
684
        system_db(0), logdb(0), fed_logdb(0),
685
        vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0),
686
        dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0),
687
        vdcpool(0), vrouterpool(0), marketpool(0), apppool(0), vmgrouppool(0),
688
        lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0), authm(0), aclm(0),
689
        imagem(0), marketm(0), ipamm(0), raftm(0), frm(0)
690
    {
691
        const char * nl = getenv("ONE_LOCATION");
692

    
693
        if (nl == 0) //OpenNebula installed under root directory
694
        {
695
            nebula_location = "/";
696

    
697
            mad_location     = "/usr/lib/one/mads/";
698
            etc_location     = "/etc/one/";
699
            log_location     = "/var/log/one/";
700
            var_location     = "/var/lib/one/";
701
            remotes_location = "/var/lib/one/remotes/";
702
            vms_location     = "/var/lib/one/vms/";
703
        }
704
        else
705
        {
706
            nebula_location = nl;
707

    
708
            if ( nebula_location.at(nebula_location.size()-1) != '/' )
709
            {
710
                nebula_location += "/";
711
            }
712

    
713
            mad_location     = nebula_location + "lib/mads/";
714
            etc_location     = nebula_location + "etc/";
715
            log_location     = nebula_location + "var/";
716
            var_location     = nebula_location + "var/";
717
            remotes_location = nebula_location + "var/remotes/";
718
            vms_location     = nebula_location + "var/vms/";
719
        }
720
    };
721

    
722
    ~Nebula()
723
    {
724
        delete vmpool;
725
        delete vnpool;
726
        delete hpool;
727
        delete upool;
728
        delete ipool;
729
        delete gpool;
730
        delete tpool;
731
        delete dspool;
732
        delete clpool;
733
        delete docpool;
734
        delete zonepool;
735
        delete secgrouppool;
736
        delete vdcpool;
737
        delete vrouterpool;
738
        delete marketpool;
739
        delete apppool;
740
        delete vmgrouppool;
741
        delete vmm;
742
        delete lcm;
743
        delete im;
744
        delete tm;
745
        delete dm;
746
        delete rm;
747
        delete hm;
748
        delete authm;
749
        delete aclm;
750
        delete imagem;
751
        delete marketm;
752
        delete ipamm;
753
        delete raftm;
754
        delete frm;
755
        delete nebula_configuration;
756
        delete logdb;
757
        delete fed_logdb;
758
        delete system_db;
759
    };
760

    
761
    Nebula& operator=(Nebula const&){return *this;};
762

    
763
    // ---------------------------------------------------------------
764
    // Environment variables
765
    // ---------------------------------------------------------------
766

    
767
    string  nebula_location;
768

    
769
    string  mad_location;
770
    string  etc_location;
771
    string  log_location;
772
    string  var_location;
773
    string  hook_location;
774
    string  remotes_location;
775
    string  vms_location;
776

    
777
    string  hostname;
778

    
779
    // ---------------------------------------------------------------
780
    // Configuration
781
    // ---------------------------------------------------------------
782

    
783
    OpenNebulaTemplate * nebula_configuration;
784

    
785
    // ---------------------------------------------------------------
786
    // Federation - HA
787
    // ---------------------------------------------------------------
788

    
789
    bool    federation_enabled;
790
    bool    federation_master;
791
    int     zone_id;
792
    int     server_id;
793
    string  master_oned;
794

    
795
    // ---------------------------------------------------------------
796
    // Default quotas
797
    // ---------------------------------------------------------------
798

    
799
    DefaultQuotas default_user_quota;
800
    DefaultQuotas default_group_quota;
801

    
802
    // ---------------------------------------------------------------
803
    // The system database
804
    // ---------------------------------------------------------------
805

    
806
    SystemDB * system_db;
807

    
808
    // ---------------------------------------------------------------
809
    // Nebula Pools
810
    // ---------------------------------------------------------------
811

    
812
    LogDB              * logdb;
813
    FedLogDB           * fed_logdb;
814
    VirtualMachinePool * vmpool;
815
    HostPool           * hpool;
816
    VirtualNetworkPool * vnpool;
817
    UserPool           * upool;
818
    ImagePool          * ipool;
819
    GroupPool          * gpool;
820
    VMTemplatePool     * tpool;
821
    DatastorePool      * dspool;
822
    ClusterPool        * clpool;
823
    DocumentPool       * docpool;
824
    ZonePool           * zonepool;
825
    SecurityGroupPool  * secgrouppool;
826
    VdcPool            * vdcpool;
827
    VirtualRouterPool  * vrouterpool;
828
    MarketPlacePool    * marketpool;
829
    MarketPlaceAppPool * apppool;
830
    VMGroupPool        * vmgrouppool;
831

    
832
    // ---------------------------------------------------------------
833
    // Nebula Managers
834
    // ---------------------------------------------------------------
835

    
836
    LifeCycleManager *      lcm;
837
    VirtualMachineManager * vmm;
838
    InformationManager *    im;
839
    TransferManager *       tm;
840
    DispatchManager *       dm;
841
    RequestManager *        rm;
842
    HookManager *           hm;
843
    AuthManager *           authm;
844
    AclManager *            aclm;
845
    ImageManager *          imagem;
846
    MarketPlaceManager *    marketm;
847
    IPAMManager *           ipamm;
848
    RaftManager *           raftm;
849
    FedReplicaManager *     frm;
850

    
851
    // ---------------------------------------------------------------
852
    // Implementation functions
853
    // ---------------------------------------------------------------
854

    
855
    friend void nebula_signal_handler (int sig);
856

    
857
    // ---------------------------------------------------------------
858
    // Helper functions
859
    // ---------------------------------------------------------------
860

    
861
    /**
862
     *  Gets a Generic configuration attribute
863
     *  @param key String that identifies the configuration parameter group name
864
     *  @param name Name of the specific configuration parameter
865
     *  @param value Value of the specific configuration parameter
866
     *  @return a reference to the generated string
867
     */
868
    int get_conf_attribute(
869
        const std::string& key,
870
        const std::string& name,
871
        const VectorAttribute* &value) const;
872

    
873
    /**
874
     *  Gets a Generic configuration attribute
875
     *  @param key String that identifies the configuration parameter group name
876
     *  @param name Name of the specific configuration parameter
877
     *  @param value Value of the specific configuration parameter
878
     *  @return a reference to the generated string
879
     */
880
    template<typename T>
881
    int get_conf_attribute(
882
        const std::string& key,
883
        const std::string& name,
884
        const std::string& vname,
885
        T& value) const
886
    {
887
        const VectorAttribute* vattr;
888

    
889
        if ( get_conf_attribute(key, name, vattr) != 0 )
890
        {
891
            return -1;
892
        }
893

    
894
        return vattr->vector_value(vname, value);
895
    }
896
};
897

    
898
#endif /*NEBULA_H_*/