예제 #1
0
    def execute(self):
        """
        Executes the task.
        """
        try:
            user = User.objects.get(pk=self.user_id)

            subject = "Orthos password restored"
            message = """Hi {username},

Your Orthos password has been restored.

  Login:    {username}
  Password: {password}


Regards,
Orthos""".format(username=user.username, password=self.new_password)

            send_email(user.email, subject, message)

        except User.DoesNotExist:
            logger.error("User not found: id={}".format(self.user_id))
        except Exception as e:
            logger.exception(e)
def save_report(name, email=None):
    # write to stdout
    summarize_results(name)

    # write to report file
    if not os.path.exists(report_dir(name)):
        os.mkdir(report_dir(name))
    summarize_results(name, open(report_file(name), "w"))

    if email is not None and email.find("@") != -1:
        header = "experiment %s finished" % name
        buff = StringIO.StringIO()
        print >> buff, "These results are best viewed in a monospace font."
        print >> buff
        summarize_results(name, buff)
        body = buff.getvalue()
        buff.close()
        misc.send_email(header, body, email)
예제 #3
0
def save_report(name, email=None):
    # write to stdout
    summarize_results(name)

    # write to report file
    if not os.path.exists(report_dir(name)):
        os.mkdir(report_dir(name))
    summarize_results(name, open(report_file(name), 'w'))

    if email is not None and email.find('@') != -1:
        header = 'experiment %s finished' % name
        buff = StringIO()
        print('These results are best viewed in a monospace font.', file=buff)
        print(file=buff)
        summarize_results(name, buff)
        body = buff.getvalue()
        buff.close()
        misc.send_email(header, body, email)
예제 #4
0
    def execute(self):
        """
        Executes the task.
        """
        try:
            user = User.objects.get(pk=self.user_id)

            prefix = user.email.split('@')[0] + '@'
            usernames = list(
                User.objects.filter(email__startswith=prefix).values(
                    'username', 'email'))

            if len(usernames) <= 1:
                return

            subject = "Multiple Accounts found!"
            message = """Hi {username},

We found multiple accounts related to your email address (local part):

{usernames}

Please send a short email to <{contact}> and tell which accounts are in use at
the moment.

This information is needed in order to make Orthos great again!


Regards,
Orthos""".format(username=user.username,
                 usernames="\n".join([
                     '  {} ({})'.format(user['username'], user['email'])
                     for user in usernames
                 ]),
                 contact=settings.CONTACT)

            send_email(user.email, subject, message)

        except User.DoesNotExist:
            logger.error("User not found: id={}".format(self.user_id))
        except Exception as e:
            logger.exception(e)
예제 #5
0
    def execute(self):
        """
        Executes the task.
        """
        try:
            user = User.objects.get(pk=self.user_id)
            machine = Machine.objects.get(fqdn=self.fqdn)

            subject = "Reservation of {}".format(machine.fqdn)
            message = """Hi {username},

The machine {fqdn} was just reserved for you.

To login, just SSH to {fqdn} or {ip}.

If you have any problems, contact <{support_contact}>.""".format(
                username=user.username,
                fqdn=machine.fqdn,
                ip=machine.ipv4,
                support_contact=machine.get_support_contact())

            if machine.has_remotepower():
                message += """

To reset the machine if the kernel has crashed, you can use the remote power
switch capability. Just use the Orthos web interface at:

  {url}

Or use the following commandline interface command:

  (orthos) POWER {fqdn} REBOOT""".format(url=settings.BASE_URL + '/machine/' +
                                         str(machine.pk),
                                         fqdn=machine.fqdn)

            if machine.has_serialconsole():
                message += """

For a serial console, establish a SSH login on {serialconsole_fqdn} and
follow the instructions on the screen.""".format(
                    serialconsole_fqdn=machine.serialconsole.cscreen_server.
                    fqdn)

            message += """

Remember that the machine reservation ends at {reserved_until}. You'll get
another email as reminder one day before the machine gets released automatically.
Information about Orthos can be found here: http://orthos-host.domain.de/


Regards,
Orthos""".format(reserved_until=machine.reserved_until)

            send_email(user.email, subject, message)

        except User.DoesNotExist:
            logger.error("User not found: id={}".format(self.user_id))
        except Machine.DoesNotExist:
            logger.error("Machine does not exist: fqdn={}".format(self.fqdn))
        except Exception as e:
            logger.exception(e)
예제 #6
0
    def execute(self):
        """
        Executes the task.
        """
        today = datetime.date.today()

        try:
            machine = Machine.objects.get(fqdn=self.fqdn)

            if not machine.reserved_by:
                return

            user = machine.reserved_by
            delta = machine.reserved_until.date() - today

            if delta.days > 5 or delta.days in [4, 3]:
                logger.debug("{}d left for {}@{}".format(
                    delta.days, user.username, machine.fqdn))
                return

            if delta.days < 0:
                # release machine and return
                machine.release(user)
                return

            elif delta.days == 1:
                subject = "Reservation of {} expires tomorrow".format(
                    machine.fqdn)
            elif delta.days == 0:
                subject = "Reservation of {} expires today".format(
                    machine.fqdn)
            else:
                subject = "Reservation of {} expires in {} days".format(
                    machine.fqdn, delta.days)

            message = """Hi {username},

The machine reservation for {fqdn} expires at {reserved_until}.

If you need the machine longer, you can just extend the reservation. Just use
the Orthos web interface at:

  {url}

Or use the following commandline interface command:

  (orthos) RESERVE {fqdn}

Please note, that the machine will be setup after reservation expired!

If you have any problems, contact <{support_contact}>.


Regards,
Orthos""".format(username=user.username,
                 fqdn=machine.fqdn,
                 reserved_until=machine.reserved_until,
                 url=settings.BASE_URL + '/machine/' + str(machine.pk),
                 support_contact=machine.get_support_contact())

            send_email(user.email, subject, message)

        except User.DoesNotExist:
            logger.error("User not found: id={}".format(self.user_id))
        except Machine.DoesNotExist:
            logger.error("Machine does not exist: fqdn={}".format(self.fqdn))
        except Exception as e:
            logger.exception(e)