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


Golang container.Initialiser类代码示例

本文整理汇总了Golang中github.com/juju/juju/container.Initialiser的典型用法代码示例。如果您正苦于以下问题:Golang Initialiser类的具体用法?Golang Initialiser怎么用?Golang Initialiser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: runInitialiser

// runInitialiser runs the container initialiser with the initialisation hook held.
func (cs *ContainerSetup) runInitialiser(containerType instance.ContainerType, initialiser container.Initialiser) error {
	if err := cs.initLock.Lock(fmt.Sprintf("initialise-%s", containerType)); err != nil {
		return fmt.Errorf("failed to acquire initialization lock: %v", err)
	}
	defer cs.initLock.Unlock()
	return initialiser.Initialise()
}
开发者ID:rogpeppe,项目名称:juju,代码行数:8,代码来源:container_initialisation.go

示例2: runInitialiser

// runInitialiser runs the container initialiser with the initialisation hook held.
func (cs *ContainerSetup) runInitialiser(containerType instance.ContainerType, initialiser container.Initialiser) error {
	logger.Debugf("running initialiser for %s containers", containerType)
	if err := cs.initLock.Lock(fmt.Sprintf("initialise-%s", containerType)); err != nil {
		return errors.Annotate(err, "failed to acquire initialization lock")
	}
	defer cs.initLock.Unlock()

	// Only tweak default LXC network config when address allocation
	// feature flag is enabled.
	if environs.AddressAllocationEnabled() {
		// In order to guarantee stable statically assigned IP addresses
		// for LXC containers, we need to install a custom version of
		// /etc/default/lxc-net before we install the lxc package. The
		// custom version of lxc-net is almost the same as the original,
		// but the defined LXC_DHCP_RANGE (used by dnsmasq to give away
		// 10.0.3.x addresses to containers bound to lxcbr0) has infinite
		// lease time. This is necessary, because with the default lease
		// time of 1h, dhclient running inside each container will request
		// a renewal from dnsmasq and replace our statically configured IP
		// address within an hour after starting the container.
		err := maybeOverrideDefaultLXCNet(containerType, cs.addressableContainers)
		if err != nil {
			return errors.Trace(err)
		}
	}

	if err := initialiser.Initialise(); err != nil {
		return errors.Trace(err)
	}

	return nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:33,代码来源:container_initialisation.go

示例3: runInitialiser

// runInitialiser runs the container initialiser with the initialisation hook held.
func (cs *ContainerSetup) runInitialiser(abort <-chan struct{}, containerType instance.ContainerType, initialiser container.Initialiser) error {
	logger.Debugf("running initialiser for %s containers", containerType)
	spec := mutex.Spec{
		Name:  cs.initLockName,
		Clock: clock.WallClock,
		// If we don't get the lock straigh away, there is no point trying multiple
		// times per second for an operation that is likelty to take multiple seconds.
		Delay:  time.Second,
		Cancel: abort,
	}
	logger.Debugf("acquire lock %q for container initialisation", cs.initLockName)
	releaser, err := mutex.Acquire(spec)
	if err != nil {
		return errors.Annotate(err, "failed to acquire initialization lock")
	}
	logger.Debugf("lock %q acquired", cs.initLockName)
	defer logger.Debugf("release lock %q for container initialisation", cs.initLockName)
	defer releaser.Release()

	if err := initialiser.Initialise(); err != nil {
		return errors.Trace(err)
	}

	return nil
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:container_initialisation.go

示例4: runInitialiser

// runInitialiser runs the container initialiser with the initialisation hook held.
func (cs *ContainerSetup) runInitialiser(containerType instance.ContainerType, initialiser container.Initialiser) error {
	logger.Debugf("running initialiser for %s containers", containerType)
	if err := cs.initLock.Lock(fmt.Sprintf("initialise-%s", containerType)); err != nil {
		return errors.Annotate(err, "failed to acquire initialization lock")
	}
	defer cs.initLock.Unlock()
	return initialiser.Initialise()
}
开发者ID:kapilt,项目名称:juju,代码行数:9,代码来源:container_initialisation.go


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