Fixed bugs to create servers
This commit is contained in:
parent
92ae8e7d36
commit
44ffe2da55
5 changed files with 144 additions and 8 deletions
76
tasks/apache/apache/delete_vhost.py
Normal file
76
tasks/apache/apache/delete_vhost.py
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#/usr/bin/env python3
|
||||
|
||||
from collections import OrderedDict
|
||||
#from modules.pastafari2.models.servers import Server
|
||||
from modules.webservers.models.webservers import WebServer, VirtualHost
|
||||
import json
|
||||
|
||||
from modules.pastafari2.libraries.task import Task
|
||||
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||
#import distro
|
||||
|
||||
class ServerTask(Task):
|
||||
|
||||
def __init__(self, server, conn, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='pastafari2', task_id=0, data={}, port=22):
|
||||
|
||||
super().__init__(server, conn, remote_user, remote_password, private_key, password_key, remote_path, task_id, data, port)
|
||||
|
||||
self.name_task='Remove virtualhost in server'
|
||||
|
||||
self.description_task='Virtual host delete in a server, or many of them'
|
||||
|
||||
self.codename_task='del_virtualhost_apache'
|
||||
|
||||
self.files=[]
|
||||
|
||||
self.files=[['modules/apache/scripts/manage_apache.py', 0o755]]
|
||||
|
||||
# Format first array element is command with the interpreter, the task is agnostic, the files in os directory. The commands are setted with 750 permission.
|
||||
# First element is the file, next elements are the arguments
|
||||
|
||||
self.commands_to_execute=[['modules/apache/scripts/manage_apache.py', '']]
|
||||
|
||||
#THe files to delete
|
||||
|
||||
self.delete_files=[]
|
||||
|
||||
self.delete_directories=['modules/webservers/scripts']
|
||||
|
||||
#self.task=Task(conn)
|
||||
|
||||
self.one_time=False
|
||||
|
||||
self.version='1.0'
|
||||
|
||||
self.path_module='admin_app.webservers'
|
||||
|
||||
def pre_task(self):
|
||||
|
||||
#self.commands_to_execute=[['modules/webservers/scripts/manager/${os_server}/manage_apache.py', '--password=%s' % self.extra_data['mysql_password']]]
|
||||
|
||||
# usage: manager.py [-h] --operation OPERATION --domain DOMAIN [--email EMAIL] [--user USER] [--root_dir ROOT_DIR] [--indexes] [--allow_override]
|
||||
|
||||
indexes=''
|
||||
|
||||
if 'indexes' in self.data:
|
||||
indexes='--indexes'
|
||||
|
||||
allow_override=''
|
||||
|
||||
if 'allow_override' in self.data:
|
||||
allow_override='--allow_override'
|
||||
|
||||
self.commands_to_execute=[['modules/apache/scripts/manage_apache.py', '--operation=remove --domain=%s --email=%s --user=%s --root_dir=%s --type_cgi=%s %s %s' % (self.data['domain'], self.data['email'], self.data['user'], self.data['root_dir'], self.data['cgi_type'], indexes, allow_override), 'sudo']]
|
||||
|
||||
return True
|
||||
|
||||
def post_task(self):
|
||||
|
||||
vhost=VirtualHost(self.connection)
|
||||
vhost.safe_query()
|
||||
|
||||
#vhost.insert({'servers': servers, 'principal_ip': servers[0], 'domain': self.extra_data['domain'], 'email': self.extra_data['email'], 'user': self.extra_data['user'], 'root_dir': self.extra_data['root_dir'], 'indexes': self.extra_data['indexes'], 'allow_override': self.extra_data['allow_override']})
|
||||
if not vhost.set_conditions('WHERE domain=%s', [self.data['domain']]).delete():
|
||||
return False
|
||||
|
||||
return True
|
||||
Loading…
Add table
Add a link
Reference in a new issue