internal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FailedResponse       = Response{Status: Failure}
	SuccessfulResponse   = Response{Status: Success, Message: "success"}
	NotSupportedResponse = Response{Status: NotSupported}
)
View Source
var (
	ErrNotExist = errors.New("resource does not exists")
)

ovirt api common errors

Functions

func GetOvirtNodeName

func GetOvirtNodeName(hostname string) (string, error)

GetOvirtNodeName returns the k8s ExternalID as fetched by kubectl describe node IP One of its usages is to bridge the gap when invoking some flexdriver command and we need the name of the co-responding VM This call expects this label to be set on the node: $ovirtNodeNameLabel TODO fragile approach, what happens if the node is not deployed under its `hostname`? This must be communicated as well in the deployment section.

Types

type AttachRequest

type AttachRequest struct {
	StorageDomain string `json:"ovirtStorageDomain"`
	VolumeName    string `json:"kubernetes.io/pvOrVolumeName,omitempty"`
	Size          string `json:"capacity,omitempty"`
	FsType        string `json:"kubernetes.io/fsType"`
	Mode          string `json:"kubernetes.io/readwrite"`
	// TODO use k8s secret?
	Secret     string `json:"kubernetes.io/secret,omitempty"`
	VolumeId   string `json:"volumeID,omitempty"`
	CustomSize string `json:"size,omitempty"`
}

func AttachRequestFrom

func AttachRequestFrom(s string) (AttachRequest, error)

type AttchResponse

type AttchResponse struct {
	Response
}

type Capabilities

type Capabilities struct {
	//"capabilities": <Only included as part of the Init response>
	Attach bool `json:"attach,omitempty"` //: <True/False (Return true if the driver implements attach and detach)>
}

type Connection

type Connection struct {
	Url      string
	Username string
	Password string
	Insecure bool
	CAFile   string
}

type Device added in v0.4.0

type Device struct {
	Ips struct {
		Ips []Ip `json:"ip"`
	} `json:"ips"`
}

type Disk

type Disk struct {
	Id              string         `json:"id,omitempty"`
	Name            string         `json:"name"`
	ActualSize      uint64         `json:"actual_size,omitempty,string"`
	ProvisionedSize uint64         `json:"provisioned_size,string"`
	Status          string         `json:"status,omitempty"`
	Format          DiskFormat     `json:"format"`
	StorageDomains  StorageDomains `json:"storage_domains"`
	Sparse          Sparse         `json:"sparse,string"`
}

type DiskAttachment

type DiskAttachment struct {
	Id          string `json:"id,omitempty"`
	Bootable    bool   `json:"bootable,string"`
	PassDiscard bool   `json:"pass_discard,string"`
	Interface   string `json:"interface,omitempty"`
	Active      bool   `json:"active,string"`
	Disk        Disk   `json:"disk"`
	ReadOnly    bool   `json:"read_only,string"`
}

type DiskAttachmentResult

type DiskAttachmentResult struct {
	DiskAttachments []DiskAttachment `json:"disk_attachment"`
}

type DiskFormat

type DiskFormat string

type DiskResult

type DiskResult struct {
	Disks []Disk `json:"disk"`
}

type Ip added in v0.4.0

type Ip struct {
	Address string `json:"address"`
	// v4, v6
	Version string `json:"version"`
}

type Nic added in v0.4.0

type Nic struct {
	Interface string `json:"interface"`
	Linked    bool   `json:"linked:string"`
	Devices   struct {
		Devices []Device `json:"reported_device"`
	} `json:"reported_devices"`
}

type NotFound

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

func (NotFound) Error

func (n NotFound) Error() string

type Ovirt

type Ovirt struct {
	Connection Connection
	// contains filtered or unexported fields
}

func (*Ovirt) Authenticate

func (ovirt *Ovirt) Authenticate() error

func (*Ovirt) CreateDisk

func (ovirt *Ovirt) CreateDisk(
	diskName string,
	storageDomainName string,
	readOnly bool,
	vmId string,
	diskId string,
	diskInterface string) (DiskAttachment, error)

func (*Ovirt) CreateUnattachedDisk

func (ovirt *Ovirt) CreateUnattachedDisk(diskName string, storageDomainName string, sizeIbBytes int64, readOnly bool, thinProvisioning bool) (Disk, error)

func (*Ovirt) DefaultDiskParamsBy added in v0.4.0

func (ovirt *Ovirt) DefaultDiskParamsBy(storageDomainName string, thinProvisioned bool) (DiskFormat, Sparse, error)

this logic is aligned with oVirt logic for determining disk format and spareness the combination are determined by the type of the storage domain.

func (*Ovirt) Delete

func (ovirt *Ovirt) Delete(path string) ([]byte, error)

