Authored by xuhui

腾讯云运维系统-nginx切换添加入口切换

@@ -117,6 +117,14 @@ public class HttpUriContants { @@ -117,6 +117,14 @@ public class HttpUriContants {
117 public static final String VIEW_CURRENT_CONF = "/luaswitch/viewCurrentConf"; 117 public static final String VIEW_CURRENT_CONF = "/luaswitch/viewCurrentConf";
118 118
119 /** 119 /**
  120 + * nginx切换
  121 + * 之
  122 + * dnsswitch
  123 + */
  124 + public static final String NGINX_VIEW_DNS_CONF = "/luaswitch/dnsViewConf";
  125 + public static final String NGINX_SWITCH_DNS = "/luaswitch/dnsSwitchConf";
  126 +
  127 + /**
120 * lbswitch 128 * lbswitch
121 */ 129 */
122 public static final String VIEW_LB_CONF = "/lbswitch/viewConf"; 130 public static final String VIEW_LB_CONF = "/lbswitch/viewConf";
@@ -155,11 +163,11 @@ public class HttpUriContants { @@ -155,11 +163,11 @@ public class HttpUriContants {
155 public static final String GET_DEGRADE_FUNCTION = "/degrade/getInitInfo"; 163 public static final String GET_DEGRADE_FUNCTION = "/degrade/getInitInfo";
156 public static final String GET_DEGRADE_INFO = "/degrade/getList"; 164 public static final String GET_DEGRADE_INFO = "/degrade/getList";
157 public static final String EDIT_DEGRADE_INFO = "/degrade/change"; 165 public static final String EDIT_DEGRADE_INFO = "/degrade/change";
158 - 166 +
159 public static final String GET_HYSTRIX_FUNCTION = "/hystrixInfo/getInitInfo"; 167 public static final String GET_HYSTRIX_FUNCTION = "/hystrixInfo/getInitInfo";
160 public static final String GET_HYSTRIX_INFO = "/hystrixInfo/getList"; 168 public static final String GET_HYSTRIX_INFO = "/hystrixInfo/getList";
161 public static final String EDIT_HYSTRIX_INFO = "/hystrixInfo/change"; 169 public static final String EDIT_HYSTRIX_INFO = "/hystrixInfo/change";
162 - 170 +
163 public static final String GET_CACHE_FUNCTION = "/cacheInfo/getInitInfo"; 171 public static final String GET_CACHE_FUNCTION = "/cacheInfo/getInitInfo";
164 public static final String GET_CACHE_INFO = "/cacheInfo/getList"; 172 public static final String GET_CACHE_INFO = "/cacheInfo/getList";
165 public static final String EDIT_CACHE_INFO = "/cacheInfo/change"; 173 public static final String EDIT_CACHE_INFO = "/cacheInfo/change";
@@ -246,7 +254,7 @@ public class HttpUriContants { @@ -246,7 +254,7 @@ public class HttpUriContants {
246 public static final String INTERNAL_DOMAIN_REFRESH = "/internalDns/refresh"; 254 public static final String INTERNAL_DOMAIN_REFRESH = "/internalDns/refresh";
247 public static final String INTERNAL_DOMAIN_SELECTBYID = "/internalDns/selectById"; 255 public static final String INTERNAL_DOMAIN_SELECTBYID = "/internalDns/selectById";
248 public static final String INTERNAL_DOMAIN_HISTORY = "/internalDns/getHistory"; 256 public static final String INTERNAL_DOMAIN_HISTORY = "/internalDns/getHistory";
249 - 257 +
250 /** 258 /**
251 * 配置管理 259 * 配置管理
252 * 恶意请求ip 260 * 恶意请求ip
@@ -259,7 +267,7 @@ public class HttpUriContants { @@ -259,7 +267,7 @@ public class HttpUriContants {
259 public static final String GET_MALICIOUS_REMOVEIP = "/maliciousIp/removeIp"; 267 public static final String GET_MALICIOUS_REMOVEIP = "/maliciousIp/removeIp";
260 public static final String GET_MALICIOUS_IP_BL = "/maliciousIp/getIpsBL"; 268 public static final String GET_MALICIOUS_IP_BL = "/maliciousIp/getIpsBL";
261 public static final String GET_MALICIOUS_IP_CS = "/maliciousIp/getIpsCS"; 269 public static final String GET_MALICIOUS_IP_CS = "/maliciousIp/getIpsCS";
262 - 270 +
263 //告警组管理 271 //告警组管理
264 public static final String GET_ALARMGROUP_GET = "/alarmGroup/getAlarmGroup"; 272 public static final String GET_ALARMGROUP_GET = "/alarmGroup/getAlarmGroup";
265 public static final String GET_ALARMGROUP_ADD_OR_UPDATE = "/alarmGroup/addOrUpdateAlarmGroup"; 273 public static final String GET_ALARMGROUP_ADD_OR_UPDATE = "/alarmGroup/addOrUpdateAlarmGroup";
@@ -75,7 +75,45 @@ public class LuaSwitchCtrl { @@ -75,7 +75,45 @@ public class LuaSwitchCtrl {
75 @RequestMapping(value = "viewCurrentConf") 75 @RequestMapping(value = "viewCurrentConf")
76 @ResponseBody 76 @ResponseBody
77 public BaseResponse viewCurrentConf() { 77 public BaseResponse viewCurrentConf() {
78 - return httpRestClient.defaultGet(HttpUriContants.VIEW_CURRENT_CONF, BaseResponse.class, null); 78 + try{
  79 + return httpRestClient.defaultGet(HttpUriContants.VIEW_CURRENT_CONF, BaseResponse.class, null);
  80 + }catch (Exception e){
  81 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  82 + }
  83 + return null;
79 } 84 }
80 85
81 -} 86 +
  87 + /**
  88 + * 查看当前流量入口配置
  89 + *
  90 + * @return BaseResponse
  91 + */
  92 + @RequestMapping(value = "dnsViewCurrentConf")
  93 + @ResponseBody
  94 + public BaseResponse dnsViewCurrentConf(){
  95 + try{
  96 + return httpRestClient.defaultGet(HttpUriContants.NGINX_VIEW_DNS_CONF, BaseResponse.class, null);
  97 + }catch (Exception e){
  98 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  99 + }
  100 + return null;
  101 + }
  102 +
  103 + /**
  104 + * 当前流量入口切换
  105 + *
  106 + * @param cloudName toAws toQcloud
  107 + * @return BaseResponse
  108 + */
  109 + @RequestMapping(value = "dnsSwitchConf")
  110 + @ResponseBody
  111 + public BaseResponse dnsSwitchConf(String cloudName){
  112 + try{
  113 + return httpRestClient.defaultGet(HttpUriContants.NGINX_SWITCH_DNS+"?cloudName="+cloudName, BaseResponse.class, null);
  114 + }catch (Exception e){
  115 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  116 + }
  117 + return null;
  118 + }
  119 +}
@@ -69,7 +69,6 @@ public class TopoSwitchCtrl { @@ -69,7 +69,6 @@ public class TopoSwitchCtrl {
69 luaType = "aws"; 69 luaType = "aws";
70 } 70 }
71 } 71 }
72 -  
73 //nginx 72 //nginx
74 BaseResponse<Map<String, List<Map<String, Object>>>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_NGINX_CONF, new ParameterizedTypeReference<BaseResponse<Map<String, List<Map<String, Object>>>>>() { 73 BaseResponse<Map<String, List<Map<String, Object>>>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_NGINX_CONF, new ParameterizedTypeReference<BaseResponse<Map<String, List<Map<String, Object>>>>>() {
75 }, null); 74 }, null);
@@ -139,7 +138,6 @@ public class TopoSwitchCtrl { @@ -139,7 +138,6 @@ public class TopoSwitchCtrl {
139 }catch (Exception e){ 138 }catch (Exception e){
140 logger.error(" TopoSwitchCtrl - getNgixnStatus - https://dnsapi.cn/Record.Info - err", e); 139 logger.error(" TopoSwitchCtrl - getNgixnStatus - https://dnsapi.cn/Record.Info - err", e);
141 } 140 }
142 -  
143 resultMap.put("luaType", luaType); 141 resultMap.put("luaType", luaType);
144 resultMap.put("awsApiNginx", awsApiNginx); 142 resultMap.put("awsApiNginx", awsApiNginx);
145 resultMap.put("awsGrayNginx", awsGrayNginx); 143 resultMap.put("awsGrayNginx", awsGrayNginx);
  1 +package com.ui.ctrl.app;
  2 +
  3 +import com.ui.contants.HttpUriContants;
  4 +import com.ui.http.HttpRestClient;
  5 +import com.ui.model.BaseResponse;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Controller;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.ResponseBody;
  12 +import org.springframework.web.servlet.ModelAndView;
  13 +
  14 +import java.util.HashMap;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + * 中心入口切换
  19 + *
  20 + * @author bblu 2016-10-27
  21 + */
  22 +@Controller
  23 +@RequestMapping("app_luaswitch")
  24 +public class AppLuaSwitchCtrl {
  25 +
  26 + private Logger logger = LoggerFactory.getLogger(getClass());
  27 +
  28 + @Autowired
  29 + HttpRestClient httpRestClient;
  30 +
  31 + /**
  32 + * 展示当前配置
  33 + *
  34 + * @return ModelAndView
  35 + */
  36 + @RequestMapping(value = "toLuaSwitch")
  37 + public ModelAndView viewNginxConf() {
  38 + String response = httpRestClient.defaultGet(HttpUriContants.VIEW_LUA_CONF, String.class, null);
  39 + ModelAndView mdv = new ModelAndView("switch/luaSwitch");
  40 + mdv.addObject("conf", response);
  41 + return mdv;
  42 + }
  43 +
  44 + /**
  45 + * 展示修改后配置文件内容
  46 + *
  47 + * @param cloudName 目标中心名称
  48 + * @return BaseResponse
  49 + */
  50 + @RequestMapping(value = "viewToChangeLuaConf")
  51 + @ResponseBody
  52 + public BaseResponse viewToChangeLuaConf(String cloudName) {
  53 + Map<String, Object> map = new HashMap<>();
  54 + map.put("cloudName", cloudName);
  55 + return httpRestClient.defaultGet(HttpUriContants.VIEW_TOCHANGE_LUA_CONF, BaseResponse.class, map);
  56 + }
  57 +
  58 + /**
  59 + * 切换配置,并重启nginx
  60 + *
  61 + * @return BaseResponse
  62 + */
  63 + @RequestMapping(value = "switchConf")
  64 + @ResponseBody
  65 + public BaseResponse switchConf() {
  66 + Map<String, Object> map = new HashMap<>();
  67 + return httpRestClient.defaultGet(HttpUriContants.SWITCH_LUA, BaseResponse.class, map);
  68 + }
  69 +
  70 + /**
  71 + * 查看当前配置
  72 + *
  73 + * @return BaseResponse
  74 + */
  75 + @RequestMapping(value = "viewCurrentConf")
  76 + @ResponseBody
  77 + public BaseResponse viewCurrentConf() {
  78 + try{
  79 + return httpRestClient.defaultGet(HttpUriContants.VIEW_CURRENT_CONF, BaseResponse.class, null);
  80 + }catch (Exception e){
  81 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  82 + }
  83 + return null;
  84 + }
  85 +
  86 +
  87 + /**
  88 + * 查看当前流量入口配置
  89 + *
  90 + * @return BaseResponse
  91 + */
  92 + @RequestMapping(value = "dnsViewCurrentConf")
  93 + @ResponseBody
  94 + public BaseResponse dnsViewCurrentConf(){
  95 + try{
  96 + return httpRestClient.defaultGet(HttpUriContants.NGINX_VIEW_DNS_CONF, BaseResponse.class, null);
  97 + }catch (Exception e){
  98 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  99 + }
  100 + return null;
  101 + }
  102 +
  103 + /**
  104 + * 当前流量入口切换
  105 + *
  106 + * @param cloudName toAws toQcloud
  107 + * @return BaseResponse
  108 + */
  109 + @RequestMapping(value = "dnsSwitchConf")
  110 + @ResponseBody
  111 + public BaseResponse dnsSwitchConf(String cloudName){
  112 + try{
  113 + return httpRestClient.defaultGet(HttpUriContants.NGINX_SWITCH_DNS+"?cloudName="+cloudName, BaseResponse.class, null);
  114 + }catch (Exception e){
  115 + logger.error(" - LuaSwitchCtrl - viewCurrentConf - err ",e);
  116 + }
  117 + return null;
  118 + }
  119 +}
  1 +package com.ui.ctrl.app;
  2 +
  3 +import com.ui.contants.HttpUriContants;
  4 +import com.ui.http.HttpRestClient;
  5 +import com.ui.model.BaseResponse;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.core.ParameterizedTypeReference;
  10 +import org.springframework.stereotype.Controller;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.ResponseBody;
  13 +import org.springframework.web.servlet.ModelAndView;
  14 +
  15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +
  19 +/**
  20 + * nginx->gateway切换
  21 + *
  22 + * @author bblu 2016-10-27
  23 + */
  24 +@Controller
  25 +@RequestMapping("app_nginxswitch")
  26 +public class AppNginxSwitchCtrl {
  27 +
  28 + private Logger logger = LoggerFactory.getLogger(getClass());
  29 +
  30 + @Autowired
  31 + HttpRestClient httpRestClient;
  32 +
  33 + /**
  34 + * 展示当前配置
  35 + *
  36 + * @return ModelAndView
  37 + */
  38 + @RequestMapping(value = "toNginxSwitch")
  39 + public ModelAndView viewNginxConf() {
  40 + BaseResponse<Map<String, List<Map<String, Object>>>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_NGINX_CONF, new ParameterizedTypeReference<BaseResponse<Map<String, List<Map<String, Object>>>>>() {
  41 + }, null);
  42 + Map<String, List<Map<String, Object>>> map = response.getData();
  43 + ModelAndView mdv = new ModelAndView("switch/nginxSwitch");
  44 + mdv.addObject("awsList", map.get("awsList"));
  45 + mdv.addObject("qcloudList", map.get("qcloudList"));
  46 + return mdv;
  47 + }
  48 +
  49 + /**
  50 + * 修改配置,并重启nginx
  51 + *
  52 + * @param cloudName 源中心名称
  53 + * @return BaseResponse
  54 + */
  55 + @RequestMapping(value = "switchNginxConf")
  56 + @ResponseBody
  57 + public BaseResponse switchNginxConf(String cloudName) {
  58 + Map<String, String> map = new HashMap<>();
  59 + map.put("cloudName", cloudName);
  60 + return httpRestClient.defaultGet(HttpUriContants.SWITCH_NGINX, BaseResponse.class, map);
  61 + }
  62 +
  63 + /**
  64 + * 展示修改后配置文件内容
  65 + *
  66 + * @param cloudName 源中心名称
  67 + * @param target 目标中心名称
  68 + * @param onlineOrGray 线上/灰度切换
  69 + * @param noChangeIps 不变更配置的ip
  70 + * @return BaseResponse
  71 + */
  72 + @RequestMapping(value = "viewToChangeNginxConf")
  73 + @ResponseBody
  74 + public BaseResponse viewToChangeNginxConf(String cloudName, String target, String onlineOrGray, String noChangeIps) {
  75 + Map<String, String> map = new HashMap<>();
  76 + map.put("cloudName", cloudName);
  77 + map.put("target", target);
  78 + map.put("onlineOrGray", onlineOrGray);
  79 + map.put("ips", noChangeIps);
  80 + return httpRestClient.defaultGet(HttpUriContants.VIEW_TOCHANGE_NGINX_CONF, BaseResponse.class, map);
  81 + }
  82 +
  83 + /**
  84 + * 查看 当前配置
  85 + *
  86 + */
  87 + @RequestMapping(value = "viewCurrentConf")
  88 + @ResponseBody
  89 + public BaseResponse viewCurrentConf(String cloudName) {
  90 + Map<String, String> map = new HashMap<>();
  91 + map.put("cloudName", cloudName);
  92 + return httpRestClient.defaultGet(HttpUriContants.VIEW_NGINX_CURRENT_CONF, BaseResponse.class, map);
  93 + }
  94 +
  95 +}
  1 +package com.ui.ctrl.app;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.ui.contants.HttpUriContants;
  5 +import com.ui.http.HttpRestClient;
  6 +import com.ui.model.BaseResponse;
  7 +import org.apache.commons.lang.StringUtils;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.core.ParameterizedTypeReference;
  12 +import org.springframework.stereotype.Controller;
  13 +import org.springframework.util.LinkedMultiValueMap;
  14 +import org.springframework.util.MultiValueMap;
  15 +import org.springframework.web.bind.annotation.RequestMapping;
  16 +import org.springframework.web.bind.annotation.ResponseBody;
  17 +import org.springframework.web.servlet.ModelAndView;
  18 +
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +/**
  24 + * 限流调整
  25 + *
  26 + * @author bblu 2016-10-26
  27 + */
  28 +@Controller
  29 +@RequestMapping("app_topoSwitch")
  30 +public class AppTopoSwitchCtrl {
  31 +
  32 + private Logger logger = LoggerFactory.getLogger(getClass());
  33 +
  34 + @Autowired
  35 + HttpRestClient httpRestClient;
  36 +
  37 + @RequestMapping(value = "toAppTopoSwitch")
  38 + public ModelAndView toAppTopoSwitch() {
  39 + ModelAndView mdv = new ModelAndView("switch/switch_topology_app");
  40 + return mdv;
  41 + }
  42 +
  43 + /**
  44 + * 展示当前配置
  45 + *
  46 + * @return ModelAndView
  47 + */
  48 + @RequestMapping(value = "getNgixnStatus")
  49 + @ResponseBody
  50 + public BaseResponse getNgixnStatus() {
  51 + Map<String, Object> resultMap = new HashMap<>();
  52 +
  53 + try{
  54 + //lua
  55 + String luaResponse = httpRestClient.defaultGet(HttpUriContants.VIEW_LUA_CONF, String.class, null);
  56 + String luaType = "";
  57 + if(StringUtils.isNotBlank(luaResponse)){
  58 + if (luaResponse.matches(".*context.cloud_flag\\s*=\\s*2.*")) {
  59 + luaType = "qq";
  60 + } else if (luaResponse.matches(".*context.cloud_flag\\s*=\\s*3.*")) {
  61 + luaType = "aws+qq";
  62 + } else{
  63 + luaType = "aws";
  64 + }
  65 + }
  66 +
  67 + logger.info("getNgixnStatus 1...");
  68 +
  69 + //nginx
  70 + BaseResponse<Map<String, List<Map<String, Object>>>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_NGINX_CONF, new ParameterizedTypeReference<BaseResponse<Map<String, List<Map<String, Object>>>>>() {
  71 + }, null);
  72 +
  73 + logger.info("getNgixnStatus 2...");
  74 +
  75 + Map<String, List<Map<String, Object>>> map = response.getData();
  76 + List<Map<String, Object>> awsList = map.get("awsList");
  77 + List<Map<String, Object>> qcloudList = map.get("qcloudList");
  78 +
  79 + String awsApiNginx = "aws";
  80 + String awsGrayNginx = "aws";
  81 + String qqApiNginx = "qq";
  82 + String qqGrayNginx = "qq";
  83 +
  84 + for (Map<String, Object> apiMap : awsList) {
  85 + if (StringUtils.equals("apigateway", String.valueOf(apiMap.get("name")))) {
  86 + List<String> serverList = (List<String>) apiMap.get("server");
  87 + if (serverList.get(0).startsWith("10")) {
  88 + awsApiNginx = "qq";
  89 + }
  90 + }
  91 +
  92 + if (StringUtils.equals("grayapigateway", String.valueOf(apiMap.get("name")))) {
  93 + List<String> serverList = (List<String>) apiMap.get("server");
  94 + if (serverList.get(0).startsWith("10")) {
  95 + awsGrayNginx = "qq";
  96 + }
  97 + }
  98 + }
  99 +
  100 + for (Map<String, Object> apiMap : qcloudList) {
  101 + if (StringUtils.equals("apigateway", String.valueOf(apiMap.get("name")))) {
  102 + List<String> serverList = (List<String>) apiMap.get("server");
  103 + if (serverList.get(0).startsWith("172")) {
  104 + qqApiNginx = "aws";
  105 + }
  106 + }
  107 +
  108 + if (StringUtils.equals("grayapigateway", String.valueOf(apiMap.get("name")))) {
  109 + List<String> serverList = (List<String>) apiMap.get("server");
  110 + if (serverList.get(0).startsWith("172")) {
  111 + qqApiNginx = "aws";
  112 + }
  113 + }
  114 + }
  115 +
  116 + //dns
  117 + String defaultDns = "";
  118 +
  119 + MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
  120 + requestEntity.add("login_token", "31578,5f5402160468dc375159e2e94eeef1da");
  121 + requestEntity.add("format","json");
  122 + requestEntity.add("domain_id", "16862974");
  123 + requestEntity.add("record_id","293178513");
  124 +
  125 + try{
  126 + String requestResponse = httpRestClient.post("https://dnsapi.cn/Record.Info", requestEntity, String.class);
  127 + JSONObject responseJSON = JSONObject.parseObject(requestResponse);
  128 + JSONObject responseStatus = JSONObject.parseObject(responseJSON.getString("status"));
  129 + if ("1".equals(responseStatus.getString("code"))){
  130 + if (requestResponse.indexOf("amazonaws") == -1){
  131 + defaultDns = "qq";
  132 + }else{
  133 + defaultDns = "aws";
  134 + }
  135 + }else{
  136 + logger.error(" TopoSwitchCtrl - getNgixnStatus - JSON - err:" + responseJSON.getString("message"));
  137 + }
  138 + }catch (Exception e){
  139 + logger.error(" TopoSwitchCtrl - getNgixnStatus - https://dnsapi.cn/Record.Info - err", e);
  140 + }
  141 +
  142 + logger.info("getNgixnStatus 3...");
  143 +
  144 + resultMap.put("luaType", luaType);
  145 + resultMap.put("awsApiNginx", awsApiNginx);
  146 + resultMap.put("awsGrayNginx", awsGrayNginx);
  147 + resultMap.put("qqApiNginx", qqApiNginx);
  148 + resultMap.put("qqGrayNginx", qqGrayNginx);
  149 + resultMap.put("defaultDns", defaultDns);
  150 + }catch (Exception e){
  151 + logger.error(" TopoSwitchCtrl - getNgixnStatus - err", e);
  152 + }
  153 +
  154 + return new BaseResponse(resultMap);
  155 + }
  156 +}
