add vg build

This commit is contained in:
fanqq 2015-11-24 18:17:57 +08:00
parent 394fab59ba
commit 65f936ce05
2 changed files with 16 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package com.ctrip.zeus.service.build.conf;
import com.ctrip.zeus.exceptions.ValidationException;
import com.ctrip.zeus.model.entity.Group;
import com.ctrip.zeus.model.entity.GroupVirtualServer;
import com.ctrip.zeus.model.entity.Slb;
@ -32,8 +33,19 @@ public class LocationConf {
public static String generate(Slb slb, VirtualServer vs, Group group, String upstreamName)throws Exception {
StringBuilder b = new StringBuilder(1024);
if (group.isVirtual()){
b.append("location ").append(getPath(slb, vs, group)).append(" {\n");
if (group.getGroupVirtualServers().size()==1)
{
b.append("rewrite ").append(group.getGroupVirtualServers().get(0).getRedirect()).append(" redirect;\n");
}else {
throw new ValidationException("Virtual Group has Multiple Group VirtualServers Redirect");
}
b.append("}\n");
return b.toString();
}
b.append("location ").append(getPath(slb, vs, group)).append(" {\n");
if (clientMaxSizeList.get() !=null)
{
String []sizeList = clientMaxSizeList.get().split(";");

View file

@ -40,6 +40,9 @@ public class UpstreamsConf {
}
public static String buildUpstreamConf(Slb slb, VirtualServer vs, Group group, String upstreamName, Set<String> allDownServers, Set<String> allUpGroupServers) throws Exception {
if (group.isVirtual()){
return "";
}
StringBuilder b = new StringBuilder(1024);
String body = buildUpstreamConfBody(slb,vs,group,allDownServers,allUpGroupServers);
if (null == body){