Skip to content

Commit 7f7973d

Browse files
author
Dougal Ballantyne
committed
Support for GovCloud, improved error messages parsing config.
1 parent 49bde0e commit 7f7973d

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
CHANGELOG
33
=========
44

5+
0.0.16
6+
======
7+
* feature:``cfncluster``: Support for GovCloud region
8+
* updates:``cli``: Improved error messages parsing config file
9+
510
0.0.15
611
======
712

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ everything is done using CloudFormation or resources within AWS.
88

99
### Installation
1010

11-
The current working version is cfncluster-0.0.15. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
11+
The current working version is cfncluster-0.0.16. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
1212

1313
#### Linux/OSX
1414

cli/cfncluster/cfnconfig.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ def __init__(self, args):
113113
try:
114114
self.key_name = __config.get(self.__cluster_section, 'key_name')
115115
if not self.key_name:
116-
raise Exception
116+
print("ERROR: key_name set in [%s] section but not defined." % self.__cluster_section)
117+
sys.exit(1)
117118
if self.__sanity_check:
118119
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
119120
'EC2KeyPair', self.key_name)
120121
except ConfigParser.NoOptionError:
121-
raise Exception
122+
print("ERROR: Missing key_name option in [%s] section." % self.__cluster_section)
123+
sys.exit(1)
122124
self.parameters.append(('KeyName', self.key_name))
123125

124126
# Determine the CloudFormation URL to be used
@@ -130,15 +132,21 @@ def __init__(self, args):
130132
self.template_url = __config.get(self.__cluster_section,
131133
'template_url')
132134
if not self.template_url:
133-
raise Exception
135+
print("ERROR: template_url set in [%s] section but not defined." % self.__cluster_section)
136+
sys.exit(1)
134137
if self.__sanity_check:
135138
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
136139
'URL', self.template_url)
137140
except ConfigParser.NoOptionError:
138141
if self.region == 'eu-central-1':
139-
self.template_url = ('https://s3.%s.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json' % (self.region, self.region, self.version))
142+
self.template_url = ('https://s3.%s.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json'
143+
% (self.region, self.region, self.version))
144+
elif self.region == 'us-gov-west-1':
145+
self.template_url = ('https://s3-%s.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json'
146+
% (self.region, self.region, self.version))
140147
else:
141-
self.template_url = ('https://s3.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json' % (self.region, self.version))
148+
self.template_url = ('https://s3.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json'
149+
% (self.region, self.version))
142150
except AttributeError:
143151
pass
144152

@@ -149,15 +157,18 @@ def __init__(self, args):
149157
# Dictionary list of all VPC options
150158
self.__vpc_options = dict(vpc_id=('VPCId','VPC'), master_subnet_id=('MasterSubnetId', 'VPCSubnet'),
151159
compute_subnet_cidr=('ComputeSubnetCidr',None),
152-
compute_subnet_id=('ComputeSubnetId', 'VPCSubnet'), use_public_ips=('UsePublicIps', None),
160+
compute_subnet_id=('ComputeSubnetId', 'VPCSubnet'), use_public_ips=('UsePublicIps',
161+
None),
153162
ssh_from=('SSHFrom', None))
154163

155164
# Loop over all VPC options and add define to parameters, raise Exception is defined but null
156165
for key in self.__vpc_options:
157166
try:
158167
__temp__ = __config.get(self.__vpc_section, key)
159168
if not __temp__:
160-
raise Exception
169+
print("ERROR: %s defined but not set in [%s] section"
170+
% (key, self.__vpc_section))
171+
sys.exit(1)
161172
if self.__sanity_check and self.__vpc_options.get(key)[1] is not None:
162173
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
163174
self.__vpc_options.get(key)[1],__temp__)
@@ -182,7 +193,9 @@ def __init__(self, args):
182193
try:
183194
__temp__ = __config.get(self.__cluster_section, key)
184195
if not __temp__:
185-
raise Exception
196+
print("ERROR: %s defined but not set in [%s] section"
197+
% (key, self.__cluster_section))
198+
sys.exit(1)
186199
if self.__sanity_check and self.__cluster_options.get(key)[1] is not None:
187200
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
188201
self.__cluster_options.get(key)[1],__temp__)
@@ -194,7 +207,9 @@ def __init__(self, args):
194207
try:
195208
self.__ebs_settings = __config.get(self.__cluster_section, 'ebs_settings')
196209
if not self.__ebs_settings:
197-
raise Exception
210+
print("ERROR: ebs_settings defined by not set in [%s] section"
211+
% self.__cluster_section)
212+
sys.exit(1)
198213
self.__ebs_section = ('ebs %s' % self.__ebs_settings)
199214
except ConfigParser.NoOptionError:
200215
pass
@@ -210,7 +225,9 @@ def __init__(self, args):
210225
try:
211226
__temp__ = __config.get(self.__ebs_section, key)
212227
if not __temp__:
213-
raise Exception
228+
print("ERROR: %s defined but not set in [%s] section"
229+
% (key, self.__ebs_section))
230+
sys.exit(1)
214231
if self.__sanity_check and self.__ebs_options.get(key)[1] is not None:
215232
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
216233
self.__ebs_options.get(key)[1],__temp__)
@@ -224,7 +241,9 @@ def __init__(self, args):
224241
try:
225242
self.__scaling_settings = __config.get(self.__cluster_section, 'scaling_settings')
226243
if not self.__scaling_settings:
227-
raise Exception
244+
print("ERROR: scaling_settings defined by not set in [%s] section"
245+
% self.__cluster_section)
246+
sys.exit(1)
228247
self.__scaling_section = ('scaling %s' % self.__scaling_settings)
229248
except ConfigParser.NoOptionError:
230249
pass
@@ -241,7 +260,9 @@ def __init__(self, args):
241260
try:
242261
__temp__ = __config.get(self.__scaling_section, key)
243262
if not __temp__:
244-
raise Exception
263+
print("ERROR: %s defined but not set in [%s] section"
264+
% (key, self.__scaling_section))
265+
sys.exit(1)
245266
if self.__sanity_check and self.__scaling_options.get(key)[1] is not None:
246267
config_sanity.check_resource(self.region,self.aws_access_key_id, self.aws_secret_access_key,
247268
self.__scaling_options.get(key)[1],__temp__)

cli/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def read(fname):
2020
return open(os.path.join(os.path.dirname(__file__), fname)).read()
2121

2222
console_scripts = ['cfncluster = cfncluster.cli:main']
23-
version = "0.0.99"
23+
version = "0.0.16"
2424
requires = ['boto>=2.34']
2525

2626
if sys.version_info[:2] == (2, 6):

0 commit comments

Comments
 (0)