本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach.List函数的典型用法代码示例。如果您正苦于以下问题:Golang List函数的具体用法?Golang List怎么用?Golang List使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了List函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getVolumeAttachments
func getVolumeAttachments(computeClient *gophercloud.ServiceClient, d *schema.ResourceData) error {
var attachments []volumeattach.VolumeAttachment
err := volumeattach.List(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, err
}
attachments = actual
return true, nil
})
if err != nil {
return err
}
vols := make([]map[string]interface{}, len(attachments))
for i, attachment := range attachments {
vols[i] = make(map[string]interface{})
vols[i]["id"] = attachment.ID
vols[i]["volume_id"] = attachment.VolumeID
vols[i]["device"] = attachment.Device
}
log.Printf("[INFO] Volume attachments: %v", vols)
d.Set("volume", vols)
return nil
}
开发者ID:MattiasGees,项目名称:terraform,代码行数:29,代码来源:resource_openstack_compute_instance_v2.go
示例2: testAccCheckComputeV2InstanceVolumeAttachment
func testAccCheckComputeV2InstanceVolumeAttachment(
instance *servers.Server, volume *volumes.Volume) resource.TestCheckFunc {
return func(s *terraform.State) error {
var attachments []volumeattach.VolumeAttachment
config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
if err != nil {
return err
}
err = volumeattach.List(computeClient, instance.ID).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, fmt.Errorf("Unable to lookup attachment: %s", err)
}
attachments = actual
return true, nil
})
for _, attachment := range attachments {
if attachment.VolumeID == volume.ID {
return nil
}
}
return fmt.Errorf("Volume not found: %s", volume.ID)
}
}
开发者ID:morts1a,项目名称:terraform,代码行数:29,代码来源:resource_openstack_compute_instance_v2_test.go
示例3: testAccCheckComputeV2InstanceBootVolumeAttachment
func testAccCheckComputeV2InstanceBootVolumeAttachment(
instance *servers.Server) resource.TestCheckFunc {
return func(s *terraform.State) error {
var attachments []volumeattach.VolumeAttachment
config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
if err != nil {
return err
}
err = volumeattach.List(computeClient, instance.ID).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, fmt.Errorf("Unable to lookup attachment: %s", err)
}
attachments = actual
return true, nil
})
if len(attachments) == 1 {
return nil
}
return fmt.Errorf("No attached volume found.")
}
}
开发者ID:morts1a,项目名称:terraform,代码行数:27,代码来源:resource_openstack_compute_instance_v2_test.go
示例4: getBlockDevices
func (driver *Driver) getBlockDevices(instanceID string) ([]volumeattach.VolumeAttachment, error) {
// volumes := volumeattach.Get(driver.Client, driver.InstanceID, "")
allPages, err := volumeattach.List(driver.Client, driver.InstanceID).AllPages()
// volumeAttachments, err := volumes.VolumeAttachmentResult.ExtractAll()
volumeAttachments, err := volumeattach.ExtractVolumeAttachments(allPages)
if err != nil {
return []volumeattach.VolumeAttachment{}, fmt.Errorf("Error: %v", err)
}
return volumeAttachments, nil
}
开发者ID:bkeyoumarsi,项目名称:rexray,代码行数:13,代码来源:storage.go
示例5: getBlockDevices
func (driver *Driver) getBlockDevices(instanceID string) ([]volumeattach.VolumeAttachment, error) {
// volumes := volumeattach.Get(driver.Client, driver.InstanceID, "")
allPages, err := volumeattach.List(driver.Client, driver.InstanceID).AllPages()
// volumeAttachments, err := volumes.VolumeAttachmentResult.ExtractAll()
volumeAttachments, err := volumeattach.ExtractVolumeAttachments(allPages)
if err != nil {
return []volumeattach.VolumeAttachment{},
errors.WithFieldsE(eff(errors.Fields{
"instanceId": instanceID}),
"error extracting volume attachments", err)
}
return volumeAttachments, nil
}
开发者ID:robnolen,项目名称:rexray,代码行数:16,代码来源:storage.go
示例6: getVolumeAttachments
func getVolumeAttachments(computeClient *gophercloud.ServiceClient, serverId string) ([]volumeattach.VolumeAttachment, error) {
var attachments []volumeattach.VolumeAttachment
err := volumeattach.List(computeClient, serverId).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, err
}
attachments = actual
return true, nil
})
if err != nil {
return nil, err
}
return attachments, nil
}
开发者ID:semarj,项目名称:terraform,代码行数:18,代码来源:resource_openstack_compute_instance_v2.go
示例7: getVolumeAttachments
func getVolumeAttachments(computeClient *gophercloud.ServiceClient, d *schema.ResourceData) error {
var attachments []volumeattach.VolumeAttachment
err := volumeattach.List(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, err
}
attachments = actual
return true, nil
})
if err != nil {
return err
}
var vols []map[string]interface{}
for _, attachment := range attachments {
// ignore the volume if it is attached as a root device
rootDevFound := false
for _, rootDev := range []string{"/dev/vda", "/dev/xda", "/dev/sda", "/dev/xvda"} {
if attachment.Device == rootDev {
rootDevFound = true
}
}
if rootDevFound {
continue
}
vol := make(map[string]interface{})
vol["id"] = attachment.ID
vol["volume_id"] = attachment.VolumeID
vol["device"] = attachment.Device
vols = append(vols, vol)
}
log.Printf("[INFO] Volume attachments: %v", vols)
d.Set("volume", vols)
return nil
}
开发者ID:Zordrak,项目名称:terraform,代码行数:42,代码来源:resource_openstack_compute_instance_v2.go
示例8: testAccCheckComputeV2InstanceVolumeDetached
func testAccCheckComputeV2InstanceVolumeDetached(instance *servers.Server, volume_id string) resource.TestCheckFunc {
return func(s *terraform.State) error {
var attachments []volumeattach.VolumeAttachment
rs, ok := s.RootModule().Resources[volume_id]
if !ok {
return fmt.Errorf("Not found: %s", volume_id)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}
config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
if err != nil {
return err
}
err = volumeattach.List(computeClient, instance.ID).EachPage(func(page pagination.Page) (bool, error) {
actual, err := volumeattach.ExtractVolumeAttachments(page)
if err != nil {
return false, fmt.Errorf("Unable to lookup attachment: %s", err)
}
attachments = actual
return true, nil
})
for _, attachment := range attachments {
if attachment.VolumeID == rs.Primary.ID {
return fmt.Errorf("Volume is still attached.")
}
}
return nil
}
}
开发者ID:hooklift,项目名称:terraform,代码行数:37,代码来源:resource_openstack_compute_instance_v2_test.go
示例9: getVolumeAttachments
func getVolumeAttachments(computeClient *gophercloud.ServiceClient, d *schema.ResourceData) error {
var vols []map[string]interface{}
allPages, err := volumeattach.List(computeClient, d.Id()).AllPages()
if err != nil {
return err
}
allVolumeAttachments, err := volumeattach.ExtractVolumeAttachments(allPages)
if err != nil {
return err
}
if v, ok := d.GetOk("volume"); ok {
volumes := v.(*schema.Set).List()
for _, volume := range volumes {
if volumeMap, ok := volume.(map[string]interface{}); ok {
if v, ok := volumeMap["volume_id"].(string); ok {
for _, volumeAttachment := range allVolumeAttachments {
if v == volumeAttachment.ID {
vol := make(map[string]interface{})
vol["id"] = volumeAttachment.ID
vol["volume_id"] = volumeAttachment.VolumeID
vol["device"] = volumeAttachment.Device
vols = append(vols, vol)
}
}
}
}
}
}
log.Printf("[INFO] Volume attachments: %v", vols)
d.Set("volume", vols)
return nil
}
开发者ID:Originate,项目名称:terraform,代码行数:37,代码来源:resource_openstack_compute_instance_v2.go
示例10: List
// List returns a Pager that allows you to iterate over a collection of VolumeAttachments.
func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager {
return os.List(client, serverID)
}
开发者ID:40a,项目名称:bootkube,代码行数:4,代码来源:delegate.go
注:本文中的github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach.List函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论