Authored by zhouxiang

no message

@@ -16,11 +16,11 @@ default_err_code=9999991 @@ -16,11 +16,11 @@ default_err_code=9999991
16 default_err_msg="系统正忙,请稍后重试!" 16 default_err_msg="系统正忙,请稍后重试!"
17 --limit interface 17 --limit interface
18 limit_config={ 18 limit_config={
19 - {@{#each limit_config}@}{@{this}@} 19 + {@{#each limit_config}@}{@{{this}}@}
20 {@{/each}@} 20 {@{/each}@}
21 } 21 }
22 22
23 limit_service_config={ 23 limit_service_config={
24 - {@{#each limit_service_config}@}{@{this}@} 24 + {@{#each limit_service_config}@}{@{{this}}@}
25 {@{/each}@} 25 {@{/each}@}
26 } 26 }
@@ -10,6 +10,7 @@ import org.apache.commons.lang.StringUtils; @@ -10,6 +10,7 @@ import org.apache.commons.lang.StringUtils;
10 import org.slf4j.Logger; 10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
12 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Controller;
13 import org.springframework.web.bind.annotation.RequestMapping; 14 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.ResponseBody; 15 import org.springframework.web.bind.annotation.ResponseBody;
15 16
@@ -22,6 +23,8 @@ import java.util.Map; @@ -22,6 +23,8 @@ import java.util.Map;
22 /** 23 /**
23 * Created by zhouxiang on 2016/10/25. 24 * Created by zhouxiang on 2016/10/25.
24 */ 25 */
  26 +@Controller
  27 +@RequestMapping("lbswitch")
25 public class LbSwitchCtrl { 28 public class LbSwitchCtrl {
26 29
27 private Logger logger = LoggerFactory.getLogger(getClass()); 30 private Logger logger = LoggerFactory.getLogger(getClass());
@@ -40,9 +43,9 @@ public class LbSwitchCtrl { @@ -40,9 +43,9 @@ public class LbSwitchCtrl {
40 @ResponseBody 43 @ResponseBody
41 public Map<String,String> viewConf() throws Exception { 44 public Map<String,String> viewConf() throws Exception {
42 //直连的配置放在腾讯云nginx上 45 //直连的配置放在腾讯云nginx上
43 - List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTagAndCloudType("nginx", 2); 46 + List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTag("直连");
44 if (CollectionUtils.isEmpty(qcloudNginxHosts)) { 47 if (CollectionUtils.isEmpty(qcloudNginxHosts)) {
45 - throw new Exception("没有找到nginx服务器"); 48 + throw new Exception("没有找到直连nginx服务器");
46 } 49 }
47 return analyseConfigFile(exe("view", qcloudNginxHosts.get(0).getHostIp(),null)); 50 return analyseConfigFile(exe("view", qcloudNginxHosts.get(0).getHostIp(),null));
48 } 51 }
@@ -52,15 +55,15 @@ public class LbSwitchCtrl { @@ -52,15 +55,15 @@ public class LbSwitchCtrl {
52 * 55 *
53 * @return 2016年5月12日下午1:49:48 56 * @return 2016年5月12日下午1:49:48
54 */ 57 */
55 - @RequestMapping(value = "viewToChangeLuaConf") 58 + @RequestMapping(value = "viewToChangeLbConf")
56 @ResponseBody 59 @ResponseBody
57 public BaseResponse viewToChangeLuaConf(String status, HttpServletRequest request) throws Exception { 60 public BaseResponse viewToChangeLuaConf(String status, HttpServletRequest request) throws Exception {
58 logger.info("will change status {}", status); 61 logger.info("will change status {}", status);
59 - if(!StringUtils.equals("open", status) && !StringUtils.equals("close", status)){ 62 + if(!StringUtils.equals("1", status) && !StringUtils.equals("0", status)){
60 throw new Exception("切换状态参数不正确!"); 63 throw new Exception("切换状态参数不正确!");
61 } 64 }
62 Map<String, Object> map = new HashMap(); 65 Map<String, Object> map = new HashMap();
63 - map.put("open_dl", StringUtils.equals("open", status) ? OPENDL : CLOSEDL); 66 + map.put("open_dl", StringUtils.equals("1", status) ? OPENDL : CLOSEDL);
64 String path = request.getSession().getServletContext().getRealPath("/") + "lua/lb.lua"; 67 String path = request.getSession().getServletContext().getRealPath("/") + "lua/lb.lua";
65 String result = HandlebarsUtils.replace(map, "template/lb", path); 68 String result = HandlebarsUtils.replace(map, "template/lb", path);
66 return new BaseResponse(200, "success", result); 69 return new BaseResponse(200, "success", result);
@@ -76,7 +79,7 @@ public class LbSwitchCtrl { @@ -76,7 +79,7 @@ public class LbSwitchCtrl {
76 String path = request.getSession().getServletContext().getRealPath("/") + "lua/lb.lua"; 79 String path = request.getSession().getServletContext().getRealPath("/") + "lua/lb.lua";
77 logger.info("lb.lua template path {}", path); 80 logger.info("lb.lua template path {}", path);
78 //lua dns 只放在腾讯云nginx服务器上 81 //lua dns 只放在腾讯云nginx服务器上
79 - List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTagAndCloudType("nginx", 2); 82 + List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTag("直连");
80 if (CollectionUtils.isEmpty(nginxHosts)) { 83 if (CollectionUtils.isEmpty(nginxHosts)) {
81 return new BaseResponse(500, "在cmdb中未找到直连对应的nginx服务器!"); 84 return new BaseResponse(500, "在cmdb中未找到直连对应的nginx服务器!");
82 } 85 }
@@ -117,11 +120,11 @@ public class LbSwitchCtrl { @@ -117,11 +120,11 @@ public class LbSwitchCtrl {
117 result.put("conf",sb.toString()); 120 result.put("conf",sb.toString());
118 String dl = str[i].substring(str[i].indexOf("\"")).replaceAll("\"","").trim(); 121 String dl = str[i].substring(str[i].indexOf("\"")).replaceAll("\"","").trim();
119 if(StringUtils.equals(OPENDL,dl)){ 122 if(StringUtils.equals(OPENDL,dl)){
120 - result.put("status","open"); 123 + result.put("status","1");
121 return result; 124 return result;
122 } 125 }
123 if(StringUtils.equals(CLOSEDL,dl)){ 126 if(StringUtils.equals(CLOSEDL,dl)){
124 - result.put("status","close"); 127 + result.put("status","0");
125 return result; 128 return result;
126 } 129 }
127 } 130 }
@@ -12,6 +12,7 @@ import org.apache.commons.lang.StringUtils; @@ -12,6 +12,7 @@ import org.apache.commons.lang.StringUtils;
12 import org.slf4j.Logger; 12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Controller;
15 import org.springframework.web.bind.annotation.RequestMapping; 16 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.ResponseBody; 17 import org.springframework.web.bind.annotation.ResponseBody;
17 18
@@ -25,6 +26,8 @@ import java.util.Map; @@ -25,6 +26,8 @@ import java.util.Map;
25 /** 26 /**
26 * Created by zhouxiang on 2016/10/25. 27 * Created by zhouxiang on 2016/10/25.
27 */ 28 */
  29 +@Controller
  30 +@RequestMapping("limitswitch")
28 public class NginxLimit { 31 public class NginxLimit {
29 32
30 private Logger logger = LoggerFactory.getLogger(getClass()); 33 private Logger logger = LoggerFactory.getLogger(getClass());
@@ -40,7 +43,7 @@ public class NginxLimit { @@ -40,7 +43,7 @@ public class NginxLimit {
40 @RequestMapping(value = "viewConf") 43 @RequestMapping(value = "viewConf")
41 @ResponseBody 44 @ResponseBody
42 public Map<String,Object> viewConf() throws Exception { 45 public Map<String,Object> viewConf() throws Exception {
43 - List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTagAndCloudType("nginx", 2); 46 + List<HostInfo> qcloudNginxHosts = hostInfoMapper.selectHostInfosByTag("限流");
44 if (CollectionUtils.isEmpty(qcloudNginxHosts)) { 47 if (CollectionUtils.isEmpty(qcloudNginxHosts)) {
45 throw new Exception("没有找到限流nginx服务器"); 48 throw new Exception("没有找到限流nginx服务器");
46 } 49 }
@@ -52,7 +55,7 @@ public class NginxLimit { @@ -52,7 +55,7 @@ public class NginxLimit {
52 * 55 *
53 * @return 2016年5月12日下午1:49:48 56 * @return 2016年5月12日下午1:49:48
54 */ 57 */
55 - @RequestMapping(value = "viewToChangeLuaConf") 58 + @RequestMapping(value = "viewToChangeLimitConf")
56 @ResponseBody 59 @ResponseBody
57 public BaseResponse viewToChangeLuaConf(String limitFlow, String apiConfs, String serviceConfs, HttpServletRequest request) { 60 public BaseResponse viewToChangeLuaConf(String limitFlow, String apiConfs, String serviceConfs, HttpServletRequest request) {
58 logger.info("limitFlow {} apiConfig {} serviceCong {}", limitFlow,apiConfs,serviceConfs); 61 logger.info("limitFlow {} apiConfig {} serviceCong {}", limitFlow,apiConfs,serviceConfs);
@@ -87,11 +90,11 @@ public class NginxLimit { @@ -87,11 +90,11 @@ public class NginxLimit {
87 * 90 *
88 * @return 2016年5月12日下午1:49:48 91 * @return 2016年5月12日下午1:49:48
89 */ 92 */
90 - @RequestMapping(value = "switchLuaConf") 93 + @RequestMapping(value = "switchConf")
91 @ResponseBody 94 @ResponseBody
92 public BaseResponse switchNginxConf(HttpServletRequest httpRequest) { 95 public BaseResponse switchNginxConf(HttpServletRequest httpRequest) {
93 //获取对应cloud的机器 aws 1 qcloud 2 96 //获取对应cloud的机器 aws 1 qcloud 2
94 - List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTag("nginx_limit"); 97 + List<HostInfo> nginxHosts = hostInfoMapper.selectHostInfosByTag("限流");
95 if (CollectionUtils.isEmpty(nginxHosts)) { 98 if (CollectionUtils.isEmpty(nginxHosts)) {
96 return new BaseResponse(500, "在cmdb中未找到限流对应的nginx服务器!"); 99 return new BaseResponse(500, "在cmdb中未找到限流对应的nginx服务器!");
97 } 100 }