Fix wo_prompt
This commit is contained in:
@@ -9,6 +9,12 @@ class CliTestCaseStack(test.WOTestCase):
|
|||||||
self.app.run()
|
self.app.run()
|
||||||
self.app.close()
|
self.app.close()
|
||||||
|
|
||||||
|
def test_wo_cli_stack_install(self):
|
||||||
|
self.app = get_test_app(argv=['stack', 'install'])
|
||||||
|
self.app.setup()
|
||||||
|
self.app.run()
|
||||||
|
self.app.close()
|
||||||
|
|
||||||
def test_wo_cli_stack_install_web(self):
|
def test_wo_cli_stack_install_web(self):
|
||||||
self.app = get_test_app(argv=['stack', 'install', '--web'])
|
self.app = get_test_app(argv=['stack', 'install', '--web'])
|
||||||
self.app.setup()
|
self.app.setup()
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ class WOStackController(CementBaseController):
|
|||||||
.format(WOVariables.wo_webroot)]
|
.format(WOVariables.wo_webroot)]
|
||||||
|
|
||||||
if (packages) or (apt_packages):
|
if (packages) or (apt_packages):
|
||||||
if not pargs.force:
|
if ((not pargs.no_prompt) and (not pargs.force)):
|
||||||
wo_prompt = input('Are you sure you to want to'
|
wo_prompt = input('Are you sure you to want to'
|
||||||
' remove from server.'
|
' remove from server.'
|
||||||
'\nPackage configuration will remain'
|
'\nPackage configuration will remain'
|
||||||
@@ -590,31 +590,30 @@ class WOStackController(CementBaseController):
|
|||||||
'Any answer other than '
|
'Any answer other than '
|
||||||
'"yes" will be stop this'
|
'"yes" will be stop this'
|
||||||
' operation : ')
|
' operation : ')
|
||||||
|
if (wo_prompt == 'YES' or wo_prompt == 'yes' or pargs.force):
|
||||||
|
Log.error(self, "Not removing packages")
|
||||||
|
|
||||||
if (wo_prompt == 'YES' or wo_prompt == 'yes'
|
if (set(["nginx-custom"]).issubset(set(apt_packages))):
|
||||||
or pargs.force):
|
WOService.stop_service(self, 'nginx')
|
||||||
|
|
||||||
if (set(["nginx-custom"]).issubset(set(apt_packages))):
|
# Netdata uninstaller
|
||||||
WOService.stop_service(self, 'nginx')
|
if (set(['/var/lib/wo/tmp/'
|
||||||
|
'kickstart.sh']).issubset(set(packages))):
|
||||||
|
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
|
||||||
|
"libexec/netdata-"
|
||||||
|
"uninstaller.sh -y -f")
|
||||||
|
|
||||||
# Netdata uninstaller
|
if (packages):
|
||||||
if (set(['/var/lib/wo/tmp/'
|
WOFileUtils.remove(self, packages)
|
||||||
'kickstart.sh']).issubset(set(packages))):
|
WOAptGet.auto_remove(self)
|
||||||
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
|
|
||||||
"libexec/netdata-"
|
|
||||||
"uninstaller.sh -y -f")
|
|
||||||
|
|
||||||
if (packages):
|
if (apt_packages):
|
||||||
WOFileUtils.remove(self, packages)
|
Log.debug(self, "Removing apt_packages")
|
||||||
WOAptGet.auto_remove(self)
|
Log.info(self, "Removing packages, please wait...")
|
||||||
|
WOAptGet.remove(self, apt_packages)
|
||||||
|
WOAptGet.auto_remove(self)
|
||||||
|
|
||||||
if (apt_packages):
|
Log.info(self, "Successfully removed packages")
|
||||||
Log.debug(self, "Removing apt_packages")
|
|
||||||
Log.info(self, "Removing packages, please wait...")
|
|
||||||
WOAptGet.remove(self, apt_packages)
|
|
||||||
WOAptGet.auto_remove(self)
|
|
||||||
|
|
||||||
Log.info(self, "Successfully removed packages")
|
|
||||||
|
|
||||||
@expose(help="Purge packages")
|
@expose(help="Purge packages")
|
||||||
def purge(self):
|
def purge(self):
|
||||||
@@ -762,39 +761,39 @@ class WOStackController(CementBaseController):
|
|||||||
.format(WOVariables.wo_webroot)]
|
.format(WOVariables.wo_webroot)]
|
||||||
|
|
||||||
if (packages) or (apt_packages):
|
if (packages) or (apt_packages):
|
||||||
if not pargs.force:
|
if ((not pargs.no_prompt) and (not pargs.force)):
|
||||||
wo_prompt = input('Are you sure you to want to purge '
|
wo_prompt = input('Are you sure you to want to purge '
|
||||||
'from server '
|
'from server '
|
||||||
'along with their configuration'
|
'along with their configuration'
|
||||||
' packages,\nAny answer other than '
|
' packages,\nAny answer other than '
|
||||||
'"yes" will be stop this '
|
'"yes" will be stop this '
|
||||||
'operation :')
|
'operation :')
|
||||||
|
if (wo_prompt == 'YES' or wo_prompt == 'yes' or pargs.force):
|
||||||
|
Log.error(self, "Not purging packages")
|
||||||
|
|
||||||
if (wo_prompt == 'YES' or wo_prompt == 'yes' or pargs.force):
|
if (set(["nginx-custom"]).issubset(set(apt_packages))):
|
||||||
|
WOService.stop_service(self, 'nginx')
|
||||||
|
|
||||||
if (set(["nginx-custom"]).issubset(set(apt_packages))):
|
# Netdata uninstaller
|
||||||
WOService.stop_service(self, 'nginx')
|
if (set(['/var/lib/wo/tmp/'
|
||||||
|
'kickstart.sh']).issubset(set(packages))):
|
||||||
|
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
|
||||||
|
"libexec/netdata-"
|
||||||
|
"uninstaller.sh -y -f")
|
||||||
|
|
||||||
# Netdata uninstaller
|
if (set(["fail2ban"]).issubset(set(apt_packages))):
|
||||||
if (set(['/var/lib/wo/tmp/'
|
WOService.stop_service(self, 'fail2ban')
|
||||||
'kickstart.sh']).issubset(set(packages))):
|
|
||||||
WOShellExec.cmd_exec(self, "bash /opt/netdata/usr/"
|
|
||||||
"libexec/netdata-"
|
|
||||||
"uninstaller.sh -y -f")
|
|
||||||
|
|
||||||
if (set(["fail2ban"]).issubset(set(apt_packages))):
|
if (apt_packages):
|
||||||
WOService.stop_service(self, 'fail2ban')
|
Log.info(self, "Purging packages, please wait...")
|
||||||
|
WOAptGet.remove(self, apt_packages, purge=True)
|
||||||
|
WOAptGet.auto_remove(self)
|
||||||
|
|
||||||
if (apt_packages):
|
if (packages):
|
||||||
Log.info(self, "Purging packages, please wait...")
|
WOFileUtils.remove(self, packages)
|
||||||
WOAptGet.remove(self, apt_packages, purge=True)
|
WOAptGet.auto_remove(self)
|
||||||
WOAptGet.auto_remove(self)
|
|
||||||
|
|
||||||
if (packages):
|
Log.info(self, "Successfully purged packages")
|
||||||
WOFileUtils.remove(self, packages)
|
|
||||||
WOAptGet.auto_remove(self)
|
|
||||||
|
|
||||||
Log.info(self, "Successfully purged packages")
|
|
||||||
|
|
||||||
|
|
||||||
def load(app):
|
def load(app):
|
||||||
|
|||||||
27
wo/core/template.py
Normal file
27
wo/core/template.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from wo.core.logging import Log
|
||||||
|
import os
|
||||||
|
|
||||||
|
"""
|
||||||
|
Render Templates
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class WOTemplate():
|
||||||
|
def tmpl_render(self, fileconf, template, data, overwrite=False):
|
||||||
|
if overwrite:
|
||||||
|
Log.debug(self, 'Writting the configuration to '
|
||||||
|
'file {0}'.format(fileconf))
|
||||||
|
wo_template = open('{0}'.format(fileconf),
|
||||||
|
encoding='utf-8', mode='w')
|
||||||
|
self.app.render((data), '{0}'.format(template),
|
||||||
|
out=wo_template)
|
||||||
|
wo_template.close()
|
||||||
|
else:
|
||||||
|
if not os.path.isfile('{0}'.format(fileconf)):
|
||||||
|
Log.debug(self, 'Writting the configuration to '
|
||||||
|
'file {0}'.format(fileconf))
|
||||||
|
wo_template = open('{0}'.format(fileconf),
|
||||||
|
encoding='utf-8', mode='w')
|
||||||
|
self.app.render((data), '{0}'.format(template),
|
||||||
|
out=wo_template)
|
||||||
|
wo_template.close()
|
||||||
Reference in New Issue
Block a user