Authored by qinchao

dnspod切换

@@ -67,11 +67,6 @@ public class CommodUtil { @@ -67,11 +67,6 @@ public class CommodUtil {
67 public static final String LIMIT_SWITCH_SH = "nginx_limit.sh"; 67 public static final String LIMIT_SWITCH_SH = "nginx_limit.sh";
68 68
69 69
70 - /**  
71 - * dns查看  
72 - */  
73 - public static final String DNS_POD = "switch_dnspod.sh";  
74 -  
75 public static String exe(String commond, String param) { 70 public static String exe(String commond, String param) {
76 Process process = null; 71 Process process = null;
77 StringBuilder sb = new StringBuilder(); 72 StringBuilder sb = new StringBuilder();
@@ -3,6 +3,7 @@ package com.monitor.switchs; @@ -3,6 +3,7 @@ package com.monitor.switchs;
3 import com.model.HostInfo; 3 import com.model.HostInfo;
4 import com.monitor.model.response.BaseResponse; 4 import com.monitor.model.response.BaseResponse;
5 import com.monitor.mysql.mapper.HostInfoMapper; 5 import com.monitor.mysql.mapper.HostInfoMapper;
  6 +import com.yoho.ops.cmdb.qcloud.util.QcloudDnspotUtil;
6 import org.apache.commons.collections.CollectionUtils; 7 import org.apache.commons.collections.CollectionUtils;
7 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -162,7 +163,7 @@ public class LuaSwitchCtrl { @@ -162,7 +163,7 @@ public class LuaSwitchCtrl {
162 @ResponseBody 163 @ResponseBody
163 public BaseResponse dnsViewConf() { 164 public BaseResponse dnsViewConf() {
164 try{ 165 try{
165 - String result = exeDns("status"); 166 + String result = QcloudDnspotUtil.recordList();
166 return new BaseResponse(200, "success", result); 167 return new BaseResponse(200, "success", result);
167 }catch (Exception e){ 168 }catch (Exception e){
168 logger.error(" LuaSwitchCtrl - dnsViewConf - 1 - error" , e); 169 logger.error(" LuaSwitchCtrl - dnsViewConf - 1 - error" , e);
@@ -170,18 +171,6 @@ public class LuaSwitchCtrl { @@ -170,18 +171,6 @@ public class LuaSwitchCtrl {
170 } 171 }
171 } 172 }
172 173
173 - /**  
174 - * 执行命令  
175 - *  
176 - * @param commod  
177 - * @return  
178 - */  
179 - public String exeDns(String commod) {  
180 - StringBuilder commond = new StringBuilder();  
181 - commond.append(" " + commod);  
182 - return CommodUtil.exeDns(CommodUtil.DNS_POD, commond.toString());  
183 - }  
184 -  
185 174
186 /** 175 /**
187 * 切换dns配置,是基于api的切换,直接切换 176 * 切换dns配置,是基于api的切换,直接切换
@@ -199,12 +188,14 @@ public class LuaSwitchCtrl { @@ -199,12 +188,14 @@ public class LuaSwitchCtrl {
199 }else if("toQcloud".equals(cloudName)){ 188 }else if("toQcloud".equals(cloudName)){
200 cloud = "qcloud"; 189 cloud = "qcloud";
201 } 190 }
  191 +
202 //如果切向双云,则默认到aws 192 //如果切向双云,则默认到aws
203 if("mix".equals(cloudName)){ 193 if("mix".equals(cloudName)){
204 cloudName = "toAws"; 194 cloudName = "toAws";
205 } 195 }
  196 +
206 //1:切dns 197 //1:切dns
207 - String result = exeDns(cloudName); 198 + String result = QcloudDnspotUtil.recordModify(cloudName);
208 //2:切 dns_resolver_worker.lua -> context.cloud_flag 199 //2:切 dns_resolver_worker.lua -> context.cloud_flag
209 viewToChangeLuaConf(cloud, request); 200 viewToChangeLuaConf(cloud, request);
210 switchConf(request); 201 switchConf(request);