cloudservers

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJobEntity

func GetJobEntity(client *golangsdk.ServiceClient, jobID string, label string) (interface{}, error)

func WaitForJobSuccess

func WaitForJobSuccess(client *golangsdk.ServiceClient, secs int, jobID string) error

Types

type Address

type Address struct {
	Version string `json:"version"`
	Addr    string `json:"addr"`
	MacAddr string `json:"OS-EXT-IPS-MAC:mac_addr"`
	PortID  string `json:"OS-EXT-IPS:port_id"`
	Type    string `json:"OS-EXT-IPS:type"`
}

type BandWidth

type BandWidth struct {
	// Specifies the bandwidth size.
	Size int `json:"size" required:"true"`

	// Specifies the bandwidth sharing type
	ShareType string `json:"sharetype" required:"true"`

	// Specifies the bandwidth billing mode.
	ChargeMode string `json:"chargemode" required:"true"`
}

type BindingProfile added in v0.2.7

type BindingProfile struct {
	// DisableSecurityGroups indicates that a HANA ECS NIC is not added to a security group.
	DisableSecurityGroups *bool `json:"disable_security_groups,omitempty"`
}

type CloudServer

type CloudServer struct {
	Status             string               `json:"status"`
	Updated            time.Time            `json:"updated"`
	HostID             string               `json:"hostId"`
	Addresses          map[string][]Address `json:"addresses"`
	ID                 string               `json:"id"`
	Name               string               `json:"name"`
	AccessIPv4         string               `json:"accessIPv4"`
	AccessIPv6         string               `json:"accessIPv6"`
	Created            time.Time            `json:"created"`
	Tags               []string             `json:"tags"`
	Description        string               `json:"description"`
	Locked             bool                 `json:"locked"`
	ConfigDrive        string               `json:"config_drive"`
	TenantID           string               `json:"tenant_id"`
	UserID             string               `json:"user_id"`
	HostStatus         string               `json:"host_status"`
	SysTags            []SysTags            `json:"sys_tags"`
	Flavor             Flavor               `json:"flavor"`
	Metadata           Metadata             `json:"metadata"`
	SecurityGroups     []SecurityGroups     `json:"security_groups"`
	KeyName            string               `json:"key_name"`
	Image              Image                `json:"image"`
	Progress           int                  `json:"progress"`
	PowerState         int                  `json:"OS-EXT-STS:power_state"`
	VMState            string               `json:"OS-EXT-STS:vm_state"`
	TaskState          string               `json:"OS-EXT-STS:task_state"`
	DiskConfig         string               `json:"OS-DCF:diskConfig"`
	AvailabilityZone   string               `json:"OS-EXT-AZ:availability_zone"`
	LaunchedAt         string               `json:"OS-SRV-USG:launched_at"`
	TerminatedAt       string               `json:"OS-SRV-USG:terminated_at"`
	RootDeviceName     string               `json:"OS-EXT-SRV-ATTR:root_device_name"`
	RamdiskID          string               `json:"OS-EXT-SRV-ATTR:ramdisk_id"`
	KernelID           string               `json:"OS-EXT-SRV-ATTR:kernel_id"`
	LaunchIndex        int                  `json:"OS-EXT-SRV-ATTR:launch_index"`
	ReservationID      string               `json:"OS-EXT-SRV-ATTR:reservation_id"`
	Hostname           string               `json:"OS-EXT-SRV-ATTR:hostname"`
	UserData           string               `json:"OS-EXT-SRV-ATTR:user_data"`
	Host               string               `json:"OS-EXT-SRV-ATTR:host"`
	InstanceName       string               `json:"OS-EXT-SRV-ATTR:instance_name"`
	HypervisorHostname string               `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"`
	VolumeAttached     []VolumeAttached     `json:"os-extended-volumes:volumes_attached"`
	OsSchedulerHints   OsSchedulerHints     `json:"os:scheduler_hints"`
}

CloudServer is only used for method that requests details on a single server, by ID. Because metadata struct must be a map.

type CreateOpts

