package com.bocloud.cmp.model;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bocloud.acd.entity.resource.VendorModel;
import com.bocloud.cmp.model.fusionsphere.NicSpecificationModel;
import com.bocloud.cmp.model.sangfor.SangforDiskModel;
import com.bocloud.cmp.model.sangfor.SangforNetWorkConfig;
import com.bocloud.cmp.model.sangfor.SangforNetwork;
import lombok.Data;

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

@Data
public class ServerModel implements VendorModel {
	private String name;
	private Boolean ha; // 高可用
	private Boolean autoSchedule; // 自动调整所属主机
	private String biosUuid;
	private Integer cpu;
	private Double hmcCpu;
	private BigDecimal memory;
	private Integer disk;// 磁盘大小(预分配的虚拟磁盘大小，实际使用空间可能会大于这个值)
	private String diskUnit;// 磁盘单位
	private String privateIps;
	private String publicIps;
	private String managerIp;
	private String imageUuid;
	private String flavorUuid;
	private String networkUuid;
	private String instanceId;
	private String subnetUuid;
	private String routerUuid;
	private String zone;
	private String groups;
	private String requestId;
	private String regionId;
	private String remark;
	private String account;
	private String password;
	private String status;
	private String internetChargeType;// 网络计费类型
	private Integer internetMaxBandwidthIn;// 公网入带宽最大值
	private Integer internetMaxBandwidthOut;// 公网出带宽最大值
	private String instanceChargeType;// 实例付费类型
	private String instanceNetworkType;// 实例的网络类型
	private String instanceType;// 实例类型
	private String systemDiskCategory;// 系统盘的类型
	private Integer systemDiskSize;// 系统盘的大小
	private String rootVolumeType;// 根磁盘类型
	private Integer dataDisk;// 数据盘
	private String dataDisks;
	private Boolean isTemplate;
	private Integer count;
	private Integer feeType;
	private String template;// 模板名称
	private Double templateSize;// 模板占用空间大小
	private List<String> stores;
	private List<SnapshotModel> snapshots;
	private Boolean toolsInstalled;
	private Integer extendDisk;
	private String clusterUuid;
	private String clusterName;
	private String vdcName;
	private String hostName;
	private String hostIp; // 所属主机ip
	private String datastores;
	private String datastore;
	private Boolean toolsRunning;
	private List<SangforNetwork> sangforNetworks;
	private List<SangforNetWorkConfig> sangforNetWorkConfigs;
	private Integer diskStorage;
	private String diskStorageUuid;
	private List<NetworkModel> networks;
	private List<NetworkCardModel> netcards;// 网卡
	private List<NetcardOperation> operations;
	private List<IpModel> ips;// 自定义多IP信息
	private Long hostId;
	private Long vdcId;
	private Date gmtVmCreate; // 云主机创建时间
	private Date gmtVmModify; // 云主机创建时间
	private Date gmtExpiredTime; // 到期时间
	private Date gmtModify; // 云主机修改时间
	private List<NetworkBean> networkBeans;// 创建OpenStack云主机时指定的所有网络
	private List<String> securityGroups;// 创建OpenStack云主机时指定的安全组(名称)
	private List<PortModel> ports;// 与云主机绑定的所有端口
	private Integer rootSize;// 根磁盘容量
	private String osCategory;
	private String osName;
	private String osVersion;
	private Boolean isEnableQga;// 镜像是否启用QEMU客户端
	private String keypairName;// 密钥名称
	private String dns;
	private String gateway;
	private Boolean cpuHotEnable;// 是否开启CPU热插拔
	private Boolean memHotEnable;// 是否开启内存热插拔
	private Long resPoolId;// 所属资源池ID
	private String resPoolName;// 所属资源池名称
	private String resPoolVal;// 所属资源池value
	private String isoPath;// 数据存储ISO文件
	private List<NicAdapterModel> nicAdapters;// 网卡(key)+适配器(value)
	private List<VolumeModel> diskDevices;// 云主机磁盘设备
	private Boolean bootFromVolume;// 是否从卷创建
	private String vSwitchId;
	private List<Integer> disks;// 云主机新增的磁盘(vcenter)
	private List<String> dataStoreNames; // 云主机(vcenter)新增的磁盘对应的datastore的名称
	private List<SangforDiskModel> sangforDisks;// 深信服的磁盘信息
	private String vmHostName;
	private List<String> isos;
	private List<String> vSwitchIds;
	private Long sourceValidId;// 源卷ID
	private String sourceValidUuid;// 源卷UUID
	private Long sourceSnapId;// 源快照ID
	private String sourceSnapUuid;// 源快照UUID
	private String vendorVersion;// 平台版本
	private String templatePasswd;// 模板的密码
	private String props;
	private List<Long> labelIds;// 云主机标签
	private String labelNames;
	private Boolean isUsePublicIp; // 是否分配公网IP
	private String vpcId;
	private String storeName;// 要迁移的数据存储名称
	private String tempInstId;// 模板实例ID
	private List<JSONObject> diskLocators;// 重定位的磁盘
	private List<NetworkCardModel> networkCards;
	private JSONObject healthStatus; // 云主机健康状态
	private String activeCmd; // 激活时需要执行的脚本内容
	private String taskState; // 云主机任务执行状况，不为空说明有任务在操作。
	private String[] InstanceIds;
	private String[] keypairIds;
	private Integer instancePeriod; // 购买时长
	private String instanceRenewFlag; // 包年包月业务 策略 是否自动续费等
	private VmwareToolsConfig vmwareToolsConfig;
	private String toolsConfig;// VMware Tools配置
	private String vpcUuid;
	private AzureParams azureParams; // azure云所属参数格式
	private String azureResourceGroupName;
	private List<JSONObject> addDiskList;
	private List<JSONObject> dataDiskList;
	private List<JSONObject> editDiskList;
	private Boolean toolsExpired;
	private Integer localVolumeSize;
	private Integer bandWidth; // 内网带宽
	private String policyUuid; // qos policyId
	private String tenantUuid;// openstack底层租户id
	private String vmFolder;// 云主机创建文件夹
	private String parentVmFolder;// 云主机创建父级文件夹
	private Boolean migrate; // 冷迁移
	private String resourceGroupUuid;
	private String backupSize; // 副本大小
	private String backupCount; // 副本数量
	private List<JSONObject> h3cNetworkCards;
	private String systemDiskPerformanceLevel;// 系统盘性能级别
	private Boolean hasIpv6;
	private Boolean hasEip;
	private Long eipId;
	private JSONArray labelContent;
	private String firmware; // 引导方式
    private String enterpriseProjectUuid;
    private String ipType;
    private ElasticIpModel elasticIpModel;

