func (*environSuite) TestSupportedArchitectures(c *gc.C) { testConfig := minimalConfig(c) environ, err := local.Provider.Open(testConfig) c.Assert(err, jc.ErrorIsNil) arches, err := environ.SupportedArchitectures() c.Assert(err, jc.ErrorIsNil) for _, a := range arches { c.Assert(arch.IsSupportedArch(a), jc.IsTrue) } }
func (v *Value) setArch(str string) error { if v.Arch != nil { return errors.Errorf("already set") } if str != "" && !arch.IsSupportedArch(str) { return errors.Errorf("%q not recognized", str) } v.Arch = &str return nil }
func (hc *HardwareCharacteristics) setArch(str string) error { if hc.Arch != nil { return fmt.Errorf("already set") } if str != "" && !arch.IsSupportedArch(str) { return fmt.Errorf("%q not recognized", str) } hc.Arch = &str return nil }
// getHardwareCharacteristics compiles hardware-related details about // the given instance and relative to the provided spec and returns it. func (env *environ) getHardwareCharacteristics(args environs.StartInstanceParams, inst *environInstance) *instance.HardwareCharacteristics { raw := inst.raw.Hardware archStr := raw.Architecture if archStr == "unknown" || !arch.IsSupportedArch(archStr) { // TODO(ericsnow) This special-case should be improved. archStr = arch.HostArch() } cores := uint64(raw.NumCores) mem := uint64(raw.MemoryMB) return &instance.HardwareCharacteristics{ Arch: &archStr, CpuCores: &cores, Mem: &mem, } }
// getHardwareCharacteristics compiles hardware-related details about // the given instance and relative to the provided spec and returns it. func (env *environ) getHardwareCharacteristics(args environs.StartInstanceParams, inst *environInstance) *instance.HardwareCharacteristics { raw := inst.raw.Hardware archStr := raw.Architecture if archStr == "unknown" || !arch.IsSupportedArch(archStr) { // TODO(ericsnow) This special-case should be improved. archStr = arch.HostArch() } hwc, err := instance.ParseHardware( "arch="+archStr, fmt.Sprintf("cpu-cores=%d", raw.NumCores), fmt.Sprintf("mem=%dM", raw.MemoryMB), //"root-disk=", //"tags=", ) if err != nil { logger.Errorf("unexpected problem parsing hardware info: %v", err) // Keep moving... } return &hwc }
func (s *archSuite) TestIsSupportedArch(c *gc.C) { for _, a := range arch.AllSupportedArches { c.Assert(arch.IsSupportedArch(a), jc.IsTrue) } c.Assert(arch.IsSupportedArch("invalid"), jc.IsFalse) }
func (s *archSuite) TestHostArch(c *gc.C) { a := arch.HostArch() c.Assert(arch.IsSupportedArch(a), jc.IsTrue) }