本文整理匯總了Golang中github.com/juju/juju/storage.VolumeSource類的典型用法代碼示例。如果您正苦於以下問題:Golang VolumeSource類的具體用法?Golang VolumeSource怎麽用?Golang VolumeSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了VolumeSource類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testCreateVolumesInsideLXC
func (s *loopSuite) testCreateVolumesInsideLXC(c *gc.C, source storage.VolumeSource) {
s.commands.expect("fallocate", "-l", "2MiB", filepath.Join(s.storageDir, "volume-0"))
volumes, _, err := source.CreateVolumes([]storage.VolumeParams{{
Tag: names.NewVolumeTag("0"), Size: 2,
}})
c.Assert(err, jc.ErrorIsNil)
c.Assert(volumes, gc.HasLen, 1)
c.Assert(volumes[0].VolumeInfo.Persistent, jc.IsTrue)
}
示例2: createVolumes
func (s *ebsVolumeSuite) createVolumes(vs storage.VolumeSource, instanceId string) ([]storage.Volume, error) {
if instanceId == "" {
instanceId = s.srv.ec2srv.NewInstances(1, "m1.medium", imageId, ec2test.Running, nil)[0]
}
volume0 := names.NewVolumeTag("0")
volume1 := names.NewVolumeTag("1")
volume2 := names.NewVolumeTag("2")
params := []storage.VolumeParams{{
Tag: volume0,
Size: 10 * 1000,
Provider: ec2.EBS_ProviderType,
Attributes: map[string]interface{}{
"persistent": true,
"volume-type": "io1",
"iops": 100,
},
Attachment: &storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
InstanceId: instance.Id(instanceId),
},
},
ResourceTags: map[string]string{
tags.JujuEnv: s.TestConfig["uuid"].(string),
},
}, {
Tag: volume1,
Size: 20 * 1000,
Provider: ec2.EBS_ProviderType,
Attributes: map[string]interface{}{
"persistent": true,
},
Attachment: &storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
InstanceId: instance.Id(instanceId),
},
},
ResourceTags: map[string]string{
tags.JujuEnv: "something-else",
},
}, {
Tag: volume2,
Size: 30 * 1000,
Provider: ec2.EBS_ProviderType,
ResourceTags: map[string]string{
"abc": "123",
},
Attachment: &storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
InstanceId: instance.Id(instanceId),
},
},
}}
vols, _, err := vs.CreateVolumes(params)
return vols, err
}
示例3: validateVolumeParams
// validateVolumeParams validates a collection of volume parameters.
func validateVolumeParams(
volumeSource storage.VolumeSource, volumeParams []storage.VolumeParams,
) ([]storage.VolumeParams, []error) {
valid := make([]storage.VolumeParams, 0, len(volumeParams))
results := make([]error, len(volumeParams))
for i, params := range volumeParams {
err := volumeSource.ValidateVolumeParams(params)
if err == nil {
valid = append(valid, params)
}
results[i] = err
}
return valid, results
}