Пример #1
0
 def _stop_dnsmasq(self):
     # Shutdown dnsmasq which is typically used by nova-network
     # to provide dhcp leases and since nova currently doesn't
     # seem to shut them down itself (why not?) we have to do it for it..
     #
     # TODO(harlowja) file a bug to get that fixed...
     to_kill = []
     for proc in psutil.process_iter():
         if proc.name.find("dnsmasq") == -1:
             continue
         cwd = ''
         cmdline = ''
         cwd = proc.getcwd()
         cmdline = " ".join(proc.cmdline)
         to_try = False
         for t in [cwd, cmdline]:
             if t.lower().find("nova") != -1:
                 to_try = True
         if to_try:
             to_kill.append(proc.pid)
     if len(to_kill):
         utils.log_iterable(to_kill,
                            header="Killing leftover nova dnsmasq processes with process ids",
                            logger=nconf.LOG)
         for pid in to_kill:
             sh.kill(pid)
Пример #2
0
 def _stop_dnsmasq(self):
     # Shutdown dnsmasq which is typically used by nova-network
     # to provide dhcp leases and since nova currently doesn't
     # seem to shut them down itself (why not?) we have to do it for it..
     #
     # TODO(harlowja) file a bug to get that fixed...
     to_kill = []
     for proc in psutil.process_iter():
         if proc.name.find("dnsmasq") == -1:
             continue
         cwd = ''
         cmdline = ''
         cwd = proc.getcwd()
         cmdline = " ".join(proc.cmdline)
         to_try = False
         for t in [cwd, cmdline]:
             if t.lower().find("nova") != -1:
                 to_try = True
         if to_try:
             to_kill.append(proc.pid)
     if len(to_kill):
         utils.log_iterable(
             to_kill,
             header=
             "Killing leftover nova dnsmasq processes with process ids",
             logger=nconf.LOG)
         for pid in to_kill:
             sh.kill(pid)
Пример #3
0
 def stop(self, app_name):
     trace_dir = self.runtime.get_option('trace_dir')
     if not sh.isdir(trace_dir):
         msg = "No trace directory found from which to stop: %s" % (app_name)
         raise excp.StopException(msg)
     with sh.Rooted(True):
         fn_name = FORK_TEMPL % (app_name)
         (pid_file, stderr_fn, stdout_fn) = self._form_file_names(fn_name)
         pid = self._extract_pid(pid_file)
         if not pid:
             msg = "Could not extract a valid pid from %s" % (pid_file)
             raise excp.StopException(msg)
         (killed, attempts) = sh.kill(pid)
         # Trash the files if it worked
         if killed:
             LOG.debug("Killed pid %s after %s attempts." % (pid, attempts))
             LOG.debug("Removing pid file %s" % (pid_file))
             sh.unlink(pid_file)
             LOG.debug("Removing stderr file %r" % (stderr_fn))
             sh.unlink(stderr_fn)
             LOG.debug("Removing stdout file %r" % (stdout_fn))
             sh.unlink(stdout_fn)
             trace_fn = tr.trace_fn(trace_dir, fn_name)
             if sh.isfile(trace_fn):
                 LOG.debug("Removing %r trace file %r" % (app_name, trace_fn))
                 sh.unlink(trace_fn)
         else:
             msg = "Could not stop %r after %s attempts" % (app_name, attempts)
             raise excp.StopException(msg)
