コード例 #1
0
ファイル: nodelist.go プロジェクト: digitalfishpond/dashboard
func toNode(node api.Node) Node {
	return Node{
		ObjectMeta: common.NewObjectMeta(node.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindNode),
		Ready:      getNodeConditionStatus(node, api.NodeReady),
	}
}
コード例 #2
0
ファイル: limitrangedetail.go プロジェクト: bryk/dashboard
func getLimitRangeDetail(rawLimitRange *api.LimitRange) *LimitRangeDetail {
	return &LimitRangeDetail{
		ObjectMeta:  common.NewObjectMeta(rawLimitRange.ObjectMeta),
		TypeMeta:    common.NewTypeMeta(common.ResourceKindLimitRange),
		LimitRanges: toLimitRanges(rawLimitRange.Spec.Limits),
	}
}
コード例 #3
0
func getConfigMapDetail(rawConfigMap *api.ConfigMap) *ConfigMapDetail {
	return &ConfigMapDetail{
		ObjectMeta: common.NewObjectMeta(rawConfigMap.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindConfigMap),
		Data:       rawConfigMap.Data,
	}
}
コード例 #4
0
func toNamespace(namespace api.Namespace) Namespace {
	return Namespace{
		ObjectMeta: common.NewObjectMeta(namespace.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindNamespace),
		Phase:      namespace.Status.Phase,
	}
}
コード例 #5
0
func getPersistentVolumeList(persistentVolumes []api.PersistentVolume, dsQuery *dataselect.DataSelectQuery) *PersistentVolumeList {
	result := &PersistentVolumeList{
		Items:    make([]PersistentVolume, 0),
		ListMeta: common.ListMeta{TotalItems: len(persistentVolumes)},
	}

	persistentVolumes = fromCells(dataselect.GenericDataSelect(toCells(persistentVolumes), dsQuery))

	for _, item := range persistentVolumes {

		var claim string
		if item.Spec.ClaimRef != nil {
			claim = item.Spec.ClaimRef.Name
		}

		result.Items = append(result.Items,
			PersistentVolume{
				ObjectMeta:  common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:    common.NewTypeMeta(common.ResourceKindPersistentVolume),
				Capacity:    item.Spec.Capacity,
				AccessModes: item.Spec.AccessModes,
				Status:      item.Status.Phase,
				Claim:       claim,
				Reason:      item.Status.Reason,
			})
	}

	return result
}
コード例 #6
0
func getSecretDetail(rawSecret *api.Secret) *SecretDetail {
	return &SecretDetail{
		ObjectMeta: common.NewObjectMeta(rawSecret.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindSecret),
		Data:       rawSecret.Data,
		Type:       rawSecret.Type,
	}
}
コード例 #7
0
// ToReplicaSet converts replica set api object to replica set model object.
func ToReplicaSet(replicaSet *extensions.ReplicaSet, podInfo *common.PodInfo) ReplicaSet {
	return ReplicaSet{
		ObjectMeta:      common.NewObjectMeta(replicaSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicaSet),
		ContainerImages: common.GetContainerImages(&replicaSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
コード例 #8
0
ファイル: ingressdetail.go プロジェクト: kubernetes/dashboard
func getIngressDetail(rawIngress *extensions.Ingress) *IngressDetail {
	return &IngressDetail{
		ObjectMeta: common.NewObjectMeta(rawIngress.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindIngress),
		Spec:       rawIngress.Spec,
		Status:     rawIngress.Status,
	}
}
コード例 #9
0
ファイル: petsetlist.go プロジェクト: cheld/dashboard
// ToPetSet transforms pet set into PetSet object returned by API.
func ToPetSet(petSet *apps.PetSet, podInfo *common.PodInfo) PetSet {
	return PetSet{
		ObjectMeta:      common.NewObjectMeta(petSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindPetSet),
		ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
コード例 #10
0
// ToStatefulSet transforms pet set into StatefulSet object returned by API.
func ToStatefulSet(statefulSet *apps.StatefulSet, podInfo *common.PodInfo) StatefulSet {
	return StatefulSet{
		ObjectMeta:      common.NewObjectMeta(statefulSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindStatefulSet),
		ContainerImages: common.GetContainerImages(&statefulSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
コード例 #11
0
ファイル: joblist.go プロジェクト: cheld/dashboard
func ToJob(job *batch.Job, podInfo *common.PodInfo) Job {
	return Job{
		ObjectMeta:      common.NewObjectMeta(job.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindJob),
		ContainerImages: common.GetContainerImages(&job.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
コード例 #12
0
// NewIngress - creates a new instance of Ingress struct based on K8s Ingress.
func NewIngress(ingress *extensions.Ingress) *Ingress {
	modelIngress := &Ingress{
		ObjectMeta: common.NewObjectMeta(ingress.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindIngress),
		Endpoints:  getEndpoints(ingress),
	}

	return modelIngress
}
コード例 #13
0
// ToReplicationController converts replication controller api object to replication controller
// model object.
func ToReplicationController(replicationController *api.ReplicationController,
	podInfo *common.PodInfo) ReplicationController {

	return ReplicationController{
		ObjectMeta:      common.NewObjectMeta(replicationController.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicationController),
		Pods:            *podInfo,
		ContainerImages: common.GetContainerImages(&replicationController.Spec.Template.Spec),
	}
}
コード例 #14
0
func toNamespaceDetail(namespace api.Namespace, events common.EventList, resourceQuotaList *resourcequota.ResourceQuotaDetailList) NamespaceDetail {

	return NamespaceDetail{
		ObjectMeta:        common.NewObjectMeta(namespace.ObjectMeta),
		TypeMeta:          common.NewTypeMeta(common.ResourceKindNamespace),
		Phase:             namespace.Status.Phase,
		EventList:         events,
		ResourceQuotaList: resourceQuotaList,
	}
}
コード例 #15
0
func getPersistentVolumeClaimDetail(persistentVolumeClaim *api.PersistentVolumeClaim) *PersistentVolumeClaimDetail {

	return &PersistentVolumeClaimDetail{
		ObjectMeta:  common.NewObjectMeta(persistentVolumeClaim.ObjectMeta),
		TypeMeta:    common.NewTypeMeta(common.ResourceKindPersistentVolumeClaim),
		Status:      persistentVolumeClaim.Status.Phase,
		Volume:      persistentVolumeClaim.Spec.VolumeName,
		Capacity:    persistentVolumeClaim.Status.Capacity,
		AccessModes: persistentVolumeClaim.Spec.AccessModes,
	}
}
コード例 #16
0
// ToServiceDetail returns api service object based on kubernetes service object
func ToServiceDetail(service *api.Service) ServiceDetail {
	return ServiceDetail{
		ObjectMeta:        common.NewObjectMeta(service.ObjectMeta),
		TypeMeta:          common.NewTypeMeta(common.ResourceKindService),
		InternalEndpoint:  common.GetInternalEndpoint(service.Name, service.Namespace, service.Spec.Ports),
		ExternalEndpoints: common.GetExternalEndpoints(service),
		Selector:          service.Spec.Selector,
		ClusterIP:         service.Spec.ClusterIP,
		Type:              service.Spec.Type,
	}
}
コード例 #17
0
func getPetSetDetail(petSet *apps.PetSet, heapsterClient client.HeapsterClient,
	eventList common.EventList, podList pod.PodList, podInfo common.PodInfo) PetSetDetail {

	return PetSetDetail{
		ObjectMeta:      common.NewObjectMeta(petSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindPetSet),
		ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
	}
}
コード例 #18
0
ファイル: jobdetail.go プロジェクト: kubernetes/dashboard
func getJobDetail(job *batch.Job, heapsterClient client.HeapsterClient,
	eventList common.EventList, podList pod.PodList, podInfo common.PodInfo) JobDetail {
	return JobDetail{
		ObjectMeta:      common.NewObjectMeta(job.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindJob),
		ContainerImages: common.GetContainerImages(&job.Spec.Template.Spec),
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
		Parallelism:     job.Spec.Parallelism,
		Completions:     job.Spec.Completions,
	}
}
コード例 #19
0
ファイル: replicasetdetail.go プロジェクト: cheld/dashboard
// ToReplicaSetDetail converts replica set api object to replica set detail model object.
func ToReplicaSetDetail(replicaSet *extensions.ReplicaSet, eventList common.EventList,
	podList pod.PodList, podInfo common.PodInfo, serviceList resourceService.ServiceList) ReplicaSetDetail {

	return ReplicaSetDetail{
		ObjectMeta:      common.NewObjectMeta(replicaSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicaSet),
		ContainerImages: common.GetContainerImages(&replicaSet.Spec.Template.Spec),
		Selector:        replicaSet.Spec.Selector,
		PodInfo:         podInfo,
		PodList:         podList,
		ServiceList:     serviceList,
		EventList:       eventList,
	}
}
コード例 #20
0
ファイル: podcommon.go プロジェクト: kubernetes/dashboard
// ToPod transforms Kubernetes pod object into object returned by API.
func ToPod(pod *api.Pod, metrics *common.MetricsByPod, warnings []common.Event) Pod {
	podDetail := Pod{
		ObjectMeta:   common.NewObjectMeta(pod.ObjectMeta),
		TypeMeta:     common.NewTypeMeta(common.ResourceKindPod),
		PodStatus:    getPodStatus(*pod, warnings),
		RestartCount: getRestartCount(*pod),
	}

	if metrics != nil && metrics.MetricsMap[pod.Namespace] != nil {
		metric := metrics.MetricsMap[pod.Namespace][pod.Name]
		podDetail.Metrics = &metric
	}

	return podDetail
}
コード例 #21
0
func toHorizontalPodAutoScaler(hpa *autoscaling.HorizontalPodAutoscaler) HorizontalPodAutoscaler {
	return HorizontalPodAutoscaler{
		ObjectMeta: common.NewObjectMeta(hpa.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindHorizontalPodAutoscaler),

		ScaleTargetRef: horizontalpodautoscaler.ScaleTargetRef{
			Kind: hpa.Spec.ScaleTargetRef.Kind,
			Name: hpa.Spec.ScaleTargetRef.Name,
		},

		MinReplicas:                     hpa.Spec.MinReplicas,
		MaxReplicas:                     hpa.Spec.MaxReplicas,
		CurrentCPUUtilizationPercentage: hpa.Status.CurrentCPUUtilizationPercentage,
		TargetCPUUtilizationPercentage:  hpa.Spec.TargetCPUUtilizationPercentage,
	}

}
コード例 #22
0
// ToReplicationControllerDetail converts replication controller api object to replication
// controller detail model object.
func ToReplicationControllerDetail(replicationController *api.ReplicationController,
	podInfo common.PodInfo, podList pod.PodList, eventList common.EventList,
	serviceList resourceService.ServiceList) ReplicationControllerDetail {

	replicationControllerDetail := ReplicationControllerDetail{
		ObjectMeta:      common.NewObjectMeta(replicationController.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicationController),
		LabelSelector:   replicationController.Spec.Selector,
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
		ServiceList:     serviceList,
		ContainerImages: common.GetContainerImages(&replicationController.Spec.Template.Spec),
	}

	return replicationControllerDetail
}
コード例 #23
0
// Returns detailed information about the given daemon set in the given namespace.
func GetDaemonSetDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient,
	namespace, name string) (*DaemonSetDetail, error) {
	log.Printf("Getting details of %s daemon set in %s namespace", name, namespace)

	daemonSet, err := client.Extensions().DaemonSets(namespace).Get(name)
	if err != nil {
		return nil, err
	}

	podList, err := GetDaemonSetPods(client, heapsterClient, dataselect.DefaultDataSelectWithMetrics, name, namespace)
	if err != nil {
		return nil, err
	}

	podInfo, err := getDaemonSetPodInfo(client, daemonSet)
	if err != nil {
		return nil, err
	}

	serviceList, err := GetDaemonSetServices(client, dataselect.DefaultDataSelect, namespace, name)
	if err != nil {
		return nil, err
	}

	eventList, err := GetDaemonSetEvents(client, dataselect.DefaultDataSelect, daemonSet.Namespace, daemonSet.Name)
	if err != nil {
		return nil, err
	}

	daemonSetDetail := &DaemonSetDetail{
		ObjectMeta:    common.NewObjectMeta(daemonSet.ObjectMeta),
		TypeMeta:      common.NewTypeMeta(common.ResourceKindDaemonSet),
		LabelSelector: daemonSet.Spec.Selector,
		PodInfo:       *podInfo,
		PodList:       *podList,
		ServiceList:   *serviceList,
		EventList:     *eventList,
	}

	for _, container := range daemonSet.Spec.Template.Spec.Containers {
		daemonSetDetail.ContainerImages = append(daemonSetDetail.ContainerImages,
			container.Image)
	}

	return daemonSetDetail, nil
}
コード例 #24
0
func ToResourceQuotaDetail(rawResourceQuota *api.ResourceQuota) *ResourceQuotaDetail {
	statusList := make(map[api.ResourceName]ResourceStatus)

	for key, value := range rawResourceQuota.Status.Hard {
		used := rawResourceQuota.Status.Used[key]
		statusList[key] = ResourceStatus{
			Used: used.String(),
			Hard: value.String(),
		}
	}
	return &ResourceQuotaDetail{
		ObjectMeta: common.NewObjectMeta(rawResourceQuota.ObjectMeta),
		TypeMeta:   common.NewTypeMeta(common.ResourceKindResourceQuota),
		Scopes:     rawResourceQuota.Spec.Scopes,
		StatusList: statusList,
	}
}
コード例 #25
0
ファイル: eventcommon.go プロジェクト: kubernetes/dashboard
// ToEvent converts event api Event to Event model object.
func ToEvent(event api.Event) common.Event {
	result := common.Event{
		ObjectMeta:      common.NewObjectMeta(event.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindEvent),
		Message:         event.Message,
		SourceComponent: event.Source.Component,
		SourceHost:      event.Source.Host,
		SubObject:       event.InvolvedObject.FieldPath,
		Count:           event.Count,
		FirstSeen:       event.FirstTimestamp,
		LastSeen:        event.LastTimestamp,
		Reason:          event.Reason,
		Type:            event.Type,
	}

	return result
}
コード例 #26
0
func getPersistentVolumeDetail(persistentVolume *api.PersistentVolume) *PersistentVolumeDetail {

	var claim string
	if persistentVolume.Spec.ClaimRef != nil {
		claim = persistentVolume.Spec.ClaimRef.Name
	}
	return &PersistentVolumeDetail{
		ObjectMeta:             common.NewObjectMeta(persistentVolume.ObjectMeta),
		TypeMeta:               common.NewTypeMeta(common.ResourceKindPersistentVolume),
		Status:                 persistentVolume.Status.Phase,
		Claim:                  claim,
		ReclaimPolicy:          persistentVolume.Spec.PersistentVolumeReclaimPolicy,
		AccessModes:            persistentVolume.Spec.AccessModes,
		Capacity:               persistentVolume.Spec.Capacity,
		Message:                persistentVolume.Status.Message,
		PersistentVolumeSource: persistentVolume.Spec.PersistentVolumeSource,
	}
}
コード例 #27
0
func getConfigMapList(configMaps []api.ConfigMap, dsQuery *dataselect.DataSelectQuery) *ConfigMapList {

	result := &ConfigMapList{
		Items:    make([]ConfigMap, 0),
		ListMeta: common.ListMeta{TotalItems: len(configMaps)},
	}

	configMaps = fromCells(dataselect.GenericDataSelect(toCells(configMaps), dsQuery))

	for _, item := range configMaps {
		result.Items = append(result.Items,
			ConfigMap{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindConfigMap),
			})
	}

	return result
}
コード例 #28
0
func getLimitRangeList(limitRanges []api.LimitRange, dsQuery *dataselect.DataSelectQuery) *LimitRangeList {

	result := &LimitRangeList{
		Items:    make([]LimitRange, 0),
		ListMeta: common.ListMeta{TotalItems: len(limitRanges)},
	}

	limitRanges = fromCells(dataselect.GenericDataSelect(toCells(limitRanges), dsQuery))

	for _, item := range limitRanges {
		result.Items = append(result.Items,
			LimitRange{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindLimitRange),
			})
	}

	return result
}
コード例 #29
0
ファイル: nodedetail.go プロジェクト: floreks/dashboard
func toNodeDetail(node api.Node, pods *pod.PodList, eventList *common.EventList,
	allocatedResources NodeAllocatedResources, metrics []metric.Metric) NodeDetail {

	return NodeDetail{
		ObjectMeta:         common.NewObjectMeta(node.ObjectMeta),
		TypeMeta:           common.NewTypeMeta(common.ResourceKindNode),
		Phase:              node.Status.Phase,
		ExternalID:         node.Spec.ExternalID,
		ProviderID:         node.Spec.ProviderID,
		PodCIDR:            node.Spec.PodCIDR,
		Unschedulable:      node.Spec.Unschedulable,
		NodeInfo:           node.Status.NodeInfo,
		Conditions:         node.Status.Conditions,
		ContainerImages:    getContainerImages(node),
		PodList:            *pods,
		EventList:          *eventList,
		AllocatedResources: allocatedResources,
		Metrics:            metrics,
	}
}
コード例 #30
0
func getPersistentVolumeClaimList(persistentVolumeClaims []api.PersistentVolumeClaim, dsQuery *dataselect.DataSelectQuery) *PersistentVolumeClaimList {

	result := &PersistentVolumeClaimList{
		Items:    make([]PersistentVolumeClaim, 0),
		ListMeta: common.ListMeta{TotalItems: len(persistentVolumeClaims)},
	}

	persistentVolumeClaims = fromCells(dataselect.GenericDataSelect(toCells(persistentVolumeClaims), dsQuery))

	for _, item := range persistentVolumeClaims {
		result.Items = append(result.Items,
			PersistentVolumeClaim{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindPersistentVolumeClaim),
				Status:     string(item.Status.Phase),
				Volume:     item.Spec.VolumeName,
			})
		fmt.Println(item.Status.Capacity)
	}

	return result
}