Commit e11537cd authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Fix type error

parent 0e560529
...@@ -81,17 +81,18 @@ def get_resource(name, value, for_update=False): ...@@ -81,17 +81,18 @@ def get_resource(name, value, for_update=False):
else: else:
capital_name = name.capitalize() capital_name = name.capitalize()
if name in ["server", "network", "port"]: if isinstance(value, basestring) and name in ["server", "network", "port"]:
try: if value.startswith(settings.BACKEND_PREFIX_ID):
if value.startswith(settings.BACKEND_PREFIX_ID): try:
if name == "server": if name == "server":
value = id_from_instance_name(value) value = id_from_instance_name(value)
elif name == "network": elif name == "network":
value = id_from_network_name(value) value = id_from_network_name(value)
elif name == "port": elif name == "port":
value = id_from_nic_name(value) value = id_from_nic_name(value)
except ValueError: except ValueError:
raise CommandError("Invalid {} ID: {}".format(capital_name, value)) raise CommandError("Invalid {} ID: {}".format(capital_name,
value))
if for_update: if for_update:
objects = objects.select_for_update() objects = objects.select_for_update()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment