Example #1
0
 def clear_crm_res(self, node):
     if node:
         for ssh, n in zip(self.conn.list_ssh, self.conn.cluster['node']):
             if node == n['hostname']:
                 pacemaker = action.Pacemaker(ssh)
     else:
         pacemaker = action.Pacemaker()
     pacemaker.clear_crm_res()
Example #2
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]
Example #3
0
 def check_packmaker(self):
     # cluster_name = self.conn.cluster['cluster'] // cluster name 缺少日期,不进行判断
     packmaker = action.Pacemaker()
     if packmaker.check_crm_conf():
         return [True] * len(self.conn.list_ssh)
     else:
         return [False] * len(self.conn.list_ssh)
Example #4
0
 def packmaker_conf_change(self):
     cluster_name = self.conn.conf_file.get_cluster_name()
     packmaker = action.Pacemaker()
     packmaker.modify_cluster_name(cluster_name)
     packmaker.modify_policy()
     packmaker.modify_stickiness()
     packmaker.modify_stonith_enabled()
Example #5
0
 def check_packmaker(self):
     cluster_name = self.cluster['cluster']
     packmaker = action.Pacemaker()
     if packmaker.check_crm_conf(cluster_name):
         return [True] * len(self.list_ssh)
     else:
         return [False] * len(self.list_ssh)
Example #6
0
 def clear_crm_node(self):
     for ssh, local_node in zip(self.conn.list_ssh,
                                self.conn.cluster['node']):
         pacemaker = action.Pacemaker(ssh)
         pacemaker.restart()
         time.sleep(2)
         for node in self.conn.cluster['node']:
             if local_node['hostname'] != node['hostname']:
                 pacemaker.clear_crm_node(node['hostname'])
Example #7
0
    def packmaker_conf_change(self):
        cluster_name = self.conf_file.get_cluster_name()
        packmaker = action.Pacemaker()

        lst = []
        lst.append(gevent.spawn(packmaker.modify_cluster_name, cluster_name))
        lst.append(gevent.spawn(packmaker.modify_policy))
        lst.append(gevent.spawn(packmaker.modify_stickiness))
        lst.append(gevent.spawn(packmaker.modify_stonith_enabled))

        gevent.joinall(lst)
        self.conf_file.cluster['cluster'] = cluster_name
        self.conf_file.update_yaml()
Example #8
0
 def build_drbd_attr(self, args):
     print('*start*')
     pcm = action.Pacemaker()
     pcm.config_drbd_attr()
     print('*success*')
Example #9
0
 def uninstall_pacemaker(self):
     for ssh in self.conn.list_ssh:
         handler = action.Pacemaker(ssh)
         handler.uninstall()
Example #10
0
 def pacmaker_conf_change(self):
     pacemaker = action.Pacemaker()
     pacemaker.modify_policy()
     pacemaker.modify_stickiness()
     pacemaker.modify_stonith_enabled()
Example #11
0
 def modify_cluster_name(self, name=None):
     if not name:
         name = self.conn.conf_file.get_cluster_name()
     pacemaker = action.Pacemaker()
     pacemaker.modify_cluster_name(name)