70
70
71
71
# Note: this python script was initially developed with boto 2.13.3.
72
72
def botoVersionMismatch ():
73
- print 'WARNING: Unsupported boto version. Please upgrade boto to at least 2.13.x and try again.'
74
- print 'Comment this out to run anyway.'
75
- print 'Exiting.'
73
+ print ( 'WARNING: Unsupported boto version. Please upgrade boto to at least 2.13.x and try again.' )
74
+ print ( 'Comment this out to run anyway.' )
75
+ print ( 'Exiting.' )
76
76
sys .exit (1 )
77
77
78
78
if not 'AWS_ACCESS_KEY_ID' in os .environ :
79
- print 'ERROR: You must set AWS_ACCESS_KEY_ID in the environment.'
79
+ print ( 'ERROR: You must set AWS_ACCESS_KEY_ID in the environment.' )
80
80
sys .exit (1 )
81
81
82
82
if not 'AWS_SECRET_ACCESS_KEY' in os .environ :
83
- print 'ERROR: You must set AWS_SECRET_ACCESS_KEY in the environment.'
83
+ print ( 'ERROR: You must set AWS_SECRET_ACCESS_KEY in the environment.' )
84
84
sys .exit (1 )
85
85
86
86
if not 'AWS_SSH_PRIVATE_KEY_FILE' in os .environ :
87
- print 'ERROR: You must set AWS_SSH_PRIVATE_KEY_FILE in the environment.'
87
+ print ( 'ERROR: You must set AWS_SSH_PRIVATE_KEY_FILE in the environment.' )
88
88
sys .exit (1 )
89
89
90
90
publicFileName = 'nodes-public'
@@ -94,7 +94,7 @@ def botoVersionMismatch():
94
94
fpublic = open (publicFileName , 'w' )
95
95
fprivate = open (privateFileName , 'w' )
96
96
97
- print 'Using boto version' , boto .Version
97
+ print ( 'Using boto version' , boto .Version )
98
98
if True :
99
99
botoVersionArr = boto .Version .split ("." )
100
100
if (botoVersionArr [0 ] != 2 ):
@@ -106,7 +106,7 @@ def botoVersionMismatch():
106
106
boto .set_stream_logger ('h2o-ec2' )
107
107
ec2 = boto .ec2 .connect_to_region (regionName , debug = debug )
108
108
109
- print 'Launching' , numInstancesToLaunch , 'instances.'
109
+ print ( 'Launching' , numInstancesToLaunch , 'instances.' )
110
110
111
111
if spotBid is None :
112
112
reservation = ec2 .run_instances (
@@ -148,22 +148,22 @@ def botoVersionMismatch():
148
148
149
149
# unrecoverable error without increasing the spot bid
150
150
elif request .status .code == u'price-too-low' :
151
- print request .status .message
152
- print 'Cancelling Spot requests...'
151
+ print ( request .status .message )
152
+ print ( 'Cancelling Spot requests...' )
153
153
# get original request ids since some requests may have already been fulfilled
154
154
ec2 .cancel_spot_instance_requests (
155
155
request_ids = [request .id for request in spotRequests ],
156
156
)
157
157
158
- print 'Exiting...'
158
+ print ( 'Exiting...' )
159
159
sys .exit (1 )
160
160
161
- print request .id , request .status .message
161
+ print ( request .id , request .status .message )
162
162
163
- print '%s/%s requests fulfilled' % (len (fulfilled ), numInstancesToLaunch )
163
+ print ( '%s/%s requests fulfilled' % (len (fulfilled ), numInstancesToLaunch ) )
164
164
165
165
if requestIDs :
166
- print 'Waiting for remaining requests to be fulfilled...'
166
+ print ( 'Waiting for remaining requests to be fulfilled...' )
167
167
time .sleep (5 )
168
168
169
169
reservation = ec2 .get_all_instances (
@@ -173,51 +173,51 @@ def botoVersionMismatch():
173
173
instances = reservation .instances
174
174
175
175
for i , instance in enumerate (instances ):
176
- print 'Waiting for instance' , i + 1 , 'of' , numInstancesToLaunch , '...'
176
+ print ( 'Waiting for instance' , i + 1 , 'of' , numInstancesToLaunch , '...' )
177
177
instance .update ()
178
178
while instance .state != 'running' :
179
- print ' .'
179
+ print ( ' .' )
180
180
time .sleep (1 )
181
181
instance .update ()
182
- print ' instance' , i + 1 , 'of' , numInstancesToLaunch , 'is up.'
182
+ print ( ' instance' , i + 1 , 'of' , numInstancesToLaunch , 'is up.' )
183
183
name = instanceNameRoot + str (i )
184
184
instance .add_tag ('Name' , value = name )
185
185
186
- print
187
- print 'Creating output files: ' , publicFileName , privateFileName
188
- print
186
+ print ( "" )
187
+ print ( 'Creating output files: ' , publicFileName , privateFileName )
188
+ print ( "" )
189
189
190
190
for i , instance in enumerate (instances ):
191
191
instanceName = instance .tags .get ('Name' , '' )
192
192
193
- print 'Instance' , i + 1 , 'of' , numInstancesToLaunch
194
- print ' Name: ' , instanceName
195
- print ' PUBLIC: ' , instance .public_dns_name
196
- print ' PRIVATE:' , instance .private_ip_address
197
- print
193
+ print ( 'Instance' , i + 1 , 'of' , numInstancesToLaunch )
194
+ print ( ' Name: ' , instanceName )
195
+ print ( ' PUBLIC: ' , instance .public_dns_name )
196
+ print ( ' PRIVATE:' , instance .private_ip_address )
197
+ print ( "" )
198
198
fpublic .write (instance .public_dns_name + '\n ' )
199
199
fprivate .write (instance .private_ip_address + '\n ' )
200
200
201
201
fpublic .close ()
202
202
fprivate .close ()
203
203
204
- print 'Sleeping for 60 seconds for ssh to be available...'
204
+ print ( 'Sleeping for 60 seconds for ssh to be available...' )
205
205
time .sleep (60 )
206
206
207
207
d = os .path .dirname (os .path .realpath (__file__ ))
208
208
209
- print 'Testing ssh access...'
209
+ print ( 'Testing ssh access...' )
210
210
cmd = d + '/' + 'h2o-cluster-test-ssh.sh'
211
211
rv = os .system (cmd )
212
212
if rv != 0 :
213
- print 'Failed.'
213
+ print ( 'Failed.' )
214
214
sys .exit (1 )
215
215
216
- print
217
- print 'Distributing flatfile...'
216
+ print ( "" )
217
+ print ( 'Distributing flatfile...' )
218
218
cmd = d + '/' + 'h2o-cluster-distribute-flatfile.sh'
219
219
rv = os .system (cmd )
220
220
if rv != 0 :
221
- print 'Failed.'
221
+ print ( 'Failed.' )
222
222
sys .exit (1 )
223
223
# Distribute flatfile script already prints success when it completes.
0 commit comments