Esempio n. 1
0
def delivery_deploy(request, project_id):
    server_list = []
    project = Delivery.objects.get(job_name_id=project_id)
    project.bar_data = 10
    job_name = project.job_name.name
    source_address = project.job_name.source_address
    app_path = project.job_name.appPath
    source_auth = project.source_auth
    if project.auth:
        auth_info = {
            "username": project.auth.username,
            "password": project.auth.password,
            "deploy_port": project.auth.deploy_port,
        }
    else:
        auth_info = None
    project.status = True
    project.deploy_num += 1
    project.save()
    sleep(2)
    os.system("mkdir -p /var/opt/adminset/workspace/{0}/logs".format(job_name))
    os.system(
        "mkdir -p /var/opt/adminset/workspace/{0}/scripts".format(job_name))
    if app_path == "/":
        return HttpResponse("app deploy destination cannot /")
    # foreign key query need add .all()
    servers = project.job_name.serverList.all()
    for server in servers:
        server_ip = str(server.ip)
        server_list.append(server_ip)
    project.bar_data = 15
    rsync_status = project.rsync_delete
    deploy.delay(job_name, server_list, app_path, source_address, project_id,
                 auth_info, rsync_status, source_auth)
    return HttpResponse("ok")
Esempio n. 2
0
def delivery_deploy(request, ids):
    deli_obj = Delivery.objects.filter(id=ids).first()
    deli_obj.bar_data = 10
    deli_obj.deploy_num += 1
    deli_obj.status = True
    deli_obj.save()

    project_name = deli_obj.job_name.name
    os.system("mkdir -p /var/opt/demo/workspace/{}/code".format(project_name))
    os.system("mkdir -p /var/opt/demo/workspace/{}/logs".format(project_name))
    os.system("mkdir -p /var/opt/demo/workspace/{}/scripts".format(project_name))

    app_path = deli_obj.job_name.appPath
    if app_path == '/':
        return HttpResponse(u"项目部署路径不能为根目录")

    deploy.delay(ids)
    deli_obj.bar_data = 15
    return JsonResponse({"msg": u'部署任务已经提交'})