common

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 67 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OwnerLabel -
	OwnerLabel = "osp-director"
	// GroupLabel -
	GroupLabel = OwnerLabel + ".openstack.org"
	// OwnerUIDLabelSelector -
	OwnerUIDLabelSelector = GroupLabel + "/uid"
	// OwnerNameSpaceLabelSelector -
	OwnerNameSpaceLabelSelector = GroupLabel + "/namespace"
	// OwnerNameLabelSelector -
	OwnerNameLabelSelector = GroupLabel + "/name"
	// OwnerControllerNameLabelSelector -
	OwnerControllerNameLabelSelector = GroupLabel + "/controller"

	// OSPHostnameLabelSelector - Tripleo Hostname
	OSPHostnameLabelSelector = GroupLabel + "/osphostname"
	// HostRemovalAnnotation - Annotation key placed on VM or BMH resources to target them for scale-down
	HostRemovalAnnotation = GroupLabel + "/delete-host"

	// MustGatherSecret - Label placed on secrets that are safe to collect with must-gater
	MustGatherSecret = GroupLabel + "/must-gather-secret"

	// FinalizerName -
	FinalizerName = GroupLabel

	// ServiceAccountAnnotationName -
	ServiceAccountAnnotationName = "kubernetes.io/service-account.name"

	// TripleOServicesDefaultKeyName -
	TripleOServicesDefaultKeyName = "ServicesDefault"

	// TripleOPacemakerServiceName -
	TripleOPacemakerServiceName = "OS::TripleO::Services::Pacemaker"

	// TripleORolesDataFile -
	TripleORolesDataFile = "roles_data.yaml"
)
View Source
const (
	// BITSIZE -
	BITSIZE int = 4096
)

Variables

This section is empty.

Functions

func AssignIP

func AssignIP(assignIPDetails AssignIPDetails) (net.IPNet, []ospdirectorv1beta1.IPReservation, error)

AssignIP assigns an IP using a range and a reserve list.

func BigIntToIP

func BigIntToIP(inipint big.Int) net.IP

BigIntToIP converts a big.Int to a net.IP

func CreateOrGetCustomConfigMap

func CreateOrGetCustomConfigMap(r ReconcilerCommon, configMap *corev1.ConfigMap) (string, error)

CreateOrGetCustomConfigMap -

func CreateOrGetHostname

func CreateOrGetHostname(hostStore HostnameStore, host *Hostname) error

CreateOrGetHostname -

func CreateOrUpdateNetworkAttachmentDefinition

func CreateOrUpdateNetworkAttachmentDefinition(r ReconcilerCommon, obj metav1.Object, managerRef string, ownerRef *metav1.OwnerReference, nad *NetworkAttachmentDefinition) error

CreateOrUpdateNetworkAttachmentDefinition - create or update NetworkConfigurationPolicy

func CreateOrUpdateNetworkConfigurationPolicy

func CreateOrUpdateNetworkConfigurationPolicy(r ReconcilerCommon, obj metav1.Object, managerRef string, ncp *NetworkConfigurationPolicy) error

CreateOrUpdateNetworkConfigurationPolicy - create or update NetworkConfigurationPolicy

func CreateOrUpdatePvc

CreateOrUpdatePvc -

func CreateOrUpdateSecret

func CreateOrUpdateSecret(r ReconcilerCommon, obj metav1.Object, secret *corev1.Secret) (string, controllerutil.OperationResult, error)

CreateOrUpdateSecret -

func DeleteJob

func DeleteJob(job *batchv1.Job, kclient kubernetes.Interface, log logr.Logger) (bool, error)

DeleteJob func kclient required to properly cleanup the job depending pods with DeleteOptions

func DeletePodsWithLabel

func DeletePodsWithLabel(r ReconcilerCommon, obj metav1.Object, labelSelectorMap map[string]string) error

DeletePodsWithLabel - Delete all pods in namespace of the obj matching label selector

func DeleteReplicasetsWithLabel

func DeleteReplicasetsWithLabel(r ReconcilerCommon, obj metav1.Object, labelSelectorMap map[string]string) error

DeleteReplicasetsWithLabel - Delete all replicasets in namespace of the obj matching label selector

func DeleteSecretsWithLabel

