Example #1
0
    def _as_root(self, options, command, args, use_root_namespace=False):
        if not self.root_helper:
            raise exceptions.SudoRequired()

        namespace = self.namespace if not use_root_namespace else None

        return self._execute(options, command, args, self.root_helper,
                             namespace)
Example #2
0
 def execute(self, cmds, addl_env={}):
     if not self._parent.root_helper:
         raise exceptions.SudoRequired()
     elif not self._parent.namespace:
         raise Exception(_('No namespace defined for parent'))
     else:
         return utils.execute(
             ['%s=%s' % pair for pair in addl_env.items()] +
             ['ip', 'netns', 'exec', self._parent.namespace] + list(cmds),
             root_helper=self._parent.root_helper)