cloudvolumes

package
v0.0.0-...-63319d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns Volumes optionally limited by the conditions provided in ListOpts.

Types

type Attachment

type Attachment struct {
	// Specifies the ID of the attachment information
	AttachmentID string `json:"attachment_id"`
	// Specifies the disk ID
	VolumeID string `json:"volume_id"`
	// Specifies the ID of the attached resource, equals to volume_id
	ResourceID string `json:"id"`
	// Specifies the ID of the server to which the disk is attached
	ServerID string `json:"server_id"`
	// Specifies the name of the host accommodating the server to which the disk is attached
	HostName string `json:"host_name"`
	// Specifies the device name
	Device string `json:"device"`
	// Specifies the time when the disk was attached. Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX
	AttachedAt string `json:"attached_at"`
}

Attachment contains the disk attachment information

type BssParam

type BssParam struct {
	// Specifies the billing mode. The default value is postPaid.
	//   prePaid: indicates the yearly/monthly billing mode.
	//   postPaid: indicates the pay-per-use billing mode.
	ChargingMode string `json:"chargingMode" required:"true"`
	// Specifies the unit of the subscription term.
	// This parameter is valid and mandatory only when chargingMode is set to prePaid.
	//   month: indicates that the unit is month.
	//   year: indicates that the unit is year.
	PeriodType string `json:"periodType,omitempty"`
	// Specifies the subscription term. This parameter is valid and mandatory only when chargingMode is set to prePaid.
	//   When periodType is set to month, the parameter value ranges from 1 to 9.
	//   When periodType is set to year, the parameter value must be set to 1.
	PeriodNum int `json:"periodNum,omitempty"`
	// Specifies whether to pay immediately. This parameter is valid only when chargingMode is set to prePaid. The default value is false.
	//   false: indicates not to pay immediately after an order is created.
	//   true: indicates to pay immediately after an order is created. The system will automatically deduct fees from the account balance.
	IsAutoPay string `json:"isAutoPay,omitempty"`
	// Specifies whether to automatically renew the subscription.
	// This parameter is valid only when chargingMode is set to prePaid. The default value is false.
	//   false: indicates not to automatically renew the subscription.
	//   true: indicates to automatically renew the subscription. The automatic renewal term is the same as the subscription term.
	IsAutoRenew string `json:"isAutoRenew,omitempty"`
}

type CreateOpts

type CreateOpts struct {
	Volume     VolumeOpts     `json:"volume" required:"true"`
	ChargeInfo *BssParam      `json:"bssParam,omitempty"`
	Scheduler  *SchedulerOpts `json:"OS-SCH-HNT:scheduler_hints,omitempty"`
	ServerID   string         `json:"server_id,omitempty"`
}

CreateOpts contains options for creating a Volume. This object is passed to the cloudvolumes.Create function.

func (CreateOpts) ToVolumeCreateMap

func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error)

ToVolumeCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToVolumeCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type DeleteOpts

type DeleteOpts struct {
	// Specifies to delete all snapshots associated with the EVS disk.
	Cascade bool `q:"cascade"`
}

DeleteOpts contain options for deleting an existing Volume. This object is passed to the cloudvolumes.Delete function.

func (DeleteOpts) ToVolumeDeleteQuery

func (opts DeleteOpts) ToVolumeDeleteQuery() (string, error)

ToVolumeDeleteQuery assembles a request body based on the contents of an DeleteOpts.

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToVolumeDeleteQuery() (string, error)
}

DeleteOptsBuilder is an interface by which can be able to build the query string of volume deletion.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult contains the response body and error from a Delete request.

func Delete

func Delete(client *golangsdk.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)

Delete will delete the existing Volume with the provided ID

type ErrorInfo

type ErrorInfo struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

ErrorInfo contains the error message returned when an error occurs

type ExtendChargeOpts

type ExtendChargeOpts struct {
	IsAutoPay string `json:"isAutoPay,omitempty"`
}

ExtendChargeOpts contains the charging parameters of the volume

type ExtendOpts

type ExtendOpts struct {
	SizeOpts   ExtendSizeOpts    `json:"os-extend" required:"true"`
	ChargeInfo *ExtendChargeOpts `json:"bssParam,omitempty"`
}

