Exemplo n.º 1
0
def main(argv):
    options = parseOption(argv)
    env = options.env
    proj = options.proj
    playbook_file = options.pbook

    opt_hosts = options.hosts
    json_hosts = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["hosts"]
    if opt_hosts != "none":
        hosts = opt_hosts
    elif opt_hosts == "none" and json_hosts != "none":
        hosts = json_hosts
    else:
        hosts = proj

    log_path = load_pub_json_conf(env, "log_path")
    log_file = log_path + "pl_deploy_ansible_playbook.log"

    serial = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["serial"]
    playbook_path = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                       proj)["playbook_path"]

    os.chdir(CONFIG_BASE_DIR)
    ansible_playbook_func(playbook_file, playbook_path, hosts, serial,
                          log_file)
def main(argv):
    options = parseOption(argv)
    env = options.env
    proj = options.proj
    branch = options.branch
    repo_url = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["repo_url"]
    proj_local_path = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["proj_local_path"]
    commit_lists = get_git_commitid_by_command(repo_url, proj_local_path,branch)
    print(commit_lists)
def main(argv):
    options = parseOption(argv)
    env = options.env
    hosts = options.proj
    proj = hosts
    log_path = load_pub_json_conf(env, "log_path")
    log_file = log_path + "pl_deploy_package.log"
    proj_type = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["type"]
    repo_url = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["repo_url"]
    proj_local_path = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                         proj)["proj_local_path"]
    version_id = options.file
    get_repo_file(proj_type, repo_url, proj_local_path, version_id, log_file)
def main(argv):
    options = parseOption(argv)
    env = options.env
    ansible_hosts_file = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                            "ansible_hosts_file")

    list_group_key = get_AnsibleHostsDic(ansible_hosts_file)
    print(list_group_key)
Exemplo n.º 5
0
def main(argv):
    options = parseOption(argv)
    env = options.env
    proj = options.proj
    opt_hosts = options.hosts
    serial = options.serial
    json_hosts = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["hosts"]
    if opt_hosts != "none":
        hosts = opt_hosts
    elif opt_hosts == "none" and json_hosts != "none":
        hosts = json_hosts
    else:
        hosts = proj
    log_path = load_pub_json_conf(env, "log_path")
    log_file = log_path + "pl_deploy_git.log"

    deploy_src_path = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                         proj)["deploy_src_path"]
    rsync_opts = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["rsync_opts"]
    deploy_dest_path = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                          proj)["deploy_dest_path"]
    delete_enable = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                       proj)["delete_enable"]
    owner = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["owner"]
    group = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["group"]

    if deploy_src_path.endswith('/'):
        change_owner_tag = "dir_change_owner"
    else:
        change_owner_tag = "file_change_owner"

    os.chdir(CONFIG_BASE_DIR)
    static_deploy(change_owner_tag, hosts, deploy_src_path, deploy_dest_path,
                  delete_enable, owner, group, log_file, rsync_opts, serial)
Exemplo n.º 6
0
def main(argv):
    options = parseOption(argv)
    env = options.env
    proj = options.proj

    ansible_playbook_path = load_pri_json_conf(CONFIG_BASE_DIR, env,
                                               proj)["playbook_path"]
    list_plyabook_file = get_AnsiblePlaybookFile(ansible_playbook_path)
    print(list_plyabook_file)
def main(argv):
    options = parseOption(argv)
    hosts = options.group
    cmd = options.cmd
    env = options.env
    forks = load_pri_json_conf(CONFIG_BASE_DIR, env, "forks")
    log_path = load_pub_json_conf(env, "log_path")
    log_file = log_path + "pl_ansible_shell.log"
    ansible_cmd_func(hosts, forks, cmd, log_file)
Exemplo n.º 8
0
def main(argv):
    options = parseOption(argv)
    env = options.env
    hosts = options.proj
    proj = hosts
    
    log_path = load_pub_json_conf(env, "log_path")
    log_file = log_path + "pl_deploy_git.log"
    

    proj_type = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["type"]
    repo_url = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["repo_url"]
    proj_local_path = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["proj_local_path"]

    if proj_type == "git":
        commit_str = options.id
      
        pattern = re.compile(r'\w+')
        m = pattern.match(commit_str)
        commit_id = m.group(0)
        git_check_out_by_commit_num(repo_url, proj_local_path, commit_id,log_file)
    else:
        pass
def main(argv):
    options = parseOption(argv)
    env = options.env
    proj = options.proj
    repo_url = load_pri_json_conf(CONFIG_BASE_DIR, env, proj)["repo_url"]
    url_response = urllib.request.urlopen(repo_url)
    html_doc = url_response.read()
    soup = BeautifulSoup(html_doc, "html.parser", from_encoding="utf-8")
    links = soup.find_all('a', href=re.compile(r"%s" % proj))

    tar_list = []
    for link in links:
        tar_list.append(link['href'])
    tar_list.sort(reverse=True)
    print(tar_list)
Exemplo n.º 10
0
def main(argv):
    options = parseOption(argv)
    env = options.env
    log_path = load_pub_json_conf(env, "log_path")

    proj = options.proj
    tag = options.tag
    wait_times = options.times
    exec_mode = options.mode
    check_time = options.checktime
    task_name_created = options.task_name_created
    serial = options.serial
    opt_hosts = options.hosts
    json_hosts = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["hosts"]
    if opt_hosts != "none" :
        hosts = opt_hosts
    elif opt_hosts == "none" and json_hosts != "none":
        hosts = json_hosts
    else:
        hosts = proj

    docker_image_url = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["DockerImageURL"]
    eureka_url = load_pri_json_conf(CONFIG_BASE_DIR,env, "public")["EurekaUrl"]
    docker_run_arg = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["DockerRunArg"]
    docker_run_cmd = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["DockerRunCmd"]
    app_spring_name = load_pri_json_conf(CONFIG_BASE_DIR,env, proj)["AppSpringName"]
    docker_run_image = "%s%s:%s" % (docker_image_url,proj,tag)
    docker_run_time = time.strftime("%Y%m%d.%H%M%S", time.localtime())
    docker_run_name = "%s-%s" % (proj,docker_run_time)
    docker_run_arg = "--name %s %s" % (docker_run_name,docker_run_arg)
    docker_run = "docker run  %s %s %s" % (docker_run_arg,docker_run_image,docker_run_cmd)

    task_id = task_name_created
    # task_id = lambda x: datetime.datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%Y%m%d.%H%M%S.%f')
    log_file = log_path + "pl_deploy_docker.log." + task_name_created
    os.chdir(CONFIG_BASE_DIR)
    docker_deploy(hosts,proj,tag,docker_run,docker_image_url,wait_times,eureka_url,app_spring_name,exec_mode,log_file,check_time,task_id,serial)