AutoScalingGroupProjectConstant.java 4.12 KB
package com.ui.ctrl;

import org.apache.commons.lang.StringUtils;

/**
 * Created by craig.qin on 2017/8/23.
 */
public class AutoScalingGroupProjectConstant {
    public static String getProjectNames(String cloudType,String groupName){
        return getProjectsOrTags(cloudType,groupName,true);
    }

    public static String getTags(String cloudType,String groupName){
        return getProjectsOrTags(cloudType,groupName,false);
    }

    private static String getProjectsOrTags(String cloudType,String groupName,boolean retainProjectFlag){
        String projects="";
        String tags="";
        if("qcloud".equalsIgnoreCase(cloudType)){
            switch (groupName){
                case "PCH5-AutoScaling":
                    projects = "YOHOBUY-PC-NODE,YOHOBUY-WAP-NODE,YOHOBLK-WAP";
                    tags = "PC/H5,BLK,node,";
                    break;
                case "gateway":
                    projects = "yoho-gateway";
                    tags = "java,gateway,";
                    break;
                case "resources-user":
                    projects = "yohobuy-resources,yoho-users";
                    tags = "java,users,resources,";
                    break;
                case "product-message-sns":
                    projects = "yohobuy-product,yoho-message,yoho-sns";
                    tags = "java,product,message,sns,";
                    break;
                case "order-promotion":
                    projects = "yohobuy-order,yohobuy-promotion";
                    tags = "java,promotion,order,";
                    break;
                case "uic":
                    projects = "uic";
                    tags = "java,uic,";
                    break;
                case "activity-brower-bigdata":
                    projects = "yohobuy-activity,yohobuy-brower,yohobuy-bigdata";
                    tags = "java,activity,brower,bigdata,";
                    break;
            }
        }else if("aws".equalsIgnoreCase(cloudType)){
            switch (groupName){
                case "PCH5-AutoScaling":
                    projects = "YOHOBUY-PC-NODE,YOHOBUY-WAP-NODE,YOHOBLK-WAP";
                    tags = "PC/H5,BLK,node,";
                    break;
                case "gateway":
                    projects = "yoho-gateway";
                    tags = "java,gateway,";
                    break;
                case "product-message-sns":
                    projects = "yohobuy-product,yoho-message,yoho-sns";
                    tags = "java,product,message,sns,";
                    break;
                case "order-promotion":
                    projects = "yohobuy-order,yohobuy-promotion";
                    tags = "java,promotion,order,";
                    break;
                case "resources-user":
                    projects = "yohobuy-resources,yoho-users";
                    tags = "java,users,resources,";
                    break;
                case "activity-bigdata":
                    projects = "yohobuy-activity,yohobuy-bigdata";
                    tags = "java,activity,bigdata,";
                    break;
                case "uic-social-brower":
                    projects = "uic,yoho-social,yohobuy-brower";
                    tags = "java,uic,social,brower,";
                    break;
                case "yoho-now":
                    projects = "yoho-now";
                    tags = "java,yohonow";
                    break;
                case "java-nginx":
                    //////  只有tag projects="";
                    tags = "nginx,Nginx-JAVA,limit-switch,upstream-switch,";
                    break;
            }
        }
        if(retainProjectFlag){
            if(StringUtils.isNotBlank(projects)){
                return projects;
            }else{
                return groupName;
            }
        }else{
            if(StringUtils.isNotBlank(tags)){
                return  tags;
            }else{
                if(groupName.contains("java")){
                    return groupName.replace("-",",")+",";
                }else{
                    return "java,"+groupName.replace("-",",")+",";
                }
            }
        }

    }
}