Skip to content

Commit

Permalink
feat(deadline): add ability to import repository settings (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
jericht authored Apr 19, 2021
1 parent cf44a13 commit c55c078
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
36 changes: 30 additions & 6 deletions packages/aws-rfdk/lib/deadline/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ import {
import {
PolicyStatement,
} from '@aws-cdk/aws-iam';
import {
Asset,
} from '@aws-cdk/aws-s3-assets';
import {
Annotations,
Construct,
Expand Down Expand Up @@ -376,6 +379,14 @@ export interface RepositoryProps {
* Options to add additional security groups to the Repository.
*/
readonly securityGroupsOptions?: RepositorySecurityGroupsOptions;

/**
* The Deadline Repository settings file to import.
* @see https://docs.thinkboxsoftware.com/products/deadline/10.1/1_User%20Manual/manual/repository-settings-importer-exporter.html
*
* @default Repository settings are not imported.
*/
readonly repositorySettings?: Asset;
}

/**
Expand Down Expand Up @@ -657,6 +668,7 @@ export class Repository extends Construct implements IRepository {
this.installerGroup,
repositoryInstallationPath,
props.version,
props.repositorySettings,
);

this.configureSelfTermination();
Expand Down Expand Up @@ -887,7 +899,9 @@ export class Repository extends Construct implements IRepository {
private configureRepositoryInstallerScript(
installerGroup: AutoScalingGroup,
installPath: string,
version: IVersion) {
version: IVersion,
settings?: Asset,
) {
const installerScriptAsset = ScriptAsset.fromPathConvention(this, 'DeadlineRepositoryInstallerScript', {
osType: installerGroup.osType,
baseName: 'installDeadlineRepository',
Expand All @@ -902,13 +916,23 @@ export class Repository extends Construct implements IRepository {

version.linuxInstallers.repository.s3Bucket.grantRead(installerGroup, version.linuxInstallers.repository.objectKey);

const installerArgs = [
`"s3://${version.linuxInstallers.repository.s3Bucket.bucketName}/${version.linuxInstallers.repository.objectKey}"`,
`"${installPath}"`,
version.linuxFullVersionString(),
];

if (settings) {
const repositorySettingsFilePath = installerGroup.userData.addS3DownloadCommand({
bucket: settings.bucket,
bucketKey: settings.s3ObjectKey,
});
installerArgs.push(repositorySettingsFilePath);
}

installerScriptAsset.executeOn({
host: installerGroup,
args: [
`"s3://${version.linuxInstallers.repository.s3Bucket.bucketName}/${version.linuxInstallers.repository.objectKey}"`,
`"${installPath}"`,
version.linuxFullVersionString(),
],
args: installerArgs,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
# $1: s3 path for the deadline repository installer.
# $2: Path where deadline repository needs to be installed.
# $3: Deadline Repository Version being installed.
# $4: (Optional) Deadline Repository settings file to import.

# exit when any command fails
set -xeuo pipefail

S3PATH=$1
PREFIX=$2
DEADLINE_REPOSITORY_VERSION=$3
DEADLINE_REPOSITORY_SETTINGS_FILE=${4:-}
shift;shift;

# check if repository is already installed at the given path
Expand Down Expand Up @@ -69,7 +71,18 @@ set +x

INSTALLER_DB_ARGS_STRING=''
for key in "${!INSTALLER_DB_ARGS[@]}"; do INSTALLER_DB_ARGS_STRING=$INSTALLER_DB_ARGS_STRING"${key} ${INSTALLER_DB_ARGS[$key]} "; done
$REPO_INSTALLER --mode unattended --setpermissions false --prefix "$PREFIX" --installmongodb false --backuprepo false ${INSTALLER_DB_ARGS_STRING}

REPOSITORY_SETTINGS_ARG_STRING=''
if [ ! -z "$DEADLINE_REPOSITORY_SETTINGS_FILE" ]; then
if [ ! -f "$DEADLINE_REPOSITORY_SETTINGS_FILE" ]; then
echo "ERROR: Repository settings file was specified but is not a file: $DEADLINE_REPOSITORY_SETTINGS_FILE."
exit 1
else
REPOSITORY_SETTINGS_ARG_STRING="--importrepositorysettings true --repositorysettingsimportoperation append --repositorysettingsimportfile \"$DEADLINE_REPOSITORY_SETTINGS_FILE\""
fi
fi

$REPO_INSTALLER --mode unattended --setpermissions false --prefix "$PREFIX" --installmongodb false --backuprepo false ${INSTALLER_DB_ARGS_STRING} $REPOSITORY_SETTINGS_ARG_STRING

set -x

Expand Down
19 changes: 19 additions & 0 deletions packages/aws-rfdk/lib/deadline/test/repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
FileSystem as EfsFileSystem,
} from '@aws-cdk/aws-efs';
import { Bucket } from '@aws-cdk/aws-s3';
import { Asset } from '@aws-cdk/aws-s3-assets';
import {
App,
CfnElement,
Expand Down Expand Up @@ -1205,3 +1206,21 @@ test('throws an error if supplied a MountableEfs with no Access Point', () => {
// THEN
expect(when).toThrow('When using EFS with the Repository, you must provide an EFS Access Point');
});

test('imports repository settings', () => {
// GIVEN
const repositorySettings = new Asset(stack, 'RepositorySettingsAsset', {
path: __filename,
});

// WHEN
const repository = new Repository(stack, 'Repository', {
vpc,
version,
repositorySettings,
});

// THEN
const installerGroup = repository.node.tryFindChild('Installer') as AutoScalingGroup;
expect(installerGroup.userData.render()).toContain(`aws s3 cp '${repositorySettings.s3ObjectUrl}'`);
});

0 comments on commit c55c078

Please sign in to comment.