public function getDiffInfoAction() { $main_buss_id = $this->getRequest("main_buss_id", ""); $path = trim($this->getRequest("path", ""), "/"); $idc = $this->getRequest("idc", ""); // 1. parameter null if ($path === "" || $main_buss_id === "" || $idc === "") { $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_BAD_ARGS); QconfMgrLog::err(__FILE__, __LINE__, "parameter 'main_buss_id', 'path' or 'idc' is null!"); echo json_encode($res); return; } // 2. check node exist $path = "/" . $path; $node = NodeServ::getNodeByNodeWhole($path, $main_buss_id); if ($node === FALSE) { $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_NODE_NOT_EXIST); QconfMgrLog::err(__FILE__, __LINE__, "node({$path}) with main_buss_id({$main_buss_id}) not exist!"); echo json_encode($res); return; } $node_whole = $node["node_whole"]; $main_buss_id = $node["main_buss_id"]; // 3. idc validation $cur_idcs = $node["idc"]; $check_res = self::idcValidation($idc, $cur_idcs); if ($check_res["errno"] != "0") { echo json_encode($check_res); return; } // 4. get snapshot content $snapshot_content = SnapShotUtil::getSnapShotContent($main_buss_id, $node_whole); if ($snapshot_content === FALSE) { $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_SNAPSHOT_MODULE_FAILED); QconfMgrLog::err(__FILE__, __LINE__, "failed to get snapshot by node_whole({$node_whole}), main_buss_id({$main_buss_id})"); echo json_encode($res); return; } // 5.add current value into content if (!array_key_exists($idc, $snapshot_content)) { $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_SNAPSHOT_IDC_NOT_EXIST); QconfMgrLog::err(__FILE__, __LINE__, "snapshot of node_whole({$node_whole}), main_buss_id({$main_buss_id}) do not exist on idc({$idc}) "); echo json_encode($res); return; } $result_idc = $snapshot_content[$idc]; if (!array_key_exists("conf", $result_idc) || !array_key_exists("serv", $result_idc)) { $res = InfoDescUtil::getErrorMsg(InfoDescUtil::ERR_SNAPSHOT_FILE_ERROR); QconfMgrLog::err(__FILE__, __LINE__, "snapshot error of node_whole({$node_whole}), main_buss_id({$main_buss_id})"); echo json_encode($res); return; } $idc_host = ZkConf::getZkHost($idc); $zk_web = new QconfZkWebBase(Log::INFO); $zk_web->connect($idc_host); $result_conf = $result_idc["conf"]; $final_conf = array(); foreach ($result_conf as $key => $value) { $get_conf = NodeController::getConfWithLink($zk_web, $key, $idc, $cur_val); if ($get_conf != InfoDescUtil::QCONF_OK) { $res = InfoDescUtil::getErrorMsg($get_conf); $res["data"] .= $idc; echo json_encode($res); return; } if ($cur_val === $value) { continue; } $value_cmp["path"] = $key; $value_cmp["cur"] = $cur_val; $value_cmp["snp"] = $value; $final_conf[] = $value_cmp; } $result_serv = $result_idc["serv"]; $final_serv = array(); foreach ($result_serv as $key => $service) { $get_service = ServiceController::getServicesAndStatusWithLink($zk_web, $key, $idc, $cur_service); if ($get_service != InfoDescUtil::QCONF_OK) { $res = InfoDescUtil::getErrorMsg($get_service); $res["data"] .= $idc; echo json_encode($res); return; } if ($cur_service === $service) { continue; } $hosts_cmp["path"] = $key; $hosts_cmp["cur"] = $cur_service; $hosts_cmp["snp"] = $service; $final_serv[] = $hosts_cmp; } $final_idc["conf"] = $final_conf; $final_idc["serv"] = $final_serv; $final["info"] = $final_idc; $res = array("errno" => "0", "errmsg" => "", "data" => $final); $json = json_encode($res); echo $json; return; }