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'
16 def __init__(self, conf, log):
17 super(DaisyInstaller, self).__init__(conf, log)
18 self.client = SSHClient(self.conf.installer.ip,
19 self.conf.installer.username,
22 self.controllers = list()
25 self.log.info('Setup Daisy installer start......')
27 self.key_file = self.get_ssh_key_from_installer()
28 self.controllers = self.get_controller_ips()
33 for server in self.servers:
36 def get_ssh_key_from_installer(self):
37 key_path = '/root/.ssh/id_dsa'
38 return self._get_ssh_key(self.client, key_path)
40 def get_controller_ips(self):
41 self.log.info('Get controller ips from Daisy installer......')
43 command = "source daisyrc_admin; " \
44 "daisy host-list | grep 'CONTROLLER_LB' | cut -d '|' -f 3 "
45 controller_names = self._run_cmd_remote(self.client, command)
47 [self.get_host_ip_from_hostname(controller)
48 for controller in controller_names]
49 self.log.info('Get controller_ips:%s from Daisy installer'
53 def get_host_ip_from_hostname(self, hostname):
54 self.log.info('Get host ip from host name......')
56 hostip = hostname.split('-')[1:]
57 host_ip = '.'.join(hostip)
58 self.log.info('Get host_ip:%s from host_name:%s'
59 % (host_ip, hostname))