@@ -86,9 +86,6 @@ @@ -86,9 +86,6 @@
86 <mvc:exclude-mapping path="/systemTest/**"/> 86 <mvc:exclude-mapping path="/systemTest/**"/>
87 <mvc:exclude-mapping path="/recvMonitAlarm"/> 87 <mvc:exclude-mapping path="/recvMonitAlarm"/>
88 <mvc:exclude-mapping path="/awsapi/sns" /> 88 <mvc:exclude-mapping path="/awsapi/sns" />
89 - <mvc:exclude-mapping path="/luaswitch/**" />  
90 - <mvc:exclude-mapping path="/nginxswitch/**" />  
91 - <mvc:exclude-mapping path="/topoSwitch/**" />  
92 <mvc:exclude-mapping path="/testcommon/testUpLoadData" /> 89 <mvc:exclude-mapping path="/testcommon/testUpLoadData" />
93 <bean class="com.ui.interceptor.AuthInterceptor"/> 90 <bean class="com.ui.interceptor.AuthInterceptor"/>
94 </mvc:interceptor> 91 </mvc:interceptor>
@@ -78,6 +78,21 @@ @@ -78,6 +78,21 @@
78 <div class="tree_container" style="height: 540px;color: black;overflow:auto;"> 78 <div class="tree_container" style="height: 540px;color: black;overflow:auto;">
79 <div class="panel panel-default"> 79 <div class="panel panel-default">
80 <div class="widget-title" style="height: 50px;"> 80 <div class="widget-title" style="height: 50px;">
  81 + <h5 style="display: inline">入口切换</h5>
  82 + </div>
  83 + <div class="panel-body">
  84 + <button class="btn btn-sm btn-primary"
  85 + onclick="dnsViewConf()">
  86 + <em class="icon-cogs bigger-110"></em>
  87 + 查看当前入口配置
  88 + </button>
  89 + <h3 class="header smaller red"></h3>
  90 +
  91 + <div id="dns-div" class="btn-group">
  92 + </div>
  93 + </div>
  94 +
  95 + <div class="widget-title" style="height: 50px;">
