1/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package devicemanager
18
19import (
20	v1 "k8s.io/api/core/v1"
21	"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
22	"k8s.io/kubernetes/pkg/kubelet/config"
23	"k8s.io/kubernetes/pkg/kubelet/lifecycle"
24	"k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
25	schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
26)
27
28// ManagerStub provides a simple stub implementation for the Device Manager.
29type ManagerStub struct{}
30
31// NewManagerStub creates a ManagerStub.
32func NewManagerStub() (*ManagerStub, error) {
33	return &ManagerStub{}, nil
34}
35
36// Start simply returns nil.
37func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error {
38	return nil
39}
40
41// Stop simply returns nil.
42func (h *ManagerStub) Stop() error {
43	return nil
44}
45
46// Allocate simply returns nil.
47func (h *ManagerStub) Allocate(pod *v1.Pod, container *v1.Container) error {
48	return nil
49}
50
51// UpdatePluginResources simply returns nil.
52func (h *ManagerStub) UpdatePluginResources(node *schedulerframework.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error {
53	return nil
54}
55
56// GetDeviceRunContainerOptions simply returns nil.
57func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) (*DeviceRunContainerOptions, error) {
58	return nil, nil
59}
60
61// GetCapacity simply returns nil capacity and empty removed resource list.
62func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string) {
63	return nil, nil, []string{}
64}
65
66// GetWatcherHandler returns plugin watcher interface
67func (h *ManagerStub) GetWatcherHandler() cache.PluginHandler {
68	return nil
69}
70
71// GetTopologyHints returns an empty TopologyHint map
72func (h *ManagerStub) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
73	return map[string][]topologymanager.TopologyHint{}
74}
75
76// GetPodTopologyHints returns an empty TopologyHint map
77func (h *ManagerStub) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
78	return map[string][]topologymanager.TopologyHint{}
79}
80
81// GetDevices returns nil
82func (h *ManagerStub) GetDevices(_, _ string) ResourceDeviceInstances {
83	return nil
84}
85
86// GetAllocatableDevices returns nothing
87func (h *ManagerStub) GetAllocatableDevices() ResourceDeviceInstances {
88	return nil
89}
90
91// ShouldResetExtendedResourceCapacity returns false
92func (h *ManagerStub) ShouldResetExtendedResourceCapacity() bool {
93	return false
94}
95
96// UpdateAllocatedDevices returns nothing
97func (h *ManagerStub) UpdateAllocatedDevices() {
98	return
99}
100