package com.bocloud.ims.entity.resource;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.IgnoreInsert;
import com.bocloud.entity.annotations.IgnoreUpdate;
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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 数据存储实体类
 *
 * @author dmw
 */
@Table("data_store")
@Data
public class DataStore extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("vendor_id")
	private Long vendorId; // 云供应商ID
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@Column("gmt_expired")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtExpired;// 过期时间
	@Column("capacity")
	private Long capacity;
	@Column("free_space")
	private Long freeSpace;
	@Column("vdc_id")
	private Long vdcId;

	// 物理主机唯一标识
	@Column("server_id")
	private Long serverId;

	@Column("type")
	private String type;
	@Column("path")
	private String path;
	@Column("host_num")
	private Integer hostNum;
	@Column("vm_num")
	private Integer vmNum;// 存储管理的云主机数量
	@IgnoreAll
	private Integer vmNumUm;// 存储未管理的云主机数量
	@Column("template_num")
	private Integer templateNum;// 存储下的模板数量
	@Column("store_val")
	private String storeVal;// 存储value
	// 集群ID
	@Column("cluster_id")
	private Long clusterId;
	@IgnoreAll
	private String clusterName;

	// 是否为共享存储
	@Column("is_shared")
	private Boolean shared;

	@Column("enabled")
	private Boolean enabled;

	@Column("az_uuid")
	private String azUuid;

	@IgnoreAll
	private String azName;

	@IgnoreAll
	private List<Image> images;// 数据存储下镜像
	@IgnoreAll
	private List<DataStoreFile> files; // 数据存储下文件
	@IgnoreAll
	private Long hostId;// 指定主机ID
	@IgnoreAll
	private String accessMode;
	@IgnoreAll
	private String remoteHost;// 服务器
	@IgnoreAll
	private String remotePath;// 服务器文件夹路径
	@IgnoreAll
	private String scId;
	@IgnoreAll
	private String userName;
	@IgnoreAll
	private String password;
	@IgnoreAll
	private String remoteHostNames;
	@Column("guid")
	private String guid;// 全局唯一标识
	@Column("catalog_id")
	private Long catalogId; // 存储服务目录id
	@IgnoreAll
	private String catalogName; // 存储服务目录名称
	@Column("distributable_ratio")
	private BigDecimal distributableRatio; // 存储容量可分配百分比
	@Column("resource_label")
	private String resourceLabel; // 标签
	@IgnoreAll
	private Integer distributable;// 存储可分配容量
	@IgnoreAll
	private String vdcName;// 数据中心名称
	@IgnoreAll
	private Long ruleRelationId;// 资源告警规则关联关系id
	@IgnoreAll
	private String thresholdGroupName;// 阈值组名称
	@IgnoreAll
	private String policyName;// 分发策略名称
	@IgnoreAll
	private Long thresholdGroupId;// 阈值组id
	@IgnoreAll
	private Long policyId;// 分发策略id
	@IgnoreAll
	private String address;// vCenter地址
	@IgnoreAll
	private Cluster cluster;

	@Column("host_guid")
	private String hostGuid;// 所属物理机
	/**
	 * 存储使用率（单位%）
	 * <p>
	 * 数值取值范围[0,100]
	 * </p>
	 */
	@IgnoreAll
	private double usageRate;

	//fc 纳管
	@Column("storage_device_id")
	private Long storageDeviceId; // 存储设备ID
	@Column("use_type")
	private Integer useType;
	@Column("uri")
	private String uri;//访问主机的uri
	//fc 纳管

	@Column("free_rate")
	private String freeRate;
	@Column("replica")
	private Integer replica;
	@Column("io_read")
	private Integer ioRead;
	@Column("io_write")
	private Integer ioWrite;
	@Column("sangfor_type")
	private String sangforType;
	@Column("ssd_remaining_life")
	private String ssdRemainingLife;
	@IgnoreAll
	private String version;


	/**
	 * @return the vdcId
	 */
	public Long getVdcId() {
		return vdcId;
	}

	/**
	 * @param vdcId the vdcId to set
	 */
	public void setVdcId(Long vdcId) {
		this.vdcId = vdcId;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the gmtExpired
	 */
	public Date getGmtExpired() {
		return gmtExpired;
	}

	/**
	 * @param gmtExpired the gmtExpired to set
	 */
	public void setGmtExpired(Date gmtExpired) {
		this.gmtExpired = gmtExpired;
	}

	/**
	 * @return the capacity
	 */
	public Long getCapacity() {
		return capacity;
	}

	/**
	 * @param capacity the capacity to set
	 */
	public void setCapacity(Long capacity) {
		this.capacity = capacity;
	}

	/**
	 * @return the freeSpace
	 */
	public Long getFreeSpace() {
		return freeSpace;
	}

	/**
	 * @param freeSpace the freeSpace to set
	 */
	public void setFreeSpace(Long freeSpace) {
		this.freeSpace = freeSpace;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the path
	 */
	public String getPath() {
		return path;
	}

	/**
	 * @param path the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * @return the hostNum
	 */
	public Integer getHostNum() {
		return hostNum;
	}

	/**
	 * @param hostNum the hostNum to set
	 */
	public void setHostNum(Integer hostNum) {
		this.hostNum = hostNum;
	}

	/**
	 * @return the vmNum
	 */
	public Integer getVmNum() {
		return vmNum;
	}

	/**
	 * @param vmNum the vmNum to set
	 */
	public void setVmNum(Integer vmNum) {
		this.vmNum = vmNum;
	}

	/**
	 * @return the vmNumUm
	 */
	public Integer getVmNumUm() {
		return vmNumUm;
	}

	/**
	 * @param vmNumUm the vmNumUm to set
	 */
	public void setVmNumUm(Integer vmNumUm) {
		this.vmNumUm = vmNumUm;
	}

	/**
	 * @return the templateNum
	 */
	public Integer getTemplateNum() {
		return templateNum;
	}

	/**
	 * @param templateNum the templateNum to set
	 */
	public void setTemplateNum(Integer templateNum) {
		this.templateNum = templateNum;
	}

	/**
	 * @return the storeVal
	 */
	public String getStoreVal() {
		return storeVal;
	}

	/**
	 * @param storeVal the storeVal to set
	 */
	public void setStoreVal(String storeVal) {
		this.storeVal = storeVal;
	}

	/**
	 * @return the images
	 */
	public List<Image> getImages() {
		return images;
	}

	/**
	 * @param images the images to set
	 */
	public void setImages(List<Image> images) {
		this.images = images;
	}

	/**
	 * @return the hostId
	 */
	public Long getHostId() {
		return hostId;
	}

	/**
	 * @param hostId the hostId to set
	 */
	public void setHostId(Long hostId) {
		this.hostId = hostId;
	}

	/**
	 * @return the accessMode
	 */
	public String getAccessMode() {
		return accessMode;
	}

	/**
	 * @param accessMode the accessMode to set
	 */
	public void setAccessMode(String accessMode) {
		this.accessMode = accessMode;
	}

	/**
	 * @return the remoteHost
	 */
	public String getRemoteHost() {
		return remoteHost;
	}

	/**
	 * @param remoteHost the remoteHost to set
	 */
	public void setRemoteHost(String remoteHost) {
		this.remoteHost = remoteHost;
	}

	/**
	 * @return the remotePath
	 */
	public String getRemotePath() {
		return remotePath;
	}

	/**
	 * @param remotePath the remotePath to set
	 */
	public void setRemotePath(String remotePath) {
		this.remotePath = remotePath;
	}

	/**
	 * @return the scId
	 */
	public String getScId() {
		return scId;
	}

	/**
	 * @param scId the scId to set
	 */
	public void setScId(String scId) {
		this.scId = scId;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the remoteHostNames
	 */
	public String getRemoteHostNames() {
		return remoteHostNames;
	}

	/**
	 * @param remoteHostNames the remoteHostNames to set
	 */
	public void setRemoteHostNames(String remoteHostNames) {
		this.remoteHostNames = remoteHostNames;
	}

	/**
	 * @return the guid
	 */
	public String getGuid() {
		return guid;
	}

	/**
	 * @param guid the guid to set
	 */
	public void setGuid(String guid) {
		this.guid = guid;
	}

	public Long getCatalogId() {
		return catalogId;
	}

	public void setCatalogId(Long catalogId) {
		this.catalogId = catalogId;
	}

	public String getCatalogName() {
		return catalogName;
	}

	public void setCatalogName(String catalogName) {
		this.catalogName = catalogName;
	}

	public List<DataStoreFile> getFiles() {
		return files;
	}

	public void setFiles(List<DataStoreFile> files) {
		this.files = files;
	}

	public BigDecimal getDistributableRatio() {
		return distributableRatio;
	}

	public void setDistributableRatio(BigDecimal distributableRatio) {
		this.distributableRatio = distributableRatio;
	}

	public Integer getDistributable() {
		return distributable;
	}

	public void setDistributable(Integer distributable) {
		this.distributable = distributable;
	}

	public Long getServerId() {
		return serverId;
	}

	public void setServerId(Long serverId) {
		this.serverId = serverId;
	}

	public Boolean getShared() {
		return shared;
	}

	public void setShared(Boolean shared) {
		this.shared = shared;
	}

	public double getUsageRate() {
		return usageRate;
	}

	public void setUsageRate(double usageRate) {
		this.usageRate = usageRate;
	}

	public String getVdcName() {
		return vdcName;
	}

	public void setVdcName(String vdcName) {
		this.vdcName = vdcName;
	}

	public String getResourceLabel() {
		return resourceLabel;
	}

	public void setResourceLabel(String resourceLabel) {
		this.resourceLabel = resourceLabel;
	}

	public Long getRuleRelationId() {
		return ruleRelationId;
	}

	public void setRuleRelationId(Long ruleRelationId) {
		this.ruleRelationId = ruleRelationId;
	}

	public String getThresholdGroupName() {
		return thresholdGroupName;
	}

	public void setThresholdGroupName(String thresholdGroupName) {
		this.thresholdGroupName = thresholdGroupName;
	}

	public String getPolicyName() {
		return policyName;
	}

	public void setPolicyName(String policyName) {
		this.policyName = policyName;
	}

	public Long getThresholdGroupId() {
		return thresholdGroupId;
	}

	public void setThresholdGroupId(Long thresholdGroupId) {
		this.thresholdGroupId = thresholdGroupId;
	}

	public Long getPolicyId() {
		return policyId;
	}

	public void setPolicyId(Long policyId) {
		this.policyId = policyId;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Long getClusterId() {
		return clusterId;
	}

	public void setClusterId(Long clusterId) {
		this.clusterId = clusterId;
	}

	public Cluster getCluster() {
		return cluster;
	}

	public void setCluster(Cluster cluster) {
		this.cluster = cluster;
	}

	/**
	 * @param creatorId
	 * @param ownerId
	 * @param menderId
	 * @param id
	 * @param vendorId
	 * @param vendorName
	 * @param gmtExpired
	 * @param capacity
	 * @param freeSpace
	 * @param type
	 */
	public DataStore(Long creatorId, Long ownerId, Long menderId, Long id, Long vendorId, String vendorName,
			Date gmtExpired, Long capacity, Long freeSpace, String type, String path, Integer hostNum, Integer vmNum,
			Integer templateNum, String storeVal) {
		this.setCreatorId(creatorId);
		this.setOwnerId(ownerId);
		this.setMenderId(menderId);
		this.id = id;
		this.vendorId = vendorId;
		this.vendorName = vendorName;
		this.gmtExpired = gmtExpired;
		this.capacity = capacity;
		this.freeSpace = freeSpace;
		this.type = type;
		this.path = path;
		this.hostNum = hostNum;
		this.vmNum = vmNum;
		this.templateNum = templateNum;
		this.storeVal = storeVal;
	}

	/**
	 *
	 */
	public DataStore() {
		super();
	}

	public void preSave(Long creatorId, Long menderId, Long vendorId, Long vdcId) {
		this.setCreatorId(creatorId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setVdcId(vdcId);
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public String getClusterName() {
		return this.clusterName;
	}

	public void setClusterName(final String clusterName) {
		this.clusterName = clusterName;
	}
	
	public String getAzUuid() {
		return this.azUuid;
	}

	public void setAzUuid(final String azUuid) {
		this.azUuid = azUuid;
	}
	
	public String getAzName() {
		return this.azName;
	}

	public void setAzName(final String azName) {
		this.azName = azName;
	}

	

}
