From 896963c68491a6318d31e601d89d966599bd6046 Mon Sep 17 00:00:00 2001 From: Kushal Das Date: Aug 06 2015 12:21:45 +0000 Subject: Adds find_instance_ip function to find the IP of an instance. --- diff --git a/computer/virt.py b/computer/virt.py index a963c37..bc13034 100644 --- a/computer/virt.py +++ b/computer/virt.py @@ -76,4 +76,13 @@ def setup_instance(instance_name, storage_path, ram=1024, vcpus=1): # When we are here, means the system booted properly. return True - +def find_instance_ip(instance_name): + """ + Finds the ip of the given instance + :param instance_name: Name of the instance. + :return: IP, or None + """ + # Now let us find the ip of the instance. + cmd = 'virt-addr {0}'.format(instance_name) + out, err, ret_code = system(cmd) + return out.strip().decode("utf-8")