コード例 #1
0
ファイル: driver.py プロジェクト: udemyhoangit86/neutron
 def cleanup_config_file(uuid, state_path):
     """Delete config file created when metadata proxy was spawned."""
     # Delete config file if it exists
     cfg_path = os.path.join(
         HaproxyConfigurator.get_config_path(state_path),
         "%s.conf" % uuid)
     linux_utils.delete_if_exists(cfg_path, run_as_root=True)
コード例 #2
0
    def disable(self, sig='9', get_stop_command=None):
        pid = self.pid

        if self.active:
            if get_stop_command:
                cmd = get_stop_command(self.get_pid_file_name())
                ip_wrapper = ip_lib.IPWrapper(namespace=self.namespace)
                ip_wrapper.netns.execute(cmd,
                                         addl_env=self.cmd_addl_env,
                                         run_as_root=self.run_as_root,
                                         privsep_exec=True)
            else:
                cmd = self.get_kill_cmd(sig, pid)
                utils.execute(cmd,
                              run_as_root=self.run_as_root,
                              privsep_exec=True)
                # In the case of shutting down, remove the pid file
                if sig == '9':
                    utils.delete_if_exists(self.get_pid_file_name(),
                                           run_as_root=self.run_as_root)
        elif pid:
            LOG.debug(
                '%(service)s process for %(uuid)s pid %(pid)d is stale, '
                'ignoring signal %(signal)s', {
                    'service': self.service,
                    'uuid': self.uuid,
                    'pid': pid,
                    'signal': sig
                })
        else:
            LOG.debug('No %(service)s process started for %(uuid)s', {
                'service': self.service,
                'uuid': self.uuid
            })
コード例 #3
0
    def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf, ns_name):
        monitor.unregister(uuid, METADATA_SERVICE_NAME)
        pm = cls._get_metadata_proxy_process_manager(uuid,
                                                     conf,
                                                     ns_name=ns_name)
        pm.disable(sig=str(int(signal.SIGTERM)))
        try:
            common_utils.wait_until_true(lambda: not pm.active,
                                         timeout=SIGTERM_TIMEOUT)
        except common_utils.WaitTimeout:
            LOG.warning(
                'Metadata process %s did not finish after SIGTERM '
                'signal in %s seconds, sending SIGKILL signal', pm.pid,
                SIGTERM_TIMEOUT)
            pm.disable(sig=str(int(signal.SIGKILL)))

        # Delete metadata proxy config and PID files.
        HaproxyConfigurator.cleanup_config_file(uuid, cfg.CONF.state_path)
        linux_utils.delete_if_exists(pm.get_pid_file_name(), run_as_root=True)

        cls.monitors.pop(uuid, None)