当前位置: 首页>>代码示例>>Golang>>正文


Golang Value.Mem方法代码示例

本文整理汇总了Golang中github.com/juju/juju/constraints.Value.Mem方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Mem方法的具体用法?Golang Value.Mem怎么用?Golang Value.Mem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/juju/juju/constraints.Value的用法示例。


在下文中一共展示了Value.Mem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: constraints

func (i *importer) constraints(cons description.Constraints) constraints.Value {
	var result constraints.Value
	if cons == nil {
		return result
	}

	if arch := cons.Architecture(); arch != "" {
		result.Arch = &arch
	}
	if container := instance.ContainerType(cons.Container()); container != "" {
		result.Container = &container
	}
	if cores := cons.CpuCores(); cores != 0 {
		result.CpuCores = &cores
	}
	if power := cons.CpuPower(); power != 0 {
		result.CpuPower = &power
	}
	if inst := cons.InstanceType(); inst != "" {
		result.InstanceType = &inst
	}
	if mem := cons.Memory(); mem != 0 {
		result.Mem = &mem
	}
	if disk := cons.RootDisk(); disk != 0 {
		result.RootDisk = &disk
	}
	if spaces := cons.Spaces(); len(spaces) > 0 {
		result.Spaces = &spaces
	}
	if tags := cons.Tags(); len(tags) > 0 {
		result.Tags = &tags
	}
	return result
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:35,代码来源:migration_import.go

示例2: MatchingInstanceTypes

// MatchingInstanceTypes returns all instance types matching constraints and available
// in region, sorted by increasing region-specific cost (if known).
func MatchingInstanceTypes(allInstanceTypes []InstanceType, region string, cons constraints.Value) ([]InstanceType, error) {
	var itypes []InstanceType

	// Rules used to select instance types:
	// - non memory constraints like cpu-cores etc are always honoured
	// - if no mem constraint specified and instance-type not specified,
	//   try opinionated default with enough mem to run a server.
	// - if no matches and no mem constraint specified, try again and
	//   return any matching instance with the largest memory
	origCons := cons
	if !cons.HasInstanceType() && cons.Mem == nil {
		minMem := uint64(minMemoryHeuristic)
		cons.Mem = &minMem
	}
	itypes = matchingTypesForConstraint(allInstanceTypes, cons)

	// No matches using opinionated default, so if no mem constraint specified,
	// look for matching instance with largest memory.
	if len(itypes) == 0 && cons.Mem != origCons.Mem {
		itypes = matchingTypesForConstraint(allInstanceTypes, origCons)
		if len(itypes) > 0 {
			sort.Sort(byMemory(itypes))
			itypes = []InstanceType{itypes[len(itypes)-1]}
		}
	}
	// If we have matching instance types, we can return those, sorted by cost.
	if len(itypes) > 0 {
		sort.Sort(byCost(itypes))
		return itypes, nil
	}

	// No luck, so report the error.
	return nil, fmt.Errorf("no instance types in %s matching constraints %q", region, origCons)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:36,代码来源:instancetype.go

示例3: TestConstraints

func (s *constraintsSuite) TestConstraints(c *gc.C) {
	for i, t := range newConstraintTests {
		var cv constraints.Value
		if t.arch != nil {
			cv.Arch = &t.arch.v
		}
		if t.cores != nil {
			cv.CpuCores = &t.cores.v
		}
		if t.power != nil {
			cv.CpuPower = &t.power.v
		}
		if t.mem != nil {
			cv.Mem = &t.mem.v
		}
		if t.disk != nil {
			cv.RootDisk = &t.disk.v
		}
		v := newConstraints(t.bootstrap, cv, img)
		if !c.Check(*v, gc.Equals, t.expected) {
			c.Logf("test (%d): %+v", i, t)
		}
	}
}
开发者ID:howbazaar,项目名称:juju,代码行数:24,代码来源:constraints_test.go


注:本文中的github.com/juju/juju/constraints.Value.Mem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。