+fqdn = os.uname()[1]
+internal_ip = None
+# This hack is necessary because cfg.hosts is an array rather than a dict.
+for host in cfg.hosts:
+ if host.hostname == fqdn:
+ internal_ip = host.internal_ip
+ break
+
+class xend_template_exception(Exception): pass
+if internal_ip is None:
+ raise xend_template_exception('Could not find an internal IP in the configuration for host %s' % fqdn)