示例#1
0
 def add_additional_location_config(src, dst):
     """
     These conf files is used for user that wanna add additional customized locations to harbor proxy
     :params src: source of the file
     :params dst: destination file path
     """
     if not os.path.isfile(src):
         return
     print("Copying nginx configuration file {src} to {dst}".format(src=src, dst=dst))
     shutil.copy2(src, dst)
     mark_file(dst, mode=0o644)
示例#2
0
def add_additional_location_config(src, dst):
    """
    These conf files is used for user that wanna add additional customized locations to harbor proxy
    :params src: source of the file
    :params dst: destination file path
    """
    if not os.path.isfile(src):
        return
    print("Copying nginx configuration file {src} to {dst}".format(
        src=src, dst=dst))
    shutil.copy2(src, dst)
    mark_file(dst, mode=0o644)
示例#3
0
def prepare_nginx_certs(cert_key_path, cert_path):
    """
    Prepare the certs file with proper ownership
    1. Remove nginx cert files in secret dir
    2. Copy cert files on host filesystem to secret dir
    3. Change the permission to 644 and ownership to 10000:10000
    """
    host_ngx_cert_key_path = Path(os.path.join(host_root_dir, cert_key_path.lstrip('/')))
    host_ngx_cert_path = Path(os.path.join(host_root_dir, cert_path.lstrip('/')))

    if host_ngx_real_cert_dir.exists() and host_ngx_real_cert_dir.is_dir():
        shutil.rmtree(host_ngx_real_cert_dir)

    os.makedirs(host_ngx_real_cert_dir, mode=0o755)
    real_key_path = os.path.join(host_ngx_real_cert_dir, 'server.key')
    real_crt_path = os.path.join(host_ngx_real_cert_dir, 'server.crt')
    shutil.copy2(host_ngx_cert_key_path, real_key_path)
    shutil.copy2(host_ngx_cert_path, real_crt_path)

    os.chown(host_ngx_real_cert_dir, uid=DEFAULT_UID, gid=DEFAULT_GID)
    mark_file(real_key_path, uid=DEFAULT_UID, gid=DEFAULT_GID)
    mark_file(real_crt_path, uid=DEFAULT_UID, gid=DEFAULT_GID)