+class Interfaces(object):
+ @staticmethod
+ def primary_ip(name):
+ """primary_ip returns an interface's primary IP address.
+
+ This is the first IPv4 address returned by "ip addr show $name"
+ """
+ # TODO(quentin): The netifaces module is a pile of crappy C.
+ # Figure out a way to do this in native Python.
+ return ni.ifaddresses(name)[ni.AF_INET][0]['addr']
+
+ @staticmethod
+ def exists(name):
+ """exists checks if an interface exists.
+
+ Args:
+ name: Interface name
+ """
+ return os.path.exists("/sys/class/net/"+name)
+
+