Ejemplo n.º 1
0
 def git_update(self,options):
     if options.nogit:
         return
     else:
         if options.verbose:
            print "- updating git"
     mytime = time.asctime()
     cwd = os.getcwd()
     os.chdir(options.tree)
     rc1 = sub_process.call(["/usr/bin/git", "add", "*" ], shell=False)
     rc2 = sub_process.call(["/usr/bin/git", "commit", "-a", "-m", "Func-inventory update: %s" % mytime], shell=False)
     # FIXME: check rc's
     os.chdir(cwd)
Ejemplo n.º 2
0
 def check_service(self, which):
     if os.path.exists("/etc/rc.d/init.d/%s" % which):
         rc = sub_process.call(
             "/sbin/service %s status >/dev/null 2>/dev/null" % which,
             shell=True)
         if rc != 0:
             print "* service %s is not running" % which
Ejemplo n.º 3
0
    def check_iptables(self):
        if os.path.exists("/etc/rc.d/init.d/iptables"):
            rc = sub_process.call("/sbin/service iptables status >/dev/null 2>/dev/null", shell=True)

            if rc == 0:
                # FIXME: don't hardcode port
                print "* iptables may be running, ensure 51234 is unblocked"
Ejemplo n.º 4
0
 def pkill(self, name, level=""):
     # example killall("thunderbird","-9")
     rc = sub_process.call(["/usr/bin/pkill", name, level],
                           executable="/usr/bin/pkill",
                           shell=False,
                           close_fds=True)
     return rc
Ejemplo n.º 5
0
    def check_iptables(self):
        if os.path.exists("/etc/rc.d/init.d/iptables"):
            rc = sub_process.call("/sbin/service iptables status >/dev/null 2>/dev/null", shell=True)

            if rc == 0:
                # FIXME: don't hardcode port
                print "* iptables may be running"
                print "Insure that port %s is open for minions to connect to certmaster" % self.minion_config.certmaster_port
                print "Insure that port %s is open for overlord to connect to minions" % self.funcd_config.listen_port
Ejemplo n.º 6
0
    def check_iptables(self):
        if os.path.exists("/etc/rc.d/init.d/iptables"):
            rc = sub_process.call(
                "/sbin/service iptables status >/dev/null 2>/dev/null",
                shell=True)

            if rc == 0:
                # FIXME: don't hardcode port
                print "* iptables may be running, ensure 51234 is unblocked"
Ejemplo n.º 7
0
    def check_iptables(self):
        if os.path.exists("/etc/rc.d/init.d/iptables"):
            rc = sub_process.call(
                "/sbin/service iptables status >/dev/null 2>/dev/null",
                shell=True)

            if rc == 0:
                # FIXME: don't hardcode port
                print "* iptables may be running"
                print "Insure that port %s is open for minions to connect to certmaster" % self.minion_config.certmaster_port
                print "Insure that port %s is open for overlord to connect to minions" % self.funcd_config.listen_port
Ejemplo n.º 8
0
 def kill(self,pid,signal="TERM"):
     if pid == "0":
         raise codes.FuncException("Killing pid group 0 not permitted")
     if signal == "":
         # this is default /bin/kill behaviour,
         # it claims, but enfore it anyway
         signal = "-TERM"
     if signal[0] != "-":
         signal = "-%s" % signal
     rc = sub_process.call(["/bin/kill",signal, pid],
                           executable="/bin/kill", shell=False,
                           close_fds=True)
     print rc
     return rc
Ejemplo n.º 9
0
 def kill(self, pid, signal="TERM"):
     if pid == "0":
         raise codes.FuncException("Killing pid group 0 not permitted")
     if signal == "":
         # this is default /bin/kill behaviour,
         # it claims, but enfore it anyway
         signal = "-TERM"
     if signal[0] != "-":
         signal = "-%s" % signal
     rc = sub_process.call(["/bin/kill", signal, pid],
                           executable="/bin/kill",
                           shell=False,
                           close_fds=True)
     print rc
     return rc
Ejemplo n.º 10
0
 def git_setup(self,options):
     if options.nogit:
         return  
     if not os.path.exists("/usr/bin/git"):
         print "git-core is not installed, so no change tracking is available."
         print "use --no-git or, better, just install it."
         sys.exit(411) 
         
     if not os.path.exists(options.tree):
         os.makedirs(options.tree)
     dirname = os.path.join(options.tree, ".git")
     if not os.path.exists(dirname):
         if options.verbose:
             print "- initializing git repo: %s" % options.tree
         cwd = os.getcwd()
         os.chdir(options.tree)
         rc1 = sub_process.call(["/usr/bin/git", "init"], shell=False)
         # FIXME: check rc's
         os.chdir(cwd)
     else:
         if options.verbose:
             print "- git already initialized: %s" % options.tree
Ejemplo n.º 11
0
def call_iptables(args):
    return sub_process.call(["/sbin/iptables"] + args.split(),
                            executable="/sbin/iptables",
                            shell=False)
Ejemplo n.º 12
0
 def check_service(self, which):
     if os.path.exists("/etc/rc.d/init.d/%s" % which):
         rc = sub_process.call("/sbin/service %s status >/dev/null 2>/dev/null" % which, shell=True)
         if rc != 0:
             print "* service %s is not running" % which
Ejemplo n.º 13
0
 def pkill(self,name,level=""):
     # example killall("thunderbird","-9")
     rc = sub_process.call(["/usr/bin/pkill", name, level],
                           executable="/usr/bin/pkill", shell=False,
                           close_fds=True)
     return rc
Ejemplo n.º 14
0
 def reboot(self, when='now', message=''):
     return sub_process.call(["/sbin/shutdown", '-r', when, message],
                             close_fds=True)
Ejemplo n.º 15
0
def call_iptables(args):
    return sub_process.call(["/sbin/iptables"] + args.split(),
                            executable="/sbin/iptables",
                            shell=False)
Ejemplo n.º 16
0
 def reboot(self, when='now', message=''):
     return sub_process.call(["/sbin/shutdown", '-r', when, message], close_fds=True)