예제 #1
0
파일: ajax.php 프로젝트: hshoghi/cms
     $cluster = $params['a'];
     $conninfo = $params['b'];
     $id = $params['c'];
     $json = array();
     #$repmgr->add_soft has all these checks
     #but it does not give detailed error output
     #we need these details for our interface
     if (!is_numeric($id)) {
         $json['error'] = "bad id";
     }
     $rs = $db->Execute("select count(*) as count from repmgr_{$repmgr_cluster_name}.repl_nodes where id = {$id}");
     if ($rs->Fields('count') > 0) {
         $json['error'] = 'that id already exists';
     }
     if (!$json['error']) {
         $json[$soft = $repmgr->add_soft($cluster, $conninfo, $id) ? 'success' : 'error'] = $soft ? true : 'query_failure';
     }
     echo json_encode($json);
     break;
 case 'drop_soft':
     $node = $params['a'];
     $json = array();
     $json[$repmgr->drop_soft($node) ? 'success' : 'error'] = true;
     echo json_encode($json);
     break;
 case 'drop_hard':
     $node = $params['a'];
     $json = array('success' => $repmgr->stop_replication($node));
     echo json_encode($json);
     break;
 case 'cleanup':