예제 #1
0
func (this *OverviewService) GetMachineInfo() OverviewList {
	_nodeModel := k8sModel.NodeModel{}
	data := _nodeModel.GetNodeList()

	var _overview_list OverviewList
	_overview_list.Status = "ok"
	for _, data_items := range data.Items {
		var _machine_info machine_info
		_machine_info.Name = data_items.Metadata.Name
		_machine_info.Ip = data_items.Status.Addresses[0].Address
		_machine_info.Cpu, _ = strconv.Atoi(data_items.Status.Capacity["cpu"])

		mem_str := strings.Split(data_items.Status.Capacity["memory"], "Ki")[0]
		mem, _ := strconv.ParseFloat(mem_str, 64)
		_machine_info.Mem = mem / 1024

		if data_items.Status.Conditions[0].Status == "True" {
			_machine_info.Status = "Ready"
		} else {
			_machine_info.Status = data_items.Status.Conditions[0].Reason
		}

		_overview_list.Data.Machine_info = append(_overview_list.Data.Machine_info, _machine_info)
	}
	return _overview_list
}
예제 #2
0
func (this *NodeService) GetPodList() Nodes {
	var _node_list Nodes
	_nodeModel := k8sModel.NodeModel{}
	_node_data := _nodeModel.GetNodeList()

	_node_list.Status = "ok"
	_node_list.Data = _node_data.Items
	return _node_list
}
예제 #3
0
func (this *OverviewService) GetMachineCount() OverviewList {
	_nodeModel := k8sModel.NodeModel{}
	data := _nodeModel.GetNodeList()

	var _overview_list OverviewList
	_overview_list.Status = "ok"
	_overview_list.Data.Machine_count = len(data.Items)
	return _overview_list
}