github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/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  
    29  Example of Creating an Image from a Volume
    30  
    31  	uploadImageOpts := volumeactions.UploadImageOpts{
    32  		ImageName: "my_vol",
    33  		Force:     true,
    34  	}
    35  
    36  	volumeImage, err := volumeactions.UploadImage(client, volume.ID, uploadImageOpts).Extract()
    37  	if err != nil {
    38  		panic(err)
    39  	}
    40  
    41  	fmt.Printf("%+v\n", volumeImage)
    42  
    43  Example of Extending a Volume's Size
    44  
    45  	extendOpts := volumeactions.ExtendSizeOpts{
    46  		NewSize: 100,
    47  	}
    48  
    49  	err := volumeactions.ExtendSize(client, volume.ID, extendOpts).ExtractErr()
    50  	if err != nil {
    51  		panic(err)
    52  	}
    53  
    54  Example of Initializing a Volume Connection
    55  
    56  	connectOpts := &volumeactions.InitializeConnectionOpts{
    57  		IP:        "127.0.0.1",
    58  		Host:      "stack",
    59  		Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
    60  		Multipath: golangsdk.Disabled,
    61  		Platform:  "x86_64",
    62  		OSType:    "linux2",
    63  	}
    64  
    65  	connectionInfo, err := volumeactions.InitializeConnection(client, volume.ID, connectOpts).Extract()
    66  	if err != nil {
    67  		panic(err)
    68  	}
    69  
    70  	fmt.Printf("%+v\n", connectionInfo["data"])
    71  
    72  	terminateOpts := &volumeactions.InitializeConnectionOpts{
    73  		IP:        "127.0.0.1",
    74  		Host:      "stack",
    75  		Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
    76  		Multipath: golangsdk.Disabled,
    77  		Platform:  "x86_64",
    78  		OSType:    "linux2",
    79  	}
    80  
    81  	err = volumeactions.TerminateConnection(client, volume.ID, terminateOpts).ExtractErr()
    82  	if err != nil {
    83  		panic(err)
    84  	}
    85  */
    86  package volumeactions