def _disable_requiretty(no_sudo): """ Disables the requiretty directive in the /etc/sudoers file. This will enable operations that require sudo permissions to work properly. This is needed because operations are executed from within the worker process, which is not a tty process. """ from cloudify_agent.shell.main import get_logger runner = LocalCommandRunner(get_logger()) disable_requiretty_script_path = utils.resource_to_tempfile( resource_path='disable-requiretty.sh', executable=True) runner.run('chmod +x {0}'.format(disable_requiretty_script_path)) maybe_sudo = '' if no_sudo else 'sudo' runner.run('{0} {1}'.format(disable_requiretty_script_path, maybe_sudo))
def _disable_requiretty(): """ Disables the requiretty directive in the /etc/sudoers file. This will enable operations that require sudo permissions to work properly. This is needed because operations are executed from within the worker process, which is not a tty process. """ from cloudify_agent.shell.main import get_logger runner = LocalCommandRunner(get_logger()) disable_requiretty_script_path = utils.resource_to_tempfile( resource_path='disable-requiretty.sh' ) runner.run('chmod +x {0}'.format(disable_requiretty_script_path)) runner.run('{0}'.format(disable_requiretty_script_path))
def test_resource_to_tempfile(): temp = utils.resource_to_tempfile( resource_path=os.path.join('pm', 'initd', 'initd.conf.template')) assert os.path.exists(temp)
def test_resource_to_tempfile(self): temp = utils.resource_to_tempfile( resource_path=os.path.join('pm', 'initd', 'initd.conf.template') ) self.assertTrue(os.path.exists(temp))
def test_resource_to_tempfile(self): temp = utils.resource_to_tempfile( resource_path=os.path.join('pm', 'initd', 'initd.conf.template')) self.assertTrue(os.path.exists(temp))