avoid iterationa nd use search option in nova

parent 474d9a9f
...@@ -93,16 +93,17 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None) ...@@ -93,16 +93,17 @@ def actionIDS(start_response, cmd, name, vlan, tunid, switchid=None, ryuip=None)
credentials = get_nova_credentials_v2() credentials = get_nova_credentials_v2()
nova_client = Client(**credentials) nova_client = Client(**credentials)
server_list = nova_client.servers.list()
server_list = nova_client.servers.list(search_opts={"name": name})
ids = None
for server in server_list: for server in server_list:
if server.name == name: if server.name == name:
ids = server ids = server
break; break;
else:
print "No IDS Found" if ids is None:
sys.exit(0) print "No IDS found"
break; return;
ids_dict = vars(ids); ids_dict = vars(ids);
network_info = ids_dict['addresses'] network_info = ids_dict['addresses']
......
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