controllers

package
v0.0.0-...-27a102d Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

(C) Copyright [2022] Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrivateKey holds the value for PrivateKey
	PrivateKey *rsa.PrivateKey
	// PublicKey holds the value for PublicKey
	PublicKey *rsa.PublicKey
	// RootCA contains the RootCA value
	RootCA []byte
)
View Source
var (
	// MuxLock is used for avoiding race conditions
	MuxLock = &sync.Mutex{}
)

Functions

func CaseInsensitiveContains

func CaseInsensitiveContains(s string) (string, bool)

CaseInsensitiveContains used to check if vendor is available

func CompareArray

func CompareArray(arr1, arr2 []string) bool

CompareArray is used to compare two arrays

func CompareMaps

func CompareMaps(m1, m2 map[string]string) (bool, map[string]string)

CompareMaps function compares values of two maps and return true if equal else returns false

func ContainsValue

func ContainsValue(elems []string, v string) bool

ContainsValue checks if array contains the string value

func ConvertInterfaceToStringArray

func ConvertInterfaceToStringArray(items []interface{}) []string

ConvertInterfaceToStringArray will convert and return an array of interface into array of string

func ConvertToArray

func ConvertToArray(data []interface{}) []string

ConvertToArray is used to convert interface to array of string

func DecryptWithPrivateKey

func DecryptWithPrivateKey(ctx context.Context, cipherText string,
	privKey rsa.PrivateKey, doBase64Decode bool) string

Decryption

func EncryptWithPublicKey

func EncryptWithPublicKey(ctx context.Context, secretMessage string,
	key rsa.PublicKey) string

Encryption with OAEP padding

func ExportRsaPrivateKeyAsPemStr

func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string

func ExportRsaPublicKeyAsPemStr

func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error)

func GetHostPort

func GetHostPort(ctx context.Context, uri string) (string, string, error)

getHostPort returns host,port of odim

func IgnoreStatusUpdate

func IgnoreStatusUpdate() predicate.Predicate

ignoreStatusUpdate ignores reconcile when status/metadata is updated

func ParseRsaPrivateKeyFromPemStr

func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)

func ParseRsaPublicKeyFromPemStr

func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error)

func RemoveSpecialChar

func RemoveSpecialChar(str string) string

RemoveSpecialChar used to remove special char from ID to get bios object name

Types

type CommonReconciler

type CommonReconciler struct {
	Client client.Client
	Scheme *runtime.Scheme
}

func (*CommonReconciler) CheckAndCreateBiosSchemaObject

func (r *CommonReconciler) CheckAndCreateBiosSchemaObject(ctx context.Context, attributeResp map[string]interface{}, bmcObj *infraiov1.Bmc) bool

CheckAndCreateBiosSchemaObject verifies if bios schema object is available else create it

func (*CommonReconciler) CheckAndCreateEventMessageObject

func (r *CommonReconciler) CheckAndCreateEventMessageObject(ctx context.Context, messageRegistryResp map[string]interface{}, bmcObj *infraiov1.Bmc) bool

CheckAndCreateEventMessageObject checks if the message registry object already exist, if not then the object is created

func (*CommonReconciler) CreateBiosSettingObject

func (r *CommonReconciler) CreateBiosSettingObject(ctx context.Context, biosAttributes map[string]string, bmcObj *infraiov1.Bmc) bool

createBiosSettingObject is used for creating bios setting object with same name and namespace as of bmc

func (*CommonReconciler) CreateBootOrderSettingObject

func (r *CommonReconciler) CreateBootOrderSettingObject(ctx context.Context, bootAttributes *infraiov1.BootSetting, bmcObj *infraiov1.Bmc) bool

CreateBootOrderSettingObject is used for creating boot order object with same name and namespace as of bmc

func (*CommonReconciler) CreateEventSubscriptionObject

func (r *CommonReconciler) CreateEventSubscriptionObject(ctx context.Context, subscriptionDetails map[string]interface{}, ns string, originResources []string) bool

CreateEventSubscriptionObject creates an eventsubscription object in system

func (*CommonReconciler) DeleteBmcObject

func (r *CommonReconciler) DeleteBmcObject(ctx context.Context, bmcObj *infraiov1.Bmc)

DeleteBmcObject will delete the bmc object from operator

