Documentation ¶
Index ¶
- Constants
- Variables
- func BoxDataDiskSize(size uint64) uint64
- func BoxStoragePool(pool string) string
- func CloneBootDisk(client *LivirtClient) ...
- func CreateBootDiskXML(client *LivirtClient) func(key string) (*libvirtxml.DomainDisk, error)
- func CreateCloudInit(userData, metaData []byte) ([]byte, error)
- func CreateCloudInitDisk(client *LivirtClient) func(key string) (*libvirtxml.DomainDisk, error)
- func CreateCustomResource(opt *OnPremCustomResourceOptions) E.Either[error, *OnPremCustomResource]
- func CreateCustomResourceFromEnv(envMap env.Environment) ...
- func CreateDataDisk(client *LivirtClient) func(storagePool, name string, size uint64) (*libvirt.StorageVol, error)
- func CreateDataDiskSync(client *LivirtClient) func(opt *DataDiskOptions) (*libvirt.StorageVol, error)
- func CreateDataDiskXML(client *LivirtClient) func(storagePool, name string, index int) (*libvirtxml.DomainDisk, error)
- func CreateInstanceHash(opt *InstanceOptions) string
- func CreateInstanceSync(client *LivirtClient) func(opt *InstanceOptions) (*libvirtxml.Domain, error)
- func CreateLoggingVolume(client *LivirtClient) func(storagePool, name string) (*libvirtxml.StorageVolume, error)
- func CreateSSHDialer(config *SSHConfig) socket.Dialer
- func DeleteDataDiskSync(client *LivirtClient) func(storagePool, name string) error
- func DeleteDomainByName(client *LivirtClient) func(name string) error
- func DeleteInstanceSync(client *LivirtClient) func(storagePool, name string) error
- func GetBootVolumeName(name string) string
- func GetCIDataVolumeName(name string) string
- func GetEnvMapFromSSHConfig(config *SSHConfig) env.Environment
- func GetLoggingVolume(client *LivirtClient) func(storagePool, name string) (string, error)
- func GetLoggingVolumeName(name string) string
- func GetSSHConfigPath() (string, error)
- func GetStorageVolXMLDesc(client *LivirtClient) func(vol *libvirt.StorageVol) (*libvirtxml.StorageVolume, error)
- func IsDataDiskValid(client *LivirtClient) func(opt *DataDiskOptions) (*libvirtxml.StorageVolume, bool)
- func IsInstanceValid(client *LivirtClient) func(opt *InstanceOptions) (*libvirtxml.Domain, bool)
- func LoadSSHConfig(configFile string) func(configName string) (*SSHConfig, error)
- func PartitionLogs(logs []string) ([]string, []string)
- func RemoveCloudInit(client *LivirtClient) func(key string) error
- func RemoveDataDisk(client *LivirtClient) func(key string) error
- func StartDomain(client *LivirtClient) func(*libvirtxml.Domain) (*libvirtxml.Domain, error)
- func UploadBootDisk(client *LivirtClient) func(storagePool, name, url string) (*libvirtxml.StorageVolume, error)
- func UploadCloudInit(client *LivirtClient) ...
- func VSIFailedToStart(logs []string) bool
- func VSIStartedSuccessfully(logs []string) bool
- func XMLMarshall(b any) (string, error)
- type AttachedDataDisk
- type CloudInit
- type DataDiskCustomResource
- type DataDiskCustomResourceSpec
- type DataDiskOptions
- type DataDiskStatus
- type Domain
- type InstanceMetadata
- type InstanceOptions
- type LivirtClient
- type OnPremCustomResource
- type OnPremCustomResourceEnvOptions
- type OnPremCustomResourceOptions
- type OnPremCustomResourceSpec
- type SSHConfig
Constants ¶
const ( DefaultStoragePool = "default" DefaultDataDiskSize = uint64(100 * 1024 * 1024 * 1024) APIVersion = "hpse.ibm.com/v1" KindVSI = "HyperProtectContainerRuntimeOnPrem" KindDataDisk = "HyperProtectContainerRuntimeOnPremDataDisk" ResourceNameDataDisks = "onprem-datadisks" ResourceNameVSIs = "onprem-hpcrs" )
const ( // KeyOnPremConfig is the key into the environment to read the name of the ssh config KeyOnPremConfig = "ONPREM_CONFIG" // KeyStoragePool is the key into the environment to read the name of the target storage pool KeyStoragePool = "STORAGE_POOL" )
const ( // Environment variable names KeyHostname = "HOSTNAME" KeyPrivateKey = "KEY" KeyPort = "PORT" KeyKnownHosts = "KNOWN_HOSTS" KeyUser = "USER" )
Variables ¶
var DataDiskCustomResourcesToAttachedDataDisks = A.Map(dataDiskCustomResourceToAttachedDataDisk)
DataDiskCustomResourcesToAttachedDataDisks converts from an array of DataDiskCustomResource to an array of attached disks
var ( // full identifier of the disk config entry KeyDiskConfig = fmt.Sprintf("%s.%s", KindDataDisk, APIVersion) )
Functions ¶
func BoxDataDiskSize ¶
func BoxStoragePool ¶
func CloneBootDisk ¶
func CloneBootDisk(client *LivirtClient) func(storagePool string, existingVolumeXML *libvirtxml.StorageVolume, newName string) (*libvirtxml.StorageVolume, error)
CloneBootDisk will clone an existing (boot) disk, so the clone may safely be modified
func CreateBootDiskXML ¶
func CreateBootDiskXML(client *LivirtClient) func(key string) (*libvirtxml.DomainDisk, error)
CreateBootDiskXML creates the XML for the boot disk
func CreateCloudInit ¶
CreateCloudInit produces a cloud init ISO file as a data blob with a userdata and a metadata section
func CreateCloudInitDisk ¶
func CreateCloudInitDisk(client *LivirtClient) func(key string) (*libvirtxml.DomainDisk, error)
CreateCloudInitDisk creates the XML for the cloud init disk
func CreateCustomResource ¶
func CreateCustomResource(opt *OnPremCustomResourceOptions) E.Either[error, *OnPremCustomResource]
CreateCustomResource creates a custom resource from a contract
func CreateCustomResourceFromEnv ¶
func CreateCustomResourceFromEnv(envMap env.Environment) func(opt *OnPremCustomResourceEnvOptions) E.Either[error, *OnPremCustomResource]
CreateCustomResourceFromEnv creates a custom resource from some environment
func CreateDataDisk ¶
func CreateDataDisk(client *LivirtClient) func(storagePool, name string, size uint64) (*libvirt.StorageVol, error)
CreateDataDisk creates a data disk or resizes an existing one if required
func CreateDataDiskSync ¶
func CreateDataDiskSync(client *LivirtClient) func(opt *DataDiskOptions) (*libvirt.StorageVol, error)
CreateDataDiskSync creates a data disk or resizes an existing one if required
func CreateDataDiskXML ¶
func CreateDataDiskXML(client *LivirtClient) func(storagePool, name string, index int) (*libvirtxml.DomainDisk, error)
CreateDataDiskXML creates the XML for the data disk
func CreateInstanceHash ¶
func CreateInstanceHash(opt *InstanceOptions) string
createInstanceHash computes a hash value for the instance options
func CreateInstanceSync ¶
func CreateInstanceSync(client *LivirtClient) func(opt *InstanceOptions) (*libvirtxml.Domain, error)
CreateInstanceSync (synchronously) creates an instance
func CreateLoggingVolume ¶
func CreateLoggingVolume(client *LivirtClient) func(storagePool, name string) (*libvirtxml.StorageVolume, error)
CreateLoggingVolume creates a logging volume for the console log
func CreateSSHDialer ¶
CreateSSHDialer produces a dialer that can connect to the given SSH config
func DeleteDataDiskSync ¶
func DeleteDataDiskSync(client *LivirtClient) func(storagePool, name string) error
DeleteDataDiskSync (synchronously) deletes a data disk
func DeleteDomainByName ¶
func DeleteDomainByName(client *LivirtClient) func(name string) error
func DeleteInstanceSync ¶
func DeleteInstanceSync(client *LivirtClient) func(storagePool, name string) error
DeleteInstanceSync (synchronously) deletes an instance
func GetBootVolumeName ¶
func GetCIDataVolumeName ¶
func GetEnvMapFromSSHConfig ¶
func GetEnvMapFromSSHConfig(config *SSHConfig) env.Environment
GetEnvMapFromSSHConfig serializes an SSH config into a string map
func GetLoggingVolume ¶
func GetLoggingVolume(client *LivirtClient) func(storagePool, name string) (string, error)
GetLoggingVolume retrieves the value of the logging volume the HPCR console log is very small by design, so passing it as a string does make sense
func GetLoggingVolumeName ¶
func GetSSHConfigPath ¶
GetSSHConfigPath returns the path to the SSH config file
func GetStorageVolXMLDesc ¶ added in v0.0.18
func GetStorageVolXMLDesc(client *LivirtClient) func(vol *libvirt.StorageVol) (*libvirtxml.StorageVolume, error)
func IsDataDiskValid ¶
func IsDataDiskValid(client *LivirtClient) func(opt *DataDiskOptions) (*libvirtxml.StorageVolume, bool)
IsDataDiskValid tests if a data disk has a valid configuration
func IsInstanceValid ¶
func IsInstanceValid(client *LivirtClient) func(opt *InstanceOptions) (*libvirtxml.Domain, bool)
IsInstanceValid tests if an instance has a valid configuration
func LoadSSHConfig ¶
LoadSSHConfig loads the SSH config file
func PartitionLogs ¶
PartitionLogs partitions the original logs into success and error logs
func RemoveCloudInit ¶
func RemoveCloudInit(client *LivirtClient) func(key string) error
RemoveCloudInit removes the cloud init data from the storage pool
func RemoveDataDisk ¶
func RemoveDataDisk(client *LivirtClient) func(key string) error
RemoveDataDisk removes the data disk
func StartDomain ¶
func StartDomain(client *LivirtClient) func(*libvirtxml.Domain) (*libvirtxml.Domain, error)
func UploadBootDisk ¶
func UploadBootDisk(client *LivirtClient) func(storagePool, name, url string) (*libvirtxml.StorageVolume, error)
UploadBootDisk uploads the iso file to the remote storage pool
func UploadCloudInit ¶
func UploadCloudInit(client *LivirtClient) func(storagePool, name string, isoData []byte) (*libvirtxml.StorageVolume, error)
UploadCloudInit uploads the iso file to the remote storage pool
func VSIFailedToStart ¶
VSIFailedToStart tests if the VSI failed to start
func VSIStartedSuccessfully ¶
VSIStartedSuccessfully tests if the VSI started successfully
Types ¶
type AttachedDataDisk ¶
type DataDiskCustomResource ¶
type DataDiskCustomResource struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the desired behavior of the pod. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status // +optional Spec DataDiskCustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // status of this custom resource Status DataDiskStatus `json:"status,omitempty"` }
func DataDisksFromRelated ¶
func DataDisksFromRelated(data map[string]any) ([]*DataDiskCustomResource, error)
DataDisksFromRelated decodes the set of configured data disks from the related data structure
type DataDiskCustomResourceSpec ¶
type DataDiskCustomResourceSpec struct { // size of the data disk, defaults to 100GiB Size uint64 `json:"size"` // name of the storage pool, must exist and must be large enough StoragePool string `json:"storagePool"` // specification of the associated config maps TargetSelector *metav1.LabelSelector `json:"targetSelector"` }
type DataDiskOptions ¶
type DataDiskStatus ¶ added in v0.0.18
type InstanceMetadata ¶
type InstanceOptions ¶
type InstanceOptions struct { // name of the instance, will also be the hostname Name string // the userdata field UserData string // URL to the HPCR qcow2 ImageURL string // name of the libvirt storage pool, the pool must exist StoragePool string // attached data disks DataDisks []*AttachedDataDisk }
type LivirtClient ¶
func CreateLivirtClient ¶
func CreateLivirtClient(sshConfig *SSHConfig) (*LivirtClient, error)
CreateLivirtClient creates a libvirt connection based on an SSH config
func CreateLivirtClientFromEnvMap ¶
func CreateLivirtClientFromEnvMap(envMap env.Environment) (*LivirtClient, error)
CreateLivirtClientFromEnvMap constructs the libvirt client from an env map
func (*LivirtClient) Close ¶
func (client *LivirtClient) Close() error
type OnPremCustomResource ¶
type OnPremCustomResource struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the desired behavior of the pod. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status // +optional Spec OnPremCustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` }
type OnPremCustomResourceEnvOptions ¶
type OnPremCustomResourceEnvOptions struct { // name of the instance, will also be the hostname Name string // labels Labels map[string]string // references to the configs (for SSH) TargetLabels map[string]string // URL to the HPCR qcow2 ImageURL string // name of the libvirt storage pool, the pool must exist StoragePool string // encryption Certificate EncryptionCert []byte // folder containing the compose file ComposeFolder string }
type OnPremCustomResourceOptions ¶
type OnPremCustomResourceOptions struct { // name of the instance, will also be the hostname Name string // labels Labels map[string]string // references to the configs (for SSH) TargetLabels map[string]string // URL to the HPCR qcow2 ImageURL string // name of the libvirt storage pool, the pool must exist StoragePool string // encryption Certificate EncryptionCert []byte // clear text contract Contract C.RawMap }
type OnPremCustomResourceSpec ¶
type OnPremCustomResourceSpec struct { // the encrypted contract document Contract string `json:"contract"` // URL to the service that serves the base qcow2 image ImageURL string `json:"imageURL"` // name of the storage pool, must exist and must be large enough StoragePool string `json:"storagePool"` // specification of the associated config maps TargetSelector *metav1.LabelSelector `json:"targetSelector"` // specification of the associated data disks DiskSelector *metav1.LabelSelector `json:"diskSelector"` }
type SSHConfig ¶
type SSHConfig struct { Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"` Port int `json:"port,omitempty" yaml:"port,omitempty"` User string `json:"user,omitempty" yaml:"user,omitempty"` KnownHosts []string `json:"knownHosts,omitempty" yaml:"knownHosts,omitempty"` Key string `json:"key,omitempty" yaml:"key,omitempty"` }
func GetSSHConfigFromConfigMap ¶
GetSSHConfigFromConfigMap deserializes an SSH config from a config map object
func GetSSHConfigFromEnvMap ¶
func GetSSHConfigFromEnvMap(envMap env.Environment) *SSHConfig
GetSSHConfigFromEnvMap deserializes an SSH config from a set of (env) parameters