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'))
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)
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')
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')
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)
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'))
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)
def application_post_config(sender, **kwargs): app = kwargs.get('instance') args = (app.id, ) utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
def update_config(self): args = (self.id, ) utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
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)
def application_post_config(sender, **kwargs): app = kwargs.get('instance') args = (app.id,) utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)
def update_config(self): args = (self.id,) utils.get_queue('shipyard').enqueue(tasks.update_hipache, args=args)