示例#1
0
    def __init__(self,
                 conf,
                 uuid,
                 namespace=None,
                 service=None,
                 pids_path=None,
                 default_cmd_callback=None,
                 cmd_addl_env=None,
                 pid_file=None):

        self.conf = conf
        self.uuid = uuid
        self.namespace = namespace
        self.default_cmd_callback = default_cmd_callback
        self.cmd_addl_env = cmd_addl_env
        self.pids_path = pids_path or self.conf.external_pids
        self.pid_file = pid_file

        if service:
            self.service_pid_fname = 'pid.' + service
            self.service = service
        else:
            self.service_pid_fname = 'pid'
            self.service = 'default-service'

        utils.ensure_dir(os.path.dirname(self.get_pid_file_name()))
示例#2
0
 def __init__(self, conf, network, process_monitor, version=None,
              plugin=None):
     super(DhcpLocalProcess, self).__init__(conf, network, process_monitor,
                                            version, plugin)
     self.confs_dir = self.get_confs_dir(conf)
     self.network_conf_dir = os.path.join(self.confs_dir, network.id)
     utils.ensure_dir(self.network_conf_dir)
示例#3
0
 def __init__(self, conf, network, process_monitor, version=None,
              plugin=None):
     super(DhcpLocalProcess, self).__init__(conf, network, process_monitor,
                                            version, plugin)
     self.confs_dir = self.get_confs_dir(conf)
     self.network_conf_dir = os.path.join(self.confs_dir, network.id)
     utils.ensure_dir(self.network_conf_dir)
示例#4
0
 def enable(self):
     """Enables DHCP for this network by spawning a local process."""
     if self.active:
         self.restart()
     elif self._enable_dhcp():
         utils.ensure_dir(self.network_conf_dir)
         self.interface_name = cfg.CONF.symcpe.dhcp_interface
         self.spawn_process()
 def _get_state_file_path(self, loadbalancer_id, kind,
                          ensure_state_dir=True):
     """Returns the file name for a given kind of config file."""
     confs_dir = os.path.abspath(os.path.normpath(self.state_path))
     conf_dir = os.path.join(confs_dir, loadbalancer_id)
     if ensure_state_dir:
         linux_utils.ensure_dir(conf_dir)
     return os.path.join(conf_dir, kind)
 def enable(self):
     """Enables DHCP for this network by spawning a local process."""
     if self.active:
         self.restart()
     elif self._enable_dhcp():
         utils.ensure_dir(self.network_conf_dir)
         interface_name = self.device_manager.setup(self.network)
         self.interface_name = interface_name
         self.spawn_process()
示例#7
0
 def enable(self):
     """Enables DHCP for this network by spawning a local process."""
     if self.active:
         self.restart()
     elif self._enable_dhcp():
         utils.ensure_dir(self.network_conf_dir)
         interface_name = self.device_manager.setup(self.network)
         self.interface_name = interface_name
         self.spawn_process()
示例#8
0
 def get_pid_file_name(self, ensure_pids_dir=False):
     """Returns the file name for a given kind of config file."""
     if self.pid_file:
         if ensure_pids_dir:
             utils.ensure_dir(os.path.dirname(self.pid_file))
         return self.pid_file
     else:
         return utils.get_conf_file_name(self.pids_path, self.uuid,
                                         self.service_pid_fname,
                                         ensure_pids_dir)
 def _get_state_file_path(self,
                          loadbalancer_id,
                          kind,
                          ensure_state_dir=True):
     """Returns the file name for a given kind of config file."""
     confs_dir = os.path.abspath(os.path.normpath(self.state_path))
     conf_dir = os.path.join(confs_dir, loadbalancer_id)
     if ensure_state_dir:
         linux_utils.ensure_dir(conf_dir)
     return os.path.join(conf_dir, kind)
示例#10
0
    def start(self):
        fmt = self.process_name + "--%Y-%m-%d--%H%M%S.log"
        log_dir = os.path.join(DEFAULT_LOG_DIR, self.test_name)
        utils.ensure_dir(log_dir)

        cmd = [spawn.find_executable(self.exec_name),
               '--log-dir', log_dir,
               '--log-file', timeutils.strtime(fmt=fmt)]
        for filename in self.config_filenames:
            cmd += ['--config-file', filename]
        self.process = async_process.AsyncProcess(cmd)
        self.process.start(block=True)