type CreateOpts struct {
	// ImageRef ID  the ID of the system image used for creating ECSs.
	ImageRef string `json:"imageRef" required:"true"`

	// FlavorRef ID of the ECS to be created.
	FlavorRef string `json:"flavorRef" required:"true"`

	// Name of the ECS instance.
	Name string `json:"name" required:"true"`

	// UserData to be injected during the ECS creation process.
	UserData []byte `json:"-"`

	// AdminPass sets the root user password. If not set, a randomly-generated
	// password will be created and returned in the response.
	AdminPass string `json:"adminPass,omitempty"`

	// KeyName of the SSH key used for logging in to the ECS.
	KeyName string `json:"key_name,omitempty"`

	// VpcId of the VPC to which the ECS belongs.
	VpcId string `json:"vpcid" required:"true"`

	// Nics information of the ECS.
	Nics []Nic `json:"nics" required:"true"`

	// PublicIp of the ECS.
	PublicIp *PublicIp `json:"publicip,omitempty"`

	// Count of ECSs to be created.
	// If this parameter is not specified, the default value is 1.
	Count int `json:"count,omitempty"`

	// ECS RootVolume configurations.
	RootVolume RootVolume `json:"root_volume" required:"true"`

	// ECS DataVolumes configurations.
	DataVolumes []DataVolume `json:"data_volumes,omitempty"`

	// SecurityGroups of the ECS.
	SecurityGroups []SecurityGroup `json:"security_groups,omitempty"`

	// AvailabilityZone specifies name of the AZ where the ECS is located.
	AvailabilityZone string `json:"availability_zone" required:"true"`

	// ExtendParam provides the supplementary information about the ECS to be created.
	ExtendParam *ServerExtendParam `json:"extendparam,omitempty"`

	// MetaData specifies the metadata of the ECS to be created.
	MetaData *MetaData `json:"metadata,omitempty"`

	// SchedulerHints schedules ECSs, for example, by configuring an ECS group.
	SchedulerHints *SchedulerHints `json:"os:scheduler_hints,omitempty"`

	// ECS Tags.
	Tags []string `json:"tags,omitempty"`

	ServerTags []ServerTags `json:"server_tags,omitempty"`
}

func (CreateOpts) ToServerCreateMap

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

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

type CreateOptsBuilder

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

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

type DataVolume

