Example #1
0
File: list.go Project: juito/hyper
// PodList implements GET /list?item=pod
func (s *ServerRPC) PodList(ctx context.Context, req *types.PodListRequest) (*types.PodListResponse, error) {
	glog.V(3).Infof("PodList with request %s", req.String())

	result := make([]*types.PodListResult, 0, 1)
	podList, err := s.daemon.ListPods(req.PodID, req.VmID)
	if err != nil {
		glog.Errorf("PodList error: %v", err)
		return nil, err
	}

	for _, p := range podList {
		vmID := ""
		if p.VM != nil {
			vmID = p.VM.Id
		}

		result = append(result, &types.PodListResult{
			PodID:     p.Id,
			PodName:   p.Spec.Name,
			Labels:    p.Spec.Labels,
			CreatedAt: p.CreatedAt,
			VmID:      vmID,
			Status:    s.daemon.GetPodStatus(p.PodStatus.Status, p.Spec.Type),
		})
	}

	return &types.PodListResponse{
		PodList: result,
	}, nil
}
Example #2
0
File: list.go Project: gnawux/hyper
// PodList implements GET /list?item=pod
func (s *ServerRPC) PodList(ctx context.Context, req *types.PodListRequest) (*types.PodListResponse, error) {
	glog.V(3).Infof("PodList with request %s", req.String())

	podList, err := s.daemon.ListPods(req.PodID, req.VmID)
	if err != nil {
		glog.Errorf("PodList error: %v", err)
		return nil, err
	}

	return &types.PodListResponse{
		PodList: podList,
	}, nil
}