	// 存储路径
	private String folderName;
	
	/**
	 * vcenter磁盘格式(sameAsSource与源格式相同|flat厚置备延迟置零|thick厚置备快速置零|thin精简置备)
	 */
	private String diskType;
	/**
	 * 实际使用的磁盘大小（单位GB）
	 * <p>
	 * 这个值是云主机实际占用的磁盘空间大小，这个值可能会大于预分配的值(即disk)
	 * </p>
	 */
	private Double diskUsed;
	// azure 新增字段.start
	private String popularLinuxImage; // Linux通用镜像
	private String PopularWindowsImage;// Windows通用镜像
	private String systemDiskName;// 系统盘名
	private String systemDiskCaching;// 系统盘缓存
	private String subnetName;// 创建云主机所需指定的子网名字
	private String networkInterfaceUuid; // 网络接口uuid
	private String imageType;// 用于创建主机是区分镜像类型是公有镜像还是私有镜像
	private String systemDiskUuid; // 系统盘uuid
	private String availabilitySetUuid; // 可用性集uuid
	// azure 新增字段.end
	// aws 新增字段.start
	private List<NetworkInterfaceModel> networkInterfaces;// 网络接口数组
	// aws 新增字段.end
	private String resourceLabel;// 资源标签
	// 存储策略id
	private String profileId;// 存储策略id
	// vcenter rdm磁盘
	private List<JSONObject> rdmDisks;
	// vapp名称
	private String vappName;
	private Long vappId;
	private String ovfItemId;
	private String nicPortGroup;
	private String nicPortType;

	private String offer;
	private String sku;
	private String publisher;
	private Integer period;// 购买资源的时长
	private String periodUnit;// 取值范围：Week和Month（默认）

	private Boolean terminationProtected; // 是否启动终止保护
	private List<TagModel> tagModels;
	private List<Nics> nicses;
	private String serverVal;
	private Boolean autoRenew;// 是否要自动续费
	private Integer autoRenewPeriod;// 每次自动续费的时长

	private List<JSONObject> tags;
	private String cloudTags;

