本文整理汇总了Golang中github.com/juju/juju/environs/cloudinit.MachineConfig.DisablePackageCommands方法的典型用法代码示例。如果您正苦于以下问题:Golang MachineConfig.DisablePackageCommands方法的具体用法?Golang MachineConfig.DisablePackageCommands怎么用?Golang MachineConfig.DisablePackageCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs/cloudinit.MachineConfig
的用法示例。
在下文中一共展示了MachineConfig.DisablePackageCommands方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateContainer
func (manager *containerManager) CreateContainer(
machineConfig *cloudinit.MachineConfig,
series string,
network *container.NetworkConfig,
) (instance.Instance, *instance.HardwareCharacteristics, error) {
start := time.Now()
name := names.NewMachineTag(machineConfig.MachineId).String()
if manager.name != "" {
name = fmt.Sprintf("%s-%s", manager.name, name)
}
// Create the cloud-init.
directory, err := container.NewDirectory(name)
if err != nil {
return nil, nil, err
}
logger.Tracef("write cloud-init")
if manager.createWithClone {
// If we are using clone, disable the apt-get steps
machineConfig.DisablePackageCommands = true
}
userDataFilename, err := container.WriteUserData(machineConfig, directory)
if err != nil {
logger.Errorf("failed to write user data: %v", err)
return nil, nil, err
}
logger.Tracef("write the lxc.conf file")
configFile, err := writeLxcConfig(network, directory)
if err != nil {
logger.Errorf("failed to write config file: %v", err)
return nil, nil, err
}
var lxcContainer golxc.Container
if manager.createWithClone {
templateContainer, err := EnsureCloneTemplate(
manager.backingFilesystem,
series,
network,
machineConfig.AuthorizedKeys,
machineConfig.AptProxySettings,
)
if err != nil {
return nil, nil, err
}
templateParams := []string{
"--debug", // Debug errors in the cloud image
"--userdata", userDataFilename, // Our groovey cloud-init
"--hostid", name, // Use the container name as the hostid
}
var extraCloneArgs []string
if manager.backingFilesystem == Btrfs || manager.useAUFS {
extraCloneArgs = append(extraCloneArgs, "--snapshot")
}
if manager.backingFilesystem != Btrfs && manager.useAUFS {
extraCloneArgs = append(extraCloneArgs, "--backingstore", "aufs")
}
lock, err := AcquireTemplateLock(templateContainer.Name(), "clone")
if err != nil {
return nil, nil, fmt.Errorf("failed to acquire lock on template: %v", err)
}
defer lock.Unlock()
lxcContainer, err = templateContainer.Clone(name, extraCloneArgs, templateParams)
if err != nil {
logger.Errorf("lxc container cloning failed: %v", err)
return nil, nil, err
}
} else {
// Note here that the lxcObjectFacotry only returns a valid container
// object, and doesn't actually construct the underlying lxc container on
// disk.
lxcContainer = LxcObjectFactory.New(name)
templateParams := []string{
"--debug", // Debug errors in the cloud image
"--userdata", userDataFilename, // Our groovey cloud-init
"--hostid", name, // Use the container name as the hostid
"-r", series,
}
// Create the container.
logger.Tracef("create the container")
if err := lxcContainer.Create(configFile, defaultTemplate, nil, templateParams); err != nil {
logger.Errorf("lxc container creation failed: %v", err)
return nil, nil, err
}
logger.Tracef("lxc container created")
}
if err := autostartContainer(name); err != nil {
return nil, nil, err
}
if err := mountHostLogDir(name, manager.logdir); err != nil {
return nil, nil, err
}
// Start the lxc container with the appropriate settings for grabbing the
// console output and a log file.
consoleFile := filepath.Join(directory, "console.log")
lxcContainer.SetLogFile(filepath.Join(directory, "container.log"), golxc.LogDebug)
logger.Tracef("start the container")
// We explicitly don't pass through the config file to the container.Start
// method as we have passed it through at container creation time. This
// is necessary to get the appropriate rootfs reference without explicitly
//.........这里部分代码省略.........