def post_delete_bot(sender, instance, **kwargs):
    """
    post delete call back

    :Parameters:
       - sender: the sending object.
       - instance: instance of the object being saved
       - kwargs: any keyword arguments
    """
    # stop bot
    bot_path = os.path.join(BUILDBOT_MASTERS, instance.name)
    if instance.alive:
        build_bot_run(['stop', instance.path])

    # delete bot
    if os.path.isdir(instance.path):
        import shutil
        shutil.rmtree(instance.path)
Exemple #2
0
 def _run(self, action):
     # run commands based on remote or local
     if self.host.id == 1:
         # local bot
         if action == 'cfg':
             content = self.generate_cfg()
             cfg_file = os.path.join(self.path, self.cfg_file)
             cfg = open(cfg_file, 'w')
             cfg.write(content)
             cfg.close()
             action = ''
         elif action == 'create':
             action = self.buildbot_create % self.path
             if not os.path.exists(self.base_path):
                 os.mkdir(self.base_path)
         else:
             action = '%s %s' % (action, self.path)
         if action:
             build_bot_run(action.split(' '))
     elif not self.ssh:
         return "Paramiko is not installed. Remote bot management is not supported."
     else:
         # remote bot
         self.ssh.connect(self.host.hostname,
                     username=self.host.username,
                     password=self.host.password,
             allow_agent=True, look_for_keys=True)
         if action == 'cfg':
             content = self.generate_cfg()
             cfg_file = os.path.join(self.path, self.cfg_file)
             sftp = self.ssh.open_sftp()
             f = sftp.file(cfg_file, 'w')
             f.write(content)
             f.close()
             sftp.close()
         else:
             if action == 'create':
                 command = 'buildbot %s' % self.buildbot_create % self.path
             elif action == 'delete':
                 command = 'rm -rf %s' % self.path
             else:
                 command = 'buildbot %s %s' % (action, self.path)
             stdin, stdout, stderr = self.ssh.exec_command(command)
         self.ssh.close()
def post_save_config(sender, instance, **kwargs):
    """
    post save call back

    :Parameters:
       - sender: the sending object.
       - instance: instance of the object being saved
       - created: if a new record was created
       - kwargs: any keyword arguments
    """
    # find the master
    if hasattr(instance, 'master'):
        master = instance.master
    else:
        master = instance.slave.master

    # regen and hup
    master.generate_cfg()
    if master.alive:
        build_bot_run(['sighup', master.path])
def post_save_bot(sender, instance, created, **kwargs):
    """
    post save call back

    :Parameters:
       - sender: the sending object.
       - instance: instance of the object being saved
       - created: if a new record was created
       - kwargs: any keyword arguments
    """
    # create bot if new
    if created:
        build_bot_run(instance.buildbot_create)

    # update the config file
    instance.generate_cfg()

    if hasattr(instance, 'master'):
        instance.master.generate_cfg()
        if instance.master.alive:
            build_bot_run(['sighup', instance.master.path])

    if instance.alive:
        build_bot_run(['sighup', instance.path])
Exemple #5
0
 def buildbot_run(self, action):
     build_bot_run([action, self.path])