Skip to content

Commit

Permalink
Fix uninitialized var when security groups stack not configured with …
Browse files Browse the repository at this point in the history
…res. (#294)
  • Loading branch information
cartalla authored Dec 20, 2024
1 parent c8f5053 commit b7bc3d5
Showing 1 changed file with 39 additions and 34 deletions.
73 changes: 39 additions & 34 deletions source/cdk/cdk_slurm_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,51 +710,56 @@ def update_config_for_res(self):
logger.error(f"RES VDC controller security group not found.")
exit(1)

self.config['ExternalLoginNodes'] = self.config.get('ExternalLoginNodes', [])
self.config['ExternalLoginNodes'].append(
{
if 'AdditionalSecurityGroupsStackName' not in self.config:
logger.warning(f"Can't automatically configure RES ExternalLoginNodes or DomainJoinedInstance because AdditionalSecurityGroupsStackName not configured.")

if 'AdditionalSecurityGroupsStackName' in self.config:
self.config['ExternalLoginNodes'] = self.config.get('ExternalLoginNodes', [])
self.config['ExternalLoginNodes'].append(
{
'Tags': [
{
'Key': 'res:EnvironmentName',
'Values': [self.res_environment_name]
},
{
'Key': 'res:NodeType',
'Values': ['virtual-desktop-dcv-host']
}
],
'SecurityGroupId': self.slurm_login_node_sg_id
}
)

if 'DomainJoinedInstance' in self.config:
logger.error(f"Can't specify both DomainJoinedInstance and RESStackName in config file.")
exit(1)
if 'AdditionalSecurityGroupsStackName' in self.config:
self.config['DomainJoinedInstance'] = {
'Tags': [
{
'Key': 'Name',
'Values': [f"{self.res_environment_name}-cluster-manager",]
},
{
'Key': 'res:EnvironmentName',
'Values': [self.res_environment_name]
},
{
'Key': 'res:ModuleName',
'Values': ['cluster-manager']
},
{
'Key': 'res:ModuleId',
'Values': ['cluster-manager']
},
{
'Key': 'res:NodeType',
'Values': ['virtual-desktop-dcv-host']
'Values': ['app']
}
],
'SecurityGroupId': self.slurm_login_node_sg_id
}
)

if 'DomainJoinedInstance' in self.config:
logger.error(f"Can't specify both DomainJoinedInstance and RESStackName in config file.")
exit(1)
self.config['DomainJoinedInstance'] = {
'Tags': [
{
'Key': 'Name',
'Values': [f"{self.res_environment_name}-cluster-manager",]
},
{
'Key': 'res:EnvironmentName',
'Values': [self.res_environment_name]
},
{
'Key': 'res:ModuleName',
'Values': ['cluster-manager']
},
{
'Key': 'res:ModuleId',
'Values': ['cluster-manager']
},
{
'Key': 'res:NodeType',
'Values': ['app']
}
],
'SecurityGroupId': self.slurm_login_node_sg_id
}

# Configure the /home mount from RES if /home not already configured
home_mount_found = False
Expand Down

0 comments on commit b7bc3d5

Please sign in to comment.