func (*CommonReconciler) DeleteVolumeObject

func (r *CommonReconciler) DeleteVolumeObject(ctx context.Context, volObj *infraiov1.Volume)

DeleteVolumeObject will delete the volume object from operator

func (*CommonReconciler) GetAllBiosSchemaRegistryObjects

func (r *CommonReconciler) GetAllBiosSchemaRegistryObjects(ctx context.Context, ns string) *[]infraiov1.BiosSchemaRegistry

GetAllBiosSchemaRegistryObjects will get all the bios schema registry objects

func (*CommonReconciler) GetAllBmcObject

func (r *CommonReconciler) GetAllBmcObject(ctx context.Context, ns string) *[]infraiov1.Bmc

GetAllBmcObject is used to get all bmc object details based on given namespace

func (*CommonReconciler) GetAllEventSubscriptionObjects

func (r *CommonReconciler) GetAllEventSubscriptionObjects(ctx context.Context, ns string) *[]infraiov1.Eventsubscription

GetAllEventSubscriptionObjects will return all the event subscription objects present in BMC operator under the requested namespace

func (*CommonReconciler) GetAllVolumeObjectIds

func (r *CommonReconciler) GetAllVolumeObjectIds(ctx context.Context, bmc *infraiov1.Bmc, ns string) map[string][]string

GetAllVolumeObjectIds will get all the volume ids of specific bmc volume objects

func (*CommonReconciler) GetAllVolumeObjects

func (r *CommonReconciler) GetAllVolumeObjects(ctx context.Context, bmcIP, ns string) []*infraiov1.Volume

func (*CommonReconciler) GetBiosObject

func (r *CommonReconciler) GetBiosObject(ctx context.Context, field, value, ns string) *infraiov1.BiosSetting

GetBiosObject is used to get bios object details based on given field and value

func (*CommonReconciler) GetBiosSchemaObject

func (r *CommonReconciler) GetBiosSchemaObject(ctx context.Context, field, value, ns string) *infraiov1.BiosSchemaRegistry

GetBiosSchemaObject is used to get bios schema object details based on given field and value

func (*CommonReconciler) GetBmcObject

func (r *CommonReconciler) GetBmcObject(ctx context.Context, field, value, ns string) *infraiov1.Bmc

----------------------------GET OBJECTS--------------------------------- GetBmcObject is used to get bmc object details based on given field and value

func (*CommonReconciler) GetBootObject

func (r *CommonReconciler) GetBootObject(ctx context.Context, field, value, ns string) *infraiov1.BootOrderSetting

GetBootObject is used to get bios object details based on given field and value

func (*CommonReconciler) GetCommonReconcilerClient

func (c *CommonReconciler) GetCommonReconcilerClient() client.Client

func (*CommonReconciler) GetCommonReconcilerScheme

func (c *CommonReconciler) GetCommonReconcilerScheme() *runtime.Scheme

func (*CommonReconciler) GetEventMessageRegistryObject

func (r *CommonReconciler) GetEventMessageRegistryObject(ctx context.Context, field, value, ns string) *infraiov1.EventsMessageRegistry

GetEventMessageRegistryObject fetch eventsmessageregistry object based on fields and values passed

func (*CommonReconciler) GetEventSubscriptionObjectName

func (r *CommonReconciler) GetEventSubscriptionObjectName(ctx context.Context, destination, name, ns string) string

GetEventSubscriptionObjectName will parse and return eventsubscription object name which will be supported by metadata.name

func (*CommonReconciler) GetEventsubscriptionObject

func (r *CommonReconciler) GetEventsubscriptionObject(ctx context.Context, field, value, ns string) *infraiov1.Eventsubscription

GetEventsubscriptionObject will fetch the event subscription present in BMC operator based on the field and value and return the first object

func (*CommonReconciler) GetFirmwareObject

func (r *CommonReconciler) GetFirmwareObject(ctx context.Context, field, value, ns string) *infraiov1.Firmware

GetFirmwareObject will fetch and return a firmware object based on the field and value

func (*CommonReconciler) GetObjectSecret

func (r *CommonReconciler) GetObjectSecret(ctx context.Context, secret *corev1.Secret, secretName, rootdir string) (string, string, string)

-----------------------------GET OBJECT DETAILS-------------------------- getSecret returns the username,password,authenticationType for a particular secret

func (*CommonReconciler) GetOdimObject

func (r *CommonReconciler) GetOdimObject(ctx context.Context, field, value, ns string) *infraiov1.Odim

func (*CommonReconciler) GetUpdatedBmcObject

func (r *CommonReconciler) GetUpdatedBmcObject(ctx context.Context, ns types.NamespacedName, bmcObj *infraiov1.Bmc)

---------------------------------GET UPDATED OBJECT----------------------------------- getUpdatedBmcObject used to get updated BMC object

func (*CommonReconciler) GetUpdatedEventsubscriptionObjects

func (r *CommonReconciler) GetUpdatedEventsubscriptionObjects(ctx context.Context, ns types.NamespacedName, eventSubObj *infraiov1.Eventsubscription)

GetUpdatedEventsubscriptionObjects used to get updated BMC object

func (*CommonReconciler) GetUpdatedFirmwareObject

func (r *CommonReconciler) GetUpdatedFirmwareObject(ctx context.Context, ns types.NamespacedName, firmObj *infraiov1.Firmware)

GetUpdatedFirmwareObject used to get updated BMC object

func (*CommonReconciler) GetUpdatedOdimObject

func (r *CommonReconciler) GetUpdatedOdimObject(ctx context.Context, ns types.NamespacedName, odimObj *infraiov1.Odim)

GetUpdatedOdimObject gets the updated Odim object

func (*CommonReconciler) GetUpdatedVolumeObject

func (r *CommonReconciler) GetUpdatedVolumeObject(ctx context.Context, ns types.NamespacedName, volObj *infraiov1.Volume)

GetUpdatedVolumeObject used to get updated BMC object

func (*CommonReconciler) GetVolumeObject

func (r *CommonReconciler) GetVolumeObject(ctx context.Context, bmcIP, ns string) *infraiov1.Volume

func (*CommonReconciler) GetVolumeObjectByVolumeID

func (r *CommonReconciler) GetVolumeObjectByVolumeID(ctx context.Context, volumeID, ns string) *infraiov1.Volume

GetVolumeObjectByVolumeID will fetch and return volume object based on volumeID

func (*CommonReconciler) UpdateBiosSettingObject

func (r *CommonReconciler) UpdateBiosSettingObject(ctx context.Context, biosAttributes map[string]string, biosObj *infraiov1.BiosSetting) bool

----------------------------------------UPDATE OBJECT STATUS--------------------------------------- UpdateBiosSettingObject used to update the bios object

func (*CommonReconciler) UpdateBmcObjectOnReset

func (r *CommonReconciler) UpdateBmcObjectOnReset(ctx context.Context, bmcObject *infraiov1.Bmc, status string)

UpdateBmcObjectOnReset updates the systemReset field in bmc object

func (*CommonReconciler) UpdateBmcStatus

func (r *CommonReconciler) UpdateBmcStatus(ctx context.Context, bmcObj *infraiov1.Bmc)

UpdateBmcStatus used to update the bmc object

func (*CommonReconciler) UpdateEventsubscriptionStatus

func (r *CommonReconciler) UpdateEventsubscriptionStatus(ctx context.Context, eventsubObj *infraiov1.Eventsubscription, eventsubscriptionDetails map[string]interface{}, originResources []string)

UpdateEventsubscriptionStatus will update the status of event subscription object

func (*CommonReconciler) UpdateOdimStatus

func (r *CommonReconciler) UpdateOdimStatus(ctx context.Context, status string, odimObj *infraiov1.Odim)

UpdateOdimStatus updates the status of odim object under status field

func (*CommonReconciler) UpdateVolumeStatus

func (r *CommonReconciler) UpdateVolumeStatus(ctx context.Context, volObject *infraiov1.Volume, volumeID, volumeName, capBytes, durableName, durableNameFormat string)

UpdateVolumeStatus updates the volume object status

type ReconcilerInterface

