diff options
author | Cory Lueninghoener <lueningh@mcs.anl.gov> | 2007-03-20 16:20:03 +0000 |
---|---|---|
committer | Cory Lueninghoener <lueningh@mcs.anl.gov> | 2007-03-20 16:20:03 +0000 |
commit | d59947214581bc31f327477e8590b65a038d0650 (patch) | |
tree | a4c2fe9559a1f9647213213205f8efc1f8133d5c /src | |
parent | 603b27cd2794448ac3a900a2b14bcf78c51c4a2d (diff) | |
download | bcfg2-d59947214581bc31f327477e8590b65a038d0650.tar.gz bcfg2-d59947214581bc31f327477e8590b65a038d0650.tar.bz2 bcfg2-d59947214581bc31f327477e8590b65a038d0650.zip |
Added 'client add' functionality
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2953 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rwxr-xr-x | src/sbin/bcfg2-admin | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin index ab9554c9e..2f2f51bbb 100755 --- a/src/sbin/bcfg2-admin +++ b/src/sbin/bcfg2-admin @@ -18,6 +18,7 @@ init - initialize the bcfg2 repository( this is interactive; only run onc mineentry <client> <entry type> <entry name> - mine statistics for entry information minestruct <client> - mine statistics for extra entries viz [-h] [-b] [-k] [-o output.png] [-r] +client add name= profile= uuid= password= secure= location= ''' config = ''' @@ -469,12 +470,30 @@ def do_viz(repopath, args): else: print data -def do_client(args): +def do_client(repopath, args): '''Do things with clients''' '''bcfg2-admin client add name profile uuid password secure location''' - for i in args: - print i.split('=', 1) + tree = lxml.etree.parse(repopath + '/Metadata/clients.xml') + root = tree.getroot() + + if args[0] == 'add': + '''Adding a node''' + print "Adding client..." + element = lxml.etree.Element("Client") + for i in args[1:]: + attr, val = i.split('=', 1) + if not(attr in ['name', 'profile', 'uuid', 'password', 'secure', 'location']): + print "Attribute %s unknown" % attr + raise SystemExit, 1 + element.attrib[attr] = val + root.append(element) + + elif args[0] in ['delete', 'remove']: + '''Removing a node''' + print "Removing" + tree.write(repopath + '/Metadata/clients.xml') + print "Done" if __name__ == '__main__': Bcfg2.Logging.setup_logging('bcfg2-admin', to_console=True) @@ -539,7 +558,8 @@ if __name__ == '__main__': if len(args) < 4: print usage raise SystemExit, 1 - do_client(args[1:]) - + if repopath == "": + repopath = get_repo_path(configfile) + do_client(repopath, args[1:]) else: print usage |