	private String sshKey;
	private String publicIpAddressUuid;
	private String resourceGroupName;
	private Long rgId; //资源组id 用于云主机创建时保留字段
	private String licenseType;    //混合权益
	private String availabilityZoneIds;//可用性区域
	private String dnsServers;
	// 快速克隆false  完全拷贝克隆true
	private Boolean fullClone;
	// 是否安装了CloudInit
	private Boolean cloudInitSupported;

	//-----FusionSphere新增字段--------//
	private String uri;//访问主机的uri
	private String hostUuid;
	private Boolean isLinkClone;//是否为链接克隆云主机
	private String vdcUri;
	private String vdcUuid;
	private String arch;//云主机架构，可选字段，该字段可以不填充，会根据所创建云主机计算资源（集群或者主机）的架构自动填充：x86场景为“x86”,arm场景下为“arm”。
	private String vmlocation;//云主机所属，可以是集群或主机。clusterUrn或hostUrn
	private  Boolean isBindingHost;//是否与主机绑定。当location为hostUrn时有效。若指定主机不位于集群下时系统自动将此属性处理为true;若主机位于集群下时默认为fals
	private String cdRomStatus;//光驱状态
	private String createMode;//创建方式 Default Template FromServer
	private Boolean customization;//是否自定义配置创建
	private Long businessTemplateId;
	private List<NicSpecificationModel> nicSpecificationModels;

	//-----Sangfor新增字段--------//
	private Boolean isNewlyCreated; // true:全新创建虚拟机; false:虚拟机克隆
	private String targetNode;
	private Boolean start;
	private String cloneType;
	private Boolean cloneShareDisk;
	private String interfaceType;
	private String interfaceId;
	private String mac;
	private String ip;
	private String mask;
	private String primaryDns;
	private String secondaryDns;
	private Boolean disableNet;
	private String storagePolicy;
	private String alwaysTryHost;
	private String group;
	private String storage;
	private String sourceVmId;
	private String dir;
	private String label;
	private Boolean ha_enable;
	private String cfgstorage;
    private String node;
	private String always_try_host;
	private String ostype;
//	private String osname;
	private Boolean schedopt;
	private String cpuType;	// 特殊字段
	private Integer sockets;
	private Integer cores;
	private Boolean numa;
	private Boolean if_numa_on;
	private Boolean hugepage;
	private String high_performance_disks;
	private String use_vblk;
	private String set_net;
	private String graphic_type;
	private String mousetype;
	private Integer splash_time;
	private Boolean uefi_bios;
//	private String hostname;
	private Boolean abnormal_recovery;
	private Boolean onboot;
	private String boot;
	private String bootdisk;
	private Integer hotplug;
	private String lifespan;
	private Boolean use_uuid;
	private Boolean encrypted;
	private Boolean no_kvm_clock;
	private Boolean disable_ple;
	private Boolean file_filter;
	private Boolean autostart;
	private Boolean balloon_memory;
	private String ide0;    // 磁盘1
	private String ide2;    // 磁盘相关
	private String net0;    // 网卡1
	private String ip_net0; // 网卡1 ipv4相关配置
	private String ip6_net0;// 网卡1 ipv6相关配置


	private String preallocate;
	private String networkcardType;// 网卡类型
	private String bridge;  	// 物理设备id
	private String bridgename;  // 物理设备名称
	private Double disk_total;
	private String dns1;    	// dns1
	private String dns2;    	// dns2
	private String ipv6;    	// ipv6
	private String ipv6Gateway; // ipv6 网关
	private String ipv6Dns1;    // ipv6 dns1
	private String ipv6Dns2;    // ipv6 dns2
	private String prefixlen;// 前缀长度
	private String iso;// 选择的光驱(镜像)
	private String portUuid; // 设备的端口组id
	//深信服Scp V6.8字段
	private Integer addDiskTotal; //新增磁盘大小
	private String resourceId;//资源池Id
	private Boolean powerOn;//创建完成后是否启动

	private String localId;

	@Override
	public Serializable getIdInVendor(String s) {
		return this.instanceId;
	}

	//-----FusionSphere新增字段--------//
	public static class Nics {
		private String subnetUuid;
		private List<String> scGroupUuids;

		public String getSubnetUuid() {
			return subnetUuid;
		}

		public void setSubnetUuid(String subnetUuid) {
			this.subnetUuid = subnetUuid;
		}

		public List<String> getScGroupUuids() {
			return scGroupUuids;
		}

		public void setScGroupUuids(List<String> scGroupUuids) {
			this.scGroupUuids = scGroupUuids;
		}
	}


	public ServerModel() {
		super();
	}

