github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/pkg/edged/cadvisor/cadvisor_linux.go (about)

     1  // +build cgo,linux
     2  
     3  /*
     4  Copyright 2015 The Kubernetes Authors.
     5  Licensed under the Apache License, Version 2.0 (the "License");
     6  you may not use this file except in compliance with the License.
     7  You may obtain a copy of the License at
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  
    15  @CHANGELOG
    16  KubeEdge Authors: To init a cadvisor client, implement the cadvisor interface by empty functions.
    17  This file is derived from k8s kubelet code with pruned structures and interfaces
    18  and changed most of the realization.
    19  changes done are
    20  1.For cadvisor.Interface is been implemented here.
    21  */
    22  
    23  package cadvisor
    24  
    25  import (
    26  	"github.com/google/cadvisor/events"
    27  	cadvisorapi "github.com/google/cadvisor/info/v1"
    28  	cadvisorapi2 "github.com/google/cadvisor/info/v2"
    29  	"k8s.io/kubernetes/pkg/kubelet/cadvisor"
    30  )
    31  
    32  type cadvisorClient struct {
    33  	rootPath string
    34  }
    35  
    36  // New creates new cadvisor client
    37  func New(rootPath string) (cadvisor.Interface, error) {
    38  	return &cadvisorClient{
    39  		rootPath: rootPath,
    40  	}, nil
    41  }
    42  
    43  func (cadvisorClient) Start() error {
    44  	return nil
    45  }
    46  
    47  func (cadvisorClient) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
    48  	return cadvisorapi.ContainerInfo{}, nil
    49  }
    50  
    51  func (cadvisorClient) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
    52  	return nil, nil
    53  }
    54  
    55  func (cadvisorClient) ContainerInfoV2(name string, options cadvisorapi2.RequestOptions) (map[string]cadvisorapi2.ContainerInfo, error) {
    56  	return nil, nil
    57  }
    58  
    59  func (cadvisorClient) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
    60  	return nil, nil
    61  }
    62  
    63  //MachineInfo implement by hard code, just for initing a cadvisor client, edged will not use this function to get machine info.
    64  func (cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
    65  	return &cadvisorapi.MachineInfo{
    66  		NumCores:       4,
    67  		CpuFrequency:   3,
    68  		MemoryCapacity: 16000000,
    69  		HugePages:      []cadvisorapi.HugePagesInfo{{PageSize: 4096, NumPages: 1024}},
    70  		Filesystems:    []cadvisorapi.FsInfo{},
    71  		DiskMap:        make(map[string]cadvisorapi.DiskInfo),
    72  		NetworkDevices: []cadvisorapi.NetInfo{},
    73  		Topology:       []cadvisorapi.Node{},
    74  		CloudProvider:  cadvisorapi.UnknownProvider,
    75  		InstanceType:   cadvisorapi.UnknownInstance,
    76  		InstanceID:     cadvisorapi.UnNamedInstance,
    77  	}, nil
    78  }
    79  
    80  func (cadvisorClient) VersionInfo() (*cadvisorapi.VersionInfo, error) {
    81  	return nil, nil
    82  }
    83  
    84  func (cadvisorClient) ImagesFsInfo() (cadvisorapi2.FsInfo, error) {
    85  	return cadvisorapi2.FsInfo{}, nil
    86  }
    87  
    88  func (cadvisorClient) RootFsInfo() (cadvisorapi2.FsInfo, error) {
    89  	return cadvisorapi2.FsInfo{}, nil
    90  }
    91  
    92  func (cadvisorClient) WatchEvents(request *events.Request) (*events.EventChannel, error) {
    93  	return nil, nil
    94  }
    95  
    96  func (cadvisorClient) GetDirFsInfo(path string) (cadvisorapi2.FsInfo, error) {
    97  	return cadvisorapi2.FsInfo{}, nil
    98  }