1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from doctor_tests.common.utils import SSHClient
10 from doctor_tests.installer.base import BaseInstaller
13 class DaisyInstaller(BaseInstaller):
14 node_user_name = 'root'
15 installer_username = 'root'
17 def __init__(self, conf, log):
18 super(DaisyInstaller, self).__init__(conf, log)
19 self.client = SSHClient(self.conf.installer.ip,
20 self.installer_username,
23 self.controllers = list()
26 self.log.info('Setup Daisy installer start......')
28 self.key_file = self.get_ssh_key_from_installer()
29 self.controllers = self.get_controller_ips()
34 for server in self.servers:
37 def get_ssh_key_from_installer(self):
38 key_path = '/root/.ssh/id_dsa'
39 return self._get_ssh_key(self.client, key_path)
41 def get_controller_ips(self):
42 self.log.info('Get controller ips from Daisy installer......')
44 command = "source daisyrc_admin; " \
45 "daisy host-list | grep 'CONTROLLER_LB' | cut -d '|' -f 3 "
46 controller_names = self._run_cmd_remote(self.client, command)
48 [self.get_host_ip_from_hostname(controller)
49 for controller in controller_names]
50 self.log.info('Get controller_ips:%s from Daisy installer'
54 def get_host_ip_from_hostname(self, hostname):
55 self.log.info('Get host ip from host name......')
57 hostip = hostname.split('-')[1:]
58 host_ip = '.'.join(hostip)
59 self.log.info('Get host_ip:%s from host_name:%s'
60 % (host_ip, hostname))