github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/noop_agent.go (about)

     1  // Copyright (c) 2016 Intel Corporation
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  //
     5  
     6  package virtcontainers
     7  
     8  import (
     9  	"syscall"
    10  	"time"
    11  
    12  	"github.com/kata-containers/agent/protocols/grpc"
    13  	persistapi "github.com/kata-containers/runtime/virtcontainers/persist/api"
    14  	vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
    15  	"github.com/kata-containers/runtime/virtcontainers/types"
    16  	specs "github.com/opencontainers/runtime-spec/specs-go"
    17  	"golang.org/x/net/context"
    18  )
    19  
    20  // noopAgent a.k.a. NO-OP Agent is an empty Agent implementation, for testing and
    21  // mocking purposes.
    22  type noopAgent struct {
    23  }
    24  
    25  //start the proxy to watch the vm console. It does nothing.
    26  func (n *noopAgent) startProxy(sandbox *Sandbox) error {
    27  	return nil
    28  }
    29  
    30  // init initializes the Noop agent, i.e. it does nothing.
    31  func (n *noopAgent) init(ctx context.Context, sandbox *Sandbox, config interface{}) (bool, error) {
    32  	return false, nil
    33  }
    34  
    35  func (n *noopAgent) longLiveConn() bool {
    36  	return false
    37  }
    38  
    39  // createSandbox is the Noop agent sandbox creation implementation. It does nothing.
    40  func (n *noopAgent) createSandbox(sandbox *Sandbox) error {
    41  	return nil
    42  }
    43  
    44  // capabilities returns empty capabilities, i.e no capabilties are supported.
    45  func (n *noopAgent) capabilities() types.Capabilities {
    46  	return types.Capabilities{}
    47  }
    48  
    49  // disconnect is the Noop agent connection closer. It does nothing.
    50  func (n *noopAgent) disconnect() error {
    51  	return nil
    52  }
    53  
    54  // exec is the Noop agent command execution implementation. It does nothing.
    55  func (n *noopAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
    56  	return nil, nil
    57  }
    58  
    59  // startSandbox is the Noop agent Sandbox starting implementation. It does nothing.
    60  func (n *noopAgent) startSandbox(sandbox *Sandbox) error {
    61  	return nil
    62  }
    63  
    64  // stopSandbox is the Noop agent Sandbox stopping implementation. It does nothing.
    65  func (n *noopAgent) stopSandbox(sandbox *Sandbox) error {
    66  	return nil
    67  }
    68  
    69  // createContainer is the Noop agent Container creation implementation. It does nothing.
    70  func (n *noopAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
    71  	return &Process{}, nil
    72  }
    73  
    74  // startContainer is the Noop agent Container starting implementation. It does nothing.
    75  func (n *noopAgent) startContainer(sandbox *Sandbox, c *Container) error {
    76  	return nil
    77  }
    78  
    79  // stopContainer is the Noop agent Container stopping implementation. It does nothing.
    80  func (n *noopAgent) stopContainer(sandbox *Sandbox, c Container) error {
    81  	return nil
    82  }
    83  
    84  // signalProcess is the Noop agent Container signaling implementation. It does nothing.
    85  func (n *noopAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
    86  	return nil
    87  }
    88  
    89  // processListContainer is the Noop agent Container ps implementation. It does nothing.
    90  func (n *noopAgent) processListContainer(sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
    91  	return nil, nil
    92  }
    93  
    94  // updateContainer is the Noop agent Container update implementation. It does nothing.
    95  func (n *noopAgent) updateContainer(sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
    96  	return nil
    97  }
    98  
    99  // memHotplugByProbe is the Noop agent notify meomory hotplug event via probe interface implementation. It does nothing.
   100  func (n *noopAgent) memHotplugByProbe(addr uint64, sizeMB uint32, memorySectionSizeMB uint32) error {
   101  	return nil
   102  }
   103  
   104  // onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
   105  func (n *noopAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
   106  	return nil
   107  }
   108  
   109  // updateInterface is the Noop agent Interface update implementation. It does nothing.
   110  func (n *noopAgent) updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
   111  	return nil, nil
   112  }
   113  
   114  // listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
   115  func (n *noopAgent) listInterfaces() ([]*vcTypes.Interface, error) {
   116  	return nil, nil
   117  }
   118  
   119  // updateRoutes is the Noop agent Routes update implementation. It does nothing.
   120  func (n *noopAgent) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
   121  	return nil, nil
   122  }
   123  
   124  // listRoutes is the Noop agent Routes list implementation. It does nothing.
   125  func (n *noopAgent) listRoutes() ([]*vcTypes.Route, error) {
   126  	return nil, nil
   127  }
   128  
   129  // check is the Noop agent health checker. It does nothing.
   130  func (n *noopAgent) check() error {
   131  	return nil
   132  }
   133  
   134  // statsContainer is the Noop agent Container stats implementation. It does nothing.
   135  func (n *noopAgent) statsContainer(sandbox *Sandbox, c Container) (*ContainerStats, error) {
   136  	return &ContainerStats{}, nil
   137  }
   138  
   139  // waitProcess is the Noop agent process waiter. It does nothing.
   140  func (n *noopAgent) waitProcess(c *Container, processID string) (int32, error) {
   141  	return 0, nil
   142  }
   143  
   144  // winsizeProcess is the Noop agent process tty resizer. It does nothing.
   145  func (n *noopAgent) winsizeProcess(c *Container, processID string, height, width uint32) error {
   146  	return nil
   147  }
   148  
   149  // writeProcessStdin is the Noop agent process stdin writer. It does nothing.
   150  func (n *noopAgent) writeProcessStdin(c *Container, ProcessID string, data []byte) (int, error) {
   151  	return 0, nil
   152  }
   153  
   154  // closeProcessStdin is the Noop agent process stdin closer. It does nothing.
   155  func (n *noopAgent) closeProcessStdin(c *Container, ProcessID string) error {
   156  	return nil
   157  }
   158  
   159  // readProcessStdout is the Noop agent process stdout reader. It does nothing.
   160  func (n *noopAgent) readProcessStdout(c *Container, processID string, data []byte) (int, error) {
   161  	return 0, nil
   162  }
   163  
   164  // readProcessStderr is the Noop agent process stderr reader. It does nothing.
   165  func (n *noopAgent) readProcessStderr(c *Container, processID string, data []byte) (int, error) {
   166  	return 0, nil
   167  }
   168  
   169  // pauseContainer is the Noop agent Container pause implementation. It does nothing.
   170  func (n *noopAgent) pauseContainer(sandbox *Sandbox, c Container) error {
   171  	return nil
   172  }
   173  
   174  // resumeContainer is the Noop agent Container resume implementation. It does nothing.
   175  func (n *noopAgent) resumeContainer(sandbox *Sandbox, c Container) error {
   176  	return nil
   177  }
   178  
   179  // configHypervisor is the Noop agent hypervisor configuration implementation. It does nothing.
   180  func (n *noopAgent) configure(h hypervisor, id, sharePath string, builtin bool, config interface{}) error {
   181  	return nil
   182  }
   183  
   184  func (n *noopAgent) configureFromGrpc(h hypervisor, id string, builtin bool, config interface{}) error {
   185  	return nil
   186  }
   187  
   188  // reseedRNG is the Noop agent RND reseeder. It does nothing.
   189  func (n *noopAgent) reseedRNG(data []byte) error {
   190  	return nil
   191  }
   192  
   193  // reuseAgent is the Noop agent reuser. It does nothing.
   194  func (n *noopAgent) reuseAgent(agent agent) error {
   195  	return nil
   196  }
   197  
   198  // getAgentURL is the Noop agent url getter. It returns nothing.
   199  func (n *noopAgent) getAgentURL() (string, error) {
   200  	return "", nil
   201  }
   202  
   203  // setProxy is the Noop agent proxy setter. It does nothing.
   204  func (n *noopAgent) setProxy(sandbox *Sandbox, proxy proxy, pid int, url string) error {
   205  	return nil
   206  }
   207  
   208  func (n *noopAgent) setProxyFromGrpc(proxy proxy, pid int, url string) {
   209  }
   210  
   211  // getGuestDetails is the Noop agent GuestDetails queryer. It does nothing.
   212  func (n *noopAgent) getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error) {
   213  	return nil, nil
   214  }
   215  
   216  // setGuestDateTime is the Noop agent guest time setter. It does nothing.
   217  func (n *noopAgent) setGuestDateTime(time.Time) error {
   218  	return nil
   219  }
   220  
   221  // copyFile is the Noop agent copy file. It does nothing.
   222  func (n *noopAgent) copyFile(src, dst string) error {
   223  	return nil
   224  }
   225  
   226  func (n *noopAgent) markDead() {
   227  }
   228  
   229  func (n *noopAgent) cleanup(s *Sandbox) {
   230  }
   231  
   232  // save is the Noop agent state saver. It does nothing.
   233  func (n *noopAgent) save() (s persistapi.AgentState) {
   234  	return
   235  }
   236  
   237  // load is the Noop agent state loader. It does nothing.
   238  func (n *noopAgent) load(s persistapi.AgentState) {}
   239  
   240  func (n *noopAgent) getOOMEvent() (string, error) {
   241  	return "", nil
   242  }