Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cjdrake/elasticluster int…
Browse files Browse the repository at this point in the history
…o cjdrake-master

Conflicts:
	elasticluster/subcommands.py
  • Loading branch information
nicolasbaer committed May 30, 2015
2 parents 9b19996 + 45175b8 commit f9ad3ac
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions elasticluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def setup(self):
try:
# setup the cluster using the setup provider
ret = self._setup_provider.setup_cluster(self)
except Exception, e:
except Exception as e:
log.error(
"the setup provider was not able to setup the cluster, "
"but the cluster is running by now. Setup provider error "
Expand All @@ -769,7 +769,7 @@ def update(self):
for node in self.get_all_nodes():
try:
node.update_ips()
except InstanceError, ex:
except InstanceError as ex:
log.warning("Ignoring error updating information on node %s: %s",
node, str(ex))
self.repository.save_or_update(self)
Expand Down Expand Up @@ -890,7 +890,7 @@ def is_alive(self):
self.instance_id)
running = self._cloud_provider.is_instance_running(
self.instance_id)
except Exception, ex:
except Exception as ex:
log.debug("Ignoring error while looking for vm id %s: %s",
self.instance_id, str(ex))
if running:
Expand Down Expand Up @@ -951,10 +951,10 @@ def connect(self, keyfile=None):
cluster_changed = True
# Connection successful.
return ssh
except socket.error, ex:
except socket.error as ex:
log.debug("Host %s (%s) not reachable: %s.",
self.name, ip, ex)
except paramiko.SSHException, ex:
except paramiko.SSHException as ex:
log.debug("Ignoring error %s connecting to %s",
str(ex), self.name)

Expand Down
16 changes: 8 additions & 8 deletions elasticluster/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def create_cloud_provider(self, cluster_template):
provider = GoogleCloudProvider
else:
raise Invalid("Invalid provider '%s' for cluster '%s'"% (conf['provider'], cluster_template))
except ImportError, ex:
except ImportError as ex:
raise Invalid("Unable to load provider '%s': %s" % (conf['provider'], ex))

providerconf = conf.copy()
Expand Down Expand Up @@ -643,33 +643,33 @@ def read_config(self):
try:
values['setup'] = dict(self.conf[setup_name])
self.schemas['setup'](values['setup'])
except KeyError, ex:
except KeyError as ex:
errors.add(
"cluster `%s` setup section `%s` does not exists" % (
cluster, setup_name))
except MultipleInvalid, ex:
except MultipleInvalid as ex:
for error in ex.errors:
errors.add(error)

try:
values['login'] = dict(self.conf[login_name])
self.schemas['login'](values['login'])
except KeyError, ex:
except KeyError as ex:
errors.add(
"cluster `%s` login section `%s` does not exists" % (
cluster, login_name))
except MultipleInvalid, ex:
except MultipleInvalid as ex:
errors.add(Invalid("Error in login section `%s`: %s" % (
login_name, str.join(', ', [str(e) for e in ex.errors]))))

try:
values['cloud'] = dict(self.conf[cloud_name])
self.schemas['cloud'](values['cloud'])
except KeyError, ex:
except KeyError as ex:
errors.add(
"cluster `%s` cloud section `%s` does not exists" % (
cluster, cloud_name))
except MultipleInvalid, ex:
except MultipleInvalid as ex:
for error in ex.errors:
errors.add(Invalid("section %s: %s" % (cloud_name, error)))

Expand Down Expand Up @@ -698,7 +698,7 @@ def read_config(self):
name, str.join(", ", [str(e) for e in errors.errors])))
else:
conf_values[name] = values
except KeyError, ex:
except KeyError as ex:
errors.add("Error in section `%s`" % cluster)

