summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-crypt8
-rwxr-xr-xsrc/sbin/bcfg2-info2
-rwxr-xr-xsrc/sbin/bcfg2-ping-sweep70
3 files changed, 8 insertions, 72 deletions
diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt
index 89dfe3e2a..79f9e26a2 100755
--- a/src/sbin/bcfg2-crypt
+++ b/src/sbin/bcfg2-crypt
@@ -7,7 +7,13 @@ import logging
import lxml.etree
import Bcfg2.Logger
import Bcfg2.Options
-import Bcfg2.Encryption
+try:
+ import Bcfg2.Encryption
+except ImportError:
+ err = sys.exc_info()[1]
+ print("Import failed '%s'. Is M2Crypto installed?" %
+ err)
+ raise SystemExit(1)
LOGGER = None
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index f3b2aec10..bba8eca7c 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -155,7 +155,7 @@ def load_interpreters():
import IPython
if hasattr(IPython, "Shell"):
interpreters["ipython"] = lambda v: \
- IPython.Shell.IPShell(argv=[], user_ns=v).mainloop
+ IPython.Shell.IPShell(argv=[], user_ns=v).mainloop()
best = "ipython"
elif hasattr(IPython, "embed"):
interpreters["ipython"] = lambda v: IPython.embed(user_ns=v)
diff --git a/src/sbin/bcfg2-ping-sweep b/src/sbin/bcfg2-ping-sweep
deleted file mode 100755
index be8994be3..000000000
--- a/src/sbin/bcfg2-ping-sweep
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-#GenerateHostInfo - Joey Hagedorn - hagedorn@mcs.anl.gov
-
-"""Generates hostinfo.xml at a regular interval."""
-
-from os import dup2, execl, fork, uname, wait
-import sys
-import time
-import lxml.etree
-
-import Bcfg2.Options
-
-if __name__ == '__main__':
- opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY,
- 'configfile': Bcfg2.Options.CFILE}
- setup = Bcfg2.Options.OptionParser(opts)
- setup.parse(sys.argv[1:])
-
- cfpath = setup['configfile']
- clientdatapath = "%s/Metadata/clients.xml" % setup['repo']
-
- clientElement = lxml.etree.parse(clientdatapath)
- hostlist = [client.get('name')
- for client in clientElement.findall("Client")]
-
- pids = {}
- null = open('/dev/null', 'w+')
-
- #use uname to detect OS and use -t for darwin and -w for linux
- #/bin/ping on linux /sbin/ping on os x
- osname = uname()[0]
-
- while hostlist or pids:
- if hostlist and len(list(pids.keys())) < 15:
- host = hostlist.pop()
- pid = fork()
- if pid == 0:
- # in child
- dup2(null.fileno(), sys.__stdin__.fileno())
- dup2(null.fileno(), sys.__stdout__.fileno())
- dup2(null.fileno(), sys.__stderr__.fileno())
- if osname == 'Linux':
- execl('/bin/ping', 'ping', '-w', '5', '-c', '1', host)
- elif osname in ['Darwin', 'FreeBSD']:
- execl('/sbin/ping', 'ping', '-t', '5', '-c', '1', host)
- elif osname == 'SunOS':
- execl('/usr/sbin/ping', 'ping', host, '56', '1')
- else: # default
- execl('/bin/ping', 'ping', '-w', '5', '-c', '1', host)
- else:
- pids[pid] = host
- else:
- try:
- (cpid, status) = wait()
- except OSError:
- continue
- chost = pids[cpid]
- del pids[cpid]
- elm = clientElement.xpath("//Client[@name='%s']" % chost)[0]
- if status == 0:
- elm.set("pingable", 'Y')
- elm.set("pingtime", str(time.time()))
- else:
- elm.set("pingable", 'N')
-
- fout = open(clientdatapath, 'w')
- fout.write(lxml.etree.tostring(clientElement.getroot(),
- encoding='UTF-8',
- xml_declaration=True))
- fout.close()