Example #1
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.apacheinfo = self.serverinfo.get("apache", False)
     self.apachectl = self.get_keyvalue_in_first("apachectl",
                                                 self.action_info,
                                                 self.apacheinfo)
     if not self.apacheinfo:
         raise exceptions.ActionRequirementsError(
             messages.apache_info_missing)
     if not self.apachectl:
         raise exceptions.ActionRequirementsError(
             messages.apache_missing_apachectl)
     password = self.get_password(self.apacheinfo, self.serverinfo,
                                  self.action_info, self.deployment.options)
     if not password:
         password = self.get_password_in_opt(self.apacheinfo,
                                             self.serverinfo,
                                             self.action_info)
     if not password:
         raise exceptions.ActionRequirementsError(
             messages.missing_password % self.meta.action_name)
     self.password = password
     if not self.password:
         raise exceptions.ActionRequirementsError(
             messages.missing_password % self.meta.action_name)
Example #2
0
	def validate(self):
		self.servername=self.get_server_name(True)
		self.serverinfo=self.get_server_info(True)
		self.lighttpd=self.serverinfo.get("lighttpd",False)
		self.pidfile=self.get_keyvalue_in_first("pidfile",self.action_info,self.lighttpd)
		self.password=self.get_keyvalue_in_first("password",self.action_info,self.serverinfo,self.lighttpd)
		self.mods=self.get_keyvalue_in_first("mods",self.action_info,self.lighttpd)
		if not self.password: self.password=self.get_password_in_opt(self.action_info,self.lighttpd,self.serverinfo)
		if not self.lighttpd: raise exceptions.ActionRequirementsError(messages.lighttpd_info_missing % self.meta.action_name)
		if not self.pidfile: raise exceptions.ActionRequirementsError(messages.missing_pidfile % self.meta.action_name)
		if not self.password: raise exceptions.ActionRequirementsError(messages.missing_password % self.meta.action_name)
Example #3
0
 def validate(self):
     super(NginxRestartAction, self).validate()
     self.nginx_bin = self.get_keyvalue_in_first("bin", self.action_info,
                                                 self.nginx)
     self.conf = self.get_keyvalue_in_first("conf", self.action_info,
                                            self.nginx)
     if not self.nginx_bin:
         raise exceptions.ActionRequirementsError(
             messages.missing_nginx_bin)
     if not self.conf:
         raise exceptions.ActionRequirementsError(
             messages.nginx_missing_conf)
Example #4
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.dirl = self.action_info.get("dir", False)
     self.url = self.action_info.get("url", False)
     self.force_checkout = self.action_info.get("force_checkout", False)
     if not self.dirl:
         raise exceptions.ActionRequirementsError(messages.missing_dir %
                                                  self.meta.action_name)
     if not self.url:
         raise exceptions.ActionRequirementsError(messages.missing_url %
                                                  self.meta.action_name)
Example #5
0
 def run(self):
     shell = self.get_logged_in_client(self.servername,
                                       ssh.SSHSession.protocol)
     if not shell:
         raise exceptions.ActionRequirementsError(
             messages.missing_ssh_session % self.meta.action_name)
     if self.ports and self.pidfiles:
         for port in self.ports:
             pidfile = self.pidfiles + "port_" + str(port) + ".pid"
             if not (shell.sudo_command("sudo kill `cat -- '%s'`" % pidfile,
                                        self.password)):
                 shell.permission_denied_error(self.meta.action_name)
             if not (shell.sudo_command("sudo rm -f %s" % pidfile,
                                        self.password)):
                 shell.permission_denied_error(self.meta.action_name)
     elif self.socket:
         print "SOCKET KILL"
         pidfile = self.pidfiles + "socket_" + str(self.protocol) + ".pid"
         print pidfile
         if not (shell.sudo_command("sudo kill `cat -- '%s'`" % pidfile,
                                    self.password)):
             shell.permission_denied_error(self.meta.action_name)
         if not (shell.sudo_command("sudo rm -f %s" % pidfile,
                                    self.password)):
             shell.permission_denied_error(self.meta.action_name)
Example #6
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.pidfile = self.action_info.get("pidfile", False)
     if not self.pidfile:
         raise exceptions.ActionRequirementsError(messages.missing_pidfile %
                                                  self.meta.action_name)
Example #7
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.host, self.user = self.get_host_and_user(True)
     self.password = self.get_password(self.serverinfo, self.action_info,
                                       self.deployment.options)
     if not self.password:
         self.password = self.get_password_in_opt(self.serverinfo,
                                                  self.action_info)
     if not self.password:
         raise exceptions.ActionRequirementsError(
             messages.missing_password % self.meta.action_name)
