summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-02-07 12:08:55 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-02-07 12:08:55 -0500
commit697402da24ca930b3608359a61b9872fdddc62d9 (patch)
tree625403025dbfe9caca1254aab45724c8de4d8302 /scripts
parentac3061bcffd2ea634596c188beaa13339e3fa24a (diff)
downloadcertmaster-697402da24ca930b3608359a61b9872fdddc62d9.tar.gz
certmaster-697402da24ca930b3608359a61b9872fdddc62d9.tar.xz
certmaster-697402da24ca930b3608359a61b9872fdddc62d9.zip
Starting off the certmaster tree with most of the func code, shortly non-certmaster related parts will be removed, and other small parts added/tweaked
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/Makefile20
-rwxr-xr-xscripts/certmaster11
-rwxr-xr-xscripts/certmaster-ca92
-rwxr-xr-xscripts/func14
-rwxr-xr-xscripts/func-create-module79
-rwxr-xr-xscripts/func-inventory8
-rwxr-xr-xscripts/funcd10
7 files changed, 234 insertions, 0 deletions
diff --git a/scripts/Makefile b/scripts/Makefile
new file mode 100755
index 0000000..a4cc7e1
--- /dev/null
+++ b/scripts/Makefile
@@ -0,0 +1,20 @@
+
+
+PYFILES = $(wildcard *.py)
+
+PYCHECKER = /usr/bin/pychecker
+PYFLAKES = /usr/bin/pyflakes
+
+clean::
+ @rm -fv *.pyc *~ .*~ *.pyo
+ @find . -name .\#\* -exec rm -fv {} \;
+ @rm -fv *.rpm
+
+
+pychecker::
+ @$(PYCHECKER) $(PYFILES) || exit 0
+
+pyflakes::
+ifneq ($(PYFILES)x, x)
+ @$(PYFLAKES) $(PYFILES) || exit 0
+endif
diff --git a/scripts/certmaster b/scripts/certmaster
new file mode 100755
index 0000000..d5f677d
--- /dev/null
+++ b/scripts/certmaster
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+
+from func import certmaster
+
+import sys
+
+if __name__ == "__main__":
+ certmaster.main(sys.argv)
+
+
+
diff --git a/scripts/certmaster-ca b/scripts/certmaster-ca
new file mode 100755
index 0000000..b3e844a
--- /dev/null
+++ b/scripts/certmaster-ca
@@ -0,0 +1,92 @@
+#!/usr/bin/python -tt
+# sign/list keys
+# --sign hostname hostname hostname
+# --list # lists all csrs needing to be signed
+# --list-all ?
+# --clean? not sure what it will do
+
+import sys
+import glob
+import os
+
+import func
+import func.certs
+import func.certmaster
+
+
+
+from optparse import OptionParser
+
+def errorprint(stuff):
+ print >> sys.stderr, stuff
+
+
+def parseargs(args):
+ usage = 'certmaster-ca <option> [args]'
+ parser = OptionParser(usage=usage)
+
+ parser.add_option('-l', '--list', default=False, action="store_true",
+ help='list signing requests remaining')
+ parser.add_option('-s', '--sign', default=False, action="store_true",
+ help='sign requests of hosts specified')
+ parser.add_option('-c', '--clean', default=False, action="store_true",
+ help="clean out all certs or csrs for the hosts specified")
+
+ (opts, args) = parser.parse_args()
+
+
+ if not opts.list and not opts.sign and not opts.clean:
+ parser.print_help()
+ sys.exit(1)
+
+ return (opts, args)
+
+def main(args):
+ if os.geteuid() != 0:
+ errorprint('Must be root to run certmaster-ca')
+ return 1
+
+ cm = func.certmaster.CertMaster()
+
+ (opts, args) = parseargs(args)
+
+
+ if opts.list:
+ hns = cm.get_csrs_waiting()
+ if hns:
+ for hn in cm.get_csrs_waiting():
+ print hn
+ else:
+ print 'No certificates to sign'
+
+ return 0
+
+ if opts.sign:
+ if not args:
+ errorprint('Need hostnames to sign')
+ return 1
+
+ for hn in args:
+ csrglob = '%s/%s.csr' % (cm.cfg.csrroot, hn)
+ csrs = glob.glob(csrglob)
+ if not csrs:
+ errorprint('No match for %s to sign' % hn)
+ return 1
+
+ for fn in csrs:
+ certfile = cm.sign_this_csr(fn)
+ print '%s signed - cert located at %s' % (fn, certfile)
+ return 0
+
+ if opts.clean:
+ if not args:
+ errorprint('Need hostname(s) to clean up')
+ return 1
+
+ for hn in args:
+ cm.remove_this_host(hn)
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
diff --git a/scripts/func b/scripts/func
new file mode 100755
index 0000000..925d6ad
--- /dev/null
+++ b/scripts/func
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+
+import sys
+import distutils.sysconfig
+
+# sys.path.append("%s/func" % distutils.sysconfig.get_python_lib())
+
+import func.overlord.func_command as func_command
+
+myname, argv = sys.argv[0], sys.argv[1:]
+cli = func_command.FuncCommandLine()
+cli.parse(argv)
+
+
diff --git a/scripts/func-create-module b/scripts/func-create-module
new file mode 100755
index 0000000..f2885e8
--- /dev/null
+++ b/scripts/func-create-module
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# Copyright 2008, Red Hat, Inc
+# Steve 'Ashcrow' Milner <smilner@redhat.com>
+# John Eckersberg <jeckersb@redhat.com>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+TEMPLATE = """\
+#
+# Copyright %s
+# %s <%s>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import func_module
+
+class %s(func_module.FuncModule):
+
+ # Update these if need be.
+ version = "0.0.1"
+ api_version = "0.0.1"
+ description = "%s"
+
+%s
+"""
+
+METHOD_TEMPLATE = '''\
+ def %s(self):
+ """
+ TODO: Document me ...
+ """
+ pass
+
+'''
+
+
+def populate_template(author_name, author_email, module_name, desc, methods):
+ """
+ Makes the method strings and populates the template.
+ """
+ from datetime import datetime
+
+ actual_methods = ""
+ for method in methods:
+ actual_methods += METHOD_TEMPLATE % method
+ return TEMPLATE % (datetime.now().strftime("%Y"), author_name,
+ author_email, module_name, desc, actual_methods[:-2])
+
+
+if __name__ == '__main__':
+ module_name = raw_input("Module Name: ").capitalize()
+ desc = raw_input("Description: ")
+ author_name = raw_input("Author: ")
+ author_email = raw_input("Email: ")
+ methods = []
+ print "\nLeave blank to finish."
+ while True:
+ method = raw_input("Method: ")
+ if method == '':
+ break
+ methods.append(method)
+ # Write it out to a file
+ file_name = "%s.py" % module_name.lower()
+ file_obj = open(file_name, "w")
+ file_obj.write(populate_template(author_name, author_email,
+ module_name, desc, methods))
+ file_obj.close()
+ print "Your module is ready to be hacked on. Wrote out to %s." % file_name
diff --git a/scripts/func-inventory b/scripts/func-inventory
new file mode 100755
index 0000000..1a0c36b
--- /dev/null
+++ b/scripts/func-inventory
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+import sys
+import distutils.sysconfig
+import func.overlord.inventory as func_inventory
+
+inventory = func_inventory.FuncInventory()
+inventory.run(sys.argv)
diff --git a/scripts/funcd b/scripts/funcd
new file mode 100755
index 0000000..3d807bd
--- /dev/null
+++ b/scripts/funcd
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+
+import sys
+import distutils.sysconfig
+
+from func.minion import server
+
+if __name__ == "__main__":
+ server.main(sys.argv)