def _disable_default_nginx(remote): """ Fix up nginx values """ script = textwrap.dedent(''' if [ -f /etc/nginx/conf.d/default.conf ]; then mv /etc/nginx/conf.d/default.conf \ /etc/nginx/conf.d/default.disabled fi if [ -f /etc/nginx/sites-enabled/default ] ; then rm /etc/nginx/sites-enabled/default fi service nginx restart service {service} restart ''') service = pkg.get_service_name('httpd', remote) script = script.format(service=service) teuthology.sudo_write_file(remote, '/tmp/disable.nginx', script) return remote.run(args=['sudo', 'bash', '/tmp/disable.nginx'], stdout=StringIO())
def test_get_service_name_not_found(self): remote = Mock() remote.os.package_type = "rpm" assert packaging.get_service_name('notthere', remote) is None
def test_get_service_name_rpm(self): remote = Mock() remote.os.package_type = "rpm" assert packaging.get_service_name('httpd', remote) == 'httpd'
def test_get_service_name_deb(self): remote = Mock() remote.os.package_type = "deb" assert packaging.get_service_name('httpd', remote) == 'apache2'
def test_get_service_name_not_found(self, m_misc): m_misc.get_system_type.return_value = "rpm" assert packaging.get_service_name('notthere', Mock()) is None
def test_get_service_name_rpm(self, m_misc): m_misc.get_system_type.return_value = "rpm" assert packaging.get_service_name('httpd', Mock()) == 'httpd'
def test_get_service_name_deb(self, m_misc): m_misc.get_system_type.return_value = "deb" assert packaging.get_service_name('httpd', Mock()) == 'apache2'