Removed dependence on REMOTE_HOST env variable and reverse DNS.
[invirt/packages/invirt-console.git] / server / usr / sbin / invirt-console-update
index e24a3ce..8da9bfb 100755 (executable)
@@ -3,9 +3,15 @@ import sys
 import os
 import subprocess
 
+from invirt.config import structs as config
+
 def main(args):
   contents = args[2]
-  hostname = os.environ['REMOTE_HOST'].lower()
+  host_addr = os.environ['REMOTE_ADDR']
+  for h in config.hosts:
+    if host_addr in h.internal_ips or host_addr == h.ip:
+      hostname = h.hostname
+      break
   f = file('/etc/conserver/conf.d/'+hostname, 'w')
   f.write(contents)
   f.close()