Skip to content

Commit 763e87d

Browse files
Rexrexcsn
authored andcommitted
Change nfs export to work with VPC containing multiple CIDR blocks
* Changed from getting vpc-ipv4-cidr-block, which only returns the first CIDR block, to getting vpc-ipv4-cidr-blocks, which returns all CIDR blocks for a VPC, from metadata call. * Changed all nfs export to export to all CIDR blocks in a VPC Signed-off-by: Rex <[email protected]>
1 parent e6e4e95 commit 763e87d

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

libraries/helpers.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ def get_1st_partition(device)
9595
end
9696

9797
#
98-
# Get vpc-ipv4-cidr-block
98+
# Get vpc-ipv4-cidr-blocks
9999
#
100-
def get_vpc_ipv4_cidr_block(eth0_mac)
101-
uri = URI("http://169.254.169.254/latest/meta-data/network/interfaces/macs/#{eth0_mac.downcase}/vpc-ipv4-cidr-block")
100+
def get_vpc_ipv4_cidr_blocks(eth0_mac)
101+
uri = URI("http://169.254.169.254/latest/meta-data/network/interfaces/macs/#{eth0_mac.downcase}/vpc-ipv4-cidr-blocks")
102102
res = Net::HTTP.get_response(uri)
103-
vpc_ipv4_cidr_block = res.body if res.code == '200'
104-
105-
vpc_ipv4_cidr_block
103+
vpc_ipv4_cidr_blocks = res.body if res.code == '200'
104+
# Parse into array
105+
vpc_ipv4_cidr_blocks = vpc_ipv4_cidr_blocks.split("\n")
106+
vpc_ipv4_cidr_blocks
106107
end
107108

108109
def get_instance_type()

recipes/_master_base_config.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
end
2929

3030
# Get VPC CIDR
31-
node.default['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block'] = get_vpc_ipv4_cidr_block(node['macaddress'])
31+
node.default['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks'] = get_vpc_ipv4_cidr_blocks(node['macaddress'])
3232

3333
# Parse shared directory info and turn into an array
3434
shared_dir_array = node['cfncluster']['cfn_shared_dir'].split(',')
@@ -119,22 +119,22 @@
119119

120120
# Export shared dir
121121
nfs_export shared_dir_array[index] do
122-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
122+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
123123
writeable true
124124
options ['no_root_squash']
125125
end
126126
end
127127

128128
# Export /home
129129
nfs_export "/home" do
130-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
130+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
131131
writeable true
132132
options ['no_root_squash']
133133
end
134134

135135
# Export /opt/intel if it exists
136136
nfs_export "/opt/intel" do
137-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
137+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
138138
writeable true
139139
options ['no_root_squash']
140140
only_if { ::File.directory?("/opt/intel") }

recipes/_master_sge_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Export /opt/sge
1919
nfs_export "/opt/sge" do
20-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
20+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
2121
writeable true
2222
options ['no_root_squash']
2323
end

recipes/_master_slurm_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Export /opt/slurm
1919
nfs_export "/opt/slurm" do
20-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
20+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
2121
writeable true
2222
options ['no_root_squash']
2323
end

recipes/setup_raid_on_master.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
# Export RAID directory via nfs
114114
nfs_export raid_shared_dir do
115-
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-block']
115+
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']
116116
writeable true
117117
options ['no_root_squash']
118118
end

0 commit comments

Comments
 (0)