示例#1
0
func (m *manager) HyperInfo() (info.DockerStatus, error) {
	hyperClient := hyper.NewHyperClient()
	hyperInfo, err := hyperClient.Info()
	if err != nil {
		return info.DockerStatus{}, err
	}

	hyperVersion, err := hyperClient.Version()
	if err != nil {
		return info.DockerStatus{}, err
	}

	out := info.DockerStatus{
		Version:      hyperVersion,
		DriverStatus: make(map[string]string),
	}
	if val, ok := hyperInfo["KernelVersion"]; ok {
		out.KernelVersion = val.(string)
	}
	if val, ok := hyperInfo["OperatingSystem"]; ok {
		out.OS = val.(string)
	}
	if val, ok := hyperInfo["Name"]; ok {
		out.Hostname = val.(string)
	}
	if val, ok := hyperInfo["DockerRootDir"]; ok {
		out.RootDir = val.(string)
	}
	if val, ok := hyperInfo["Driver"]; ok {
		out.Driver = val.(string)
	}
	if val, ok := hyperInfo["ExecutionDriver"]; ok {
		out.ExecDriver = val.(string)
	}
	if val, ok := hyperInfo["Images"]; ok {
		out.NumImages = int(val.(float64))
	}
	if val, ok := hyperInfo["Containers"]; ok {
		out.NumContainers = int(val.(float64))
	}
	if val, ok := hyperInfo["DriverStatus"]; ok {
		for _, value := range val.([]interface{}) {
			v := value.([]interface{})
			out.DriverStatus[v[0].(string)] = v[1].(string)
		}
	}
	return out, nil
}
示例#2
0
文件: hyper.go 项目: hyperhq/cadvisor
func (self *hyperContainerWatcher) listRunningPods() ([]hyper.HyperPod, error) {
	var runningPods []hyper.HyperPod
	client := hyper.NewHyperClient()

	pods, err := client.ListPods()

	if err != nil {
		return nil, err
	}

	for _, pod := range pods {
		if pod.Status == runningStatus {
			runningPods = append(runningPods, pod)
		}
	}

	return runningPods, nil
}
示例#3
0
func (m *manager) HyperImages() ([]info.DockerImage, error) {
	hyperClient := hyper.NewHyperClient()
	images, err := hyperClient.ListImages()
	if err != nil {
		return nil, err
	}

	out := []info.DockerImage{}
	for _, image := range images {
		di := info.DockerImage{
			ID:          image.ImageID,
			RepoTags:    []string{fmt.Sprintf("%v:%v", image.Repository, image.Tag)},
			Created:     image.CreatedAt,
			VirtualSize: image.VirtualSize,
		}
		out = append(out, di)
	}
	return out, nil
}