Example #8
0
 def run(self):
     shell = self.get_logged_in_client(self.servername,
                                       ssh.SSHSession.protocol)
     if not shell:
         raise exceptions.ActionRequirementsError(
             messages.missing_ssh_session % self.meta.action_name)
     shell.command("cd %s" % self.dir)
     if self.host and self.ports:
         for port in self.ports:
             pidfile = self.pidfiles + "port_" + str(port) + ".pid"
             if not (shell.sudo_command("sudo kill `cat -- '%s'`" % pidfile,
                                        self.password)):
                 shell.permission_denied_error(self.meta.action_name)
             if not (shell.sudo_command("sudo rm -f %s" % pidfile,
                                        self.password)):
                 shell.permission_denied_error(self.meta.action_name)
             spawn = "python manage.py runfcgi protocol=" + str(
                 self.protocol
             ) + " method=" + str(self.method) + " host=" + str(
                 self.host) + " port=" + str(port) + " pidfile='" + str(
                     pidfile) + "' maxspare=" + str(self.maxspare)
             spawn += " minspare=" + str(
                 self.minspare) + " maxchildren=" + str(
                     self.maxchildren) + " maxrequests=" + str(
                         self.maxrequests)
             if not (shell.sudo_command(spawn, self.password)):
                 shell.permission_denied_error(self.meta.action_name)
     elif self.socket:
         pidfile = self.pidfiles + "socket_" + str(self.protocol) + ".pid"
         if not (shell.sudo_command("sudo kill `cat -- '%s'`" % pidfile,
                                    self.password)):
             shell.permission_denied_error(self.meta.action_name)
         if not (shell.sudo_command("sudo rm -f %s" % pidfile,
                                    self.password)):
             shell.permission_denied_error(self.meta.action_name)
         spawn = "python manage.py runfcgi protocol=" + str(
             self.protocol) + " method=" + str(
                 self.method) + " socket=" + str(
                     self.socket) + " pidfile='" + str(
                         pidfile) + "' maxspare=" + str(self.maxspare)
         spawn += " minspare=" + str(self.minspare) + " maxchildren=" + str(
             self.maxchildren) + " maxrequests=" + str(self.maxrequests)
         if not (shell.sudo_command(spawn, self.password)):
             shell.permission_denied_error(self.meta.action_name)
Example #9
0
 def run(self):
     exception = None
     self.before_head = False
     shell = self.get_logged_in_client(self.servername,
                                       ssh.SSHSession.protocol)
     if not shell:
         raise exceptions.ActionRequirementsError(
             messages.missing_ssh_session % self.meta.action_name)
     shell.mk_and_cd(self.dirl)
     shell.command("git log -1 | grep commit")
     i = shell.expect([
         "commit .*", pexpects.not_a_repo, shell.cmnf, shell.eof,
         shell.timeout
     ])
     if i == 1:
         exception = exceptions.SSHErrorDetected(messages.git_not_a_repo %
                                                 self.dirl)
     elif i == 2:
         exception = exceptions.SSHErrorDetected(messages.git_not_installed)
     elif i > 2:
         exception = exceptions.ActionError(messages.pexpect_timeout %
                                            self.meta.action_name)
     if exception: raise exception
     commit = shell.session.after
     regex = re.compile(r'[a-z0-9]{40,40}')
     search = regex.findall(commit)
     if isinstance(search, list): self.before_head = search[0]
     shell.command("git pull origin master")
     #TODO: add expect for when "master" branch isn't setup correctly
     #TODO: add expect for when the wrong remote is used.. like orign
     i = shell.expect([
         shell.permission, shell.cmnf, pexpects.not_a_repo, shell.eof,
         shell.timeout
     ])
     if i == 0:
         exception = exceptions.SSHErrorDetected(
             messages.permission_denied % self.meta.action_name)
     elif i == 1:
         exception = exceptions.SSHErrorDetected(messages.git_not_installed)
     elif i == 2:
         exception = exceptions.SSHErrorDetected(messages.git_not_a_repo %
                                                 self.dirl)
     if exception: raise exception
Example #10
0
 def run(self):
     exception = None
     self.before_head = False
     shell = self.get_logged_in_client(self.servername,
                                       ssh.SSHSession.protocol)
     if not shell:
         raise exceptions.ActionRequirementsError(
             messages.missing_ssh_session % self.meta.action_name)
     shell.mk_and_cd(self.dirl)
     shell.command("svn info | grep Revision")
     i = shell.expect(
         ["(?i)Revision: .*", self.not_a_repo, shell.eof, shell.timeout])
     if i == 1:
         exception = exceptions.SSHErrorDetected(
             messages.svn_not_a_repo_error % self.dirl)
     elif i == 2:
         exception = exceptions.SSHErrorDetected(messages.git_not_installed)
     elif i > 2:
         exception = exceptions.ActionError(messages.pexpect_timeout)
     if exception: raise exception
     commit = shell.session.after
     regex = re.compile(r'[0-9]{1,}')
     search = regex.findall(commit)
     if isinstance(search, list): self.before_head = search[0]
     if self.force_checkout:
         shell.command("svn --force checkout " + self.url + " .")
     else:
         shell.command("rm -rf ./*")
         shell.command("svn update " + self.url + " .")
     i = shell.expect([
         shell.permission, shell.cmnf, self.not_a_repo, shell.eof,
         shell.timeout
     ])
     if i == 0:
         exception = exceptions.SSHErrorDetected(
             messages.permission_denied % self.meta.action_name)
     elif i == 1:
         exception = exceptions.SSHErrorDetected(messages.svn_not_installed)
     elif i == 2:
         exception = exceptions.SSHErrorDetected(
             messages.svn_not_a_repo_error % self.dirl)
     if exception: raise exception