func DeleteSecretsWithLabel(r ReconcilerCommon, obj metav1.Object, labelSelectorMap map[string]string) error

DeleteSecretsWithLabel - Delete all secrets in namespace of the obj matching label selector

func DeleteServicesWithLabel

func DeleteServicesWithLabel(r ReconcilerCommon, obj metav1.Object, labelSelectorMap map[string]string) error

DeleteServicesWithLabel - Delete all services in namespace of the obj matching label selector

func EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) string

EncodePrivateKeyToPEM encodes Private Key from RSA to PEM format

func EnsureConfigMaps

func EnsureConfigMaps(r ReconcilerCommon, obj metav1.Object, cms []Template, envVars *map[string]EnvSetter) error

EnsureConfigMaps - get all configmaps required, verify they exist and add the hash to env and status

func EnsureSecrets

func EnsureSecrets(r ReconcilerCommon, obj metav1.Object, sts []Template, envVars *map[string]EnvSetter) error

EnsureSecrets - get all secrets required, verify they exist and add the hash to env and status

func ExecuteTemplate

func ExecuteTemplate(templateFile string, data interface{}) string

ExecuteTemplate creates a template from the file and execute it with the specified data

func ExecuteTemplateData

func ExecuteTemplateData(templateData string, data interface{}) string

ExecuteTemplateData creates a template from string and execute it with the specified data

func ExecuteTemplateFile

func ExecuteTemplateFile(filename string, data interface{}) string

ExecuteTemplateFile creates a template from the file and execute it with the specified data Note: mschuppert - can be removed when all operators switched

to the above ones.

func GeneratePasswords

func GeneratePasswords() map[string]interface{}

GeneratePasswords creates the passwords for a tripleo deployment

func GeneratePrivateKey

func GeneratePrivateKey(bitSize int) (*rsa.PrivateKey, error)

GeneratePrivateKey creates a RSA Private Key of specified byte size

func GeneratePublicKey

func GeneratePublicKey(privatekey *rsa.PublicKey) (string, error)

GeneratePublicKey take a rsa.PublicKey and return bytes suitable for writing to .pub file returns in the format "ssh-rsa ..."

func GetAllNetworkAttachmentDefinitions

func GetAllNetworkAttachmentDefinitions(r ReconcilerCommon, obj metav1.Object) (map[string]networkv1.NetworkAttachmentDefinition, error)

GetAllNetworkAttachmentDefinitions - get all NetworkAttachmentDefinition

func GetAllNetworkConfigurationPolicies

func GetAllNetworkConfigurationPolicies(r ReconcilerCommon, labelSelectorMap map[string]string) (map[string]nmstate.NodeNetworkConfigurationPolicy, error)

GetAllNetworkConfigurationPolicies - get all NetworkConfigurationPolicy

func GetAllPodsWithLabel

func GetAllPodsWithLabel(r ReconcilerCommon, labelSelectorMap map[string]string, namespace string) (*corev1.PodList, error)

GetAllPodsWithLabel - get all pods from namespace with a specific label

func GetAllTemplates

func GetAllTemplates(path string, kind string, templateType string, version string) []string

GetAllTemplates get all files from a templates sub folder

func GetBmhHosts

func GetBmhHosts(r ReconcilerCommon, namespace string, labelSelector map[string]string) (*metal3v1alpha1.BareMetalHostList, error)

GetBmhHosts -

func GetConfigMapAndHashWithName

func GetConfigMapAndHashWithName(r ReconcilerCommon, configMapName string, namespace string) (*corev1.ConfigMap, string, error)

GetConfigMapAndHashWithName -

func GetConfigMaps

func GetConfigMaps(r ReconcilerCommon, obj runtime.Object, configMaps []string, namespace string, envVars *map[string]EnvSetter) ([]ospdirectorv1beta1.Hash, error)

GetConfigMaps - get all configmaps required, verify they exist and add the hash to env and status

func GetCustomFencingRoles

func GetCustomFencingRoles(customBinaryData map[string][]byte) ([]string, error)

GetCustomFencingRoles - return a list of any custom roles included in custom tarball that require fencing support

func GetDeletionAnnotatedBmhHosts

func GetDeletionAnnotatedBmhHosts(r ReconcilerCommon, namespace string, labelSelector map[string]string) ([]string, error)

GetDeletionAnnotatedBmhHosts -