ExtendOpts contains options for extending the size of an existing Volume. This object is passed to the cloudvolumes.ExtendSize function.

func (ExtendOpts) ToVolumeExtendMap

func (opts ExtendOpts) ToVolumeExtendMap() (map[string]interface{}, error)

ToVolumeExtendMap assembles a request body based on the contents of an ExtendOpts.

type ExtendOptsBuilder

type ExtendOptsBuilder interface {
	ToVolumeExtendMap() (map[string]interface{}, error)
}

ExtendOptsBuilder allows extensions to add additional parameters to the ExtendSize request.

type ExtendSizeOpts

type ExtendSizeOpts struct {
	NewSize int `json:"new_size" required:"true"`
}

ExtendSizeOpts contains the new size of the volume, in GB.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult contains the response body from a Get request.

func Get

func Get(client *golangsdk.ServiceClient, id string) (r GetResult)

Get retrieves the Volume with the provided ID. To extract the Volume object from the response, call the Extract method on the GetResult.

func (GetResult) Extract

func (r GetResult) Extract() (*Volume, error)

Extract will get the Volume object out of the commonResult object.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

ExtractInto converts our response data into a volume struct

type JobResponse

type JobResponse struct {
	JobID     string    `json:"job_id"`
	OrderID   string    `json:"order_id"`
	VolumeIDs []string  `json:"volume_ids"`
	Error     ErrorInfo `json:"error"`
}

JobResponse contains all the information from Create and ExtendSize response

type JobResult

type JobResult struct {
	golangsdk.Result
}

JobResult contains the response body and error from Create and ExtendSize requests

func Create

func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r JobResult)

Create will create a new Volume based on the values in CreateOpts.

func ExtendSize

func ExtendSize(client *golangsdk.ServiceClient, id string, opts ExtendOptsBuilder) (r JobResult)

ExtendSize will extend the size of the volume based on the provided information. This operation does not return a response body.

func (JobResult) Extract

func (r JobResult) Extract() (*JobResponse, error)

Extract will get the JobResponse object out of the JobResult

type Link struct {
	// Specifies the corresponding shortcut link.
	Href string `json:"href"`
	// Specifies the shortcut link marker name.
	Rel string `json:"rel"`
}

Link is an object that represents a link to which the disk belongs.

type ListOpts

type ListOpts struct {
	// Name will filter by the specified volume name.
	Name string `q:"name"`
	// Status will filter by the specified status.
	Status string `q:"status"`
	// Metadata will filter results based on specified metadata.
	Metadata string `q:"metadata"`
	// Specifies the disk ID.
	ID string `q:"id"`
	// Specifies the disk IDs. The parameter value is in the ids=["id1","id2",...,"idx"] format.
	// In the response, the ids value contains valid disk IDs only. Invalid disk IDs will be ignored.
	// Details about a maximum of 60 disks can be queried.
	// If parameters id and ids are both specified in the request, id will be ignored.
	IDs string `q:"ids"`
	// Specifies the AZ.
	AvailabilityZone string `q:"availability_zone"`
	// Specifies the ID of the DSS storage pool. All disks in the DSS storage pool can be filtered out.
	// Only precise match is supported.
	DedicatedStorageID string `q:"dedicated_storage_id"`
	// Specifies the name of the DSS storage pool. All disks in the DSS storage pool can be filtered out.
	// Fuzzy match is supported.
	DedicatedStorageName string `q:"dedicated_storage_name"`
	// Specifies the enterprise project ID for filtering. If input parameter all_granted_eps exists, disks in all
	// enterprise projects that are within the permission scope will be queried.
	EnterpriseProjectID string `q:"enterprise_project_id"`
	// Specifies whether the disk is shareable.
	//   true: specifies a shared disk.
	//   false: specifies a non-shared disk.
	Multiattach bool `q:"multiattach"`
	// Specifies the service type. Currently, the supported services are EVS, DSS, and DESS.
	ServiceType string `q:"service_type"`
	// Specifies the server ID.
	// This parameter is used to filter all the EVS disks that have been attached to this server.
	ServerID string `q:"server_id"`
	// Specifies the keyword based on which the returned results are sorted.
	// The value can be id, status, size, or created_at, and the default value is created_at.
	SortKey string `q:"sort_key"`
	// Specifies the result sorting order. The default value is desc.
	//   desc: indicates the descending order.
	//   asc: indicates the ascending order.
	SortDir string `q:"sort_dir"`
	// Specifies the disk type ID.
	// You can obtain the disk type ID in Querying EVS Disk Types.
	// That is, the id value in the volume_types parameter description table.
	VolumeTypeID string `q:"volume_type_id"`
	// Requests a page size of items.
	Limit int `q:"limit"`
	// Used in conjunction with limit to return a slice of items.
	Offset int `q:"offset"`
	// The ID of the last-seen item.
	Marker string `q:"marker"`
}

