Skip to content

Commit b7bc3d5

Browse files
authored
Fix uninitialized var when security groups stack not configured with res. (#294)
1 parent c8f5053 commit b7bc3d5

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

source/cdk/cdk_slurm_stack.py

+39-34
Original file line numberDiff line numberDiff line change
@@ -710,51 +710,56 @@ def update_config_for_res(self):
710710
logger.error(f"RES VDC controller security group not found.")
711711
exit(1)
712712

713-
self.config['ExternalLoginNodes'] = self.config.get('ExternalLoginNodes', [])
714-
self.config['ExternalLoginNodes'].append(
715-
{
713+
if 'AdditionalSecurityGroupsStackName' not in self.config:
714+
logger.warning(f"Can't automatically configure RES ExternalLoginNodes or DomainJoinedInstance because AdditionalSecurityGroupsStackName not configured.")
715+
716+
if 'AdditionalSecurityGroupsStackName' in self.config:
717+
self.config['ExternalLoginNodes'] = self.config.get('ExternalLoginNodes', [])
718+
self.config['ExternalLoginNodes'].append(
719+
{
720+
'Tags': [
721+
{
722+
'Key': 'res:EnvironmentName',
723+
'Values': [self.res_environment_name]
724+
},
725+
{
726+
'Key': 'res:NodeType',
727+
'Values': ['virtual-desktop-dcv-host']
728+
}
729+
],
730+
'SecurityGroupId': self.slurm_login_node_sg_id
731+
}
732+
)
733+
734+
if 'DomainJoinedInstance' in self.config:
735+
logger.error(f"Can't specify both DomainJoinedInstance and RESStackName in config file.")
736+
exit(1)
737+
if 'AdditionalSecurityGroupsStackName' in self.config:
738+
self.config['DomainJoinedInstance'] = {
716739
'Tags': [
740+
{
741+
'Key': 'Name',
742+
'Values': [f"{self.res_environment_name}-cluster-manager",]
743+
},
717744
{
718745
'Key': 'res:EnvironmentName',
719746
'Values': [self.res_environment_name]
720747
},
748+
{
749+
'Key': 'res:ModuleName',
750+
'Values': ['cluster-manager']
751+
},
752+
{
753+
'Key': 'res:ModuleId',
754+
'Values': ['cluster-manager']
755+
},
721756
{
722757
'Key': 'res:NodeType',
723-
'Values': ['virtual-desktop-dcv-host']
758+
'Values': ['app']
724759
}
725760
],
726761
'SecurityGroupId': self.slurm_login_node_sg_id
727762
}
728-
)
729-
730-
if 'DomainJoinedInstance' in self.config:
731-
logger.error(f"Can't specify both DomainJoinedInstance and RESStackName in config file.")
732-
exit(1)
733-
self.config['DomainJoinedInstance'] = {
734-
'Tags': [
735-
{
736-
'Key': 'Name',
737-
'Values': [f"{self.res_environment_name}-cluster-manager",]
738-
},
739-
{
740-
'Key': 'res:EnvironmentName',
741-
'Values': [self.res_environment_name]
742-
},
743-
{
744-
'Key': 'res:ModuleName',
745-
'Values': ['cluster-manager']
746-
},
747-
{
748-
'Key': 'res:ModuleId',
749-
'Values': ['cluster-manager']
750-
},
751-
{
752-
'Key': 'res:NodeType',
753-
'Values': ['app']
754-
}
755-
],
756-
'SecurityGroupId': self.slurm_login_node_sg_id
757-
}
758763

759764
# Configure the /home mount from RES if /home not already configured
760765
home_mount_found = False

0 commit comments

Comments
 (0)