2015-05-12 00:04:36 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-05-12 00:04:36 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-10-10 00:09:53 +00:00
|
|
|
package cadvisor
|
2015-05-12 00:04:36 +00:00
|
|
|
|
2015-05-30 00:32:34 +00:00
|
|
|
import (
|
2016-11-30 07:27:27 +00:00
|
|
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
2017-01-25 13:13:07 +00:00
|
|
|
"k8s.io/apimachinery/pkg/api/resource"
|
2016-11-18 20:50:58 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/v1"
|
2015-05-30 00:32:34 +00:00
|
|
|
)
|
|
|
|
|
2016-11-30 07:27:27 +00:00
|
|
|
func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList {
|
2016-11-18 20:50:58 +00:00
|
|
|
c := v1.ResourceList{
|
|
|
|
v1.ResourceCPU: *resource.NewMilliQuantity(
|
2015-10-10 00:09:53 +00:00
|
|
|
int64(info.NumCores*1000),
|
|
|
|
resource.DecimalSI),
|
2016-11-18 20:50:58 +00:00
|
|
|
v1.ResourceMemory: *resource.NewQuantity(
|
2016-01-06 23:36:48 +00:00
|
|
|
int64(info.MemoryCapacity),
|
2015-10-10 00:09:53 +00:00
|
|
|
resource.BinarySI),
|
|
|
|
}
|
|
|
|
return c
|
2015-05-12 00:04:36 +00:00
|
|
|
}
|