github.com/gophercloud/gophercloud@v1.11.0/openstack/blockstorage/extensions/volumeactions/doc.go (about) 1 /* 2 Package volumeactions provides information and interaction with volumes in the 3 OpenStack Block Storage service. A volume is a detachable block storage 4 device, akin to a USB hard drive. 5 6 Example of Attaching a Volume to an Instance 7 8 attachOpts := volumeactions.AttachOpts{ 9 MountPoint: "/mnt", 10 Mode: "rw", 11 InstanceUUID: server.ID, 12 } 13 14 err := volumeactions.Attach(client, volume.ID, attachOpts).ExtractErr() 15 if err != nil { 16 panic(err) 17 } 18 19 detachOpts := volumeactions.DetachOpts{ 20 AttachmentID: volume.Attachments[0].AttachmentID, 21 } 22 23 err = volumeactions.Detach(client, volume.ID, detachOpts).ExtractErr() 24 if err != nil { 25 panic(err) 26 } 27 28 Example of Creating an Image from a Volume 29 30 uploadImageOpts := volumeactions.UploadImageOpts{ 31 ImageName: "my_vol", 32 Force: true, 33 } 34 35 volumeImage, err := volumeactions.UploadImage(client, volume.ID, uploadImageOpts).Extract() 36 if err != nil { 37 panic(err) 38 } 39 40 fmt.Printf("%+v\n", volumeImage) 41 42 Example of Extending a Volume's Size 43 44 extendOpts := volumeactions.ExtendSizeOpts{ 45 NewSize: 100, 46 } 47 48 err := volumeactions.ExtendSize(client, volume.ID, extendOpts).ExtractErr() 49 if err != nil { 50 panic(err) 51 } 52 53 Example of Initializing a Volume Connection 54 55 connectOpts := &volumeactions.InitializeConnectionOpts{ 56 IP: "127.0.0.1", 57 Host: "stack", 58 Initiator: "iqn.1994-05.com.redhat:17cf566367d2", 59 Multipath: gophercloud.Disabled, 60 Platform: "x86_64", 61 OSType: "linux2", 62 } 63 64 connectionInfo, err := volumeactions.InitializeConnection(client, volume.ID, connectOpts).Extract() 65 if err != nil { 66 panic(err) 67 } 68 69 fmt.Printf("%+v\n", connectionInfo["data"]) 70 71 terminateOpts := &volumeactions.InitializeConnectionOpts{ 72 IP: "127.0.0.1", 73 Host: "stack", 74 Initiator: "iqn.1994-05.com.redhat:17cf566367d2", 75 Multipath: gophercloud.Disabled, 76 Platform: "x86_64", 77 OSType: "linux2", 78 } 79 80 err = volumeactions.TerminateConnection(client, volume.ID, terminateOpts).ExtractErr() 81 if err != nil { 82 panic(err) 83 } 84 85 Example of Setting a Volume's Bootable status 86 87 options := volumeactions.BootableOpts{ 88 Bootable: true, 89 } 90 91 err := volumeactions.SetBootable(client, volume.ID, options).ExtractErr() 92 if err != nil { 93 panic(err) 94 } 95 96 Example of Changing Type of a Volume 97 98 changeTypeOpts := volumeactions.ChangeTypeOpts{ 99 NewType: "ssd", 100 MigrationPolicy: volumeactions.MigrationPolicyOnDemand, 101 } 102 103 err = volumeactions.ChangeType(client, volumeID, changeTypeOpts).ExtractErr() 104 if err != nil { 105 panic(err) 106 } 107 */ 108 package volumeactions