measurementdevice

package measurementdevice

import "chantico/internal/measurementdevice"

Index

Constants

const (
	StateInit                      = "Init"
	StateEntryPoint                = "Entry Point"
	StatePendingSNMPConfigUpdate   = "Pending SNMP Config Update"
	StateSucceededSNMPConfigUpdate = "Succeeded SNMP Config Update"
	StatePendingSNMPReload         = "Pending SNMP Config Reload"
	StateDelete                    = "Delete"
	StateRemove                    = "Remove"
	StateFailed                    = "Failed"
	StateEndPoint                  = "End Point"
)

Variables

var StateMachine = sm.Machine[*chantico.MeasurementDevice]{
	Actions: map[string][]sm.ActionFunction[*chantico.MeasurementDevice]{
		StateInit: {
			{Type: sm.ActionFunctionPure, Pure: sm.InitializeFinalizer[*chantico.MeasurementDevice]},
		},
		StateEntryPoint: {
			{Type: sm.ActionFunctionPure, Pure: CreateSNMPGenerator},
			{Type: sm.ActionFunctionPure, Pure: CreateSNMPDeploymentConfig},
			{Type: sm.ActionFunctionIO, IO: ScheduleSNMPGeneratorJob},
		},
		StatePendingSNMPConfigUpdate: {
			{Type: sm.ActionFunctionPure, Pure: RequeueWithDelay},
		},
		StateSucceededSNMPConfigUpdate: {
			{Type: sm.ActionFunctionPure, Pure: CreateSNMPDeploymentConfig},
			{Type: sm.ActionFunctionIO, IO: ReloadSNMPService},
		},
		StateDelete: {
			{Type: sm.ActionFunctionPure, Pure: DeleteSNMPConfig},
			{Type: sm.ActionFunctionPure, Pure: CreateSNMPDeploymentConfig},
			{Type: sm.ActionFunctionIO, IO: ReloadSNMPService},
			{Type: sm.ActionFunctionPure, Pure: sm.RemoveFinalizer[*chantico.MeasurementDevice]},
		},
		StatePendingSNMPReload: {},
		StateFailed:            {},
		StateEndPoint:          {},
	},
	FailState: StateFailed,
}

Functions

func CreateSNMPDeploymentConfig

func CreateSNMPDeploymentConfig(
	ctx context.Context,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

Combines config_*.yml into snmp.yml

func CreateSNMPGenerator

func CreateSNMPGenerator(
	ctx context.Context,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

Creates generator_[id].yml file, and empty config_[id].yml file.

func DeleteSNMPConfig

func DeleteSNMPConfig(
	ctx context.Context,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

func GenerateSNMPGeneratorConfig

func GenerateSNMPGeneratorConfig(measurementDevice chantico.MeasurementDevice) (string, error)

func MakeJob

func MakeJob(measurementDevice chantico.MeasurementDevice) *batchv1.Job

func MergeSNMPConfigs

func MergeSNMPConfigs(fileContents [][]byte) (string, error)

func ReloadSNMPService

func ReloadSNMPService(
	ctx context.Context,
	kubernetesClient client.Client,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

func RequeueWithDelay

func RequeueWithDelay(
	ctx context.Context,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

func ScheduleSNMPGeneratorJob

func ScheduleSNMPGeneratorJob(
	ctx context.Context,
	kubernetesClient client.Client,
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

Creates Job. The Job uses the MIBs and generator_[id].yml file to give actual content to the empty config_[id].yml.

func UpdateModification

func UpdateModification(
	measurementDevice *chantico.MeasurementDevice,
) *sm.ActionResult

func UpdateState

func UpdateState(
	measurementDevice *chantico.MeasurementDevice,
	snmpJob *batchv1.Job,
)

Types

type State

type State string