Example #11
0
 def validate(self):
     self.subject = self.action_info.get("subject", False)
     self.fromemail = self.action_info.get("from", False)
     if not hasattr(settings, "ADMINS"):
         raise exceptions.ActionRequirementsError(messages.missing_admins)
     if not hasattr(settings, "EMAIL_HOST"):
         raise exceptions.ActionRequirementsError(
             messages.missing_email_host)
     if not hasattr(settings, "EMAIL_HOST_USER"):
         raise exceptions.ActionRequirementsError(
             messages.missing_email_user)
     if not hasattr(settings, "EMAIL_HOST_PASSWORD"):
         raise exceptions.ActionRequirementsError(
             messages.missing_email_password)
     if not self.subject:
         raise exceptions.ActionRequirementsError(
             messages.missing_subject_key % self.meta.action_name)
     if not self.fromemail:
         raise exceptions.ActionRequirementsError(
             messages.missing_from_key % self.meta.action_name)
Example #12
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.password = self.get_password()
     if not self.password:
         self.password = self.get_password_in_opt(self.action_info,
                                                  self.serverinfo)
     self.dir = self.action_info.get("dir", False)
     self.method = self.action_info.get("method", False)
     self.pidfiles = self.action_info.get("pidfiles", False)
     self.host = self.action_info.get("host", False)
     self.ports = self.action_info.get("ports", False)
     self.socket = self.action_info.get("socket", False)
     self.maxspare = self.action_info.get("maxspare", False)
     self.minspare = self.action_info.get("minspare", False)
     self.maxchildren = self.action_info.get("maxchildren", False)
     self.maxrequests = self.action_info.get("maxrequests", False)
     self.protocol = self.action_info.get("protocol", False)
     if not self.password:
         raise exceptions.ActionRequirementsError(
             messages.missing_password % self.meta.action_name)
     if not self.method in ["prefork", "threaded"]:
         raise exceptions.ActionError(messages.incorrect_fcgi_method)
     if not self.protocol in ["fcgi", "scgi", "ajp"]:
         raise exceptions.ActionError(messages.incorrect_protocol)
     if not self.pidfiles:
         raise exceptions.ActionRequirementsError(messages.missing_pidfile %
                                                  self.meta.action_name)
     if not self.ports and self.host:
         raise exceptions.ActionRequirementsError(
             messages.missing_ports_with_host % self.meta.action_name)
     if not self.ports and not self.host and not self.socket:
         raise exceptions.ActionRequirementsError(messages.missing_ports %
                                                  self.meta.action_name)
     if not self.socket and (not self.host or not self.ports):
         raise exceptions.ActionRequirementsError(
             messages.missing_socket_and_host % self.meta.action_name)
     if self.socket and self.host:
         raise exceptions.ActionRequirementsError(
             messages.incorrect_has_socket_and_host % self.meta.action_name)
     if isinstance(self.ports, str): self.ports = [self.ports]
Example #13
0
	def validate(self):
		super(LighttpdRestartAction,self).validate()
		self.lighttpd_bin=self.get_keyvalue_in_first("bin",self.action_info,self.lighttpd)
		self.conf=self.get_keyvalue_in_first("conf",self.action_info,self.lighttpd)
		if not self.lighttpd_bin: raise exceptions.ActionRequirementsError(messages.missing_lighttpd_bin)
		if not self.conf: raise exceptions.ActionRequirementsError(messages.lighttpd_missing_conf)
Example #14
0
 def validate(self):
     self.url = self.action_info.get("url", False)
     self.data = self.action_info.get("data", False)
     if not self.url:
         raise exceptions.ActionRequirementsError(messages.missing_url %
                                                  self.meta.action_name)
Example #15
0
 def validate(self):
     self.servername = self.get_server_name(True)
     self.serverinfo = self.get_server_info(True)
     self.dirl = self.action_info.get("dir", False)
     if not self.dirl:
         raise exceptions.ActionRequirementsError(messages.missing_dir)