# FIXME: do we really need to raise an exception if we cannot
Expand Down
2 changes: 1 addition & 1 deletion elasticluster/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def pre_run(self):
# directory if we can.
try:
os.makedirs(self.params.storage)
except OSError, ex:
except OSError as ex:
sys.stderr.write("Unable to create storage directory: "
"%s\n" % (str(ex)))
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion elasticluster/providers/ansible_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def cleanup(self, cluster):
if self._storage_path_tmp:
if len(os.listdir(self._storage_path)) == 0:
shutil.rmtree(self._storage_path)
except OSError, ex:
except OSError as ex:
log.warning(
"AnsibileProvider: Ignoring error while deleting "
"inventory file %s: %s", inventory_path, ex)
Expand Down
8 changes: 4 additions & 4 deletions elasticluster/providers/ec2_boto.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def start_instance(self, key_name, public_key_path, private_key_path,
image_id, key_name=key_name, security_groups=security_groups,
instance_type=flavor, user_data=image_userdata,
network_interfaces=interfaces)
except Exception, ex:
except Exception as ex:
log.error("Error starting instance: %s", ex)
if "TooManyInstances" in ex:
raise ClusterError(ex)
Expand Down Expand Up @@ -290,7 +290,7 @@ def _allocate_address(self, instance):
if not free_addresses:
try:
address = connection.allocate_address()
except Exception, ex:
except Exception as ex:
log.error("Unable to allocate a public IP address to instance `%s`",
instance.id)
return None
Expand All @@ -299,7 +299,7 @@ def _allocate_address(self, instance):
address = free_addresses.pop()
instance.use_ip(address)
return address.public_ip
except Exception, ex:
except Exception as ex:
log.error("Unable to associate IP address %s to instance `%s`",
address, instance.id)
return None
Expand Down Expand Up @@ -395,7 +395,7 @@ def _check_keypair(self, name, public_key_path, private_key_path):
"Please specify a valid RSA key.")

connection.import_key_pair(name, key_material)
except Exception, ex:
except Exception as ex:
log.error(
"Could not import key `%s` with name `%s` to `%s`",
name, public_key_path, self._url)
Expand Down
2 changes: 1 addition & 1 deletion elasticluster/providers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _check_keypair(self, name, public_key_path, private_key_path):
key_material = f.read()
try:
self.client.keypairs.create(name, key_material)
except Exception, ex:
except Exception as ex:
log.error(
"Could not import key `%s` with name `%s` to `%s`",
name, public_key_path, self._os_auth_url)
Expand Down
24 changes: 12 additions & 12 deletions elasticluster/subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def pre_run(self):
def cluster_summary(cluster):
try:
frontend = cluster.get_frontend_node().name
except NodeNotFound, ex:
except NodeNotFound as ex:
frontend = 'unknown'
log.error("Unable to get information on the frontend node: "
"%s", str(ex))
Expand Down Expand Up @@ -185,7 +185,7 @@ def execute(self):
try:
cluster = configurator.create_cluster(
cluster_template, cluster_name)
except ConfigurationError, e:
except ConfigurationError as e:
log.error("Starting cluster %s: %s\n" % (cluster_template, e))
return

Expand Down Expand Up @@ -248,7 +248,7 @@ def execute(self):
include_config_dirs=True)
try:
cluster = configurator.load_cluster(cluster_name)
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Stopping cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -328,7 +328,7 @@ def execute(self):
try:
cluster = configurator.load_cluster(cluster_name)
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Listing nodes from cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -432,7 +432,7 @@ def execute(self):
try:
cluster = configurator.load_cluster(cluster_name)
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Error loading cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -542,7 +542,7 @@ def execute(self):
print("%s nodes: %d" % (
nodekind,
len(cluster.nodes[nodekind])))
except ConfigurationError, ex:
except ConfigurationError as ex:
log.error("unable to load cluster `%s`: %s", template, ex)


Expand Down Expand Up @@ -584,7 +584,7 @@ def execute(self):
cluster = configurator.load_cluster(cluster_name)
if self.params.update:
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Listing nodes from cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -626,7 +626,7 @@ def execute(self):
try:
cluster = configurator.load_cluster(cluster_name)
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Setting up cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -669,7 +669,7 @@ def execute(self):
try:
cluster = configurator.load_cluster(cluster_name)
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Setting up cluster %s: %s\n" %
(cluster_name, ex))
return
Expand All @@ -693,7 +693,7 @@ def execute(self):
ssh.close()
cluster.repository.save_or_update(cluster)

except NodeNotFound, ex:
except NodeNotFound as ex:
log.error("Unable to connect to the frontend node: %s" % str(ex))
sys.exit(1)
host = frontend.connection_ip()
Expand Down Expand Up @@ -740,7 +740,7 @@ def execute(self):
try:
cluster = configurator.load_cluster(cluster_name)
cluster.update()
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Setting up cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down Expand Up @@ -793,7 +793,7 @@ def execute(self):
cluster_name = self.params.cluster
try:
cluster = configurator.load_cluster(cluster_name)
except (ClusterNotFound, ConfigurationError), ex:
except (ClusterNotFound, ConfigurationError) as ex:
log.error("Listing nodes from cluster %s: %s\n" %
(cluster_name, ex))
return
Expand Down

0 comments on commit f9ad3ac

Please sign in to comment.