Merge "Add doctor-test package"
[doctor.git] / tests / installer / local.py
index e156ac1..dcdf41e 100644 (file)
@@ -8,14 +8,15 @@
 ##############################################################################
 import os
 import shutil
+import subprocess
 
 from installer.base import BaseInstaller
-from utils import load_json_file
-from utils import write_json_file
+from common.utils import load_json_file
+from common.utils import write_json_file
 
 
 class LocalInstaller(BaseInstaller):
-    computer_user_name = 'root'
+    node_user_name = 'root'
 
     nova_policy_file = '/etc/nova/policy.json'
     nova_policy_file_backup = '%s%s' % (nova_policy_file, '.bak')
@@ -34,7 +35,18 @@ class LocalInstaller(BaseInstaller):
 
     def get_ssh_key_from_installer(self):
         self.log.info('Assuming SSH keys already exchanged with computer for local installer type')
-        return
+        return None
+
+    def get_host_ip_from_hostname(self, hostname):
+        self.log.info('Get host ip from host name in local installer......')
+
+        cmd = "getent hosts %s | awk '{ print $1 }'" % (hostname)
+        server = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
+        stdout, stderr = server.communicate()
+        host_ip = stdout.strip()
+
+        self.log.info('Get host_ip:%s from host_name:%s in local installer' % (host_ip, hostname))
+        return host_ip
 
     def set_apply_patches(self):
         self._set_nova_policy()