本文整理汇总了Golang中github.com/juju/utils/os.OSType类的典型用法代码示例。如果您正苦于以下问题:Golang OSType类的具体用法?Golang OSType怎么用?Golang OSType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSType类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, os jujuos.OSType) ([]google.DiskSpec, error) {
size := common.MinRootDiskSizeGiB
if cons.RootDisk != nil && *cons.RootDisk > size {
size = common.MiBToGiB(*cons.RootDisk)
}
var imageURL string
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{
SizeHintGB: size,
ImageURL: imageURL + spec.Image.Id,
Boot: true,
AutoDelete: true,
}
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)
}
return []google.DiskSpec{dSpec}, nil
}
示例2: EncodeUserdata
func (VsphereRenderer) EncodeUserdata(udata []byte, os jujuos.OSType) ([]byte, error) {
switch os {
case jujuos.Ubuntu, jujuos.CentOS:
return renderers.ToBase64(udata), nil
default:
return nil, errors.Errorf("Cannot encode userdata for OS: %s", os.String())
}
}
示例3: Render
func (CloudSigmaRenderer) Render(cfg cloudinit.CloudConfig, os jujuos.OSType) ([]byte, error) {
switch os {
case jujuos.Ubuntu, jujuos.CentOS:
return renderers.RenderYAML(cfg, renderers.ToBase64)
default:
return nil, errors.Errorf("Cannot encode userdata for OS: %s", os.String())
}
}
示例4: getMetadata
// getMetadata builds the raw "user-defined" metadata for the new
// instance (relative to the provided args) and returns it.
func getMetadata(args environs.StartInstanceParams, os jujuos.OSType) (map[string]string, error) {
userData, err := providerinit.ComposeUserData(args.InstanceConfig, nil, GCERenderer{})
if err != nil {
return nil, errors.Annotate(err, "cannot make user data")
}
logger.Debugf("GCE user data; %d bytes", len(userData))
metadata := make(map[string]string)
if isController(args.InstanceConfig) {
metadata[metadataKeyIsState] = metadataValueTrue
} else {
metadata[metadataKeyIsState] = metadataValueFalse
}
switch os {
case jujuos.Ubuntu:
// We store a gz snapshop of information that is used by
// cloud-init and unpacked in to the /var/lib/cloud/instances folder
// for the instance. Due to a limitation with GCE and binary blobs
// we base64 encode the data before storing it.
metadata[metadataKeyCloudInit] = string(userData)
// Valid encoding values are determined by the cloudinit GCE data source.
// See: http://cloudinit.readthedocs.org
metadata[metadataKeyEncoding] = "base64"
authKeys, err := google.FormatAuthorizedKeys(args.InstanceConfig.AuthorizedKeys, "ubuntu")
if err != nil {
return nil, errors.Trace(err)
}
metadata[metadataKeySSHKeys] = authKeys
case jujuos.Windows:
metadata[metadataKeyWindowsUserdata] = string(userData)
validChars := append(utils.UpperAlpha, append(utils.LowerAlpha, utils.Digits...)...)
// The hostname must have maximum 15 characters
winHostname := "juju" + utils.RandomString(11, validChars)
metadata[metadataKeyWindowsSysprep] = fmt.Sprintf(winSetHostnameScript, winHostname)
default:
return nil, errors.Errorf("cannot pack metadata for os %s on the gce provider", os.String())
}
return metadata, nil
}