package node

// Node summary
type RecordNode struct {
	// Consumption
	Consumption ConsumptionInfo `json:"consumption"`

	// CPU Info
	CpuInfo CpuInfo `json:"cpuInfo"`

	// CPU Allocation Ratio
	CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`

	// DPDK info
	DPDK DPDK `json:"dpdk"`

	// GID
	GID uint64 `json:"gid"`

	// Node ID
	ID uint64 `json:"id"`

	// IPAddr
	IPAddr []string `json:"ipaddr"`

	// Isolated Cpus
	IsolatedCpus []interface{} `json:"isolatedCpus"`

	// MemAllocationRatio
	MemAllocationRatio float64 `json:"mem_allocation_ratio"`

	// Name
	Name string `json:"name"`

	// NeedReboot
	NeedReboot bool `json:"needReboot"`

	// Netaddr
	NetAddr NetAddr `json:"netaddr"`

	// Network mode
	NetworkMode string `json:"networkmode"`

	// Nic Info
	NicInfo ListNicInfo `json:"nicInfo"`

	// NumaTopology
	NumaTopology NumaTopologyInfo `json:"numaTopology"`

	// ReservedCPUs
	ReservedCPUs []interface{} `json:"reservedCpus"`

	// Roles
	Roles []string `json:"roles"`

	// SriovEnabled
	SriovEnabled bool `json:"sriovEnabled"`

	// Status
	Status string `json:"status"`

	// To active
	ToActive Role `json:"to_active"`

	// To installing
	ToInstalling Role `json:"to_installing"`

	// To maintenance
	ToMaintenance Role `json:"to_maintenance"`

	// To restricted
	ToRestricted Role `json:"to_restricted"`

	// Version
	Version string `json:"version"`

	// Zone ID
	ZoneID uint64 `json:"zoneId"`

	// OpenvSwitch Bridges
	OpenvSwitchBridges []string `json:"openvswitch_bridges"`

	// Description
	Description string `json:"description"`

	// SDN Hypervisor Name
	SDNHypervisorName string `json:"sdn_hypervisor_name"`

	// CPU used by the node
	UsableCPUs []string `json:"usable_cpus"`

	// AutoStart
	AutoStart bool `json:"autostart"`

	// AutoStart Count
	AutoStartCount uint64 `json:"autostart_count"`
}

// Resource consumption of the node
type ConsumptionInfo struct {
	// Consumed resources
	Consumed ConsumedResourcesInfo `json:"consumed"`

	// Free resources
	Free FreeResourcesInfo `json:"free"`

	// Hostname
	Hostname string `json:"hostname"`

	// Reserved resources
	Reserved ResourcesInfo `json:"reserved"`

	// Total resources
	Total ResourcesInfo `json:"total"`
}

// Free Resources Info
type FreeResourcesInfo struct {
	// RAM
	RAM float64 `json:"RAM"`

	// VCPU
	VCPU float64 `json:"vCPUs"`
}

// Resources Info
type ResourcesInfo struct {
	// RAM
	RAM uint64 `json:"RAM"`
}

// Consumed Resources Info
type ConsumedResourcesInfo struct {
	// RAM
	RAM uint64 `json:"RAM"`

	// Computes
	Computes uint64 `json:"computes"`

	// Routers
	Routers uint64 `json:"routers"`

	// VCPU
	VCPU uint64 `json:"vCPU"`
}

// Information about node CPU
type CpuInfo struct {
	// Clock Speed
	ClockSpeed float64 `json:"clockSpeed"`

	// CoreCount
	CoreCount uint64 `json:"coreCount"`

	// PhysCount
	PhysCount uint64 `json:"physCount"`

	// Thread count
	ThreadCount uint64 `json:"threadCount"`

	// Flags
	Flags []string `json:"flags"`

	// Mddel name
	ModelName string `json:"model_name"`
}

// Main information about node
type ItemNode struct {
	// Additional packages
	AdditionalPkgs []interface{} `json:"additionalpkgs"`

	// CPU Info
	CpuInfo CpuInfo `json:"cpuInfo"`

	// Description
	Description string `json:"description"`

	// DPDK
	DPDK DPDK `json:"dpdk"`

	// GID
	GID uint64 `json:"gid"`

	// GUID
	GUID string `json:"guid"`

	// Hostkey
	HostKey string `json:"hostkey"`

	// ID
	ID uint64 `json:"id"`

	// IPAddr
	IPAddr []string `json:"ipaddr"`

	// Isolated Cpus
	IsolatedCpus []interface{} `json:"isolatedCpus"`

	// Last check
	LastCheck uint64 `json:"lastcheck"`

	// Machine GUID
	MachineGUID string `json:"machineguid"`

	// Mainboard SN
	MainboardSN string `json:"mainboardSN"`

	// Memory
	Memory uint64 `json:"memory"`

	// Milestones
	Milestones uint64 `json:"milestones"`

	// Model
	Model string `json:"model"`

	// Name
	Name string `json:"name"`

	// NeedReboot
	NeedReboot bool `json:"needReboot"`

	// NetAddr
	NetAddr ListNetAddr `json:"netaddr"`

	// Network mode
	NetworkMode string `json:"networkmode"`

	// Nic Info
	NicInfo ListNicInfo `json:"nicInfo"`

	// Node UUID
	NodeUUID string `json:"nodeUUID"`

	// NumaTopology
	NumaTopology NumaTopologyInfo `json:"numaTopology"`

	// PeerBackup
	PeerBackup uint64 `json:"peer_backup"`

	// PeerLog
	PeerLog uint64 `json:"peer_log"`

	// PeerStats
	PeerStats uint64 `json:"peer_stats"`

	// Pgpus
	Pgpus []uint64 `json:"pgpus"`

	// PublicKeys
	PublicKeys []string `json:"publickeys"`

	// Release
	Release string `json:"release"`

	// ReservedCPUs
	ReservedCPUs []interface{} `json:"reservedCpus"`

	// Roles
	Roles []string `json:"roles"`

	// SDN Hypervisor Name
	SDNHypervisorName string `json:"sdn_hypervisor_name"`

	// Seps
	Seps []uint64 `json:"seps"`

	// SerialNum
	SerialNum string `json:"serialNum"`

	// SriovEnabled
	SriovEnabled bool `json:"sriovEnabled"`

	// Status
	Status string `json:"status"`

	// Tags
	Tags []string `json:"tags"`

	// Type
	Type string `json:"type"`

	//UEFI Firmware File
	UEFIFirmwareFile string `json:"uefiFirmwareFile"`

	// Version
	Version string `json:"version"`

	// Zone ID
	ZoneID uint64 `json:"zoneId"`

	// OpenvSwitch Bridges
	OpenvSwitchBridges []string `json:"openvswitch_bridges"`

	// APIUrl
	APIUrl string `json:"apiUrl"`

	// Drivers
	Drivers []string `json:"drivers"`

	// Old Compat LVM ID
	OldCompatLVMID uint64 `json:"old_compat_lvm_id"`

	// CPU Allocation ratio
	CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`

	// MemAllocationRatio
	MemAllocationRatio float64 `json:"mem_allocation_ratio"`

	// Packages
	Packages map[string]PackageInfo `json:"packages"`

	// CPU used by the node
	UsableCPUs []string `json:"usable_cpus"`

	// AutoStart
	AutoStart bool `json:"autostart"`

	// AutoStart Count
	AutoStartCount uint64 `json:"autostart_count"`
}