Пример #4
0
 def stop(self, app_name):
     trace_dir = self.runtime.get_option('trace_dir')
     if not sh.isdir(trace_dir):
         msg = "No trace directory found from which to stop: %s" % (app_name)
         raise excp.StopException(msg)
     with sh.Rooted(True):
         fn_name = FORK_TEMPL % (app_name)
         (pid_file, stderr_fn, stdout_fn) = self._form_file_names(fn_name)
         pid = self._extract_pid(pid_file)
         if not pid:
             msg = "Could not extract a valid pid from %s" % (pid_file)
             raise excp.StopException(msg)
         (killed, attempts) = sh.kill(pid)
         # Trash the files if it worked
         if killed:
             LOG.debug("Killed pid %s after %s attempts." % (pid, attempts))
             LOG.debug("Removing pid file %s" % (pid_file))
             sh.unlink(pid_file)
             LOG.debug("Removing stderr file %r" % (stderr_fn))
             sh.unlink(stderr_fn)
             LOG.debug("Removing stdout file %r" % (stdout_fn))
             sh.unlink(stdout_fn)
             trace_fn = tr.trace_filename(trace_dir, fn_name)
             if sh.isfile(trace_fn):
                 LOG.debug("Removing %r trace file %r" % (app_name, trace_fn))
                 sh.unlink(trace_fn)
         else:
             msg = "Could not stop %r after %s attempts" % (app_name, attempts)
             raise excp.StopException(msg)
Пример #5
0
 def stop(self, app_name):
     # The location of the pid file should be in the attached
     # runtimes trace directory, so see if we can find said file
     # and then attempt to kill the pid that exists in that file
     # which if succesffully will signal to the rest of this code
     # that we can go through and cleanup the other remnants of said
     # pid such as the stderr/stdout files that were being written to...
     trace_dir = self.runtime.get_option('trace_dir')
     if not sh.isdir(trace_dir):
         msg = "No trace directory found from which to stop: %r" % (
             app_name)
         raise excp.StopException(msg)
     fork_fns = self._form_file_names(app_name)
     skip_kill = True
     pid = None
     try:
         pid = fork_fns.extract_pid()
         skip_kill = False
     except IOError as e:
         if e.errno == errno.ENOENT:
             pass
         else:
             skip_kill = False
     if not skip_kill and pid is None:
         msg = "Could not extract a valid pid from %r" % (fork_fns.pid)
         raise excp.StopException(msg)
     # Bother trying to kill said process?
     if not skip_kill:
         (killed, attempts) = sh.kill(pid)
     else:
         (killed, attempts) = (True, 0)
     # Trash the files if it worked
     if killed:
         if not skip_kill:
             LOG.debug("Killed pid '%s' after %s attempts.", pid, attempts)
         for leftover_fn in fork_fns.as_list():
             if sh.exists(leftover_fn):
                 LOG.debug("Removing forking related file %r",
                           (leftover_fn))
                 sh.unlink(leftover_fn)
     else:
         msg = "Could not stop %r after %s attempts" % (app_name, attempts)
         raise excp.StopException(msg)
Пример #6
0
 def stop(self, app_name):
     # The location of the pid file should be in the attached
     # runtimes trace directory, so see if we can find said file
     # and then attempt to kill the pid that exists in that file
     # which if succesffully will signal to the rest of this code
     # that we can go through and cleanup the other remnants of said
     # pid such as the stderr/stdout files that were being written to...
     trace_dir = self.runtime.get_option('trace_dir')
     if not sh.isdir(trace_dir):
         msg = "No trace directory found from which to stop: %r" % (app_name)
         raise excp.StopException(msg)
     with sh.Rooted(True):
         fork_fns = self._form_file_names(app_name)
         skip_kill = True
         pid = None
         try:
             pid = fork_fns.extract_pid()
             skip_kill = False
         except IOError as e:
             if e.errno == errno.ENOENT:
                 pass
             else:
                 skip_kill = False
         if not skip_kill and pid is None:
             msg = "Could not extract a valid pid from %r" % (fork_fns.pid)
             raise excp.StopException(msg)
         # Bother trying to kill said process?
         if not skip_kill:
             (killed, attempts) = sh.kill(pid)
         else:
             (killed, attempts) = (True, 0)
         # Trash the files if it worked
         if killed:
             if not skip_kill:
                 LOG.debug("Killed pid '%s' after %s attempts.", pid, attempts)
             for leftover_fn in fork_fns.as_list():
                 if sh.exists(leftover_fn):
                     LOG.debug("Removing forking related file %r", (leftover_fn))
                     sh.unlink(leftover_fn)
         else:
             msg = "Could not stop %r after %s attempts" % (app_name, attempts)
             raise excp.StopException(msg)