ListOpts holds options for listing Volumes. It is passed to the volumes.List function.

func (ListOpts) ToVolumeListQuery

func (opts ListOpts) ToVolumeListQuery() (string, error)

ToVolumeListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToVolumeListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type SchedulerOpts

type SchedulerOpts struct {
	StorageID string `json:"dedicated_storage_id,omitempty"`
}

SchedulerOpts contains the scheduler hints

type UpdateOpts

type UpdateOpts struct {
	Name        string  `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
}

UpdateOpts contain options for updating an existing Volume. This object is passed to the cloudvolumes.Update function.

func (UpdateOpts) ToVolumeUpdateMap

func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error)

ToVolumeUpdateMap assembles a request body based on the contents of an UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToVolumeUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult contains the response body from a Update request.

func Update

func Update(client *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update will update the Volume with provided information. To extract the updated Volume from the response, call the Extract method on the UpdateResult.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Volume, error)

Extract will get the Volume object out of the commonResult object.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

ExtractInto converts our response data into a volume struct

type Volume

type Volume struct {
	// Unique identifier for the volume.
	ID string `json:"id"`
	// Human-readable display name for the volume.
	Name string `json:"name"`
	// Current status of the volume.
	Status string `json:"status"`
	// Size of the volume in GB.
	Size int `json:"size"`
	// Human-readable description for the volume.
	Description string `json:"description"`
	// The type of volume to create, either SATA or SSD.
	VolumeType string `json:"volume_type"`
	// AvailabilityZone is which availability zone the volume is in.
	AvailabilityZone string `json:"availability_zone"`
	// Instances onto which the volume is attached.
	Attachments []Attachment `json:"attachments"`
	// Specifies the disk URI.
	Links []Link `json:"links"`
	// The metadata of the disk image.
	ImageMetadata map[string]string `json:"volume_image_metadata"`
	// The ID of the snapshot from which the volume was created
	SnapshotID string `json:"snapshot_id"`
	// The ID of another block storage volume from which the current volume was created
	SourceVolID string `json:"source_volid"`
	// Specifies the ID of the tenant to which the disk belongs. The tenant ID is actually the project ID.
	OsVolTenantAttrTenantID string `json:"os-vol-tenant-attr:tenant_id"`
	// Specifies the service type. The value can be EVS, DSS or DESS.
	ServiceType string `json:"service_type"`
	// Indicates whether this is a bootable volume.
	Bootable string `json:"bootable"`
	// Multiattach denotes if the volume is multi-attach capable.
	Multiattach bool `json:"multiattach"`
	// Specifies the ID of the DSS storage pool accommodating the disk.
	DedicatedStorageID string `json:"dedicated_storage_id"`
	// Specifies the name of the DSS storage pool accommodating the disk.
	DedicatedStorageName string `json:"dedicated_storage_name"`
	// Encrypted denotes if the volume is encrypted.
	Encrypted bool `json:"encrypted"`
	// wwn of the volume.
	WWN string `json:"wwn"`
	// enterprise project ID bound to the volume
	EnterpriseProjectID string `json:"enterprise_project_id"`
	// ReplicationStatus is the status of replication.
	ReplicationStatus string `json:"replication_status"`
	// ConsistencyGroupID is the consistency group ID.
	ConsistencyGroupID string `json:"consistencygroup_id"`
	// Arbitrary key-value pairs defined by the metadata field table.
	Metadata VolumeMetadata `json:"metadata"`
	// Arbitrary key-value pairs defined by the user.
	Tags map[string]string `json:"tags"`
	// UserID is the id of the user who created the volume.
	UserID string `json:"user_id"`
	// The date when this volume was created.
	CreatedAt string `json:"created_at"`
	// The date when this volume was last updated
	UpdatedAt string `json:"updated_at"`
}

Volume contains all the information associated with a Volume.

func ExtractVolumes

func ExtractVolumes(r pagination.Page) ([]Volume, error)

ExtractVolumes extracts and returns Volumes. It is used while iterating over a cloudvolumes.List call.

func ListPage

func ListPage(client *golangsdk.ServiceClient, opts ListOptsBuilder) ([]Volume, error)

type VolumeMetadata

type VolumeMetadata struct {
	// Specifies the parameter that describes the encryption CMK ID in metadata.
	// This parameter is used together with __system__encrypted for encryption.
	// The length of cmkid is fixed at 36 bytes.
	SystemCmkID string `json:"__system__cmkid"`
	// Specifies the parameter that describes the encryption function in metadata. The value can be 0 or 1.
	//   0: indicates the disk is not encrypted.
	//   1: indicates the disk is encrypted.
	//   If this parameter does not appear, the disk is not encrypted by default.
	SystemEncrypted string `json:"__system__encrypted"`
	// Specifies the clone method. When the disk is created from a snapshot,
	// the parameter value is 0, indicating the linked cloning method.
	FullClone string `json:"full_clone"`
	// Specifies the parameter that describes the disk device type in metadata. The value can be true or false.
	//   If this parameter is set to true, the disk device type is SCSI, that is, Small Computer System
	//     Interface (SCSI), which allows ECS OSs to directly access the underlying storage media and supports SCSI
	//     reservation commands.
	//   If this parameter is set to false, the disk device type is VBD (the default type),
	//     that is, Virtual Block Device (VBD), which supports only simple SCSI read/write commands.
	//   If this parameter does not appear, the disk device type is VBD.
	HwPassthrough string `json:"hw:passthrough"`
	// Specifies the parameter that describes the disk billing mode in metadata.
	// If this parameter is specified, the disk is billed on a yearly/monthly basis.
	// If this parameter is not specified, the disk is billed on a pay-per-use basis.
	OrderID string `json:"orderID"`
	// Specifies the resource type about the disk.
	ResourceType string `json:"resourceType"`
	// Specifies the special code about the disk.
	ResourceSpecCode string `json:"resourceSpecCode"`
	// Specifies whether disk is read-only.
	ReadOnly string `json:"readonly"`
	// Specifies the attached mode about the disk.
	AttachedMode string `json:"attached_mode"`
}

VolumeMetadata is an object that represents the metadata about the disk.

type VolumeOpts

type VolumeOpts struct {
	// The availability zone
	AvailabilityZone string `json:"availability_zone" required:"true"`
	// The associated volume type
	VolumeType string `json:"volume_type" required:"true"`
	// The volume name
	Name string `json:"name,omitempty"`
	// The volume description
	Description string `json:"description,omitempty"`
	// The size of the volume, in GB
	Size int `json:"size,omitempty"`
	// The number to be created in a batch
	Count int `json:"count,omitempty"`
	// The backup_id
	BackupID string `json:"backup_id,omitempty"`
	// the ID of the existing volume snapshot
	SnapshotID string `json:"snapshot_id,omitempty"`
	// the ID of the image in IMS
	ImageID string `json:"imageRef,omitempty"`
	// Shared disk
	Multiattach bool `json:"multiattach,omitempty"`
	// One or more metadata key and value pairs to associate with the volume
	Metadata map[string]string `json:"metadata,omitempty"`
	// One or more tag key and value pairs to associate with the volume
	Tags map[string]string `json:"tags,omitempty"`
	// the enterprise project id
	EnterpriseProjectID string `json:"enterprise_project_id,omitempty"`
}

VolumeOpts contains options for creating a Volume.

type VolumePage

type VolumePage struct {
	pagination.OffsetPageBase
}

VolumePage is a pagination.pager that is returned from a call to the List function.

func (VolumePage) IsEmpty

func (r VolumePage) IsEmpty() (bool, error)

IsEmpty returns true if a ListResult contains no Volumes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL