package com.bocloud.ims.entity.resource;

import com.bocloud.cmp.model.HostSystem;
import com.bocloud.common.utils.DateSerializer;
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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

@Table("vdc")
@Data
public class Vdc extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("uuid")
	private String uuid;
	@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("cpu_total")
	private Long cpuTotal;
	@Column("mem_total")
	private Double memTotal;
	@Column("disk_total")
	private Double diskTotal;
	@Column("cpu_used")
	private Long cpuUsed;
	@Column("mem_used")
	private Double memUsed;
	@Column("disk_used")
	private Double diskUsed;
	@Column("vdc_val")
	private String vdcVal;
	@Column("type")
	private String type;
	@IgnoreAll
	private List<Cluster> clusters;
	@IgnoreAll
	private Long clusterNum;
	@IgnoreAll
	private List<HostSystem> hosts;
	@IgnoreAll
	private Long hostNum;
	@IgnoreAll
	private List<DataStore> stores;
	@IgnoreAll
	private List<Network> networks;
	@IgnoreAll
	private List<Switcher> switchers;
	@IgnoreAll
	private List<VmResourcePool> pools;
	@IgnoreAll
	private List<VApp> vapps;
	@Column("guid")
	private String guid;// 全局唯一标识

	//fc新增字段
	@Column("uri")
	private String uri;  // 站点uri
	@Column("ip")
	private String ip;//站点IP
	@Column("is_dc")
	private Boolean isDc;//是否是域控制器（KVM未支持）
	@Column("is_self")
	private Boolean isSelf;//是否是当前站点
	@Column("mgnt_network_type")
	private String mgntNetworkType;//管理面ip版本，取值ipv4,ipv6
	//fc新增字段

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

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

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

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

	/**
	 * @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 cpuTotal
	 */
	public Long getCpuTotal() {
		return cpuTotal;
	}

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

	/**
	 * @return the memTotal
	 */
	public Double getMemTotal() {
		return memTotal;
	}

	/**
	 * @param memTotal the memTotal to set
	 */
	public void setMemTotal(Double memTotal) {
		this.memTotal = memTotal;
	}

	/**
	 * @return the diskTotal
	 */
	public Double getDiskTotal() {
		return diskTotal;
	}

	/**
	 * @param diskTotal the diskTotal to set
	 */
	public void setDiskTotal(Double diskTotal) {
		this.diskTotal = diskTotal;
	}

	/**
	 * @return the cpuUsed
	 */
	public Long getCpuUsed() {
		return cpuUsed;
	}

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

	/**
	 * @return the memUsed
	 */
	public Double getMemUsed() {
		return memUsed;
	}

	/**
	 * @param memUsed the memUsed to set
	 */
	public void setMemUsed(Double memUsed) {
		this.memUsed = memUsed;
	}

	/**
	 * @return the diskUsed
	 */
	public Double getDiskUsed() {
		return diskUsed;
	}

	/**
	 * @param diskUsed the diskUsed to set
	 */
	public void setDiskUsed(Double diskUsed) {
		this.diskUsed = diskUsed;
	}

	/**
	 * @return the vdcVal
	 */
	public String getVdcVal() {
		return vdcVal;
	}

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

	/**
	 * @return the clusters
	 */
	public List<Cluster> getClusters() {
		return clusters;
	}

	/**
	 * @param clusters the clusters to set
	 */
	public void setClusters(List<Cluster> clusters) {
		this.clusters = clusters;
	}

	/**
	 * @return the hosts
	 */
	public List<HostSystem> getHosts() {
		return hosts;
	}

	/**
	 * @param hosts the hosts to set
	 */
	public void setHosts(List<HostSystem> hosts) {
		this.hosts = hosts;
	}

	/**
	 * @return the stores
	 */
	public List<DataStore> getStores() {
		return stores;
	}

	/**
	 * @param stores the stores to set
	 */
	public void setStores(List<DataStore> stores) {
		this.stores = stores;
	}

	/**
	 * @return the networks
	 */
	public List<Network> getNetworks() {
		return networks;
	}

	/**
	 * @param networks the networks to set
	 */
	public void setNetworks(List<Network> networks) {
		this.networks = networks;
	}

	/**
	 * @return the switchers
	 */
	public List<Switcher> getSwitchers() {
		return switchers;
	}

	/**
	 * @param switchers the switchers to set
	 */
	public void setSwitchers(List<Switcher> switchers) {
		this.switchers = switchers;
	}

	/**
	 * @return the pools
	 */
	public List<VmResourcePool> getPools() {
		return pools;
	}

	/**
	 * @param pools the pools to set
	 */
	public void setPools(List<VmResourcePool> pools) {
		this.pools = pools;
	}

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

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

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<VApp> getVapps() {
		return vapps;
	}

	public Long getClusterNum() {
		return clusterNum;
	}

	public void setClusterNum(Long clusterNum) {
		this.clusterNum = clusterNum;
	}

	public Long getHostNum() {
		return hostNum;
	}

	public void setHostNum(Long hostNum) {
		this.hostNum = hostNum;
	}

	public void setVapps(List<VApp> vapps) {
		this.vapps = vapps;
	}

	/**
	 * @param creatorId
	 * @param ownerId
	 * @param menderId
	 * @param id
	 * @param uuid
	 * @param vendorId
	 * @param vendorName
	 * @param gmtExpired
	 * @param cpuTotal
	 * @param memTotal
	 * @param diskTotal
	 * @param cpuUsed
	 * @param memUsed
	 * @param diskUsed
	 */
	public Vdc(Long creatorId, Long ownerId, Long menderId, Long id, String uuid, Long vendorId, String vendorName,
			Date gmtExpired, Long cpuTotal, Double memTotal, Double diskTotal, Long cpuUsed, Double memUsed,
			Double diskUsed, String vdcVal) {
		this.setCreatorId(creatorId);
		this.setOwnerId(ownerId);
		this.setMenderId(menderId);
		this.id = id;
		this.uuid = uuid;
		this.vendorId = vendorId;
		this.vendorName = vendorName;
		this.gmtExpired = gmtExpired;
		this.cpuTotal = cpuTotal;
		this.memTotal = memTotal;
		this.diskTotal = diskTotal;
		this.cpuUsed = cpuUsed;
		this.memUsed = memUsed;
		this.diskUsed = diskUsed;
		this.vdcVal = vdcVal;
	}

	public Vdc() {
		super();
	}

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

}
