github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/extensions/volumeactions/attach.go (about)

     1  package volumeactions
     2  
     3  import "github.com/opentelekomcloud/gophertelekomcloud"
     4  
     5  type AttachMode string
     6  
     7  const (
     8  	ReadOnly  AttachMode = "ro"
     9  	ReadWrite AttachMode = "rw"
    10  )
    11  
    12  type AttachOpts struct {
    13  	// The mountpoint of this volume.
    14  	MountPoint string `json:"mountpoint,omitempty"`
    15  	// The nova instance ID, can't set simultaneously with HostName.
    16  	InstanceUUID string `json:"instance_uuid,omitempty"`
    17  	// The hostname of baremetal host, can't set simultaneously with InstanceUUID.
    18  	HostName string `json:"host_name,omitempty"`
    19  	// Mount mode of this volume.
    20  	Mode AttachMode `json:"mode,omitempty"`
    21  }
    22  
    23  func Attach(client *golangsdk.ServiceClient, id string, opts AttachOpts) (err error) {
    24  	b, err := golangsdk.BuildRequestBody(opts, "os-attach")
    25  	if err != nil {
    26  		return
    27  	}
    28  
    29  	_, err = client.Post(client.ServiceURL("volumes", id, "action"), b, nil, nil)
    30  	return
    31  }