type ReconcilerInterface interface {
	//get objects
	GetBmcObject(ctx context.Context, field, value, ns string) *infraiov1.Bmc
	GetAllBmcObject(ctx context.Context, ns string) *[]infraiov1.Bmc
	GetBiosSchemaObject(ctx context.Context, field, value, ns string) *infraiov1.BiosSchemaRegistry
	GetBiosObject(ctx context.Context, field, value, ns string) *infraiov1.BiosSetting
	GetBootObject(ctx context.Context, field, value, ns string) *infraiov1.BootOrderSetting
	GetOdimObject(ctx context.Context, field, value, ns string) *infraiov1.Odim
	GetVolumeObject(ctx context.Context, bmcIP, ns string) *infraiov1.Volume
	GetAllVolumeObjects(ctx context.Context, bmcIP, ns string) []*infraiov1.Volume
	GetVolumeObjectByVolumeID(ctx context.Context, volumeID, ns string) *infraiov1.Volume
	GetEventsubscriptionObject(ctx context.Context, field, value, ns string) *infraiov1.Eventsubscription
	GetAllEventSubscriptionObjects(ctx context.Context, ns string) *[]infraiov1.Eventsubscription
	GetAllBiosSchemaRegistryObjects(ctx context.Context, ns string) *[]infraiov1.BiosSchemaRegistry
	//get attributes of objects
	GetAllVolumeObjectIds(ctx context.Context, bmc *infraiov1.Bmc, ns string) map[string][]string
	GetFirmwareObject(ctx context.Context, field, value, ns string) *infraiov1.Firmware
	GetEventMessageRegistryObject(ctx context.Context, field, value, ns string) *infraiov1.EventsMessageRegistry
	//create objects
	CreateBiosSettingObject(ctx context.Context, biosAttributes map[string]string, bmcObj *infraiov1.Bmc) bool
	CreateBootOrderSettingObject(ctx context.Context, bootAttributes *infraiov1.BootSetting, bmcObj *infraiov1.Bmc) bool
	CheckAndCreateBiosSchemaObject(ctx context.Context, attributeResp map[string]interface{}, bmcObj *infraiov1.Bmc) bool
	CreateEventSubscriptionObject(ctx context.Context, subscriptionDetails map[string]interface{}, ns string, originResources []string) bool
	CheckAndCreateEventMessageObject(ctx context.Context, messageRegistryResp map[string]interface{}, bmcObj *infraiov1.Bmc) bool
	//update objects
	UpdateBiosSettingObject(ctx context.Context, biosAttributes map[string]string, bmcObj *infraiov1.BiosSetting) bool
	UpdateBmcStatus(ctx context.Context, bmcObj *infraiov1.Bmc)
	UpdateOdimStatus(ctx context.Context, status string, odimObj *infraiov1.Odim)
	UpdateBmcObjectOnReset(ctx context.Context, bmcObject *infraiov1.Bmc, status string)
	UpdateVolumeStatus(ctx context.Context, volObject *infraiov1.Volume, volumeID, volumeName, capBytes, durableName, durableNameFormat string)
	UpdateEventsubscriptionStatus(ctx context.Context, eventsubObj *infraiov1.Eventsubscription, eventsubscriptionDetails map[string]interface{}, originResouces []string)
	//get updated objects
	GetUpdatedBmcObject(ctx context.Context, ns types.NamespacedName, bmcObj *infraiov1.Bmc)
	GetUpdatedOdimObject(ctx context.Context, ns types.NamespacedName, odimObj *infraiov1.Odim)
	GetUpdatedVolumeObject(ctx context.Context, ns types.NamespacedName, volObj *infraiov1.Volume)
	//delete objects
	DeleteBmcObject(ctx context.Context, bmcObj *infraiov1.Bmc)
	DeleteVolumeObject(ctx context.Context, volObj *infraiov1.Volume)
	GetUpdatedFirmwareObject(ctx context.Context, ns types.NamespacedName, firmObj *infraiov1.Firmware)
	GetUpdatedEventsubscriptionObjects(ctx context.Context, ns types.NamespacedName, eventSubObj *infraiov1.Eventsubscription)
	//common reconciler funcs
	GetCommonReconcilerClient() client.Client
	GetCommonReconcilerScheme() *runtime.Scheme
}

func GetCommonReconciler

func GetCommonReconciler(c client.Client, s *runtime.Scheme) ReconcilerInterface

GetCommonReconciler will return common Reconciler object

Jump to

Keyboard shortcuts

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