本文整理汇总了Golang中github.com/juju/juju/api/provisioner.Machine.Tag方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.Tag方法的具体用法?Golang Machine.Tag怎么用?Golang Machine.Tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/api/provisioner.Machine
的用法示例。
在下文中一共展示了Machine.Tag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: constructStartInstanceParams
func constructStartInstanceParams(
machine *apiprovisioner.Machine,
instanceConfig *instancecfg.InstanceConfig,
provisioningInfo *params.ProvisioningInfo,
possibleTools coretools.List,
) (environs.StartInstanceParams, error) {
volumes := make([]storage.VolumeParams, len(provisioningInfo.Volumes))
for i, v := range provisioningInfo.Volumes {
volumeTag, err := names.ParseVolumeTag(v.VolumeTag)
if err != nil {
return environs.StartInstanceParams{}, errors.Trace(err)
}
if v.Attachment == nil {
return environs.StartInstanceParams{}, errors.Errorf("volume params missing attachment")
}
machineTag, err := names.ParseMachineTag(v.Attachment.MachineTag)
if err != nil {
return environs.StartInstanceParams{}, errors.Trace(err)
}
if machineTag != machine.Tag() {
return environs.StartInstanceParams{}, errors.Errorf("volume attachment params has invalid machine tag")
}
if v.Attachment.InstanceId != "" {
return environs.StartInstanceParams{}, errors.Errorf("volume attachment params specifies instance ID")
}
volumes[i] = storage.VolumeParams{
volumeTag,
v.Size,
storage.ProviderType(v.Provider),
v.Attributes,
v.Tags,
&storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
Machine: machineTag,
ReadOnly: v.Attachment.ReadOnly,
},
Volume: volumeTag,
},
}
}
var subnetsToZones map[network.Id][]string
if provisioningInfo.SubnetsToZones != nil {
// Convert subnet provider ids from string to network.Id.
subnetsToZones = make(map[network.Id][]string, len(provisioningInfo.SubnetsToZones))
for providerId, zones := range provisioningInfo.SubnetsToZones {
subnetsToZones[network.Id(providerId)] = zones
}
}
return environs.StartInstanceParams{
Constraints: provisioningInfo.Constraints,
Tools: possibleTools,
InstanceConfig: instanceConfig,
Placement: provisioningInfo.Placement,
DistributionGroup: machine.DistributionGroup,
Volumes: volumes,
SubnetsToZones: subnetsToZones,
}, nil
}
示例2: constructStartInstanceParams
func constructStartInstanceParams(
controllerUUID string,
machine *apiprovisioner.Machine,
instanceConfig *instancecfg.InstanceConfig,
provisioningInfo *params.ProvisioningInfo,
possibleTools coretools.List,
) (environs.StartInstanceParams, error) {
volumes := make([]storage.VolumeParams, len(provisioningInfo.Volumes))
for i, v := range provisioningInfo.Volumes {
volumeTag, err := names.ParseVolumeTag(v.VolumeTag)
if err != nil {
return environs.StartInstanceParams{}, errors.Trace(err)
}
if v.Attachment == nil {
return environs.StartInstanceParams{}, errors.Errorf("volume params missing attachment")
}
machineTag, err := names.ParseMachineTag(v.Attachment.MachineTag)
if err != nil {
return environs.StartInstanceParams{}, errors.Trace(err)
}
if machineTag != machine.Tag() {
return environs.StartInstanceParams{}, errors.Errorf("volume attachment params has invalid machine tag")
}
if v.Attachment.InstanceId != "" {
return environs.StartInstanceParams{}, errors.Errorf("volume attachment params specifies instance ID")
}
volumes[i] = storage.VolumeParams{
volumeTag,
v.Size,
storage.ProviderType(v.Provider),
v.Attributes,
v.Tags,
&storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
Machine: machineTag,
ReadOnly: v.Attachment.ReadOnly,
},
Volume: volumeTag,
},
}
}
var subnetsToZones map[network.Id][]string
if provisioningInfo.SubnetsToZones != nil {
// Convert subnet provider ids from string to network.Id.
subnetsToZones = make(map[network.Id][]string, len(provisioningInfo.SubnetsToZones))
for providerId, zones := range provisioningInfo.SubnetsToZones {
subnetsToZones[network.Id(providerId)] = zones
}
}
var endpointBindings map[string]network.Id
if len(provisioningInfo.EndpointBindings) != 0 {
endpointBindings = make(map[string]network.Id)
for endpoint, space := range provisioningInfo.EndpointBindings {
endpointBindings[endpoint] = network.Id(space)
}
}
possibleImageMetadata := make([]*imagemetadata.ImageMetadata, len(provisioningInfo.ImageMetadata))
for i, metadata := range provisioningInfo.ImageMetadata {
possibleImageMetadata[i] = &imagemetadata.ImageMetadata{
Id: metadata.ImageId,
Arch: metadata.Arch,
RegionAlias: metadata.Region,
RegionName: metadata.Region,
Storage: metadata.RootStorageType,
Stream: metadata.Stream,
VirtType: metadata.VirtType,
Version: metadata.Version,
}
}
return environs.StartInstanceParams{
ControllerUUID: controllerUUID,
Constraints: provisioningInfo.Constraints,
Tools: possibleTools,
InstanceConfig: instanceConfig,
Placement: provisioningInfo.Placement,
DistributionGroup: machine.DistributionGroup,
Volumes: volumes,
SubnetsToZones: subnetsToZones,
EndpointBindings: endpointBindings,
ImageMetadata: possibleImageMetadata,
StatusCallback: machine.SetInstanceStatus,
}, nil
}