func GetFencingRoles

func GetFencingRoles() []string

GetFencingRoles - roles that normally require fencing

func GetIPRange

func GetIPRange(ip net.IP, ipnet net.IPNet) (net.IP, net.IP, error)

GetIPRange returns the first and last IP in a range

func GetLabels

func GetLabels(obj metav1.Object, controller string, custom map[string]string) map[string]string

GetLabels - get labelselector for CR

func GetOSPVersion

func GetOSPVersion(parsedVersion string) (ospdirectorv1beta1.OSPVersion, error)

GetOSPVersion -

func GetOSPVersionFromImageURL

func GetOSPVersionFromImageURL(r ReconcilerCommon, imageURL string) (ospdirectorv1beta1.OSPVersion, error)

GetOSPVersionFromImageURL -

func GetOr

func GetOr(m map[string]interface{}, key, fallback string) interface{}

GetOr returns the value of m[key] if it exists, fallback otherwise. As a special case, it also returns fallback if the value of m[key] is the empty string

func GetSecret

func GetSecret(r ReconcilerCommon, secretName string, secretNamespace string) (*corev1.Secret, string, error)

GetSecret -

func GetSecrets

func GetSecrets(r ReconcilerCommon, secretNamespace string, labelSelectorMap map[string]string) (*corev1.SecretList, error)

GetSecrets -

func GetServicesListWithLabel

func GetServicesListWithLabel(r ReconcilerCommon, namespace string, labelSelectorMap map[string]string) (*corev1.ServiceList, error)

GetServicesListWithLabel - Get all services in namespace of the obj matching label selector

func GetTemplateData

func GetTemplateData(t Template) map[string]string

GetTemplateData -

func GetTemplatesPath

func GetTemplatesPath() string

GetTemplatesPath get path to templates, either running local or deployed as container

func GetVirtualMachineInstances

func GetVirtualMachineInstances(r ReconcilerCommon, namespace string, labelSelectorMap map[string]string) (*virtv1.VirtualMachineInstanceList, error)

GetVirtualMachineInstances -

func GetVirtualMachines

func GetVirtualMachines(r ReconcilerCommon, namespace string, labelSelectorMap map[string]string) (*virtv1.VirtualMachineList, error)

GetVirtualMachines -

func IPToBigInt

func IPToBigInt(IPv6Addr net.IP) *big.Int

IPToBigInt converts a net.IP to a big.Int

func InitMap

func InitMap(m *map[string]string)

InitMap - Inititialise a map to an empty map if it is nil.

func IsIPv4

func IsIPv4(checkip net.IP) bool

IsIPv4 checks if an IP is v4.

func IsIPv6

func IsIPv6(checkip net.IP) bool

IsIPv6 checks if an IP is v6.

func IsSet

func IsSet(m map[string]interface{}, key string) interface{}

IsSet returns the value of m[key] if key exists, otherwise false Different from getOr because it will return zero values.

func IterateForAssignment

func IterateForAssignment(assignIPDetails AssignIPDetails) (net.IP, []ospdirectorv1beta1.IPReservation, error)

IterateForAssignment iterates given an IP/IPNet and a list of reserved IPs

func MergeEnvs

func MergeEnvs(envs []corev1.EnvVar, newEnvs EnvSetterMap) []corev1.EnvVar

MergeEnvs - merge envs

func MergeMaps

func MergeMaps(baseMap map[string]interface{}, extraMaps ...map[string]interface{}) map[string]interface{}

MergeMaps - merge two or more maps

func ObjectHash

func ObjectHash(i interface{}) (string, error)

ObjectHash creates a deep object hash and return it as a safe encoded string

func RemoveIndex

func RemoveIndex(s []string, index int) []string

RemoveIndex - remove int from slice

func SSAApply

func SSAApply(ctx context.Context, cfg *rest.Config, controller string, obj *uns.Unstructured) error

SSAApply - server side apply using dynamic client and unstructured obj

func SSAApplyYaml

func SSAApplyYaml(ctx context.Context, cfg *rest.Config, controller string, resource []byte) error

SSAApplyYaml - server side apply using dynamic client and obj as byte

func SSHKeySecret

func SSHKeySecret(name string, namespace string, labels map[string]string) (*corev1.Secret, error)

