Beispiel #1
0
    def get(self):
        credentials = meSchema.getCredentials("")
        config = meSchema.getConfig()
        whoami = "I am masterBlaster!"
        
        template_values = {
            'credentials':credentials,
            'config':config,
            'whoami':whoami,
            }

        path = os.path.join(os.path.dirname(__file__),'index.html')
        self.response.out.write(template.render(path,template_values))
Beispiel #2
0
def startItUp():
    conn = meConnector.createEC2connection()
    try:
        strayInstances = False
        meReservations = conn.get_all_instances()
        for reservation in meReservations:
            for instance in reservation.instances:
                if (instance.state != 'terminated'):
                    strayInstances = True
                    badInstance = instance
    except Exception, e:
        meTools.mailIt(email,'Error with get_all_instances()!', 'Exception:\n\n%s' % e)
        #raise                                                               #Raising exception may cause Cron to retry indefinitely.
    if not strayInstances:
        try:
            config = meSchema.getConfig()
            meImage = conn.get_image(config[0].AMI_id)                       # Also add wakeup-time?
            result = meImage.run( key_name        = config[0].keypair_name,
                                  placement       = config[0].placement,
                                  security_groups = config[0].security_groups )
            meTools.mailIt(email,'Started new instance up!!!', '%s\n%s' % (result, result.instances[0].id))
        except Exception, e:
            meTools.mailIt(email,'Could Not Start AMI!','Error:\n%s' % e)
            #raise                                                           #Raising exception may cause Cron to retry indefinitely.
        meTasks.addChkInstanceTask(str(result.instances[0].id))
    else:
        meTools.mailIt(email,'Instances Already Running!','InstanceID: %s is %s' % (badInstance.id,badInstance.state))

email = '*****@*****.**'
application = webapp.WSGIApplication([('/starter/startAMI', StartAMI)],
                                     debug=True)