Example #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()))
Example #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)
Example #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)
Example #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()
Example #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()
Example #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)
Example #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)
Example #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')
Example #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')
Example #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()))
Example #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)
Example #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")
Example #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)
Example #17
0
 def test_ensure_dir_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     self.assertFalse(makedirs.called)
Example #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()))
Example #20
0
 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)
Example #21
0
 def test_ensure_dir_exist(self, makedirs, isdir):
     utils.ensure_dir('/the')
     isdir.assert_called_once_with('/the')
     self.assertFalse(makedirs.called)
Example #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)
Example #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)
Example #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)
Example #25
0
 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)
Example #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")