本文整理汇总了Golang中github.com/juju/juju/provider/common.MinRootDiskSizeGiB函数的典型用法代码示例。如果您正苦于以下问题:Golang MinRootDiskSizeGiB函数的具体用法?Golang MinRootDiskSizeGiB怎么用?Golang MinRootDiskSizeGiB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MinRootDiskSizeGiB函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getDisks
// getDisks builds the raw spec for the disks that should be attached to
// the new instances and returns it. This will always include a root
// disk with characteristics determined by the provides args and
// constraints.
func getDisks(spec *instances.InstanceSpec, cons constraints.Value, ser, eUUID string) ([]google.DiskSpec, error) {
size := common.MinRootDiskSizeGiB(ser)
if cons.RootDisk != nil && *cons.RootDisk > size {
size = common.MiBToGiB(*cons.RootDisk)
}
var imageURL string
os, err := series.GetOSFromSeries(ser)
if err != nil {
return nil, errors.Trace(err)
}
switch os {
case jujuos.Ubuntu:
imageURL = ubuntuImageBasePath
case jujuos.Windows:
imageURL = windowsImageBasePath
default:
return nil, errors.Errorf("os %s is not supported on the gce provider", os.String())
}
dSpec := google.DiskSpec{
Series: ser,
SizeHintGB: size,
ImageURL: imageURL + spec.Image.Id,
Boot: true,
AutoDelete: true,
Description: eUUID,
}
if cons.RootDisk != nil && dSpec.TooSmall() {
msg := "Ignoring root-disk constraint of %dM because it is smaller than the GCE image size of %dG"
logger.Infof(msg, *cons.RootDisk, google.MinDiskSizeGB(ser))
}
return []google.DiskSpec{dSpec}, nil
}
示例2: TestStartInstanceDefaultDiskSizeIsUsedForSmallConstraintValue
func (s *environBrokerSuite) TestStartInstanceDefaultDiskSizeIsUsedForSmallConstraintValue(c *gc.C) {
s.PrepareStartInstanceFakes(c)
startInstArgs := s.CreateStartInstanceArgs(c)
rootDisk := uint64(1000)
startInstArgs.Constraints.RootDisk = &rootDisk
res, err := s.Env.StartInstance(startInstArgs)
c.Assert(err, jc.ErrorIsNil)
c.Assert(*res.Hardware.RootDisk, gc.Equals, common.MinRootDiskSizeGiB("trusty")*uint64(1024))
}
示例3: TestStartInstanceDefaultConstraintsApplied
func (s *environBrokerSuite) TestStartInstanceDefaultConstraintsApplied(c *gc.C) {
s.PrepareStartInstanceFakes(c)
startInstArgs := s.CreateStartInstanceArgs(c)
res, err := s.Env.StartInstance(startInstArgs)
c.Assert(err, jc.ErrorIsNil)
c.Assert(*res.Hardware.CpuCores, gc.Equals, vsphere.DefaultCpuCores)
c.Assert(*res.Hardware.CpuPower, gc.Equals, vsphere.DefaultCpuPower)
c.Assert(*res.Hardware.Mem, gc.Equals, vsphere.DefaultMemMb)
c.Assert(*res.Hardware.RootDisk, gc.Equals, common.MinRootDiskSizeGiB("trusty")*uint64(1024))
}
示例4: TestMinRootDiskSizeGiB
func (s *DiskSuite) TestMinRootDiskSizeGiB(c *gc.C) {
var diskTests = []struct {
series string
expectedSize uint64
}{
{"trusty", 8},
{"win2012r2", 40},
{"centos7", 8},
{"fake-series", 8},
}
for _, t := range diskTests {
actualSize := common.MinRootDiskSizeGiB(t.series)
c.Assert(t.expectedSize, gc.Equals, actualSize)
}
}
示例5: minRootDiskSizeMiB
func minRootDiskSizeMiB(ser string) uint64 {
return gibToMib(common.MinRootDiskSizeGiB(ser))
}
示例6: newRawInstance
// newRawInstance is where the new physical instance is actually
// provisioned, relative to the provided args and spec. Info for that
// low-level instance is returned.
func (env *environ) newRawInstance(args environs.StartInstanceParams, img *OvaFileMetadata) (*mo.VirtualMachine, *instance.HardwareCharacteristics, error) {
machineID, err := env.namespace.Hostname(args.InstanceConfig.MachineId)
if err != nil {
return nil, nil, errors.Trace(err)
}
cloudcfg, err := cloudinit.New(args.Tools.OneSeries())
if err != nil {
return nil, nil, errors.Trace(err)
}
cloudcfg.AddPackage("open-vm-tools")
cloudcfg.AddPackage("iptables-persistent")
userData, err := providerinit.ComposeUserData(args.InstanceConfig, cloudcfg, VsphereRenderer{})
if err != nil {
return nil, nil, errors.Annotate(err, "cannot make user data")
}
logger.Debugf("Vmware user data; %d bytes", len(userData))
rootDisk := common.MinRootDiskSizeGiB(args.InstanceConfig.Series) * 1024
if args.Constraints.RootDisk != nil && *args.Constraints.RootDisk > rootDisk {
rootDisk = *args.Constraints.RootDisk
}
cpuCores := DefaultCpuCores
if args.Constraints.CpuCores != nil {
cpuCores = *args.Constraints.CpuCores
}
cpuPower := DefaultCpuPower
if args.Constraints.CpuPower != nil {
cpuPower = *args.Constraints.CpuPower
}
mem := DefaultMemMb
if args.Constraints.Mem != nil {
mem = *args.Constraints.Mem
}
hwc := &instance.HardwareCharacteristics{
Arch: &img.Arch,
Mem: &mem,
CpuCores: &cpuCores,
CpuPower: &cpuPower,
RootDisk: &rootDisk,
}
zones, err := env.parseAvailabilityZones(args)
if err != nil {
return nil, nil, errors.Trace(err)
}
var inst *mo.VirtualMachine
for _, zone := range zones {
var availZone *vmwareAvailZone
availZone, err = env.availZone(zone)
if err != nil {
logger.Warningf("Error while getting availability zone %s: %s", zone, err)
continue
}
apiPort := 0
if args.InstanceConfig.Controller != nil {
apiPort = args.InstanceConfig.Controller.Config.APIPort()
}
spec := &instanceSpec{
machineID: machineID,
zone: availZone,
hwc: hwc,
img: img,
userData: userData,
sshKey: args.InstanceConfig.AuthorizedKeys,
isController: args.InstanceConfig.Controller != nil,
controllerUUID: args.ControllerUUID,
apiPort: apiPort,
}
inst, err = env.client.CreateInstance(env.ecfg, spec)
if err != nil {
logger.Warningf("Error while trying to create instance in %s availability zone: %s", zone, err)
continue
}
break
}
if err != nil {
return nil, nil, errors.Annotate(err, "Can't create instance in any of availability zones, last error")
}
return inst, hwc, err
}