コード例 #1
0
    def get_version(self, *args):
        """
        参数输入要获取版本信息的软件,支持sysos,syskernel,drbd,linstor,targetcli,pacemaker,corosync
        返回数据的顺序与参数顺序一致
        :param args:
        :return:
        """
        result = []
        for ssh in self.conn.list_ssh:
            host = action.Host(ssh)
            result.append(host.get_hostname())
            for soft in args:
                if soft == 'sysos':
                    result.append(host.get_sys_version())
                elif soft == 'syskernel':
                    result.append(host.get_kernel_version())
                elif soft == 'drbd':
                    drbd = action.DRBD(ssh)
                    result.append(drbd.get_version())
                elif soft == 'linstor':
                    linstor = action.Linstor(ssh)
                    result.append(linstor.get_version())
                elif soft == 'targetcli':
                    targetcli = action.TargetCLI(ssh)
                    result.append(targetcli.get_version())
                elif soft == 'pacemaker':
                    pacemaker = action.Pacemaker(ssh)
                    result.append(pacemaker.get_version())
                elif soft == 'corosync':
                    corosync = action.Corosync(ssh)
                    result.append(corosync.get_version())

        for i in range(0, len(result), len(args) + 1):
            yield result[i:i + len(args) + 1]
コード例 #2
0
 def check_ssh_authorized(self):
     lst = []
     cluster_hosts = [node['hostname'] for node in self.cluster['node']]
     for ssh in self.list_ssh:
         lst.append(gevent.spawn(action.Host(ssh).check_ssh, cluster_hosts))
     gevent.joinall(lst)
     result = [job.value for job in lst]
     return result
コード例 #3
0
 def check_ssh_authorized(self):
     result_lst = []
     cluster_hosts = [
         node['hostname'] for node in self.conn.cluster['node']
     ]
     for ssh in self.conn.list_ssh:
         result = action.Host(ssh).check_ssh(cluster_hosts)
         result_lst.append(result)
     return result_lst
コード例 #4
0
 def check_hostname(self):
     lst = []
     for ssh, node in zip(self.list_ssh, self.cluster['node']):
         lst.append(
             gevent.spawn(
                 action.Host(ssh).check_hostname, node['hostname']))
     gevent.joinall(lst)
     result = [job.value for job in lst]
     return result
コード例 #5
0
 def modify_hostname(self):
     hosts_file = []
     for node in self.conn.cluster['node']:
         hosts_file.append({
             'ip': node['public_ip'],
             'hostname': node['hostname']
         })
     for ssh, node in zip(self.conn.list_ssh, self.conn.cluster['node']):
         executor = action.Host(ssh)
         executor.modify_hostname(node['hostname'])
         executor.modify_hostsfile('127.0.1.1', node['hostname'])
         for host in hosts_file:
             executor.modify_hostsfile(host['ip'], host['hostname'])
コード例 #6
0
    def get_all_service_status(self):
        result = []
        for ssh in self.conn.list_ssh:
            service = action.ServiceSet(ssh)
            host = action.Host(ssh)
            result.append(host.get_hostname())
            result.append(service.check_pacemaker())
            result.append(service.check_corosync())
            result.append(service.check_linstor_satellite())
            result.append(service.check_drbd())
            result.append(service.check_linstor_controller())

        for i in range(0, len(result), 6):
            yield result[i:i + 6]
コード例 #7
0
    def modify_hostname(self):
        lst = []
        hosts_file = []

        for node in self.cluster['node']:
            hosts_file.append({
                'ip': node['public_ip'],
                'hostname': node['hostname']
            })

        for ssh, node in zip(self.list_ssh, self.cluster['node']):
            executor = action.Host(ssh)
            lst.append(gevent.spawn(executor.modify_hostname,
                                    node['hostname']))
            lst.append(
                gevent.spawn(executor.modify_hostsfile, '127.0.1.1',
                             node['hostname']))
            for host in hosts_file:
                lst.append(
                    gevent.spawn(executor.modify_hostsfile, host['ip'],
                                 host['hostname']))

        gevent.joinall(lst)
コード例 #8
0
 def check_hostname(self):
     result_lst = []
     for ssh, node in zip(self.conn.list_ssh, self.conn.cluster['node']):
         result = action.Host(ssh).check_hostname(node['hostname'])
         result_lst.append(result)
     return result_lst