package com.bocloud.ims.entity.resource;

import com.bocloud.common.utils.DateDeserializer;
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.bocloud.ims.entity.resource.installation.ServerPci;
import com.bocloud.ims.entity.resource.installation.ServerRaidCtrl;
import com.bocloud.ims.entity.resource.powervc.PowervcHmc;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * 物理机器类
 *
 * @author wei wei
 * @version 1.0
 * @since 2016.02.26
 */
@Table("server")
public class Server extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("expired_time")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date expiredTime;// 过期时间
	@Column("asset_category")
	private String assetCategory;// 资产类别
	@Column("category")
	private String category; // 类别
	@Column("catalog")
	private String catalog;
	@Column("uuid")
	private String uuid; // UUID
	@Column("manage_ip")
	private String manageIp; // 管理IP
	@Column("dc_id")
	private Long dcId; // 数据中心ID
	@Column("room_id")
	private Long roomId; // 机房ID
	@Column("rack_id")
	private Long rackId; // 机柜ID
	@Column("hostname")
	private String hostname;
	@Column("service_ip")
	private String serviceIp;
	@Column("tenant_id")
	private Long tenantId;
	@Column("vendor_id")
	private Long vendorId;
	@Column("is_connected")
	private Boolean connected; // 连接状态
	@Column("is_maintained")
	private Boolean maintained; // 维护模式
	@Column("ipv6_enabled")
	private Boolean ipv6Enabled; // 启用ipv6
	@Column("power_state")
	private String powerState; // 电源状态
	@Column("cluster_id")
	private Long clusterId;
	@Column("vdc_id")
	private Long vdcId;
	@Column("resource_id")
	private String resourceId; // 资源ID
	@Column("is_accurated")
	private boolean accurated;
	@Column("root_disk_id")
	private Long rootDiskId;
	@Column("cpu_model")
	private String cpuModel;
	@Column("model_name")
	private String modelName;
	@Column("enabled")
	private Boolean enabled;
	/**
	 * WINDOWS, LINUX
	 */
	@Column("os_category")
	private String osCategory;// 系统类别
	/**
	 * CENTOS, UBUNTU, REDHAT, ESXI, WINDOWSSERVER, SUSE
	 */
	@Column("os")
	private String os;// 操作系统详细信息
	@Column("resource_group")
	private String resourceGroup;// 资源分组
	@Column("vmotion_ip")
	private String vmotionIp;
	@Column("exporter_installed")
	private Boolean exporterInstalled;
	@IgnoreAll
	private String resourceGroupName;
	@IgnoreAll
	private String GroupName; // 所属资源池
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@IgnoreAll
	private String vendorType; // 云供应商类型
	@IgnoreAll
	private String roomname;
	@IgnoreAll
	private String rackname;
	@IgnoreAll
	private String dcname;
	@IgnoreAll
	private String clusterName;
	@IgnoreAll
	private String vdcName;
	@IgnoreAll
	private List<String> stores;
	@IgnoreAll
	private List<NetworkCard> netcards;
	@IgnoreAll
	private List<Network> networks;
	@IgnoreAll
	private List<CloudServer> servers;// 虚拟机
	@IgnoreAll
	private List<DataStore> dataStores;
	@IgnoreAll
	private Integer vmNum;// 宿主机（物理机）上的虚拟机数量
	@IgnoreAll
	private Integer templateNum;// 宿主机（物理机）上的虚拟机数量
	@IgnoreAll
	private Integer datastoreNum;// 数据存储数量
	@IgnoreAll
	private ServerConfig config;
	@IgnoreAll
	private ServerAssets assets;
	@IgnoreAll
	private List<Switcher> switchers;
	@Column("guid")
	private String guid;// 全局唯一标识
	@IgnoreAll
	private List<StoreHost> storeHosts;
	@IgnoreAll
	private List<PowervcHmc> powervcHmcs;

	/** 物理装机相关开始 */
	/**
	 * cop的地址信息
	 * <p>
	 * 192.168.2.85:18084
	 */
	@Column("instance")
	private String instance;
	/**
	 * 物理机的pci信息 用于显示网卡的型号等
	 */
	@IgnoreAll
	private ServerPci serverPci;
	/**
	 * 物理机的raid卡信息 用于显示Raid卡的信息等
	 */
	@IgnoreAll
	private List<ServerRaidCtrl> raids;
	/**
	 * 该节点在rackhd里面的id
	 * <p>
	 * 5c3e9bd5c324b5b4163c3643
	 */
	@Column("rackhd_node_id")
	private String rackhdNodeId;
	/**
	 * 装机使用的image id
	 */
	@Column("image_id")
	private Long imageId;
	@IgnoreAll
	private String imageName;
	@IgnoreAll
	private String imageIsoName;
	/**
	 * 发现任务开始的时间
	 */
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column("discover_time")
	private Date discoverTime;
	/**
	 * 该节点是否是被rackhd发现过
	 * <p>
	 * 如果被发现过，catalog信息都是ok的
	 * <p>
	 * 如果没有被发现过，只提供一部分功能，如设备监控
	 */
	@Column("discovered")
	private Boolean discovered;

	/**
	 * 该节点执行机器发现操作人id
	 */
	@Column("discover_user_id")
	private Long discoverUserId;
	/**
	 * 发现该物理时，使用的dhcp网卡的mac地址
	 * <p>
	 * f8:bc:12:3e:dc:64
	 */
	@Column("identifier")
	private String identifier;
	/**
	 * 物理装机相关结束
	 */

	@Column("role")
	private String role; // 角色
	@Column("services")
	private String services; // 运行的服务
	@Column("clock_diff")
	private Long clockDiff; // 服务器时间差，毫秒
	@Column("resource_label")
	private String resourceLabel; // 标签
	@IgnoreAll
	private Boolean reboot;

	@IgnoreAll
	private Integer cpuDistributable;// CPU可分配
	@IgnoreAll
	private Integer memDistributable;// 内存可分配
	@IgnoreAll
	private Long cpuRemainder;// cpu剩余
	@IgnoreAll
	private Long memoryRemainder;// 内存剩余
	@IgnoreAll
	private Long diskRemainder;// 磁盘剩余
	@IgnoreAll
	private Disk rootDisk;
	@IgnoreAll
	private Integer diskCnt;
	@IgnoreAll
	private String iqn;
	@IgnoreAll
	private List<String> roles;

	/** end */

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

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

	/**
	 * @return the expiredTime
	 */
	public Date getExpiredTime() {
		return expiredTime;
	}

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

	/**
	 * @return the assetCategory
	 */
	public String getAssetCategory() {
		return assetCategory;
	}

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

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

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

	/**
	 * @return the catalog
	 */
	public String getCatalog() {
		return catalog;
	}

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

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

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

	/**
	 * @return the manageIp
	 */
	public String getManageIp() {
		return manageIp;
	}

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

	/**
	 * @return the rackId
	 */
	public Long getRackId() {
		return rackId;
	}

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

	/**
	 * @return the hostname
	 */
	public String getHostname() {
		return hostname;
	}

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

	/**
	 * @return the serviceIp
	 */
	public String getServiceIp() {
		return serviceIp;
	}

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

	/**
	 * @return the tenantId
	 */
	public Long getTenantId() {
		return tenantId;
	}

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

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

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

	/**
	 * @return the connected
	 */
	public Boolean getConnected() {
		return connected;
	}

	/**
	 * @param connected the connected to set
	 */
	public void setConnected(Boolean connected) {
		this.connected = connected;
	}

	/**
	 * @return the maintained
	 */
	public Boolean getMaintained() {
		return maintained;
	}

	/**
	 * @param maintained the maintained to set
	 */
	public void setMaintained(Boolean maintained) {
		this.maintained = maintained;
	}

	/**
	 * @return the ipv6Enabled
	 */
	public Boolean getIpv6Enabled() {
		return ipv6Enabled;
	}

	/**
	 * @param ipv6Enabled the ipv6Enabled to set
	 */
	public void setIpv6Enabled(Boolean ipv6Enabled) {
		this.ipv6Enabled = ipv6Enabled;
	}

	/**
	 * @return the powerState
	 */
	public String getPowerState() {
		return powerState;
	}

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

	/**
	 * @return the clusterId
	 */
	public Long getClusterId() {
		return clusterId;
	}

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

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

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

	/**
	 * @return the resourceId
	 */
	public String getResourceId() {
		return resourceId;
	}

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

	/**
	 * @return the accurated
	 */
	public boolean isAccurated() {
		return accurated;
	}

	/**
	 * @param accurated the accurated to set
	 */
	public void setAccurated(boolean accurated) {
		this.accurated = accurated;
	}

	/**
	 * @return the osCategory
	 */
	public String getOsCategory() {
		return osCategory;
	}

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

	/**
	 * @return the resourceGroup
	 */
	public String getResourceGroup() {
		return resourceGroup;
	}

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

	/**
	 * @return the resourceGroupName
	 */
	public String getResourceGroupName() {
		return resourceGroupName;
	}

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

	/**
	 * @return the groupName
	 */
	public String getGroupName() {
		return GroupName;
	}

	/**
	 * @param groupName the groupName to set
	 */
	public void setGroupName(String groupName) {
		GroupName = groupName;
	}

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

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

	/**
	 * @return the roomname
	 */
	public String getRoomname() {
		return roomname;
	}

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

	/**
	 * @return the rackname
	 */
	public String getRackname() {
		return rackname;
	}

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

	/**
	 * @return the dcname
	 */
	public String getDcname() {
		return dcname;
	}

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

	/**
	 * @return the dcId
	 */
	public Long getDcId() {
		return dcId;
	}

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

	/**
	 * @return the roomId
	 */
	public Long getRoomId() {
		return roomId;
	}

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

	/**
	 * @return the clusterName
	 */
	public String getClusterName() {
		return clusterName;
	}

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

	/**
	 * @return the vdcName
	 */
	public String getVdcName() {
		return vdcName;
	}

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

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

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

	/**
	 * @return the netcards
	 */
	public List<NetworkCard> getNetcards() {
		return netcards;
	}

	/**
	 * @param netcards the netcards to set
	 */
	public void setNetcards(List<NetworkCard> netcards) {
		this.netcards = netcards;
	}

	/**
	 * @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 servers
	 */
	public List<CloudServer> getServers() {
		return servers;
	}

	/**
	 * @param servers the servers to set
	 */
	public void setServers(List<CloudServer> servers) {
		this.servers = servers;
	}

	/**
	 * @return the dataStores
	 */
	public List<DataStore> getDataStores() {
		return dataStores;
	}

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

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

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

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

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

	/**
	 * @return the datastoreNum
	 */
	public Integer getDatastoreNum() {
		return datastoreNum;
	}

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

	/**
	 * @return the config
	 */
	public ServerConfig getConfig() {
		return config;
	}

	/**
	 * @param config the config to set
	 */
	public void setConfig(ServerConfig config) {
		this.config = config;
	}

	/**
	 * @return the assets
	 */
	public ServerAssets getAssets() {
		return assets;
	}

	/**
	 * @param assets the assets to set
	 */
	public void setAssets(ServerAssets assets) {
		this.assets = assets;
	}

	/**
	 * @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 guid
	 */
	public String getGuid() {
		return guid;
	}

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

	/**
	 * @return the instance
	 */
	public String getInstance() {
		return instance;
	}

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

	/**
	 * @return the rackhdNodeId
	 */
	public String getRackhdNodeId() {
		return rackhdNodeId;
	}

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

	/**
	 * @return the imageId
	 */
	public Long getImageId() {
		return imageId;
	}

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

	/**
	 * @return the imageName
	 */
	public String getImageName() {
		return imageName;
	}

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

	public String getImageIsoName() {
		return imageIsoName;
	}

	public void setImageIsoName(String imageIsoName) {
		this.imageIsoName = imageIsoName;
	}

	/**
	 * @return the discoverTime
	 */
	public Date getDiscoverTime() {
		return discoverTime;
	}

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

	/**
	 * @return the discovered
	 */
	public Boolean getDiscovered() {
		return discovered;
	}

	/**
	 * @param discovered the discovered to set
	 */
	public void setDiscovered(Boolean discovered) {
		this.discovered = discovered;
	}

	/**
	 * @return the identifier
	 */
	public String getIdentifier() {
		return identifier;
	}

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

	public Boolean getReboot() {
		return reboot;
	}

	public void setReboot(Boolean reboot) {
		this.reboot = reboot;
	}

	public Integer getCpuDistributable() {
		return cpuDistributable;
	}

	public void setCpuDistributable(Integer cpuDistributable) {
		this.cpuDistributable = cpuDistributable;
	}

	public Integer getMemDistributable() {
		return memDistributable;
	}

	public void setMemDistributable(Integer memDistributable) {
		this.memDistributable = memDistributable;
	}

	public Long getCpuRemainder() {
		return cpuRemainder;
	}

	public void setCpuRemainder(Long cpuRemainder) {
		this.cpuRemainder = cpuRemainder;
	}

	public Long getMemoryRemainder() {
		return memoryRemainder;
	}

	public void setMemoryRemainder(Long memoryRemainder) {
		this.memoryRemainder = memoryRemainder;
	}

	public Long getDiskRemainder() {
		return diskRemainder;
	}

	public void setDiskRemainder(Long diskRemainder) {
		this.diskRemainder = diskRemainder;
	}

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

	public List<StoreHost> getStoreHosts() {
		return storeHosts;
	}

	public void setStoreHosts(List<StoreHost> storeHosts) {
		this.storeHosts = storeHosts;
	}

	public String getVendorType() {
		return vendorType;
	}

	public void setVendorType(String vendorType) {
		this.vendorType = vendorType;
	}

	public String getVmotionIp() {
		return vmotionIp;
	}

	public void setVmotionIp(String vmotionIp) {
		this.vmotionIp = vmotionIp;
	}

	public String getOs() {
		return os;
	}

	public void setOs(String os) {
		this.os = os;
	}

	/**
	 * @return the exporterInstalled
	 */
	public Boolean getExporterInstalled() {
		return exporterInstalled;
	}

	/**
	 * @param exporterInstalled the exporterInstalled to set
	 */
	public void setExporterInstalled(Boolean exporterInstalled) {
		this.exporterInstalled = exporterInstalled;
	}

	public Long getRootDiskId() {
		return rootDiskId;
	}

	public void setRootDiskId(Long rootDiskId) {
		this.rootDiskId = rootDiskId;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public Long getClockDiff() {
		return clockDiff;
	}

	public void setClockDiff(Long clockDiff) {
		this.clockDiff = clockDiff;
	}

	public Disk getRootDisk() {
		return rootDisk;
	}

	public void setRootDisk(Disk rootDisk) {
		this.rootDisk = rootDisk;
	}

	public Integer getDiskCnt() {
		return diskCnt;
	}

	public void setDiskCnt(Integer diskCnt) {
		this.diskCnt = diskCnt;
	}

	public String getIqn() {
		return iqn;
	}

	public void setIqn(String iqn) {
		this.iqn = iqn;
	}

	public String getServices() {
		return services;
	}

	public void setServices(String services) {
		this.services = services;
	}

	public List<String> getRoles() {
		return roles;
	}

	public void setRoles(List<String> roles) {
		this.roles = roles;
	}

	public String getResourceLabel() {
		return resourceLabel;
	}

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

	public ServerPci getServerPci() {
		return serverPci;
	}

	public void setServerPci(ServerPci serverPci) {
		this.serverPci = serverPci;
	}

	public List<ServerRaidCtrl> getRaids() {
		return raids;
	}

	public void setRaids(List<ServerRaidCtrl> raids) {
		this.raids = raids;
	}

	public List<PowervcHmc> getPowervcHmcs() {
		return powervcHmcs;
	}

	public void setPowervcHmcs(List<PowervcHmc> powervcHmcs) {
		this.powervcHmcs = powervcHmcs;
	}

	public String getCpuModel() {
		return cpuModel;
	}

	public void setCpuModel(String cpuModel) {
		this.cpuModel = cpuModel;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public Boolean getEnabled() {
		return enabled;
	}

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

	public Long getDiscoverUserId() {
		return discoverUserId;
	}

	public void setDiscoverUserId(Long discoverUserId) {
		this.discoverUserId = discoverUserId;
	}
}
