Documentation ¶
Index ¶
- Constants
- Variables
- func BoxDataDiskSize(size uint64) uint64
- func BoxNetworkName(name string) string
- 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 CreateMacAddressFromHash(data string) string
- func CreateMacAddressFromMaybeUUID(maybeuuid string) string
- func CreateMacAddressFromUUID(uid uuid.UUID) string
- func CreateMachineIdFromHash(data string) string
- func CreateMachineIdFromMaybeUUID(maybeuuid string) string
- func CreateMachineIdFromUUID(uid uuid.UUID) string
- func CreateNetworksXML(prefix string) func(networkNames []string) ([]libvirtxml.DomainInterface, 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 GetDCHPLeases(client *LivirtClient) func(networkName string) ([]libvirt.NetworkDhcpLease, error)
- func GetDataDiskRef(client *LivirtClient) func(opt *DataDiskRefOptions) (*libvirtxml.StorageVolume, error)
- func GetDomains(client *LivirtClient) func() ([]libvirt.Domain, error)
- func GetEnvMapFromSSHConfig(config *SSHConfig) env.Environment
- func GetLoggingVolume(client *LivirtClient) func(storagePool, name string) (string, error)
- func GetLoggingVolumeName(name string) string
- func GetLoggingVolumeViaCommand(client *LivirtClient) func(storagePool, name string) (string, error)
- func GetLoggingVolumeViaSSH(config *SSHConfig) func(path string) (string, error)
- func GetNetworkRef(client *LivirtClient) func(opt *NetworkRefOptions) (*libvirtxml.Network, error)
- func GetNetworks(opt *InstanceOptions) []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 IsNetworkDhcpLeaseForHostname(hostname string) func(libvirt.NetworkDhcpLease) 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 DataDiskRefCustomResource
- type DataDiskRefCustomResourceSpec
- type DataDiskRefOptions
- type DataDiskRefStatus
- type DataDiskStatus
- type Domain
- type InstanceMetadata
- type InstanceOptions
- type LivirtClient
- type NetworkRefCustomResource
- type NetworkRefCustomResourceSpec
- type NetworkRefOptions
- type NetworkRefStatus
- 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" KindDataDiskRef = "HyperProtectContainerRuntimeOnPremDataDiskRef" KindNetworkRef = "HyperProtectContainerRuntimeOnPremNetworkRef" ResourceNameDataDisks = "onprem-datadisks" ResourceNameDataDiskRefs = "onprem-datadiskrefs" ResourceNameNetworkRefs = "onprem-networkrefs" ResourceNameVSIs = "onprem-hpcrs" NeedResults = int32(1) )
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" )
const (
// default name for the network to attach to
DefaultNetwork = "default"
)
Variables ¶
var ( // full identifier of the disk config entry KeyDiskConfig = fmt.Sprintf("%s.%s", KindDataDisk, APIVersion) // full identifier of the disk ref config entry KeyDiskRefConfig = fmt.Sprintf("%s.%s", KindDataDiskRef, APIVersion) )
var DataDiskCustomResourcesToAttachedDataDisks = A.Map(dataDiskCustomResourceToAttachedDataDisk)
DataDiskCustomResourcesToAttachedDataDisks converts from an array of DataDiskCustomResource to an array of attached disks
var DataDiskRefCustomResourcesToAttachedDataDisks = A.Map(dataDiskRefCustomResourceToAttachedDataDisk)
DataDiskRefCustomResourcesToAttachedDataDisks converts from an array of DataDiskCustomResource to an array of attached disks
var ( // full identifier of the disk ref config entry KeyNetworkRefConfig = fmt.Sprintf("%s.%s", KindNetworkRef, APIVersion) )
var NetworkRefCustomResourceToNetworks = A.Map(networkRefCustomResourceToNetworks)
NetworkRefCustomResourceToNetworks converts from an array of NetworkRefCustomResource to an array of attached disks
Functions ¶
func BoxDataDiskSize ¶
func BoxNetworkName ¶ added in v0.0.22
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 CreateMacAddressFromHash ¶ added in v0.1.29
constructs a hash value for the string and produces a mac address from that
func CreateMacAddressFromMaybeUUID ¶ added in v0.1.29
CreateMacAddressFromMaybeUUID tries to parse the UUID from a string, then generate a MAC address from it if the string could not be decoded, create a MAC from a hash instead
func CreateMacAddressFromUUID ¶ added in v0.1.29
CreateMacAddressFromUUID creates a mac address from the first 6 bytes of the UUID
func CreateMachineIdFromHash ¶ added in v0.1.29
CreateMachineIdFromHash creates a hash of the input and then a machine ID
func CreateMachineIdFromMaybeUUID ¶ added in v0.1.29
CreateMachineIdFromMaybeUUID tries to parse the UUID from a string, then generate a machine ID from it if the string could not be decoded, create a machine ID from a hash instead
func CreateMachineIdFromUUID ¶ added in v0.1.29
CreateMachineIdFromUUID creates a machineID from a UUID
func CreateNetworksXML ¶ added in v0.1.0
func CreateNetworksXML(prefix string) func(networkNames []string) ([]libvirtxml.DomainInterface, error)
CreateNetworksXML creates the XML for the networks
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 GetDCHPLeases ¶ added in v0.0.20
func GetDCHPLeases(client *LivirtClient) func(networkName string) ([]libvirt.NetworkDhcpLease, error)
GetDCHPLeases returns the DCHP leases for a given network
func GetDataDiskRef ¶ added in v0.0.22
func GetDataDiskRef(client *LivirtClient) func(opt *DataDiskRefOptions) (*libvirtxml.StorageVolume, error)
GetDataDiskRef tests if a data disk has a valid configuration
func GetDomains ¶ added in v0.1.22
func GetDomains(client *LivirtClient) func() ([]libvirt.Domain, error)
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 GetLoggingVolumeViaCommand ¶ added in v0.1.28
func GetLoggingVolumeViaCommand(client *LivirtClient) func(storagePool, name string) (string, error)
GetLoggingVolumeViaSSH retrieves the value of the logging volume by spawning a separate command. The advantage of this approach is that that command can be canceled if it times out the HPCR console log is very small by design, so passing it as a string does make sense
func GetLoggingVolumeViaSSH ¶ added in v0.1.28
GetLoggingVolumeViaSSH retrieves the value of the logging volume via a new and direct SSH connection the HPCR console log is very small by design, so passing it as a string does make sense
func GetNetworkRef ¶ added in v0.0.22
func GetNetworkRef(client *LivirtClient) func(opt *NetworkRefOptions) (*libvirtxml.Network, error)
GetNetworkRef tries to return a network ref
func GetNetworks ¶ added in v0.1.0
func GetNetworks(opt *InstanceOptions) []string
GetNetwork returns the network attached to the instane
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 IsNetworkDhcpLeaseForHostname ¶ added in v0.0.20
func IsNetworkDhcpLeaseForHostname(hostname string) func(libvirt.NetworkDhcpLease) bool
IsNetworkDhcpLeaseForHostname checks if this lease is for the hostname
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 AttachedDataDisk struct { // name of the attached data disk Name string // name of the libvirt storage pool, the pool must exist StoragePool string }
func AttachedDataDisksFromRelated ¶ added in v0.1.24
func AttachedDataDisksFromRelated(rel map[string]any) ([]*AttachedDataDisk, error)
AttachedDataDisksFromRelated decodes the data disks and data disk references from the set of custom resources and convers them into an array of AttachedDataDisk objects
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 DataDiskRefCustomResource ¶ added in v0.0.22
type DataDiskRefCustomResource 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 DataDiskRefCustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // status of this custom resource Status DataDiskRefStatus `json:"status,omitempty"` }
func DataDiskRefsFromRelated ¶ added in v0.1.24
func DataDiskRefsFromRelated(data map[string]any) ([]*DataDiskRefCustomResource, error)
DataDiskRefsFromRelated decodes the set of configured data disks from the related data structure
type DataDiskRefCustomResourceSpec ¶ added in v0.0.22
type DataDiskRefCustomResourceSpec struct { // name of the volume, must exist VolumeName string `json:"volumeName"` // 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 DataDiskRefOptions ¶ added in v0.0.22
type DataDiskRefStatus ¶ added in v0.0.22
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 // attached networks Networks []string }
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 NetworkRefCustomResource ¶ added in v0.0.22
type NetworkRefCustomResource 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 NetworkRefCustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // status of this custom resource Status NetworkRefStatus `json:"status,omitempty"` }
func NetworkRefsFromRelated ¶ added in v0.1.0
func NetworkRefsFromRelated(data map[string]any) ([]*NetworkRefCustomResource, error)
NetworkRefsFromRelated decodes the set of configured networks from the related data structure
type NetworkRefCustomResourceSpec ¶ added in v0.0.22
type NetworkRefCustomResourceSpec struct { // name of the network, must exist NetworkName string `json:"networkName"` // specification of the associated config maps TargetSelector *metav1.LabelSelector `json:"targetSelector"` }
type NetworkRefOptions ¶ added in v0.0.22
type NetworkRefOptions struct { // name of the network Name string }
type NetworkRefStatus ¶ added in v0.0.22
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"` // specification of the associated networks NetworkSelector *metav1.LabelSelector `json:"networkSelector"` }
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