Skip to content

Commit e9bbcd1

Browse files
Enrico Usaienrico-usai
authored andcommitted
Fix proxy support
+ Add proxy configuration parameter to boto clients for all the runtime python scripts + Add possibility to download a custom node package by a proxy Signed-off-by: Enrico Usai <[email protected]>
1 parent 469db54 commit e9bbcd1

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

files/default/attachVolume.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import urllib2
66
import boto3
77
import time
8+
import ConfigParser
9+
from botocore.config import Config
810

911

1012
def main():
@@ -34,8 +36,17 @@ def main():
3436
# List of available block devices after removing currently used block devices
3537
availableDevices = [a for a in blockDevices if a not in paths]
3638

39+
# Parse configuration file to read proxy settings
40+
config = ConfigParser.RawConfigParser()
41+
config.read('/etc/boto.cfg')
42+
proxy_config = Config()
43+
if config.has_option('Boto', 'proxy') and config.has_option('Boto', 'proxy_port'):
44+
proxy = config.get('Boto', 'proxy')
45+
proxy_port = config.get('Boto', 'proxy_port')
46+
proxy_config = Config(proxies={'https': "{}:{}".format(proxy, proxy_port)})
47+
3748
# Connect to AWS using boto
38-
ec2 = boto3.client('ec2', region_name=region)
49+
ec2 = boto3.client('ec2', region_name=region, config=proxy_config)
3950

4051
# Attach the volume
4152
dev = availableDevices[0].replace('xvd', 'sd')

files/default/ec2_dev_2_volid.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import syslog
77
import time
88
import boto3
9+
import ConfigParser
10+
from botocore.config import Config
911

1012

1113
def main():
@@ -35,8 +37,17 @@ def main():
3537
region = urllib2.urlopen("http://169.254.169.254/latest/meta-data/placement/availability-zone").read()
3638
region = region[:-1]
3739

40+
# Parse configuration file to read proxy settings
41+
config = ConfigParser.RawConfigParser()
42+
config.read('/etc/boto.cfg')
43+
proxy_config = Config()
44+
if config.has_option('Boto', 'proxy') and config.has_option('Boto', 'proxy_port'):
45+
proxy = config.get('Boto', 'proxy')
46+
proxy_port = config.get('Boto', 'proxy_port')
47+
proxy_config = Config(proxies={'https': "{}:{}".format(proxy, proxy_port)})
48+
3849
# Connect to AWS using boto
39-
ec2 = boto3.client('ec2', region_name=region)
50+
ec2 = boto3.client('ec2', region_name=region, config=proxy_config)
4051

4152
# Poll for blockdevicemapping
4253
devices = ec2.describe_instance_attribute(InstanceId=instanceId, Attribute='blockDeviceMapping').get('BlockDeviceMappings')

recipes/base_install.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,16 @@
117117
# Check whether install a custom cfncluster-node package or the standard one
118118
if !node['cfncluster']['custom_node_package'].nil? && !node['cfncluster']['custom_node_package'].empty?
119119
# Install custom cfncluster-node package
120-
execute "install cfncluster-node" do
121-
command "sudo pip uninstall --yes cfncluster-node &&" \
122-
"cd /tmp &&" \
123-
"curl -v -L -o /tmp/cfncluster-node.tgz #{node['cfncluster']['custom_node_package']} &&" \
124-
"tar -xzf /tmp/cfncluster-node.tgz &&" \
125-
"cd /tmp/cfncluster-node-* &&" \
126-
"sudo /usr/bin/python setup.py install"
120+
bash "install cfncluster-node" do
121+
cwd '/tmp'
122+
code <<-EOH
123+
source /tmp/proxy.sh
124+
sudo pip uninstall --yes cfncluster-node
125+
curl -v -L -o cfncluster-node.tgz #{node['cfncluster']['custom_node_package']}
126+
tar -xzf cfncluster-node.tgz
127+
cd cfncluster-node-*
128+
sudo /usr/bin/python setup.py install
129+
EOH
127130
end
128131
else
129132
# Install cfncluster-node package

0 commit comments

Comments
 (0)