Add Nginx configuration Rollback

This commit is contained in:
VirtuBox
2019-08-27 15:12:01 +02:00
parent 5cc1c06e88
commit d24ae7e8d2
7 changed files with 199 additions and 162 deletions

View File

@@ -55,3 +55,28 @@ class WOGit:
return True
else:
return False
def rollback(self, paths, msg="Rolling-Back"):
"""
Rollback last commit to restore previous.
configuration and commit changes automatically
"""
for path in paths:
global git
git = git.bake("--git-dir={0}/.git".format(path),
"--work-tree={0}".format(path))
if os.path.isdir(path):
if not os.path.isdir(path+"/.git"):
Log.error(self, "Unable to find a git repository at {0}"
.format(path))
try:
Log.debug(self, "WOGit: git reset HEAD~ at {0}"
.format(path))
git.reset("HEAD~ --soft")
git.stash("save \"Rollback\"")
except ErrorReturnCode as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to git reset at {0} "
.format(path))
else:
Log.debug(self, "WOGit: Path {0} not present".format(path))

View File

@@ -27,7 +27,7 @@ class WOService():
"[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
return True
else:
Log.error(
Log.info(
self, "Starting Nginx " + "[" + Log.FAIL +
"Failed" + Log.OKBLUE+"]")
return False
@@ -88,13 +88,13 @@ class WOService():
"[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
return True
else:
Log.error(
self, "Restarting Nginx " + "[" + Log.FAIL +
"Failed" + Log.OKBLUE+"]")
Log.info(self, "Restarting Nginx " + "[" + Log.FAIL +
"Failed" + Log.OKBLUE+"]")
return False
else:
service_cmd = ('service {0} restart'.format(service_name))
Log.info(self, "Restart : {0:10}".format(service_name), end='')
Log.info(self, "Restart : {0:10}".format(
service_name), end='')
retcode = subprocess.getstatusoutput(service_cmd)
if retcode[0] == 0:
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")

View File

@@ -7,7 +7,7 @@ Render Templates
class WOTemplate():
def tmpl_render(self, fileconf, template, data, overwrite=True):
def render(self, fileconf, template, data, overwrite=True):
data = dict(data)
if (not os.path.isfile('{0}.custom'
.format(fileconf))):