示例#11
0
 def __init__(self, host=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.conf = cfg.CONF
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     ctx = context.get_admin_context_without_session()
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx,
                                     self.conf.use_namespaces)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     linux_utils.ensure_dir(dhcp_dir)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf, resource_type='dhcp')
示例#12
0
 def __init__(self, host=None):
     super(DhcpAgent, self).__init__(host=host)
     self.needs_resync_reasons = collections.defaultdict(list)
     self.conf = cfg.CONF
     self.cache = NetworkCache()
     self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver)
     ctx = context.get_admin_context_without_session()
     self.plugin_rpc = DhcpPluginApi(topics.PLUGIN,
                                     ctx, self.conf.use_namespaces)
     # create dhcp dir to store dhcp info
     dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path)
     linux_utils.ensure_dir(dhcp_dir)
     self.dhcp_version = self.dhcp_driver_cls.check_version()
     self._populate_networks_cache()
     self._process_monitor = external_process.ProcessMonitor(
         config=self.conf,
         resource_type='dhcp')
示例#13
0
    def __init__(self, conf, uuid, namespace=None, service=None,
                 pids_path=None, default_cmd_callback=None,
                 cmd_addl_env=None, pid_file=None):

        self.conf = conf
        self.uuid = uuid
        self.namespace = namespace
        self.default_cmd_callback = default_cmd_callback
        self.cmd_addl_env = cmd_addl_env
        self.pids_path = pids_path or self.conf.external_pids
        self.pid_file = pid_file

        if service:
            self.service_pid_fname = 'pid.' + service
            self.service = service
        else:
            self.service_pid_fname = 'pid'
            self.service = 'default-service'

        utils.ensure_dir(os.path.dirname(self.get_pid_file_name()))
示例#14
0
 def test_ensure_dir_not_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     makedirs.assert_called_once_with('/the', 0o755)
示例#15
0
 def test_ensure_dir_no_fail_if_exists(self, makedirs):
     error = OSError()
     error.errno = errno.EEXIST
     makedirs.side_effect = error
     utils.ensure_dir("/etc/create/concurrently")
示例#16
0
 def test_ensure_dir_calls_makedirs(self, makedirs):
     utils.ensure_dir("/etc/create/directory")
     makedirs.assert_called_once_with("/etc/create/directory", 0o755)
示例#17
0
 def test_ensure_dir_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     self.assertFalse(makedirs.called)
示例#18
0
 def test_ensure_dir_not_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     makedirs.assert_called_once_with('/the', 0o755)
 def ensure_pids_dir(self):
     utils.ensure_dir(os.path.dirname(self.get_pid_file_name()))
示例#20
0
文件: ha.py 项目: Intellifora/neutron
 def _init_ha_conf_path(self):
     ha_full_path = os.path.dirname("/%s/" % self.conf.ha_confs_path)
     agent_utils.ensure_dir(ha_full_path)
示例#21
0
 def test_ensure_dir_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     self.assertFalse(makedirs.called)
示例#22
0
 def test_ensure_dir_calls_makedirs(self, makedirs):
     utils.ensure_dir("/etc/create/directory")
     makedirs.assert_called_once_with("/etc/create/directory", 0o755)
示例#23
0
 def get_full_config_file_path(self, filename, ensure_conf_dir=True):
     conf_dir = self.get_conf_dir()
     if ensure_conf_dir:
         utils.ensure_dir(conf_dir)
     return os.path.join(conf_dir, filename)
示例#24
0
 def get_full_config_file_path(self, filename, ensure_conf_dir=True):
     conf_dir = self.get_conf_dir()
     if ensure_conf_dir:
         utils.ensure_dir(conf_dir)
     return os.path.join(conf_dir, filename)
示例#25
0
文件: ha.py 项目: Tehsmash/neutron
 def _init_ha_conf_path(self):
     ha_full_path = os.path.dirname("/%s/" % self.conf.ha_confs_path)
     agent_utils.ensure_dir(ha_full_path)
示例#26
0
 def test_ensure_dir_no_fail_if_exists(self, path_exists, makedirs):
     error = OSError()
     error.errno = errno.EEXIST
     makedirs.side_effect = error
     utils.ensure_dir("/etc/create/concurrently")