type DataVolume struct {
	// VolumeType of the ECS data disk.
	VolumeType string `json:"volumetype" required:"true"`

	// The data disk Size, in GB.
	Size int `json:"size" required:"true"`

	// MultiAttach is the shared disk information.
	MultiAttach *bool `json:"multiattach,omitempty"`

	// PassThrough indicates whether the data volume uses a SCSI lock.
	PassThrough *bool `json:"hw:passthrough,omitempty"`

	Extendparam *VolumeExtendParam `json:"extendparam,omitempty"`

	// DataImageID If data disks are created using a data disk
	// image, this parameter is mandatory and it does not support metadata.
	DataImageID string `json:"data_image_id,omitempty"`

	// EVS disk Metadata.
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type DeleteOpts

type DeleteOpts struct {
	// Servers to be deleted
	Servers []Server `json:"servers" required:"true"`

	// DeletePublicIP specifies whether to delete the EIP bound to the ECS when deleting the ECS.
	DeletePublicIP bool `json:"delete_publicip,omitempty"`

	// DeleteVolume specifies whether to delete the data disks of the ECS.
	DeleteVolume bool `json:"delete_volume,omitempty"`
}

func (DeleteOpts) ToServerDeleteMap

func (opts DeleteOpts) ToServerDeleteMap() (map[string]interface{}, error)

ToServerDeleteMap assembles a request body based on the contents of a DeleteOpts.

type DryRunResult added in v0.2.7

type DryRunResult struct {
	golangsdk.ErrResult
}

func DryRun added in v0.2.7

func DryRun(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r DryRunResult)

DryRun requests a server to be provisioned to the user in the current tenant.

type Eip

type Eip struct {
	// Specifies the EIP type
	IpType string `json:"iptype" required:"true"`

	// Specifies the EIP bandwidth.
	BandWidth *BandWidth `json:"bandwidth" required:"true"`
}

type ExtraDhcpOpts added in v0.2.7

type ExtraDhcpOpts struct {
	// Set the parameter value to 26.
	OptName string `json:"opt_name" required:"true"`

	// OptValue specifies the NIC MTU, which ranges from 1280 to 8888.
	OptValue int `json:"opt_value" required:"true"`
}

type Flavor

type Flavor struct {
	Disk  string `json:"disk"`
	Vcpus string `json:"vcpus"`
	RAM   string `json:"ram"`
	ID    string `json:"id"`
	Name  string `json:"name"`
}

type GetResult

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

GetResult is the response from a Get operation. Call its Extract method to interpret it as a Server.

func Get

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

Get retrieves a particular Server based on its unique ID.

func (GetResult) Extract

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

type Image

type Image struct {
	ID string `json:"id"`
}

Image defines a image struct in details of a server.

type JobEntity

type JobEntity struct {
	// Specifies the number of subtasks.
	// When no subtask exists, the value of this parameter is 0.
	SubJobsTotal int `json:"sub_jobs_total"`

	// Specifies the execution information of a subtask.
	// When no subtask exists, the value of this parameter is left blank.
	SubJobs []SubJob `json:"sub_jobs"`
}

type JobResponse

type JobResponse struct {
	JobID string `json:"job_id"`
}

type JobResult

type JobResult struct {
	golangsdk.Result
}

func Create

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

Create requests a server to be provisioned to the user in the current tenant.

func Delete

func Delete(client *golangsdk.ServiceClient, opts DeleteOpts) (r JobResult)

Delete requests a server to be deleted to the user in the current tenant.

func (JobResult) ExtractJobResponse

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

func (JobResult) ExtractJobStatus

func (r JobResult) ExtractJobStatus() (*JobStatus, error)

type JobStatus

type JobStatus struct {
	Status     string    `json:"status"`
	Entities   JobEntity `json:"entities"`
	JobID      string    `json:"job_id"`
	JobType    string    `json:"job_type"`
	BeginTime  string    `json:"begin_time"`
	EndTime    string    `json:"end_time"`
	ErrorCode  string    `json:"error_code"`
	FailReason string    `json:"fail_reason"`
	Message    string    `json:"message"`
	Code       string    `json:"code"`
}

type MetaData

type MetaData struct {
	// AdminPass specifies the password of user Administrator for logging in to a Windows ECS.
	AdminPass string `json:"admin_pass,omitempty"`

	// OpSvcUserId specifies the user ID.
	OpSvcUserId string `json:"op_svc_userid,omitempty"`

	// AgencyName specifies the IAM agency name.
	AgencyName string `json:"agency_name,omitempty"`

	// If you have an OS or a software license, you can migrate your services to the cloud
	// platform in BYOL mode to continue using your existing licenses.
	BYOL string `json:"BYOL,omitempty"`
}

type Metadata

type Metadata struct {
	ChargingMode      string `json:"charging_mode"`
	VpcID             string `json:"vpc_id"`
	EcmResStatus      string `json:"EcmResStatus"`
	ImageID           string `json:"metering.image_id"`
	ImageType         string `json:"metering.imagetype"`
	ResourceSpecCode  string `json:"metering.resourcespeccode"`
	ResourceType      string `json:"metering.resourcetype"`
	CascadeExtraInfo  string `json:"cascaded.instance_extrainfo"`
	ImageName         string `json:"image_name"`
	AgencyName        string `json:"agency_name"`
	OsBit             string `json:"os_bit"`
	OsType            string `json:"os_type"`
	LockCheckEndpoint string `json:"lockCheckEndpoint"`
	LockSource        string `json:"lockSource"`
	LockSourceID      string `json:"lockSourceId"`
	LockScene         string `json:"lockScene"`
	VirtualEnvType    string `json:"virtual_env_type"`
}

Metadata is only used for method that requests details on a single server, by ID. Because metadata struct must be a map.

type NewCloudServer

type NewCloudServer struct {
	CloudServer
	Metadata map[string]string `json:"metadata"`
}

NewCloudServer defines the response from details on a single server, by ID.

type Nic

type Nic struct {
	// SubnetId of the ECS.
	SubnetId string `json:"subnet_id" required:"true"`

	// IpAddress of the NIC used by the ECS.
	IpAddress string `json:"ip_address,omitempty"`

	// BindingProfile allows you to customize data.
	// Configure this parameter when creating a HANA ECS.
	BindingProfile BindingProfile `json:"binding:profile,omitempty"`

	// ExtraDhcpOpts indicates extended DHCP options.
	ExtraDhcpOpts []ExtraDhcpOpts `json:"extra_dhcp_opts,omitempty"`
}

type OsSchedulerHints

type OsSchedulerHints struct {
	Group           []string `json:"group"`
	Tenancy         []string `json:"tenancy"`
	DedicatedHostID []string `json:"dedicated_host_id"`
}

type PublicIp

type PublicIp struct {
	// Id of the existing EIP assigned to the ECS to be created.
	Id string `json:"id,omitempty"`

	// Eip that will be automatically assigned to an ECS.
	Eip *Eip `json:"eip,omitempty"`
}

type RootVolume

type RootVolume struct {
	// VolumeType of the ECS system disk.
	VolumeType string `json:"volumetype" required:"true"`

	// System disk Size, in GB.
	Size int `json:"size,omitempty"`

	ExtendParam *VolumeExtendParam `json:"extendparam,omitempty"`

	// Pay attention to this parameter if your ECS is SDI-compliant.
	// If the value of this parameter is true, the created disk is of SCSI type.
	PassThrough *bool `json:"hw:passthrough,omitempty"`

	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type SchedulerHints

type SchedulerHints struct {
	// ECS Group ID, which is in UUID format.
	Group string `json:"group,omitempty"`

	// Specifies whether the ECS is created on a Dedicated Host (DeH) or in a shared pool.
	Tenancy string `json:"tenancy,omitempty"`

	// DedicatedHostID specifies a DeH ID.
	DedicatedHostID string `json:"dedicated_host_id,omitempty"`
}

type SecurityGroup

type SecurityGroup struct {
	// ID of the security group to which an ECS is to be added
	ID string `json:"id,omitempty"`
}

type SecurityGroups

type SecurityGroups struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

type Server

type Server struct {
	// ID of the ECS to be deleted.
	Id string `json:"id" required:"true"`
}

type ServerExtendParam

type ServerExtendParam struct {
	// RegionID is the ID of the region where the ECS resides.
	RegionID string `json:"regionID,omitempty"`

	// SupportAutoRecovery specifies whether automatic recovery is enabled on the ECS.
	SupportAutoRecovery string `json:"support_auto_recovery,omitempty"`
}

type ServerTags

type ServerTags struct {
	Key   string `json:"key" required:"true"`
	Value string `json:"value,omitempty"`
}

type SubJob

type SubJob struct {
	// Specifies the task ID.
	Id string `json:"job_id"`

	// Task type.
	Type string `json:"job_type"`

	// Specifies the task status.
	//  SUCCESS: indicates the task is successfully executed.
	//  RUNNING: indicates that the task is in progress.
	//  FAIL: indicates that the task failed.
	//  INIT: indicates that the task is being initialized.
	Status string `json:"status"`

	// Specifies the time when the task started.
	BeginTime string `json:"begin_time"`

	// Specifies the time when the task finished.
	EndTime string `json:"end_time"`

	// Specifies the returned error code when the task execution fails.
	ErrorCode string `json:"error_code"`

	// Specifies the cause of the task execution failure.
	FailReason string `json:"fail_reason"`

	// Specifies the object of the task.
	Entities map[string]string `json:"entities"`
}

type SysTags

type SysTags struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type VolumeAttached

type VolumeAttached struct {
	ID                  string `json:"id"`
	DeleteOnTermination string `json:"delete_on_termination"`
	BootIndex           string `json:"bootIndex"`
	Device              string `json:"device"`
}

type VolumeExtendParam

type VolumeExtendParam struct {
	SnapshotId string `json:"snapshotId,omitempty"`
}

Jump to

Keyboard shortcuts

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