summaryrefslogtreecommitdiffstats
path: root/cobbler/api.py
blob: 315802e348321fc681b35ba1a66ed538cde8d048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
"""
python API module for Cobbler
see source for cobbler.py, or pydoc, for example usage.
CLI apps and daemons should import api.py, and no other cobbler code.

Copyright 2006-2008, Red Hat, Inc
Michael DeHaan <mdehaan@redhat.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301  USA
"""

import yaml
import config
import utils
import action_sync
import action_check
import action_import
import action_reposync
import action_status
import action_validate
import action_buildiso
import action_replicate
import action_acl
import action_report
import action_power
import action_hardlink
from cexceptions import *
import sub_process
import module_loader
import kickgen
import yumgen
import pxegen
import acls
from utils import _

import logging
import time
import random
import os
import xmlrpclib
import traceback

ERROR = 100
INFO  = 10
DEBUG = 5

# notes on locking:
# BootAPI is a singleton object
# the XMLRPC variants allow 1 simultaneous request
# therefore we flock on /etc/cobbler/settings for now
# on a request by request basis.

class BootAPI:

    __shared_state = {}
    __has_loaded = False

    def __init__(self, log_settings={}, is_cobblerd=False):
        """
        Constructor
        """

        self.__dict__ = BootAPI.__shared_state
        self.log_settings = log_settings
        self.perms_ok = False
        if not BootAPI.__has_loaded:

            # NOTE: we do not log all API actions, because
            # a simple CLI invocation may call adds and such
            # to load the config, which would just fill up
            # the logs, so we'll do that logging at CLI
            # level (and remote.py web service level) instead.

            random.seed()
            self.is_cobblerd = is_cobblerd

            try:
                self.logger = self.__setup_logger("api")
            except CX:
                # return to CLI/other but perms are not valid
                # perms_ok is False
                return

            # FIMXE: conslidate into 1 server instance

            self.selinux_enabled = utils.is_selinux_enabled()
            self.dist = utils.check_dist()
            self.os_version = utils.os_release()

            self.acl_engine = acls.AclEngine()
            
            BootAPI.__has_loaded   = True

            module_loader.load_modules()

            self._config         = config.Config(self)
            self.deserialize()

            self.authn = self.get_module_from_file(
                "authentication",
                "module",
                "authn_configfile"
            )
            self.authz  = self.get_module_from_file(
                "authorization",
                "module",
                "authz_allowall"
            )
            self.kickgen = kickgen.KickGen(self._config)
            self.yumgen  = yumgen.YumGen(self._config)
            self.pxegen  = pxegen.PXEGen(self._config)
            self.logger.debug("API handle initialized")
            self.perms_ok = True


    def __setup_logger(self,name):
        return utils.setup_logger(name, is_cobblerd=self.is_cobblerd, **self.log_settings)
    
    def is_selinux_enabled(self):
        """
        Returns whether selinux is enabled on the cobbler server.
        We check this just once at cobbler API init time, because
        a restart is required to change this; this does /not/ check
        enforce/permissive, nor does it need to.
        """
        return self.selinux_enabled

    def is_selinux_supported(self):
        """
        Returns whether or not the OS is sufficient enough
        to run with SELinux enabled (currently EL 5 or later).
        """
        self.dist
        if self.dist == "redhat" and self.os_version < 5:
           # doesn't support public_content_t
           return False 
        return True

    def _internal_cache_update(self, collection_type, name, remove=False):
        """
        Update cobblerd so it won't have to ever reload the config, once started.
        """
        # FIXME: take value from settings, use raw port
        if self.is_cobblerd:
           # don't signal yourself, that's asking for trouble.
           return True
        self.server = xmlrpclib.Server("http://127.0.0.1:%s" % self.settings().xmlrpc_port)
        try:
            if not remove:
                self.server.internal_cache_update(collection_type, name)
            else:
                self.server.internal_cache_remove(collection_type, name)
        except Exception, e:
            if len(e.args) == 2 and e[0] == 111:
                # if cobblerd is not running, no harm done, nothing to signal
                pass
            else: 
                raise CX("error contacting cobblerd")
        return False

    def last_modified_time(self):
        """
        Returns the time of the last modification to cobbler, made by any
        API instance, regardless of the serializer type.
        """
        if not os.path.exists("/var/lib/cobbler/.mtime"):
            fd = open("/var/lib/cobbler/.mtime","w")
            fd.write("0")
            fd.close()
            return 0
        fd = open("/var/lib/cobbler/.mtime")
        data = fd.read().strip()
        return float(data)

    def log(self,msg,args=None,debug=False):
        if debug:
            logger = self.logger.debug
        else:
            logger = self.logger.info 
        if args is None:
            logger("%s" % msg)
        else:
            logger("%s; %s" % (msg, str(args)))

    def version(self, extended=False):
        """
        What version is cobbler?

        If extended == False, returns a float for backwards compatibility
         
        If extended == True, returns a dict:

            gitstamp      -- the last git commit hash
            gitdate       -- the last git commit date on the builder machine
            builddate     -- the time of the build
            version       -- something like "1.3.2"
            version_tuple -- something like [ 1, 3, 2 ]
        """
        fd = open("/var/lib/cobbler/version")
        ydata = fd.read()
        fd.close()
        data = yaml.load(ydata)
        if not extended:
            # for backwards compatibility and use with koan's comparisons
            elems = data["version_tuple"] 
            print elems
            return int(elems[0]) + 0.1*int(elems[1]) + 0.001*int(elems[2])
        else:
            return data

    def clear(self):
        """
        Forget about current list of profiles, distros, and systems
        """
        return self._config.clear()

    def __cmp(self,a,b):
        return cmp(a.name,b.name)

    def systems(self):
        """
        Return the current list of systems
        """
        return self._config.systems()

    def profiles(self):
        """
        Return the current list of profiles
        """
        return self._config.profiles()

    def distros(self):
        """
        Return the current list of distributions
        """
        return self._config.distros()

    def repos(self):
        """
        Return the current list of repos
        """
        return self._config.repos()

    def images(self):
        """
        Return the current list of images
        """
        return self._config.images()

    def networks(self):
        """
        Return the current list of networks
        """
        return self._config.networks()

    def settings(self):
        """
        Return the application configuration
        """
        return self._config.settings()

    def update(self):
        """
        This can be called is no longer used by cobbler.
        And is here to just avoid breaking older scripts.
        """
        return True

    def copy_distro(self, ref, newname):
        self.log("copy_distro",[ref.name, newname])
        return self._config.distros().copy(ref,newname)

    def copy_profile(self, ref, newname):
        self.log("copy_profile",[ref.name, newname])
        return self._config.profiles().copy(ref,newname)

    def copy_system(self, ref, newname):
        self.log("copy_system",[ref.name, newname])
        return self._config.systems().copy(ref,newname)

    def copy_repo(self, ref, newname):
        self.log("copy_repo",[ref.name, newname])
        return self._config.repos().copy(ref,newname)
    
    def copy_image(self, ref, newname):
        self.log("copy_image",[ref.name, newname])
        return self._config.images().copy(ref,newname)

    def remove_distro(self, ref, recursive=False, delete=True, with_triggers=True, ):
        if type(ref) != str:
           self.log("remove_distro",[ref.name])
           return self._config.distros().remove(ref.name, recursive=recursive, with_delete=delete, with_triggers=with_triggers)
        else:
           self.log("remove_distro",ref)
           return self._config.distros().remove(ref, recursive=recursive, with_delete=delete, with_triggers=with_triggers)

    def remove_profile(self,ref, recursive=False, delete=True, with_triggers=True):
        if type(ref) != str:
           self.log("remove_profile",[ref.name])
           return self._config.profiles().remove(ref.name, recursive=recursive, with_delete=delete, with_triggers=with_triggers) 
        else:
           self.log("remove_profile",ref)
           return self._config.profiles().remove(ref, recursive=recursive, with_delete=delete, with_triggers=with_triggers)

    def remove_system(self, ref, recursive=False, delete=True, with_triggers=True):
        if type(ref) != str:
           self.log("remove_system",[ref.name])
           return self._config.systems().remove(ref.name, with_delete=delete, with_triggers=with_triggers)
        else:
           self.log("remove_system",ref)
           return self._config.systems().remove(ref, with_delete=delete, with_triggers=with_triggers)

    def remove_repo(self, ref, recursive=False, delete=True, with_triggers=True):
        if type(ref) != str:
           self.log("remove_repo",[ref.name])
           return self._config.repos().remove(ref.name, with_delete=delete, with_triggers=with_triggers)
        else:    
           self.log("remove_repo",ref)
           return self._config.repos().remove(ref, with_delete=delete, with_triggers=with_triggers)

    def remove_image(self, ref, recursive=False, delete=True, with_triggers=True):
        if type(ref) != str:
           self.log("remove_image",[ref.name])
           return self._config.images().remove(ref.name, recursive=recursive, with_delete=delete, with_triggers=with_triggers)
        else:
           self.log("remove_image",ref)
           return self._config.images().remove(ref, recursive=recursive, with_delete=delete, with_triggers=with_triggers)

    def rename_distro(self, ref, newname):
        self.log("rename_distro",[ref.name,newname])
        return self._config.distros().rename(ref,newname)

    def rename_profile(self, ref, newname):
        self.log("rename_profiles",[ref.name,newname])
        return self._config.profiles().rename(ref,newname)

    def rename_system(self, ref, newname):
        self.log("rename_system",[ref.name,newname])
        return self._config.systems().rename(ref,newname)

    def rename_repo(self, ref, newname):
        self.log("rename_repo",[ref.name,newname])
        return self._config.repos().rename(ref,newname)
    
    def rename_image(self, ref, newname):
        self.log("rename_image",[ref.name,newname])
        return self._config.images().rename(ref,newname)

    def new_distro(self,is_subobject=False):
        self.log("new_distro",[is_subobject])
        return self._config.new_distro(is_subobject=is_subobject)

    def new_profile(self,is_subobject=False):
        self.log("new_profile",[is_subobject])
        return self._config.new_profile(is_subobject=is_subobject)
    
    def new_system(self,is_subobject=False):
        self.log("new_system",[is_subobject])
        return self._config.new_system(is_subobject=is_subobject)

    def new_repo(self,is_subobject=False):
        self.log("new_repo",[is_subobject])
        return self._config.new_repo(is_subobject=is_subobject)
    
    def new_image(self,is_subobject=False):
        self.log("new_image",[is_subobject])
        return self._config.new_image(is_subobject=is_subobject)

    def new_network(self,is_subobject=False):
        self.log("new_network",[is_subobject])
        return self._config.new_network(is_subobject=is_subobject)

    def add_distro(self, ref, check_for_duplicate_names=False, save=True):
        self.log("add_distro",[ref.name])
        rc = self._config.distros().add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save)
        return rc

    def add_profile(self, ref, check_for_duplicate_names=False,save=True):
        self.log("add_profile",[ref.name])
        rc = self._config.profiles().add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save)
        return rc

    def add_system(self, ref, check_for_duplicate_names=False, check_for_duplicate_netinfo=False, save=True):
        self.log("add_system",[ref.name])
        rc = self._config.systems().add(ref,check_for_duplicate_names=check_for_duplicate_names,check_for_duplicate_netinfo=check_for_duplicate_netinfo,save=save)
        return rc

    def add_repo(self, ref, check_for_duplicate_names=False,save=True):
        self.log("add_repo",[ref.name])
        rc = self._config.repos().add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save)
        return rc

    def add_image(self, ref, check_for_duplicate_names=False,save=True):
        self.log("add_image",[ref.name])
        rc = self._config.images().add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save)
        return rc

    def find_distro(self, name=None, return_list=False, no_errors=False, **kargs):
        return self._config.distros().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)
        
    def find_profile(self, name=None, return_list=False, no_errors=False, **kargs):
        return self._config.profiles().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)

    def find_system(self, name=None, return_list=False, no_errors=False, **kargs):
        return self._config.systems().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)

    def find_repo(self, name=None, return_list=False, no_errors=False, **kargs):
        return self._config.repos().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)

    def find_image(self, name=None, return_list=False, no_errors=False, **kargs):
        return self._config.images().find(name=name, return_list=return_list, no_errors=no_errors, **kargs)

    def __since(self,mtime,collector,collapse=False):
        """
        Called by get_*_since functions.
        """
        results1 = collector()
        results2 = []
        for x in results1:
           if x.mtime == 0 or x.mtime >= mtime:
              if not collapse:
                  results2.append(x)
              else:
                  results2.append(x.to_datastruct())
        return results2

    def get_distros_since(self,mtime,collapse=False):
        """
        Returns distros modified since a certain time (in seconds since Epoch)
        collapse=True specifies returning a hash instead of objects.
        """
        return self.__since(mtime,self.distros,collapse=collapse)

    def get_profiles_since(self,mtime,collapse=False):
        return self.__since(mtime,self.profiles,collapse=collapse)

    def get_systems_since(self,mtime,collapse=False):
        return self.__since(mtime,self.systems,collapse=collapse)

    def get_repos_since(self,mtime,collapse=False):
        return self.__since(mtime,self.repos,collapse=collapse)

    def get_images_since(self,mtime,collapse=False):
        return self.__since(mtime,self.images,collapse=collapse)

    


    def dump_vars(self, obj, format=False):
        return obj.dump_vars(format)

    def auto_add_repos(self):
        """
        Import any repos this server knows about and mirror them.
        Credit: Seth Vidal.
        """
        self.log("auto_add_repos")
        try:
            import yum
        except:
            raise CX(_("yum is not installed"))

        version = yum.__version__
        (a,b,c) = version.split(".")
        version = a* 1000 + b*100 + c
        if version < 324:
            raise CX(_("need yum > 3.2.4 to proceed"))

        base = yum.YumBase()
        base.doRepoSetup()
        repos = base.repos.listEnabled()
        if len(repos) == 0:
            raise CX(_("no repos enabled/available -- giving up."))

        for repo in repos:
            url = repo.urls[0]
            cobbler_repo = self.new_repo()
            auto_name = repo.name.replace(" ","")
            # FIXME: probably doesn't work for yum-rhn-plugin ATM
            cobbler_repo.set_mirror(url)
            cobbler_repo.set_name(auto_name)
            print "auto adding: %s (%s)" % (auto_name, url)
            self._config.repos().add(cobbler_repo,save=True)

        # run cobbler reposync to apply changes
        return True 

    def get_repo_config_for_profile(self,obj):
        return self.yumgen.get_yum_config(obj,True)
    
    def get_repo_config_for_system(self,obj):
        return self.yumgen.get_yum_config(obj,False)

    def get_template_file_for_profile(self,obj,path):
        template_results = self.pxegen.write_templates(obj,False,path)
        if template_results.has_key(path):
            return template_results[path]
        else:
            return "# template path not found for specified profile"

    def get_template_file_for_system(self,obj,path):
        template_results = self.pxegen.write_templates(obj,False,path)
        if template_results.has_key(path):
            return template_results[path]
        else:
            return "# template path not found for specified system"

    def generate_kickstart(self,profile,system):
        self.log("generate_kickstart")
        if system:
            return self.kickgen.generate_kickstart_for_system(system)
        else:
            return self.kickgen.generate_kickstart_for_profile(profile) 

    def check(self):
        """
        See if all preqs for network booting are valid.  This returns
        a list of strings containing instructions on things to correct.
        An empty list means there is nothing to correct, but that still
        doesn't mean there are configuration errors.  This is mainly useful
        for human admins, who may, for instance, forget to properly set up
        their TFTP servers for PXE, etc.
        """
        self.log("check")
        check = action_check.BootCheck(self._config)
        return check.run()

    def validateks(self):
        """
        Use ksvalidator (from pykickstart, if available) to determine
        whether the cobbler kickstarts are going to be (likely) well
        accepted by Anaconda.  Presence of an error does not indicate
        the kickstart is bad, only that the possibility exists.  ksvalidator
        is not available on all platforms and can not detect "future"
        kickstart format correctness.
        """
        self.log("validateks")
        validator = action_validate.Validate(self._config)
        return validator.run()

    def sync(self,verbose=False):
        """
        Take the values currently written to the configuration files in
        /etc, and /var, and build out the information tree found in
        /tftpboot.  Any operations done in the API that have not been
        saved with serialize() will NOT be synchronized with this command.
        """
        self.log("sync")
        sync = self.get_sync(verbose=verbose)
        return sync.run()

    def get_sync(self,verbose=False):
        self.dhcp = self.get_module_from_file(
           "dhcp",
           "module",
           "manage_isc"
        ).get_manager(self._config)
        self.dns = self.get_module_from_file(
           "dns",
           "module",
           "manage_bind"
        ).get_manager(self._config)
        return action_sync.BootSync(self._config,dhcp=self.dhcp,dns=self.dns,verbose=verbose)

    def reposync(self, name=None, tries=1, nofail=False):
        """
        Take the contents of /var/lib/cobbler/repos and update them --
        or create the initial copy if no contents exist yet.
        """
        self.log("reposync",[name])
        reposync = action_reposync.RepoSync(self._config, tries=tries, nofail=nofail)
        return reposync.run(name)

    def status(self,mode=None):
        self.log("status")
        statusifier = action_status.BootStatusReport(self._config,mode)
        return statusifier.run()

    def import_tree(self,mirror_url,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None,breed=None):
        """
        Automatically import a directory tree full of distribution files.
        mirror_url can be a string that represents a path, a user@host 
        syntax for SSH, or an rsync:// address.  If mirror_url is a 
        filesystem path and mirroring is not desired, set network_root 
        to something like "nfs://path/to/mirror_url/root" 
        """
        self.log("import_tree",[mirror_url, mirror_name, network_root, kickstart_file, rsync_flags])
        importer = action_import.Importer(
            self, self._config, mirror_url, mirror_name, network_root, kickstart_file, rsync_flags, arch, breed
        )
        return importer.run()

    def acl_config(self,adduser=None,addgroup=None,removeuser=None,removegroup=None):
        """
        Configures users/groups to run the cobbler CLI as non-root.
        Pass in only one option at a time.  Powers "cobbler aclconfig"
        """
        acl = action_acl.AclConfig(self._config)
        return acl.run(
            adduser=adduser,
            addgroup=addgroup,
            removeuser=removeuser,
            removegroup=removegroup
        )

    def serialize(self):
        """
        Save the config file(s) to disk.
        """
        self.log("serialize")
        return self._config.serialize()

    def deserialize(self):
        """
        Load the current configuration from config file(s)
        Cobbler internal use only.
        """
        return self._config.deserialize()

    def deserialize_raw(self,collection_name):
        """
        Get the collection back just as raw data.
        Cobbler internal use only.
        """
        return self._config.deserialize_raw(collection_name)

    def deserialize_item_raw(self,collection_name,obj_name):
        """
        Get an object back as raw data.
        Can be very fast for shelve or catalog serializers
        Cobbler internal use only.
        """
        return self._config.deserialize_item_raw(collection_name,obj_name)

    def get_module_by_name(self,module_name):
        """
        Returns a loaded cobbler module named 'name', if one exists, else None.
        Cobbler internal use only.
        """
        return module_loader.get_module_by_name(module_name)

    def get_module_from_file(self,section,name,fallback=None):
        """
        Looks in /etc/cobbler/modules.conf for a section called 'section'
        and a key called 'name', and then returns the module that corresponds
        to the value of that key.
        Cobbler internal use only.
        """
        return module_loader.get_module_from_file(section,name,fallback)

    def get_modules_in_category(self,category):
        """
        Returns all modules in a given category, for instance "serializer", or "cli".
        Cobbler internal use only.
        """
        return module_loader.get_modules_in_category(category)

    def authenticate(self,user,password):
        """
        (Remote) access control.
        Cobbler internal use only.
        """
        rc = self.authn.authenticate(self,user,password)
        self.log("authenticate",[user,rc])
        return rc 

    def authorize(self,user,resource,arg1=None,arg2=None):
        """
        (Remote) access control.
        Cobbler internal use only.
        """
        rc = self.authz.authorize(self,user,resource,arg1,arg2,acl_engine=self.acl_engine)
        self.log("authorize",[user,resource,arg1,arg2,rc],debug=True)
        return rc

    def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None):
        builder = action_buildiso.BuildIso(self._config)
        return builder.run(
           iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source
        )

    def hardlink(self):
        linker = action_hardlink.HardLinker(self._config)
        return linker.run()

    def replicate(self, cobbler_master = None, sync_all=False, sync_kickstarts=False, sync_trees=False, sync_repos=False, sync_triggers=False, systems=False):
        """
        Pull down metadata from a remote cobbler server that is a master to this server.
        Optionally rsync data from it.
        """
        replicator = action_replicate.Replicate(self._config)
        return replicator.run(
              cobbler_master = cobbler_master,
              sync_all = sync_all,
              sync_kickstarts = sync_kickstarts,
              sync_trees = sync_trees,
              sync_repos = sync_repos,
              sync_triggers = sync_triggers,
              include_systems = systems
        )

    def report(self, report_what = None, report_name = None, report_type = None, report_fields = None, report_noheaders = None):
        """
        Report functionality for cobbler
        """
        reporter = action_report.Report(self._config)
        return reporter.run(report_what = report_what, report_name = report_name,\
                            report_type = report_type, report_fields = report_fields,\
                            report_noheaders = report_noheaders)

    def get_kickstart_templates(self):
        return utils.get_kickstar_templates(self)

    def power_on(self, system, user=None, password=None):
        """
        Powers up a system that has power management configured.
        """
        return action_power.PowerTool(self._config,system,self,user,password).power("on")

    def power_off(self, system, user=None, password=None):
        """
        Powers down a system that has power management configured.
        """
        return action_power.PowerTool(self._config,system,self,user,password).power("off")

    def reboot(self,system, user=None, password=None):
        """
        Cycles power on a system that has power management configured.
        """
        self.power_off(system, user, password)
        time.sleep(5)
        return self.power_on(system, user, password)
        
    def get_os_details(self):
        return (self.dist, self.os_version)