Beispiel #1
0
 def test_create_image(self):
     client = Communicator()
     data = {'username': '******', 'password': '******'}
     client.login(data)
     params = {
         'name': 'logtest',
         'version': '0.1',
         'desc': 'this is for test.',
         'is_public': 'false',
         'is_image': '0',
         'dockerfile': 'Dockerfile'
     }
     buildfile = '/home/wangtao/hummer-test/buildfiles/logtest/logtest.tar'
     ok = client.create_image(2, params, buildfile)
     print(ok)
 def test_create_image(self):
     client = Communicator()
     data = {"username": "******", "password": "******"}
     client.login(data)
     params = {
         "name": "logtest",
         "version": "0.1",
         "desc": "this is for test.",
         "is_public": "false",
         "is_image": "0",
         "dockerfile": "Dockerfile",
     }
     buildfile = "/home/wangtao/hummer-test/buildfiles/logtest/logtest.tar"
     ok = client.create_image(2, params, buildfile)
     print(ok)
Beispiel #3
0
def create_image(request, *args, **kwargs):
    project_id = kwargs['pid']

    build_type = request.POST.get('build_type', '0')
    if build_type == '0':
        form = SourceForm(request.POST)
    elif build_type == '1':
        form = ImageForm(request.POST)
    elif build_type == '2':
        form = SnapshotForm(request.POST)

    if not form.is_valid():
        return JsonResponse({"error": "data invalid"})

    buildfile = get_filename_of_buildfile(project_id)
    image_type = form.cleaned_data['image_type']
    if int(image_type) == 0:
        is_public = 'false'
    else:
        is_public = 'true'
    data = {
        'name': form.cleaned_data['name'],
        'version': form.cleaned_data['version'],
        'desc': form.cleaned_data['desc'],
        'is_public': is_public,
        'is_image': form.cleaned_data['build_type'],
    }

    build_type = form.cleaned_data['build_type']
    if build_type == '0':
        data['dockerfile'] = form.cleaned_data['dockerfile']
    elif build_type == '1':
        data['old_image_name'] = form.cleaned_data['old_name']
        data['old_image_version'] = form.cleaned_data['old_version']

    logger.debug(data)

    client = Communicator(cookies=request.COOKIES)
    ok = client.create_image(project_id, data, buildfile)

    remove_buildfile_from_disk(buildfile)

    if ok:
        return JsonResponse({"success": "success"})
    else:
        return JsonResponse({"error": "failed"})
Beispiel #4
0
def create_image(request, *args, **kwargs):
    project_id = kwargs['pid']

    build_type = request.POST.get('build_type', '0')
    if build_type == '0':
        form = SourceForm(request.POST)
    elif build_type == '1':
        form = ImageForm(request.POST)
    elif build_type == '2':
        form= SnapshotForm(request.POST)

    if not form.is_valid():
        return JsonResponse({"error": "data invalid"})

    buildfile = get_filename_of_buildfile(project_id)
    image_type = form.cleaned_data['image_type']
    if int(image_type) == 0:
        is_public = 'false'
    else:
        is_public = 'true'
    data = {
        'name': form.cleaned_data['name'],
        'version': form.cleaned_data['version'],
        'desc': form.cleaned_data['desc'],
        'is_public': is_public,
        'is_image': form.cleaned_data['build_type'],
    }

    build_type = form.cleaned_data['build_type']
    if build_type == '0':
        data['dockerfile'] = form.cleaned_data['dockerfile']
    elif build_type == '1':
        data['old_image_name'] = form.cleaned_data['old_name']
        data['old_image_version'] = form.cleaned_data['old_version']

    logger.debug(data)

    client = Communicator(cookies=request.COOKIES)
    ok = client.create_image(project_id, data, buildfile)

    remove_buildfile_from_disk(buildfile)

    if ok:
        return JsonResponse({"success": "success"})
    else:
        return JsonResponse({"error": "failed"})
Beispiel #5
0
 def test_create_image(self):
     client = Communicator()
     data = {
         'username': '******',
         'password': '******'
     }
     client.login(data)
     params = {
         'name': 'logtest',
         'version': '0.1',
         'desc': 'this is for test.',
         'is_public': 'false',
         'is_image': '0',
         'dockerfile': 'Dockerfile'
     }
     buildfile = '/home/wangtao/hummer-test/buildfiles/logtest/logtest.tar'
     ok = client.create_image(2, params, buildfile)
     print(ok)