func (*Ovirt) DetachDiskFromVM

func (ovirt *Ovirt) DetachDiskFromVM(vmId string, diskId string) error

func (*Ovirt) Get

func (ovirt *Ovirt) Get(path string) ([]byte, error)

func (*Ovirt) GetConnectionDetails added in v0.4.0

func (ovirt *Ovirt) GetConnectionDetails() Connection

func (*Ovirt) GetDiskAttachment

func (ovirt *Ovirt) GetDiskAttachment(vmId, diskId string) (DiskAttachment, error)

func (*Ovirt) GetDiskAttachments

func (ovirt *Ovirt) GetDiskAttachments(vmId string) ([]DiskAttachment, error)

func (*Ovirt) GetDiskByName

func (ovirt *Ovirt) GetDiskByName(diskName string) (DiskResult, error)

func (*Ovirt) GetStorageDomainBy added in v0.4.0

func (ovirt *Ovirt) GetStorageDomainBy(name string) (StorageDomain, error)

GetStorageDomainBy returns a storage domain type by name

func (*Ovirt) GetVM

func (ovirt *Ovirt) GetVM(name string) (VM, error)

TODO implement with invocation of the new GetVMs

func (*Ovirt) GetVMById added in v0.4.0

func (ovirt *Ovirt) GetVMById(id string) (VM, error)

func (*Ovirt) GetVMs added in v0.4.0

func (ovirt *Ovirt) GetVMs(searchQuery string) ([]VM, error)

func (*Ovirt) Post

func (ovirt *Ovirt) Post(path string, data interface{}) (string, error)

type OvirtApi

type OvirtApi interface {
	Authenticate() error
	Get(path string) ([]byte, error)
	Post(path string, data interface{}) (string, error)
	Delete(path string) ([]byte, error)
	GetVM(name string) (VM, error)
	GetVMById(id string) (VM, error)
	GetVMs(query string) ([]VM, error)
	GetDiskAttachment(vmId, diskId string) (DiskAttachment, error)
	GetDiskAttachments(vmId string) ([]DiskAttachment, error)
	DetachDiskFromVM(vmId string, diskId string) error
	GetDiskByName(diskName string) (DiskResult, error)
	CreateUnattachedDisk(diskName string, storageDomainName string, sizeIbBytes int64, readOnly bool, thinProvisioning bool) (Disk, error)
	CreateDisk(
		diskName string,
		storageDomainName string,
		readOnly bool,
		vmId string,
		diskId string,
		diskInterface string) (DiskAttachment, error)
	GetConnectionDetails() Connection
}

func NewOvirt added in v0.3.1

func NewOvirt(configReader io.Reader) (OvirtApi, error)

newDriver creates a new ovirt driver instance from a config reader, to make it easy to pass various config items, either file, string, reading from remote etc. the underlying config format supports properties files (like java)

type Response

type Response struct {
	Status       Status        `json:"status"`               //"status": "<Success/Failure/Not supported>",
	Message      string        `json:"message"`              //"message": "<Reason for success/failure>",
	Device       string        `json:"device,omitempty"`     //"device": "<Path to the device attached. This field is valid only for attach & waitforattach call-outs>"
	VolumeName   string        `json:"volumeName,omitempty"` //"volumeName": "<Cluster wide unique name of the volume. Valid only for getvolumename call-out>"
	Attached     bool          `json:"attached,omitempty"`   //"attached": <True/False (Return true if volume is attached on the node. Valid only for isattached call-out)>
	Capabilities *Capabilities `json:",omitempty"`
}

func FailedResponseFromError

func FailedResponseFromError(e error, more ...string) Response

type Sparse added in v0.4.0

type Sparse bool

type Status

type Status string
const (
	Success      Status = "Success"
	Failure      Status = "Failure"
	NotSupported Status = "Not supported"
)

type StorageDomain

type StorageDomain struct {
	Name    string `json:"name"`
	Storage struct {
		Type string `json:"type,omitempty"`
	} `json:"storage,omitempty,"`
}

type StorageDomains

type StorageDomains struct {
	Domains []StorageDomain `json:"storage_domain"`
}

type Token

type Token struct {
	Value          string `json:"access_token"`
	ExpireIn       int64  `json:"exp,string"`
	Type           string `json:"token_type"`
	ExpirationTime time.Time
}

type VM

type VM struct {
	Id   string `json:"id"`
	Name string `json:"name"`
	Fqdn string `json:"fqdn"`
	Nics struct {
		Nics []Nic `json:"nic"`
	} `json:"nics"`
	Status string `json:"status"`
}

type VMResult

type VMResult struct {
	Vms []VM `json:"vm"`
}

Jump to

Keyboard shortcuts

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