SSHKeySecret - func

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice - is string in slice

func WaitOnJob

func WaitOnJob(job *batchv1.Job, client client.Client, log logr.Logger) (bool, error)

WaitOnJob func

Types

type AssignIPDetails

type AssignIPDetails struct {
	IPnet      net.IPNet
	RangeStart net.IP
	RangeEnd   net.IP
	// RoleReservelist - Reservelist of all reservations of the role
	RoleReservelist []ospdirectorv1beta1.IPReservation
	// Reservelist - Reservelist of all reservations
	Reservelist   []ospdirectorv1beta1.IPReservation
	ExcludeRanges []string
	HostRef       string
	Hostname      string
	VIP           bool
	Deleted       bool
}

AssignIPDetails -

type AssignmentError

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

AssignmentError defines an IP assignment error.

func (AssignmentError) Error

func (a AssignmentError) Error() string

type EnvSetter

type EnvSetter func(*corev1.EnvVar)

EnvSetter -

func EnvDownwardAPI

func EnvDownwardAPI(field string) EnvSetter

EnvDownwardAPI - set env from FieldRef->FieldPath, e.g. status.podIP

func EnvValue

func EnvValue(value string) EnvSetter

EnvValue -

type EnvSetterMap

type EnvSetterMap map[string]EnvSetter

EnvSetterMap -

type Hostname

type Hostname struct {
	Basename string
	Hostname string
	HostRef  string
	VIP      bool
}

Hostname - details

type HostnameList

type HostnameList []HostnamePair

HostnameList -

func SortMapByValue

func SortMapByValue(inMap map[string]string) HostnameList

SortMapByValue -

func (HostnameList) Len

func (p HostnameList) Len() int

func (HostnameList) Less

func (p HostnameList) Less(i, j int) bool

func (HostnameList) Swap

func (p HostnameList) Swap(i, j int)

type HostnamePair

type HostnamePair struct {
	Hostname string
	HostRef  string
}

HostnamePair -

type HostnameStore

type HostnameStore interface {
	GetHostnames() map[string]string
}

HostnameStore -

type IPSet

type IPSet struct {
	Networks            []string
	Role                string
	HostCount           int
	AddToPredictableIPs bool
	VIP                 bool
	HostNameRefs        map[string]string
}

IPSet - ipset details

type NetworkAttachmentDefinition

type NetworkAttachmentDefinition struct {
	Name      string
	Namespace string
	Labels    map[string]string
	Data      map[string]string
}

NetworkAttachmentDefinition -

type NetworkConfigurationPolicy

type NetworkConfigurationPolicy struct {
	Name                           string
	Labels                         map[string]string
	NodeNetworkConfigurationPolicy shared.NodeNetworkConfigurationPolicySpec
}

NetworkConfigurationPolicy -

type Pvc

type Pvc struct {
	Name         string
	Namespace    string
	Size         string
	Labels       map[string]string
	StorageClass string
	AccessMode   []corev1.PersistentVolumeAccessMode
}

Pvc - pvc details

type ReconcilerCommon

type ReconcilerCommon interface {
	GetClient() client.Client
	GetKClient() kubernetes.Interface
	GetLogger() logr.Logger
	GetScheme() *runtime.Scheme
}

ReconcilerCommon - common reconciler interface

type TType

type TType string

TType - TemplateType

const (
	// TemplateTypeScripts - config type
	TemplateTypeScripts TType = "bin"
	// TemplateTypeConfig - config type
	TemplateTypeConfig TType = "config"
	// TemplateTypeCustom - custom config type
	TemplateTypeCustom TType = "custom"
	// TemplateTypeNone - none type, don't add configs from a directory, only files from AdditionalData
	TemplateTypeNone TType = "none"
)

type Template

type Template struct {
	Name               string
	Namespace          string
	Type               TType
	InstanceType       string
	SecretType         corev1.SecretType // Secrets only, defaults to "Opaque"
	AdditionalTemplate map[string]string
	CustomData         map[string]string
	Labels             map[string]string
	Annotations        map[string]string
	ConfigOptions      map[string]interface{}
	SkipSetOwner       bool // skip setting ownership on the associated configmap
	Version            ospdirectorv1beta1.OSPVersion
}

Template - config map and secret details

Jump to

Keyboard shortcuts

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