Example #1
0
def build_image(request):
    '''
    Builds a container image

    '''
    form = ImageBuildForm(request.POST)
    url = form.data.get('url')
    tag = form.data.get('tag')
    hosts = form.data.getlist('hosts')
    # dockerfile takes precedence
    docker_file = None
    if request.FILES.has_key('dockerfile'):
        docker_file = handle_upload(request.FILES.get('dockerfile'))
    else:
        docker_file = tempfile.mktemp()
        urllib.urlretrieve(url, docker_file)
    for i in hosts:
        host = Host.objects.get(id=i)
        args = (docker_file, tag)
        utils.get_queue('shipyard').enqueue(host.build_image,
                                            args=args,
                                            timeout=3600)
    messages.add_message(
        request, messages.INFO,
        _('Building image from docker file.  This may take a few minutes.'))
    return redirect(reverse('index'))
Example #2
0
def build_on_hosts(to_apply, args, hosts, request, success_message):
    if not hosts:
        messages.add_message(request, messages.ERROR, _("No hosts selected"))
        return
    for i in hosts:
        host = Host.objects.get(id=i)
        local_args = args + (host.hostname, client_url(host))
        utils.get_queue("shipyard").enqueue(to_apply, args=local_args, timeout=3600)
    messages.add_message(request, messages.INFO, success_message)
Example #3
0
def import_image(request):
    form = ImportRepositoryForm(request.POST)
    hosts = form.data.getlist('hosts')
    for i in hosts:
        host = Host.objects.get(id=i)
        args = (form.data.get('repository'),)
        utils.get_queue('shipyard').enqueue(host.import_image, args=args, timeout=3600)
    messages.add_message(request, messages.INFO, _('Importing') + ' {0}'.format(
        form.data.get('repository')) + '. ' + _('This may take a few minutes.'))
    return redirect('dashboard.views.index')
Example #4
0
def import_image(request):
    form = ImportRepositoryForm(request.POST)
    hosts = form.data.getlist('hosts')
    for i in hosts:
        host = Host.objects.get(id=i)
        args = (form.data.get('repository'),)
        utils.get_queue('shipyard').enqueue(host.import_image, args=args, timeout=3600)
    messages.add_message(request, messages.INFO, _('Importing') + ' {0}'.format(
        form.data.get('repository')) + '. ' + _('This may take a few minutes.'))
    return redirect('containers.views.index')
Example #5
0
def build_on_hosts(to_apply, args, hosts, request, success_message):
    if not hosts:
        messages.add_message(request, messages.ERROR, _('No hosts selected'))
        return
    for i in hosts:
        host = Host.objects.get(id=i)
        local_args = args + (host.hostname, client_url(host))
        utils.get_queue('shipyard').enqueue(to_apply,
                                            args=local_args,
                                            timeout=3600)
    messages.add_message(request, messages.INFO, success_message)
Example #6
0
def build_image(request):
    '''
    Builds a container image

    '''
    form = ImageBuildForm(request.POST)
    url = form.data.get('url')
    tag = form.data.get('tag')
    hosts = form.data.getlist('hosts')
    # dockerfile takes precedence
    docker_file = None
    if request.FILES.has_key('dockerfile'):
        docker_file = handle_upload(request.FILES.get('dockerfile'))
    else:
        docker_file = tempfile.mktemp()
        urllib.urlretrieve(url, docker_file)
    for i in hosts:
        host = Host.objects.get(id=i)
        args = (docker_file, tag)
        utils.get_queue('shipyard').enqueue(host.build_image, args=args,
            timeout=3600)
    messages.add_message(request, messages.INFO,
        _('Building image from docker file.  This may take a few minutes.'))
    return redirect(reverse('index'))
Example #7
0
def remove_application_config(sender, **kwargs):
    app = kwargs.get('instance')
    args = (app.domain_name, )
    utils.get_queue('shipyard').enqueue(tasks.remove_hipache_config, args=args)
Example #8
0
def application_post_config(sender, **kwargs):
    app = kwargs.get('instance')
    args = (app.id, )
    utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
Example #9
0
 def update_config(self):
     args = (self.id, )
     utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
Example #10
0
def remove_application_config(sender, **kwargs):
    app = kwargs.get('instance')
    args = (app.domain_name,)
    utils.get_queue('shipyard').enqueue(tasks.remove_hipache_config, args=args)
Example #11
0
def application_post_config(sender, **kwargs):
    app = kwargs.get('instance')
    args = (app.id,)
    utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
Example #12
0
 def update_config(self):
     args = (self.id,)
     utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)