type PackageInfo struct {
	// Installed size
	InstalledSize string `json:"installed_size"`
	// Version
	Ver string `json:"ver"`
}

// Numa Topology Info
type NumaTopologyInfo struct {
	// NodeNum
	NodeNum uint64 `json:"nodenum"`

	// Nodes
	Nodes map[string]NodeInfo `json:"nodes"`
}

// Node Info from NumaTopologyInfo
type NodeInfo struct {
	// CPUList
	CPUList []uint64 `json:"cpulist"`

	// Memory
	Memory ItemMemory `json:"memory"`
}

type ItemMemory struct {
	// 1G
	OneG uint64 `json:"1G"`

	// 2M
	TwoM uint64 `json:"2M"`

	// Total
	Total uint64 `json:"total"`
}

type ListNicInfo []ItemNicInfo

// Item Nic Info
type ItemNicInfo struct {
	// Driver
	Driver string `json:"driver"`

	// MaxVFS
	MaxVFS uint64 `json:"maxvfs"`

	// NumaNode
	NumaNode int64 `json:"numaNode"`

	// NumVFS
	NumVFS uint64 `json:"numvfs"`

	// OSName
	OSName string `json:"osName"`

	// PCISlot
	PCISlot string `json:"pciSlot"`

	// VFList
	VFList []interface{} `json:"vflist"`
}

type ListNetAddr []ItemNetAddr

// Item Net Addr
type ItemNetAddr struct {
	// CIDR
	CIDR []string `json:"cidr"`

	// Index
	Index uint64 `json:"index"`

	// IP
	IP []string `json:"ip"`

	// Mac
	Mac string `json:"mac"`

	// MTU
	MTU uint64 `json:"mtu"`

	// Name
	Name string `json:"name"`
}

// List of nodes
type ListNodes struct {
	// Data
	Data []ItemNode `json:"data"`

	// Entry count
	EntryCount uint64 `json:"entryCount"`
}

// Net address
type NetAddr struct {
	// Name
	Name string `json:"name"`

	// IP list backplane1 node
	IP []string `json:"ip"`
}

// DPDK info
type DPDK struct {
	// Bridges
	Bridges Bridges `json:"bridges"`

	// hp memory
	HPMemory map[string]uint64 `json:"hp_memory"`

	// pmd cpu
	PMDCPU []uint64 `json:"pmd_cpu"`
}

// Bridges
type Bridges struct {
	Backplane1 Backplane1 `json:"backplane1"`
}

// Backplane1
type Backplane1 struct {
	Interfaces []string `json:"interfaces"`
	NumaNode   int64    `json:"numa_node"`
}

// Role
type Role struct {
	Actor  string `json:"actor"`
	Reason string `json:"reason"`
	Time   uint64 `json:"time"`
}

// Information about SSH Identity
type SSHIdentity struct {
	//Host name of the client
	HostName string `json:"host_name"`

	//SSH host key of the client
	HostKey string `json:"host_key"`

	//Array of SSH public keys of the client
	PublicKeys []string `json:"public_keys"`
}