	public ServerModel(String name, String remark) {
		super();
		this.name = name;
		this.remark = remark;
	}

	public ServerModel(String name, String instanceId, String remark) {
		super();
		this.name = name;
		this.instanceId = instanceId;
		this.remark = remark;
	}

	public ServerModel(String name, Integer cpu, BigDecimal memory, Integer disk, String instanceId) {
		super();
		this.name = name;
		this.cpu = cpu;
		this.memory = memory;
		this.disk = disk;
		this.instanceId = instanceId;
	}

	public ServerModel(String instanceId, String name, String remark, Date gmtVmCreate, String privateIp,
			String publicIps, String status, Integer cpu, BigDecimal memory, Integer disk, String imageId,
			String subnetUuid, String routerUuid, String networkUuid, String groups, String requestId) {
		super();
		this.instanceId = instanceId;
		this.name = name;
		this.remark = remark;
		this.gmtVmCreate = gmtVmCreate;
		this.privateIps = privateIp;
		this.publicIps = publicIps;
		this.status = status;
		this.cpu = cpu;
		this.memory = memory;
		this.disk = disk;
		this.imageUuid = imageId;
		this.subnetUuid = subnetUuid;
		this.routerUuid = routerUuid;
		this.networkUuid = networkUuid;
		this.groups = groups;
		this.requestId = requestId;
	}

	public void prepareData(String name, String account, String password, String flavorUuid,
			List<NetworkBean> networkBeans, List<String> securityGroups) {
		this.name = name;
		this.account = account;
		this.password = password;
		this.flavorUuid = flavorUuid;
		this.networkBeans = networkBeans;
		this.securityGroups = securityGroups;
	}

	public void prepareData(String account, String password, String networkUuid, String flavorUuid, String imageUuid,
			List<IpModel> ips) {
		this.account = account;
		this.password = password;
		this.networkUuid = networkUuid;
		this.flavorUuid = flavorUuid;
		this.imageUuid = imageUuid;
		this.ips = ips;
	}

	public void prepareData(Integer cpu, BigDecimal memory, Integer disk, String hostName, String clusterName,
			String vdcName, String datastore, String template, List<NetcardOperation> operations) {
		this.cpu = cpu;
		this.memory = memory;
		this.disk = disk;
		this.hostName = hostName;
		this.clusterName = clusterName;
		this.vdcName = vdcName;
		this.datastore = datastore;
		this.template = template;
		this.operations = operations;
	}

	public void prepareData(Integer cpu, BigDecimal memory, Integer disk, String hostName, String clusterName,
			String vdcName, String datastore, String template, List<NetcardOperation> operations, List<IpModel> ips) {
		this.cpu = cpu;
		this.memory = memory;
		this.disk = disk;
		this.hostName = hostName;
		this.clusterName = clusterName;
		this.vdcName = vdcName;
		this.datastore = datastore;
		this.template = template;
		this.operations = operations;
		this.ips = ips;
	}

	public void prepareData(String account, String password, String zone, String imageUuid, String instanceChargeType,
			String groups, Integer systemDiskSize, List<VolumeModel> diskDevices, String flavorUuid, String networkUuid,
			String subnetUuid, String keypairName) {
		this.account = account;
		this.password = password;
		this.zone = zone;
		this.imageUuid = imageUuid;
		this.instanceChargeType = instanceChargeType;
		this.groups = groups;
		this.systemDiskSize = systemDiskSize;
		this.diskDevices = diskDevices;
		this.flavorUuid = flavorUuid;
		this.networkUuid = networkUuid;
		this.subnetUuid = subnetUuid;
		this.keypairName = keypairName;
	}

	public void prepareData(String account, String password, String regionId, String zone, String imageId,
			String instanceType, String groups, String internetChargeType, Integer internetMaxBandwidthIn,
			Integer internetMaxBandwidthOut, Integer systemDiskSize, String systemDiskCategory, String dataDisk) {
		this.account = account;
		this.password = password;
		this.regionId = regionId;
		this.zone = zone;
		this.imageUuid = imageId;
		this.instanceType = instanceType;
		this.groups = groups;
		this.internetChargeType = internetChargeType;
		this.internetMaxBandwidthIn = internetMaxBandwidthIn;
		this.internetMaxBandwidthOut = internetMaxBandwidthOut;
		this.systemDiskSize = systemDiskSize;
		this.systemDiskCategory = systemDiskCategory;
		this.dataDisks = dataDisk;
	}

}
