diff --git a/src/deadline_worker_agent/installer/__init__.py b/src/deadline_worker_agent/installer/__init__.py index bac5e399..1f7b1843 100644 --- a/src/deadline_worker_agent/installer/__init__.py +++ b/src/deadline_worker_agent/installer/__init__.py @@ -39,6 +39,8 @@ def install() -> None: "--scripts-path", str(scripts_path), ] + if args.vfs_install_path: + cmd += ["--vfs-install-path", args.vfs_install_path] if args.group: cmd += ["--group", args.group] if args.confirmed: @@ -75,6 +77,7 @@ class ParsedCommandLineArguments(Namespace): allow_shutdown: bool install_service: bool telemetry_opt_out: bool + vfs_install_path: str def get_argument_parser() -> ArgumentParser: # pragma: no cover @@ -137,5 +140,9 @@ def get_argument_parser() -> ArgumentParser: # pragma: no cover action="store_true", dest="confirmed", ) + parser.add_argument( + "--vfs-install-path", + help="Absolute path for the install location of the deadline vfs.", + ) return parser diff --git a/src/deadline_worker_agent/installer/install.sh b/src/deadline_worker_agent/installer/install.sh index c7a6f62d..8121f395 100755 --- a/src/deadline_worker_agent/installer/install.sh +++ b/src/deadline_worker_agent/installer/install.sh @@ -45,6 +45,7 @@ no_install_service="no" start_service="no" telemetry_opt_out="no" warning_lines=() +vfs_install_path="unset" usage() { @@ -52,6 +53,7 @@ usage() echo " [--region REGION] [--user USER]" echo " [--scripts-path SCRIPTS_PATH]" echo " [-y]" + echo " [--vfs-install-path VFS_INSTALL_PATH]" echo "" echo "Arguments" echo "---------" @@ -85,6 +87,9 @@ usage() echo " This option is ignored if --no-install-service is used." echo " -y" echo " Skips a confirmation prompt before performing the installation." + echo " --vfs-install-path VFS_INSTALL_PATH" + echo " An optional, absolute path to the directory that the Deadline Virtual File System (VFS) is" + echo " installed." exit 2 } @@ -110,7 +115,7 @@ validate_deadline_id() { } # Validate arguments -PARSED_ARGUMENTS=$(getopt -n install.sh --longoptions farm-id:,fleet-id:,region:,user:,group:,scripts-path:,start,allow-shutdown,no-install-service,telemetry-opt-out -- "y" "$@") +PARSED_ARGUMENTS=$(getopt -n install.sh --longoptions farm-id:,fleet-id:,region:,user:,group:,scripts-path:,vfs-install-path:,start,allow-shutdown,no-install-service,telemetry-opt-out -- "y" "$@") VALID_ARGUMENTS=$? if [ "${VALID_ARGUMENTS}" != "0" ]; then usage @@ -129,6 +134,7 @@ do --user) wa_user="$2" ; shift 2 ;; --group) job_group="$2" ; shift 2 ;; --scripts-path) scripts_path="$2" ; shift 2 ;; + --vfs-install-path) vfs_install_path="$2" ; shift 2 ;; --allow-shutdown) allow_shutdown="yes" ; shift ;; --no-install-service) no_install_service="yes" ; shift ;; --telemetry-opt-out) telemetry_opt_out="yes" ; shift ;; @@ -206,6 +212,22 @@ if [[ ! -z "${job_group}" ]] && [[ ! "${job_group}" =~ ^[a-z_]([a-z0-9_-]{0,31}| usage fi +if [[ "${vfs_install_path}" != "unset" ]]; then + if [[ ! -d "${vfs_install_path}" ]]; then + echo "ERROR: The specified vfs install path is not found: \"${vfs_install_path}\"" + usage + else + set +e + deadline_vfs_executable="${vfs_install_path}"/bin/deadline_vfs + if [[ ! -f "${deadline_vfs_executable}" ]]; then + echo "ERROR: Deadline vfs not found at \"${deadline_vfs_executable}\"." + exit 1 + fi + set -e + fi +fi + + banner echo @@ -229,6 +251,7 @@ echo "Worker agent program path: ${client_library_program}" echo "Allow worker agent shutdown: ${allow_shutdown}" echo "Start systemd service: ${start_service}" echo "Telemetry opt-out: ${telemetry_opt_out}" +echo "VFS install path: ${vfs_install_path}" # Confirmation prompt if [ -z "$confirm" ]; then @@ -355,7 +378,19 @@ Description=Amazon Deadline Cloud Worker Agent [Service] User=${wa_user} WorkingDirectory=${worker_agent_homedir} +EOF + # Write VFS install directory if it's set + if [[ "${vfs_install_path}" != "unset" ]]; then + cat >> /etc/systemd/system/deadline-worker.service <> /etc/systemd/system/deadline-worker.service <> /etc/systemd/system/deadline-worker.service < Generator[MagicMock, None, None]: with patch.object(installer_mod, "run") as mock_subprocess_run: @@ -82,6 +88,11 @@ def install_service() -> bool: return True +@pytest.fixture +def vfs_install_path() -> str: + return VFS_DEFAULT_INSTALL_PATH + + @pytest.fixture def parsed_args( farm_id: str, @@ -94,6 +105,7 @@ def parsed_args( allow_shutdown: bool, install_service: bool, telemetry_opt_out: bool, + vfs_install_path: str, ) -> ParsedCommandLineArguments: parsed_args = ParsedCommandLineArguments() parsed_args.farm_id = farm_id @@ -106,6 +118,7 @@ def parsed_args( parsed_args.allow_shutdown = allow_shutdown parsed_args.install_service = install_service parsed_args.telemetry_opt_out = telemetry_opt_out + parsed_args.vfs_install_path = vfs_install_path return parsed_args @@ -140,6 +153,8 @@ def expected_cmd( parsed_args.user, "--scripts-path", sysconfig.get_path("scripts"), + "--vfs-install-path", + parsed_args.vfs_install_path, ] if parsed_args.group is not None: expected_cmd.extend(("--group", parsed_args.group))