def __init__(self, cmd, *args, **kwargs): for arg in ('stdin', 'stdout', 'stderr'): kwargs.setdefault(arg, subprocess.PIPE) self.namespace = kwargs.pop('namespace', None) self.cmd = cmd if self.namespace is not None: cmd = ['ip', 'netns', 'exec', self.namespace] + cmd root_helper = config.get_root_helper(utils.cfg.CONF) cmd = shlex.split(root_helper) + cmd self.child_pid = None super(RootHelperProcess, self).__init__(cmd, *args, **kwargs) self._wait_for_child_process()
def __init__(self, cmd, *args, **kwargs): for arg in ('stdin', 'stdout', 'stderr'): kwargs.setdefault(arg, subprocess.PIPE) kwargs.setdefault('universal_newlines', True) self.namespace = kwargs.pop('namespace', None) self.cmd = cmd if self.namespace is not None: cmd = ['ip', 'netns', 'exec', self.namespace] + cmd root_helper = config.get_root_helper(utils.cfg.CONF) cmd = shlex.split(root_helper) + cmd self.child_pid = None LOG.debug("Spawning process %s", cmd) super(RootHelperProcess, self).__init__(cmd, *args, **kwargs) self._wait_for_child_process()
def create_process(cmd, run_as_root=False, addl_env=None): """Create a process object for the given command. The return value will be a tuple of the process object and the list of command arguments used to create it. """ cmd = list(map(str, addl_env_args(addl_env) + cmd)) if run_as_root: cmd = shlex.split(config.get_root_helper(cfg.CONF)) + cmd LOG.debug("Running command: %s", cmd) obj = utils.subprocess_popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return obj, cmd
def create_process(cmd, run_as_root=False, addl_env=None): """Create a process object for the given command. The return value will be a tuple of the process object and the list of command arguments used to create it. """ cmd = list(map(str, addl_env_args(addl_env) + cmd)) if run_as_root: # NOTE(ralonsoh): to be removed once the migration to privsep # execution is done. cmd = shlex.split(config.get_root_helper(cfg.CONF)) + cmd LOG.debug("Running command: %s", cmd) obj = subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return obj, cmd
def __init__(self, conf): LOG.debug("TaaS OVS Agent initialize called") self.conf = conf taas_driver_class_path = cfg.CONF.taas.driver self.taas_enabled = cfg.CONF.taas.enabled self.root_helper = config.get_root_helper(conf) try: self.taas_driver = importutils.import_object( taas_driver_class_path, self.root_helper) LOG.debug("TaaS Driver Loaded: '%s'", taas_driver_class_path) except ImportError: msg = _('Error importing TaaS device driver: %s') raise ImportError(msg % taas_driver_class_path) # setup RPC to msg taas plugin self.taas_plugin_rpc = TaasOvsPluginApi(topics.TAAS_PLUGIN, conf.host) super(TaasOvsAgentRpcCallback, self).__init__() return
def __init__(self): super(OvsTaasDriver, self).__init__() LOG.debug("Initializing Taas OVS Driver") self.agent_api = None self.root_helper = common.get_root_helper(cfg.CONF)
def __init__(self): super(SriovNicTaasDriver, self).__init__() LOG.debug("Initializing Taas SRIOV NIC Switch Driver") self.agent_api = None self.root_helper = common.get_root_helper(cfg.CONF) self.lock = threading.Lock()
def test_root_default(self): conf = config.setup_conf() config.register_root_helper(conf) self.assertEqual(config.get_root_helper(conf), 'sudo')
def test_agent_root_helper(self): conf = config.setup_conf() config.register_root_helper(conf) conf.set_override('root_helper', 'my_root_helper', 'AGENT') self.assertEqual(config.get_root_helper(conf), 'my_root_helper')