81 <h5 style="display: inline">直连切换</h5> 96 <h5 style="display: inline">直连切换</h5>
82 </div> 97 </div>
83 <div class="panel-body"> 98 <div class="panel-body">
@@ -243,4 +258,4 @@ @@ -243,4 +258,4 @@
243 258
244 </body> 259 </body>
245 260
246 -</html> 261 +</html>
@@ -116,6 +116,8 @@ function drawData(resp) { @@ -116,6 +116,8 @@ function drawData(resp) {
116 //创建lua切换按钮 116 //创建lua切换按钮
117 createLuaSwitchButton(data.luaType); 117 createLuaSwitchButton(data.luaType);
118 118
  119 + //创建入口切换按钮
  120 + createDnsSwitchButton(data.luaType);
119 } 121 }
120 122
121 /** 123 /**
@@ -165,6 +167,7 @@ function luaInitSwitch(cloudName) { @@ -165,6 +167,7 @@ function luaInitSwitch(cloudName) {
165 }; 167 };
166 sendAjax("post", getUrlBasePath() + "/luaswitch/viewToChangeLuaConf", param, "text", luaViewToChangeSuccess, errorFunc); 168 sendAjax("post", getUrlBasePath() + "/luaswitch/viewToChangeLuaConf", param, "text", luaViewToChangeSuccess, errorFunc);
167 dialog.dialog("hide"); 169 dialog.dialog("hide");
  170 + toWait();
168 } 171 }
169 }] 172 }]
170 }); 173 });
@@ -204,6 +207,86 @@ function luaViewToChangeSuccess(resp) { @@ -204,6 +207,86 @@ function luaViewToChangeSuccess(resp) {
204 } 207 }
205 208
206 /** 209 /**
  210 + * 创建Dns切换按钮
  211 + * @param luaType
  212 + */
  213 +function createDnsSwitchButton(luaType){
  214 + if(luaType == ""){
  215 + return;
  216 + }
  217 + var awsButton = "<button class=\"btn btn-sm btn-success\" onclick=\"dnsSwitch(\'toAws\')\"> <em class=\"icon-cogs bigger-110\"></em>切向aws</button>";
  218 + var qqButton = "<button class=\"btn btn-sm btn-success\" onclick=\"dnsSwitch(\'toQcloud\')\"> <em class=\"icon-cogs bigger-110\"></em>切向qcloud</button>";
  219 + var mixButton = "<button class=\"btn btn-sm btn-success\" onclick=\"dnsSwitch(\'mix\')\"> <em class=\"icon-cogs bigger-110\"></em>切向双云</button>";
  220 +
  221 + if(luaType == 'aws'){
  222 + $("#dns-div").html(qqButton + mixButton);
  223 + }else if (luaType == 'qq'){
  224 + $("#dns-div").html(awsButton + mixButton);
  225 + }else{
  226 + $("#dns-div").html(awsButton + qqButton);
  227 + }
  228 +}
  229 +
  230 +/**
  231 + * 直接切换,由于调用的是api
  232 + * @param cloud
  233 + */
  234 +function dnsSwitch(cloud){
  235 + var dialog = $("<div>").appendTo($("body"));
  236 + dialog.dialog({
  237 + title: "你确定切换吗",
  238 + backdrop: "static",
  239 + content: "由于切换dns是调用的dnspod提供的api,因此当点击确定就直接切换!!!!!!",
  240 + buttons: [{
  241 + text: "否",
  242 + className: "btn-danger",
  243 + onclick: function () {
  244 + dialog.dialog("hide");
  245 + }
  246 + }, {
  247 + text: "是",
  248 + className: "btn-success",
  249 + onclick: function () {
  250 + sendAjax("post", getUrlBasePath() + "/luaswitch/dnsSwitchConf?cloudName="+cloud, {}, "text", switchSuccess, errorFunc);
  251 + dialog.dialog("hide");
  252 + toWait();
  253 + }
  254 + }]
  255 + });
  256 +}
  257 +
  258 +/**
  259 + * 查看当前入口配置
  260 + */
  261 +function dnsViewConf(){
  262 + sendAjax("post", getUrlBasePath() + "/luaswitch/dnsViewCurrentConf", {}, "text", dnsViewCurrentConf, errorFunc);
  263 +}
  264 +
  265 +/**
  266 + * 打开对话框,查看当前dns配置
  267 + * @param resp 当前响应数据
  268 + */
  269 +function dnsViewCurrentConf(resp) {
  270 + var data = JSON.parse(resp);
  271 + var dialog = $("<div>").appendTo($("body"));
  272 + dialog.dialog({
  273 + title: "当前配置",
  274 + backdrop: "static",
  275 + content: "<pre style='width:568px'>" + data.data + "</pre>",
  276 + buttons: [{
  277 + text: "确定",
  278 + className: "btn-danger",
  279 + onclick: function () {
  280 + dialog.dialog("hide");
  281 + }
  282 + }]
  283 + }).find(".modal-body").css({
  284 + height: "280px",
  285 + width: "600px"
  286 + });
  287 +}
  288 +
  289 +/**
207 * 查看当前lua配置 290 * 查看当前lua配置
208 */ 291 */
209 function luaViewConf(){ 292 function luaViewConf(){
@@ -401,33 +484,6 @@ function toWait() { @@ -401,33 +484,6 @@ function toWait() {
401 }); 484 });
402 } 485 }
403 486
404 -  
405 -  
406 -  
407 -  
408 -  
409 -  
410 -  
411 -  
412 -  
413 -  
414 -  
415 -  
416 -  
417 -  
418 -  
419 -  
420 -  
421 -  
422 -  
423 -  
424 -  
425 -  
426 -  
427 -  
428 -  
429 -  
430 -  
431 // 节点 487 // 节点
432 function newNode(scene,x, y, w, h, text) { 488 function newNode(scene,x, y, w, h, text) {
433 var node = new JTopo.Node(text); 489 var node = new JTopo.Node(text);