package com.bocloud.ims.entity.resource;

import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.List;

/**
 * @author zhangdi
 * @version 1.0
 * @since 2018年4月23日
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Table("pool_group")
public class PoolGroup extends GenericEntity {

	// ID
	@PK(value = PKStrategy.AUTO)
	private Long id;
	// 父资源池ID(暂时无用)
	@Column("parent_id")
	private Long parentId;
	// 资源池类别(计算/网络/存储)
	@Column("category")
	private String category;
	// 绑定策略(共享/独占)
	@Column("binding_policy")
	private String bindingPolicy;
	// 所属云平台
	@Column("vendor_id")
	private Long vendorId;
	// 资源池绑定的策略id
	@Column("policy_id")
	private Long policyId;
	// 地域
	@Column("region")
	private String region;
	// 地域
	@Column("is_public")
	private Boolean isPublic;
	// 可用域
	@Column("availablitiy_zone")
	private String availablitiyZone;
	// 优先类型
	@Column("priority_type")
	private PriorityType priorityType;
	// 优先类型
	@Column("relation_type")
	private String relationType;
	// 平台类型
	@Column("vendor_type")
	private String vendorType;


	//深信服专属字段 资源池uuid 和分组id
	@Column("az_uuid")
	private String azUuid;
	@Column("group_id")
	private Long groupId;

	@IgnoreAll
	private String children;
	// 子节点
	@IgnoreAll
	private List<PoolGroup> childrenList;
	// 平台名称
	@IgnoreAll
	private String vendorName;
	// 策略类型
	@IgnoreAll
	private String policyType;
	// 地域名称
	@IgnoreAll
	private String regionName;
	// 可用域名称
	@IgnoreAll
	private String azName;
	@IgnoreAll
	private Long regId; // 对应区域的id
	@IgnoreAll
	private Boolean hasNsx;
	@IgnoreAll
	private Long poolGroupId;
	@IgnoreAll
	private List<Long> targets;
	@IgnoreAll
	private List<Long> labelIds;
	@IgnoreAll
	private Long targetId;
	@IgnoreAll
	private Long labelId;
	@IgnoreAll
	private List<Long> relationIds;
	@IgnoreAll
	private Boolean isUsed;
	/**
	 * 资源关联
	 */
	@IgnoreAll
	private List<PoolGroupRelation> relations;

	/**
	 * 网络关联
	 */
	@IgnoreAll
	private List<PortGroupRelation> networkRelations;

	/**
	 * 地域关联
	 */
	@IgnoreAll
	private List<PoolGroupZone> regionRelations;

	/**
	 * @param parentId
	 * @param category
	 * @param children
	 * @param childrenList
	 */
	public PoolGroup(Long parentId, String category, String children, List<PoolGroup> childrenList) {
		super();
		this.parentId = parentId;
		this.category = category;
		this.children = children;
		this.childrenList = childrenList;
	}

	public enum RelationType {
		/**
		 * 数据中心
		 */
		Vdc,
		/**
		 * 集群
		 */
		Cluster,
		/**
		 * 宿主机
		 */
		Host
	}

	public enum BindingPolicy {
		/**
		 * 独占
		 */
		exclusive,
		/**
		 * 共享
		 */
		share
	}

	public enum PriorityType {
		/**
		 * CPU
		 */
		Cpu,
		/**
		 * 内存
		 */
		Memory,
		/**
		 * 存储
		 */
		Disk
	}
}
