示例#1
0
 def do(self):
     logger.debug("INSIDE")
     try:
         with open(command_log, 'w') as c_log:
             call([
                 self.setup_script, self.course_uuid,
                 self.prototype['repository'],
                 self._get_students_as_string()
             ],
                  stdout=c_log,
                  stderr=STDOUT)
         notify.send_receipt({
             'status': 'success',
             'type': 'INITIALIZE',
             'courseUUID': self.course_uuid,
             'id': self.command_id,
             'testing': str(self.testing)
         })
     except Exception, fu:
         notify.send_receipt({
             'status': 'failure',
             'type': 'INITIALIZE',
             'courseUUID': self.course_uuid,
             'id': self.command_id,
             'message': str(fu)
         })
示例#2
0
 def do(self):
    logger.debug("INSIDE")
    try:
       with open(command_log, 'w') as c_log:
          call([ self.setup_script, self.course_uuid, self.prototype['repository'], self._get_students_as_string() ], stdout=c_log, stderr=STDOUT)
       notify.send_receipt({'status':'success', 'type':'INITIALIZE', 'courseUUID': self.course_uuid, 'id':self.command_id, 'testing': str(self.testing)})
    except Exception, fu:
       notify.send_receipt({'status':'failure', 'type':'INITIALIZE', 'courseUUID': self.course_uuid, 'id':self.command_id, 'message': str(fu)})
示例#3
0
    def do(self):
        logger.info(
            "Starting provision with Boto for image type %s and token %s with students %s",
            self.image_type, self.token, " ".join(self.student_ids))
        try:
            if self.stub_out is True:
                student_instances, reservation = provision.stub_boto(
                    self.image_type, self.course_uuid, self.student_ids,
                    self.init_ref, self.token)
            else:
                student_instances, reservation = provision.provision_boto(
                    self.image_type, self.course_uuid, self.student_ids,
                    self.init_ref, self.token)
            instance_map = {}
            for student, machine in student_instances:
                logger.debug('Receipt mapping\nStudent: %s\nInstance %s',
                             student, machine.id)
                m_rep = {}
                m_rep['host'] = machine.private_dns_name.split('.')[0]
                m_rep['location'] = machine.private_ip_address
                instance_map[student] = m_rep

            notify.send_receipt({
                'status': 'success',
                'type': 'PROVISION_VM',
                'courseUUID': self.course_uuid,
                'id': self.command_id,
                'instanceMap': instance_map
            })
            logger.info(
                "Instances prepared: %s",
                " ".join([instance.id for instance in reservation.instances]))
        except Exception, pe:
            logger.error("Problem provisioning instances for course: \n%s",
                         str(pe))
            notify.send_receipt({
                'status': 'failure',
                'type': 'PROVISION_VM',
                'courseUUID': self.course_uuid,
                'id': self.command_id,
                'message': str(pe)
            })
示例#4
0
   def do(self):
      logger.info("Starting provision with Boto for image type %s and token %s with students %s", self.image_type, self.token, " ".join(self.student_ids))
      try:
         if self.stub_out is True:
             student_instances, reservation = provision.stub_boto(self.image_type, self.course_uuid, self.student_ids, self.init_ref, self.token)
         else:
              student_instances, reservation = provision.provision_boto(self.image_type, self.course_uuid, self.student_ids, self.init_ref, self.token)
         instance_map = {}
         for student, machine in student_instances:
             logger.debug('Receipt mapping\nStudent: %s\nInstance %s', student, machine.id)
             m_rep = {}
             m_rep['host'] = machine.private_dns_name.split('.')[0]
             m_rep['location'] = machine.private_ip_address
             instance_map[student] = m_rep

         notify.send_receipt({'status':'success', 'type':'PROVISION_VM', 'courseUUID': self.course_uuid, 'id':self.command_id, 'instanceMap': instance_map})
         logger.info("Instances prepared: %s", " ".join([instance.id for instance in reservation.instances]))
      except Exception, pe:
         logger.error("Problem provisioning instances for course: \n%s", str(pe))
         notify.send_receipt({'status':'failure', 'type':'PROVISION_VM', 'courseUUID': self.course_uuid, 'id':self.command_id, 'message': str(pe)})