summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin/Bundle.py
blob: b9d26758a343b822bea7ff1b8dda063b9a9c8585 (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
import Bcfg2.Server.Admin
from Bcfg2.Server.Plugins.Metadata import MetadataConsistencyError

class Bundle(Bcfg2.Server.Admin.MetadataCore):
    __shorthelp__ = "Create or delete bundle entries"
    __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin bundle add <bundle> "
                                    "bcfg2-admin bundle del <bundle>")
    __usage__ = ("bcfg2-admin bundle [options] [add|del] [group]")

    def __init__(self, configfile):
        Bcfg2.Server.Admin.MetadataCore.__init__(self, configfile,
                                                 self.__usage__)

    def __call__(self, args):
        Bcfg2.Server.Admin.MetadataCore.__call__(self, args)
        if len(args) == 0:
            self.errExit("No argument specified.\n"
                         "Please see bcfg2-admin bundle help for usage.")
        if args[0] == 'add':
            try:
                self.metadata.add_bundle(args[1])
            except MetadataConsistencyError:
                print "Error in adding bundle"
                raise SystemExit(1)
        elif args[0] in ['delete', 'remove', 'del', 'rm']:
            try:
                self.metadata.remove_bundle(args[1])
            except MetadataConsistencyError:
                print "Error in deleting bundle"
                raise SystemExit(1)
        else:
            print "No command specified"
            raise SystemExit(1)