Пример #1
0
    def build(self):

        util = Utilities()

        buildconfig = util.get_dict(self.buildconfig)
        isotype = buildconfig['default']['type']

        if isotype != 'boot':
            ksstr = util.get_kickstart(buildconfig)
            #copy all KS files in the specified directory 
            #of the KS file to /tmp
            dirname, fname = os.path.split(os.path.abspath(buildconfig[isotype]['config']))
            for ksfile in glob.glob('{0:s}/*.ks'.format(os.path.abspath(dirname))):
                shutil.copyfile(ksfile,'/tmp/{0:s}'.format(os.path.split(ksfile)[1]))
        else:
            ksstr = None

        build = ImageBuilder(buildconfig, ksstr)
        logfile = build.getlogfile()

        print 'Initiating Build Process. See {0:s} for progress'.format(logfile)

        status = build.build()

        return status
Пример #2
0
def delegate():
    # Read the data/config/imagebuild.conf file
    # to find the architecture of the image sought

    util = Utilities()
    buildconfig = util.get_dict('data/config/imagebuild.conf')

    arch = buildconfig['default']['arch']
    #find an appropriate build node from nodes.conf
    #based on the arch
    config = ConfigParser.SafeConfigParser()
    config.read('nodes.conf')
    broker_url = config.get(arch,'broker_url')

    #now create the celeryconfig.py using this broker_url
    with open('celeryconfig.py','w') as f:
        f.write('BROKER_URL = {0:s}\n'.format(broker_url))
        f.write('CELERY_RESULT_BACKEND = "amqp"\n')
        f.write('\n')
    
    buildconfig_json = json.dumps(buildconfig)

    if not buildconfig['default']['type'] == 'boot':
        ksstr = util.get_kickstart(buildconfig)
    else:
        ksstr = None

    # celery task delegation
    from tasks import build

    try:
        release = buildconfig['default']['release']
        queue_name = 'fedora-{0:s}'.format(release)
        build.apply_async(args = [buildconfig_json, ksstr], queue = queue_name, serializer="json")
    except Exception as e:
        # if there is an error in submitting job to celery
        # we save this somewhere and retry (TODO)
        # for now, we just have an email error message
        # using config in smtp.py
        recipient = buildconfig['default']['email']
        subject = 'Your Image Build Request'
        message = 'Uh Oh. The image builders are having a bad day. Retry again in sometime.'

        headers = ["From: " + 'Fedora Build Service',
                   "Subject: " + subject,
                   "To: " + recipient,
                   "MIME-Version: 1.0",
                   "Content-Type: text/html"]
        headers = "\r\n".join(headers)

        notify = Notification()
        notify.send_email(recipient, headers, message)
        return 
    else:
        return
Пример #3
0
    def build(self):

        util = Utilities()

        buildconfig = util.get_dict(self.config)
        release = buildconfig['default']['release']

        arch = buildconfig['default']['arch']
        #find an appropriate build node from nodes.conf
        #based on the arch
        config = ConfigParser.SafeConfigParser()
        config.read('nodes.conf')
        broker_url = config.get(arch,'broker_url')

        #now create the celeryconfig.py using this broker_url
        with open('celeryconfig.py','w') as f:
            f.write('BROKER_URL = {0:s}\n'.format(broker_url))
            f.write('CELERY_RESULT_BACKEND = "amqp"\n')
            f.write('\n')
    
        buildconfig_json = json.dumps(buildconfig)

        isotype = buildconfig['default']['type']
        if isotype != 'boot':
            ksstr = util.get_kickstart(buildconfig)
        else:
            ksstr = None

        # task delegation
        from tasks import build

        try:
            print 'Sending build task to worker'
            queue_name = 'fedora-{0:s}'.format(release)
            result_obj = build.apply_async(args = [buildconfig_json, ksstr], queue = queue_name, serializer="json")
        except Exception as e:
            sys.exit('Error in communicating with Celery')
        else:
            result = result_obj.get()

        return result