omc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransferTypeUpload   = "upload"
	TransferTypeDownload = "download"

	UploadFileTypeConfigurationFile = "1 Vendor Configuration File"
	UploadFileTypeLogFile           = "2 Vendor Log File"

	DownloadFileTypeFirmwareUpgradeImage    = "1 Firmware Upgrade Image"
	DownloadFileTypeWebContent              = "2 Web Content"
	DownloadFileTypeVendorConfigurationFile = "3 Vendor Configuration File"
)
View Source
const DeviceUploadBucket = "omc-upload"
View Source
const FirmwareBucket = "omc-firmware"

Variables

View Source
var DeviceAlarmDeviceIndexNames = []string{"schema", "product_type", "device_id", "alarm_identifier"}
View Source
var DeviceAlarmPerceivedSeverityIndexNames = []string{"schema", "perceived_severity"}
View Source
var DeviceAlarmStatusIndexNames = []string{"schema", "product_type"}
View Source
var DeviceAlarmTypeIndexNames = []string{"schema", "product_type", "alarm_identifier", "event_type"}
View Source
var DeviceEventDeviceIndexNames = []string{"schema", "product_type", "device_id", "event_type"}
View Source
var DeviceEventIndexNames = []string{"schema", "product_type", "event_type"}
View Source
var DevicePerformanceValueDeviceIndexNames = []string{"schema", "product_type", "device_id", "name", "type"}
View Source
var DevicePerformanceValueIndexNames = []string{"schema", "product_type", "name", "type"}
View Source
var DeviceSearchHanleFuncs = search.SearchDataHandleFuncMap{
	"group": HanldeGroupSearch,
}
View Source
var DeviceStatusIndexNames = []string{"schema", "product_type"}
View Source
var SimpleDeviceInfoName = []string{
	"id", "updated", "created", "deleted",
	"schema", "oui", "product_class", "serial_number", "product_id",
	"name", "group_id",
	"enable", "online", "active_status", "last_inform_time",
	"meta_data", "properties",
}
View Source
var TaskDeviceLogIndexNames = []string{"schema", "device_id", "task_id", "task_name", "task_type", "exec_mode"}

Functions

func ClearCurrentAlarm

func ClearCurrentAlarm(db *gorm.DB, device *Device, alarmIdentifier string) error

func FetchAllDeviceAlarmStatus

func FetchAllDeviceAlarmStatus(t time.Time) error

func FetchAllDeviceStatus

func FetchAllDeviceStatus(t time.Time) error

func FetchDeviceAlarmStatus

func FetchDeviceAlarmStatus(t time.Time, schema string, productType string) error

func FetchDeviceStatus

func FetchDeviceStatus(t time.Time, schema string, productType string) error

func FormateTime

func FormateTime(t time.Time) string

func GetKPIMeasureIds

func GetKPIMeasureIds(schema string, productType string, measTypeIds []string) []uint

func HandleDeviceAlive

func HandleDeviceAlive(device *Device, t time.Time, lastOnlineStatus bool)

func HandleDeviceTimeout

func HandleDeviceTimeout(device *Device, t time.Time)

func HandleHttpPost

func HandleHttpPost(task *Task, data []any) error

func HanldeGroupSearch

func HanldeGroupSearch(values []search.SearchValue) (string, []any)

func InsertDeviceTransferLogComplete

func InsertDeviceTransferLogComplete(db *gorm.DB, device *Device, ts int64,
	bucket string,
	key string,
	fileType string,
	fileName string,
	startTime time.Time,
	completeTime time.Time,
	faultCode int,
	faultString string,
) error

func InsertDevieEvent

func InsertDevieEvent(db *gorm.DB, device *Device, eventType string, currentTime time.Time, metaData *jsontype.Tags) error

func InsertDeviePerformanceValue

func InsertDeviePerformanceValue(db *gorm.DB, device *Device, name string, source string, value float64, metaData *jsontype.Tags) error

func ParseFileName

func ParseFileName(filename string) (string, time.Time, time.Time, string, string, string, error)

A20230627.2015+0800-2030+0800_000000.65740512A3200006L.xml A20230630.2345+0800-20230701.0000+0800_000000.65740512A3200006L.xml nrm_000000.65740512A3200006L.xml

func ParseTime

func ParseTime(value string) time.Time

func ReloadAllDataModels

func ReloadAllDataModels() error

func ReloadAllKPIMeansure

func ReloadAllKPIMeansure() error

func ReloadAllProducts

func ReloadAllProducts() error

func SetProductPerformanceValueDefines

func SetProductPerformanceValueDefines(db *gorm.DB, product *Product, performanceValueDefines *jsontype.Tags) error

func Setup

func Setup()

func SetupDefaultDataModel

func SetupDefaultDataModel(db *gorm.DB, schema string) error

func SetupDefaultDataModelTemplate

func SetupDefaultDataModelTemplate(db *gorm.DB, dm *DataModel) error

func SetupDefaultKPIMeasures

func SetupDefaultKPIMeasures(db *gorm.DB, schema string) error

func SetupDefaultKPITemplates

func SetupDefaultKPITemplates(db *gorm.DB, schema string) error

func SetupProducts

func SetupProducts(db *gorm.DB, schema string)

func SetupTasks

func SetupTasks(db *gorm.DB, schema string)

func StartAllActiveDeviceKeepaliveTimers

func StartAllActiveDeviceKeepaliveTimers()

func StartDeviceKeepaliveTimer

func StartDeviceKeepaliveTimer(device *Device)

func StopDeviceKeepaliveTimer

func StopDeviceKeepaliveTimer(device *Device)

func UpdateDeviceTransferLogComplete

func UpdateDeviceTransferLogComplete(db *gorm.DB, device *Device, ts int64,
	startTime time.Time, completeTime time.Time) error

func UpdateDeviceTransferLogFault

func UpdateDeviceTransferLogFault(db *gorm.DB, device *Device, ts int64,
	startTime time.Time, completeTime time.Time, faultCode int, faultString string) error

func UpdateTaskStatus

func UpdateTaskStatus(db *gorm.DB, schema string, task *Task, status TaskStatus) error

func UpsertCurrentAlarm

func UpsertCurrentAlarm(db *gorm.DB, device *Device, data *igd.CurrentAlarm) error

func UpsertDataModelParameter

func UpsertDataModelParameter(db *gorm.DB, dm *DataModel, name string,
	typ *string, writable *bool, description *string, defaultValue *string) error

func UpsertExpeditedEvent

func UpsertExpeditedEvent(db *gorm.DB, device *Device, data *igd.ExpeditedEvent) error

func UpsertSupportedAlarm

func UpsertSupportedAlarm(db *gorm.DB, product *Product, alarmIdentifier int, data *igd.SupportedAlarm) error

Types

type DataModel

type DataModel struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`
	Default bool              `json:"Default" gorm:"index"`

	Schema        string                            `json:"Schema" gorm:"uniqueIndex:idx_datamodel_unique"`
	ProductType   string                            `json:"ProductType" gorm:"uniqueIndex:idx_datamodel_unique"`
	Name          string                            `json:"Name" gorm:"uniqueIndex:idx_datamodel_unique"`
	ParameterPath string                            `json:"ParameterPath" gorm:"index"`
	MetaDataRaw   jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData      *jsontype.Tags                    `json:"MetaData" gorm:"-"`

	Templates  []*DataModelTemplate  `json:"Templates"`
	Parameters []*DataModelParameter `json:"Parameters"`
}

func GetDataModel

func GetDataModel(schema string, productType string, name string) *DataModel

func GetDataModelByProduct

func GetDataModelByProduct(product *Product) *DataModel

func (*DataModel) AfterFind

func (m *DataModel) AfterFind(tx *gorm.DB) (err error)

func (*DataModel) BeforeSave

func (m *DataModel) BeforeSave(tx *gorm.DB) (err error)

func (DataModel) GetParameter

func (m DataModel) GetParameter(name string) *DataModelParameter

func (DataModel) GetParameterType

func (m DataModel) GetParameterType(name string) string

func (*DataModel) LoadData

func (m *DataModel) LoadData()

func (*DataModel) SaveData

func (m *DataModel) SaveData()

type DataModelParameter

type DataModelParameter struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	DataModelID uint       `json:"DataModelId" gorm:"uniqueIndex:idx_datamodel_param_unique"`
	DataModel   *DataModel `json:"-"`
	Name        string     `json:"Name" gorm:"uniqueIndex:idx_datamodel_param_unique"`
	Default     bool       `json:"Default" gorm:"index"`

	Type         string `json:"Type" gorm:"index"`
	Writable     bool   `json:"Writable" gorm:"index"`
	Description  string `json:"Description"`
	DefaultValue string `json:"DefaultValue"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func GetDataModelParameterByID

func GetDataModelParameterByID(db *gorm.DB, dm *DataModel, id uint) *DataModelParameter

func GetDataModelParameterByName

func GetDataModelParameterByName(db *gorm.DB, dm *DataModel, name string) *DataModelParameter

func (*DataModelParameter) AfterFind

func (m *DataModelParameter) AfterFind(tx *gorm.DB) (err error)

func (*DataModelParameter) BeforeSave

func (m *DataModelParameter) BeforeSave(tx *gorm.DB) (err error)

func (*DataModelParameter) LoadData

func (m *DataModelParameter) LoadData()

func (*DataModelParameter) SaveData

func (m *DataModelParameter) SaveData()

type DataModelTemplate

type DataModelTemplate struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`
	Default bool              `json:"Default" gorm:"index"`

	DataModelID       uint                              `json:"DataModelId" gorm:"uniqueIndex:idx_datamodel_template_unique"`
	DataModel         *DataModel                        `json:"-"`
	Name              string                            `json:"Name" gorm:"uniqueIndex:idx_datamodel_template_unique"`
	ParameterNames    *jsontype.Tags                    `json:"ParameterNames" gorm:"-"`
	ParameterNamesRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:parameter_names"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func GetDataModelTemplate

func GetDataModelTemplate(db *gorm.DB, dm *DataModel, id uint) *DataModelTemplate

func (*DataModelTemplate) AfterFind

func (m *DataModelTemplate) AfterFind(tx *gorm.DB) (err error)

func (*DataModelTemplate) BeforeSave

func (m *DataModelTemplate) BeforeSave(tx *gorm.DB) (err error)

func (*DataModelTemplate) LoadData

func (m *DataModelTemplate) LoadData()

func (*DataModelTemplate) SaveData

func (m *DataModelTemplate) SaveData()

type Device

type Device struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema       string `json:"Schema" gorm:"uniqueIndex:idx_device_unique"`
	Oui          string `json:"Oui" gorm:"uniqueIndex:idx_device_unique"`
	ProductClass string `json:"ProductClass" gorm:"uniqueIndex:idx_device_unique"`
	SerialNumber string `json:"SerialNumber" gorm:"uniqueIndex:idx_device_unique"`
	ProductType  string `json:"ProductType" gorm:"index"`

	ActiveStatus   string            `json:"ActiveStatus" gorm:"index"`
	Enable         bool              `json:"Enable" gorm:"index"`
	Online         bool              `json:"Online" gorm:"index"`
	LastInformTime jsontype.JSONTime `json:"LastInformTime" gorm:"index"`

	ProductID uint     `json:"ProductId" gorm:"index;not null"`
	Product   *Product `json:"Product"`

	GroupID uint   `json:"GroupId" gorm:"index"`
	Group   *Group `json:"Group"`

	Name          string                            `json:"Name"`
	MetaDataRaw   jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData      *jsontype.Tags                    `json:"MetaData" gorm:"-"`
	PropertiesRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:properties"`
	Properties    *jsontype.Tags                    `json:"Properties" gorm:"-"`

	MethodsRaw                jsontype.JSONType[*Methods]                `json:"-" gorm:"column:methods"`
	Methods                   *Methods                                   `json:"Methods" gorm:"-"`
	ParameterValuesRaw        jsontype.JSONType[*ParameterValues]        `json:"-" gorm:"column:parameter_values"`
	ParameterValues           *ParameterValues                           `json:"ParameterValues" gorm:"-"`
	ParameterWritablesRaw     jsontype.JSONType[*ParameterWritables]     `json:"-" gorm:"column:parameter_writables"`
	ParameterWritables        *ParameterWritables                        `json:"ParameterWritables" gorm:"-"`
	ParameterNotificationsRaw jsontype.JSONType[*ParameterNotifications] `json:"-" gorm:"column:parameter_notifications"`
	ParameterNotifications    *ParameterNotifications                    `json:"ParameterNotifications" gorm:"-"`
}

func GetDevice

func GetDevice(schema string, oui string, serialNumber string) *Device

func GetDeviceWithProductClass

func GetDeviceWithProductClass(schema string, oui string, productClass string, serialNumber string) *Device

func (*Device) AfterFind

func (m *Device) AfterFind(tx *gorm.DB) (err error)

func (*Device) AfterSave

func (m *Device) AfterSave(tx *gorm.DB) (err error)

func (*Device) BeforeSave

func (m *Device) BeforeSave(tx *gorm.DB) (err error)

func (*Device) FetchPmValues

func (m *Device) FetchPmValues(db *gorm.DB, t time.Time) bool

func (*Device) GetMethodCall

func (m *Device) GetMethodCall(commandKey string) acs.MethodCall

func (*Device) GetNextMethodCall

func (m *Device) GetNextMethodCall() acs.MethodCall

func (Device) GetParameterInt64Value

func (m Device) GetParameterInt64Value(name string) *int64

func (*Device) GetParameterNames

func (m *Device) GetParameterNames(path string, nextLevel bool) []string

func (*Device) GetParameterPaths

func (m *Device) GetParameterPaths(path string, nextLevel bool) []string

func (Device) GetParameterValue

func (m Device) GetParameterValue(name string) *string

func (*Device) GetProduct

func (m *Device) GetProduct() acs.Product

func (*Device) GetProperty

func (m *Device) GetProperty(k string) any

func (Device) IsMethodSupported

func (m Device) IsMethodSupported(name string) bool

func (*Device) LoadData

func (m *Device) LoadData()

func (*Device) PushGetDeviceParameterNames

func (m *Device) PushGetDeviceParameterNames(parameterPath string, nextLevel bool) (acs.MethodCall, error)

func (*Device) PushMethodCall

func (m *Device) PushMethodCall(t time.Time, methodName string, values map[string]any) (acs.MethodCall, error)

func (*Device) SaveData

func (m *Device) SaveData()

func (*Device) SendConnectRequest

func (m *Device) SendConnectRequest() error

func (*Device) UpdateByIgdValues

func (m *Device) UpdateByIgdValues(db *gorm.DB, values map[string]string)

func (*Device) UpdateMetaData

func (m *Device) UpdateMetaData(k string, v any)

func (*Device) UpdateMetaDatas

func (m *Device) UpdateMetaDatas(values map[string]any)

func (*Device) UpdateMethodCallRequestSend

func (m *Device) UpdateMethodCallRequestSend(commandKey string) error

func (*Device) UpdateMethodCallResponse

func (m *Device) UpdateMethodCallResponse(commandKey string,
	values map[string]any,
	faultCode int,
	faultString string,
) error

func (*Device) UpdateMethodCallState

func (m *Device) UpdateMethodCallState(commandKey string, state DeviceMethodCallState) error

func (*Device) UpdateMethodCallTimeout

func (m *Device) UpdateMethodCallTimeout(commandKey string) error

func (*Device) UpdateMethodCallUnknow

func (m *Device) UpdateMethodCallUnknow(commandKey string) error

func (*Device) UpdateParameterNotification

func (m *Device) UpdateParameterNotification(k string, v int)

func (*Device) UpdateParameterNotifications

func (m *Device) UpdateParameterNotifications(values map[string]int)

func (*Device) UpdateParameterValue

func (m *Device) UpdateParameterValue(k string, v string)

func (*Device) UpdateParameterValues

func (m *Device) UpdateParameterValues(values map[string]string)

func (*Device) UpdateParameterWritable

func (m *Device) UpdateParameterWritable(k string, v bool)

func (*Device) UpdateParameterWritables

func (m *Device) UpdateParameterWritables(values map[string]bool)

func (*Device) UpdateProperties

func (m *Device) UpdateProperties(values map[string]any)

func (*Device) UpdateProperty

func (m *Device) UpdateProperty(k string, v any)

type DeviceAlarm

type DeviceAlarm struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_alarm_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_device_alarm_unique;not null"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_device_alarm_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Updated  jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	AlarmIdentifier       string            `json:"AlarmIdentifier" gorm:"uniqueIndex:idx_device_alarm_unique;not null"`
	AlarmRaisedTime       jsontype.JSONTime `json:"AlarmRaisedTime"`
	AlarmChangedTime      jsontype.JSONTime `json:"AlarmChangedTime"`
	AlarmClearedTime      jsontype.JSONTime `json:"AlarmClearedTime"`
	ManagedObjectInstance string            `json:"ManagedObjectInstance"`
	EventType             string            `json:"EventType"`
	ProbableCause         string            `json:"ProbableCause"`
	SpecificProblem       string            `json:"SpecificProblem"`
	PerceivedSeverity     string            `json:"PerceivedSeverity"`
	AdditionalText        string            `json:"AdditionalText"`
	AdditionalInformation string            `json:"AdditionalInformation"`

	AlarmCleared       bool              `json:"AlarmCleared"`
	AlarmConfirmed     bool              `json:"AlarmConfirmed"`
	AlarmConfirmedTime jsontype.JSONTime `json:"AlarmConfirmedTime"`
}

type DeviceAlarmEvent

type DeviceAlarmEvent struct {
	OUI                   string
	ProductClass          string
	SerialNumber          string
	EventTime             string
	AlarmIdentifier       string
	NotificationType      string
	ManagedObjectInstance string
	EventType             string
	ProbableCause         string
	SpecificProblem       string
	PerceivedSeverity     string
	AdditionalText        string
	AdditionalInformation string
}

type DeviceAlarmStatus

type DeviceAlarmStatus struct {
	Time        jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_status_unique;not null"`
	Schema      string            `json:"Schema" gorm:"uniqueIndex:idx_device_status_unique;not null"`
	ProductType string            `json:"ProductType" gorm:"uniqueIndex:idx_device_status_unique;not null"`

	Total    int64 `json:"Total"`
	Critical int64 `json:"Critical"`
	Major    int64 `json:"Major"`
	Minor    int64 `json:"Minor"`
	Warning  int64 `json:"Warning"`
}

type DeviceEvent

type DeviceEvent struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_event_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_device_event_unique;not null"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_device_event_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Updated  jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	EventType   string            `json:"EventType" gorm:"uniqueIndex:idx_device_event_unique;not null"`
	CurrentTime jsontype.JSONTime `json:"CurrentTime"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func (*DeviceEvent) AfterFind

func (m *DeviceEvent) AfterFind(tx *gorm.DB) (err error)

func (*DeviceEvent) BeforeSave

func (m *DeviceEvent) BeforeSave(tx *gorm.DB) (err error)

func (*DeviceEvent) LoadData

func (m *DeviceEvent) LoadData()

func (*DeviceEvent) SaveData

func (m *DeviceEvent) SaveData()

type DeviceMethodCall

type DeviceMethodCall struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_method_call_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_device_method_call_unique;not null"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_device_method_call_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	Updated           jsontype.JSONTime                 `json:"Updated" gorm:"autoUpdateTime"`
	State             DeviceMethodCallState             `json:"State" gorm:"index"`
	CommandKey        string                            `json:"CommandKey"`
	MethodName        string                            `json:"MethodName"`
	RequestValuesRaw  jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:request_values"`
	RequestValues     *jsontype.Tags                    `json:"RequestValues" gorm:"-"`
	ResponseValuesRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:response_values"`
	ResponseValues    *jsontype.Tags                    `json:"ResponseValues" gorm:"-"`
	FaultCode         int                               `json:"FaultCode"`
	FaultString       string                            `json:"FaultString"`
}

func (*DeviceMethodCall) AfterFind

func (m *DeviceMethodCall) AfterFind(tx *gorm.DB) (err error)

func (*DeviceMethodCall) BeforeSave

func (m *DeviceMethodCall) BeforeSave(tx *gorm.DB) (err error)

func (DeviceMethodCall) GetCommandKey

func (m DeviceMethodCall) GetCommandKey() string

func (DeviceMethodCall) GetMethodName

func (m DeviceMethodCall) GetMethodName() string

func (DeviceMethodCall) GetRequestValue

func (m DeviceMethodCall) GetRequestValue(n string) string

func (DeviceMethodCall) GetRequestValues

func (m DeviceMethodCall) GetRequestValues() map[string]string

func (*DeviceMethodCall) LoadData

func (m *DeviceMethodCall) LoadData()

func (*DeviceMethodCall) SaveData

func (m *DeviceMethodCall) SaveData()

type DeviceMethodCallState

type DeviceMethodCallState int
const (
	DeviceMethodCallStateInit            DeviceMethodCallState = 0
	DeviceMethodCallStateRequestSend     DeviceMethodCallState = 1
	DeviceMethodCallStateResponseRecv    DeviceMethodCallState = 2
	DeviceMethodCallStateResponseTimeout DeviceMethodCallState = 3
	DeviceMethodCallStateUnknow          DeviceMethodCallState = 100
)

type DevicePerformanceValue

type DevicePerformanceValue struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_performance_value_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_device_performance_value_unique;not null"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_device_performance_value_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Updated  jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	Name   string  `json:"Name" gorm:"uniqueIndex:idx_device_performance_value_unique;not null"`
	Source string  `json:"Source"`
	Type   string  `json:"Type"`
	Value  float64 `json:"Value"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func (*DevicePerformanceValue) AfterFind

func (m *DevicePerformanceValue) AfterFind(tx *gorm.DB) (err error)

func (*DevicePerformanceValue) BeforeSave

func (m *DevicePerformanceValue) BeforeSave(tx *gorm.DB) (err error)

func (*DevicePerformanceValue) LoadData

func (m *DevicePerformanceValue) LoadData()

func (*DevicePerformanceValue) SaveData

func (m *DevicePerformanceValue) SaveData()

type DeviceStatus

type DeviceStatus struct {
	Time        jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_status_unique;not null"`
	Schema      string            `json:"Schema" gorm:"uniqueIndex:idx_device_status_unique;not null"`
	ProductType string            `json:"ProductType" gorm:"uniqueIndex:idx_device_status_unique;not null"`

	Total   int64 `json:"Total"`
	Online  int64 `json:"Online"`
	Active  int64 `json:"Active"`
	Offline int64 `json:"Offline"`
}

type DeviceTransferLog

type DeviceTransferLog struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_device_log_file_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_device_log_file_unique;not null"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_device_log_file_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Updated  jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	TransferType string            `json:"TransferType" gorm:"uniqueIndex:idx_device_log_file_unique"`
	FileType     string            `json:"FileType" gorm:"uniqueIndex:idx_device_log_file_unique"`
	FileName     string            `json:"FileName" gorm:"uniqueIndex:idx_device_log_file_unique"`
	StartTime    jsontype.JSONTime `json:"StartTime"`
	CompleteTime jsontype.JSONTime `json:"CompleteTime"`
	FaultCode    int               `json:"FaultCode"`
	FaultString  string            `json:"FaultString"`
	ObjectBucket string            `json:"ObjectBucket"`
	ObjectKey    string            `json:"ObjectKey"`

	S3ObjectID *uint        `json:"S3ObjectId" gorm:"index"`
	S3Object   *s3.S3Object `json:"S3Object"`

	FirmwareID *uint     `json:"FirmwareId" gorm:"index"`
	Firmware   *Firmware `json:"Firmware"`
}

func GetDeviceTransferLog

func GetDeviceTransferLog(db *gorm.DB, device *Device, ts int64) *DeviceTransferLog

func (*DeviceTransferLog) AfterDelete

func (m *DeviceTransferLog) AfterDelete(tx *gorm.DB) (err error)

type Firmware

type Firmware struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema      string `json:"Schema" gorm:"uniqueIndex:idx_firmware_unique"`
	Name        string `json:"Name" gorm:"uniqueIndex:idx_firmware_unique"`
	Version     string `json:"Version" gorm:"uniqueIndex:idx_firmware_unique"`
	ProductType string `json:"ProductType" gorm:"index"`

	Products []*Product `gorm:"many2many:firmware_products;"`

	Uploader   string            `json:"Uploader"`
	UploadTime jsontype.JSONTime `json:"UploadTime"`
	S3ObjectID uint              `json:"S3ObjectId" gorm:"index"`
	S3Object   *s3.S3Object      `json:"S3Object"`
}

func GetFirmware

func GetFirmware(db *gorm.DB, schema string, id uint) *Firmware

func (*Firmware) AfterDelete

func (m *Firmware) AfterDelete(tx *gorm.DB) (err error)

type Group

type Group struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Schema  string            `json:"Schema" gorm:"uniqueIndex:idx_group_unique"`
	Name    string            `json:"Name" gorm:"uniqueIndex:idx_group_unique"`

	ParentID *uint    `json:"ParentId" gorm:"index"`
	Parent   *Group   `json:"Parent"`
	Children []*Group `json:"Children" gorm:"foreignKey:ParentID"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func GetChildrenGroups

func GetChildrenGroups(db *gorm.DB, schema string, parentID uint) []*Group

func (*Group) AfterFind

func (m *Group) AfterFind(tx *gorm.DB) (err error)

func (*Group) BeforeSave

func (m *Group) BeforeSave(tx *gorm.DB) (err error)

func (Group) FindChildByID

func (m Group) FindChildByID(id uint) *Group

type KPIMeas

type KPIMeas struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema      string `json:"Schema" gorm:"uniqueIndex:idx_kpi_meas_unique"`
	ProductType string `json:"ProductType" gorm:"uniqueIndex:idx_kpi_meas_unique"`
	MeasTypeID  string `json:"MeasTypeID" gorm:"uniqueIndex:idx_kpi_meas_unique"`
	MeasTypeSet string `json:"MeasTypeSet" gorm:"index"`
	Enable      bool   `json:"Enable" gorm:"index"`
	Default     bool   `json:"Default" gorm:"index"`

	Name        string                            `json:"Name"`
	Unit        string                            `json:"Unit"`
	StatsType   string                            `json:"StatsType"`
	Formula     string                            `json:"Formula"`
	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`

	FormulaExpression *govaluate.EvaluableExpression `json:"-" gorm:"-"`
}

func GetKPIMeasure

func GetKPIMeasure(schema string, productType string, measTypeID string) *KPIMeas

func GetKPIMeasuresBySet

func GetKPIMeasuresBySet(schema string, productType string, measTypeSet string) []*KPIMeas

func (*KPIMeas) AfterFind

func (m *KPIMeas) AfterFind(tx *gorm.DB) (err error)

func (*KPIMeas) AfterSave

func (m *KPIMeas) AfterSave(tx *gorm.DB) error

func (*KPIMeas) BeforeSave

func (m *KPIMeas) BeforeSave(tx *gorm.DB) (err error)

func (*KPIMeas) LoadData

func (m *KPIMeas) LoadData()

func (*KPIMeas) SaveData

func (m *KPIMeas) SaveData()

type KPITemplate

type KPITemplate struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema      string `json:"Schema" gorm:"uniqueIndex:idx_kpi_template_unique"`
	ProductType string `json:"ProductType" gorm:"uniqueIndex:idx_kpi_template_unique"`
	Name        string `json:"Name" gorm:"uniqueIndex:idx_kpi_template_unique"`
	Default     bool   `json:"Default" gorm:"index"`

	PeriodicInterval int64                      `json:"PeriodicInterval"`
	SelectType       string                     `json:"SelectType"`
	SelectIds        []uint                     `json:"SelectIds" gorm:"-"`
	SelectIdsRaw     jsontype.JSONSlice[uint]   `json:"-" gorm:"column:select_ids"`
	MeasTypeIds      []string                   `json:"MeasTypeIds" gorm:"-"`
	MeasTypeIdsRaw   jsontype.JSONSlice[string] `json:"-" gorm:"column:meas_type_ids"`

	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`
}

func (*KPITemplate) AfterFind

func (m *KPITemplate) AfterFind(tx *gorm.DB) (err error)

func (*KPITemplate) BeforeSave

func (m *KPITemplate) BeforeSave(tx *gorm.DB) (err error)

func (*KPITemplate) LoadData

func (m *KPITemplate) LoadData()

func (*KPITemplate) SaveData

func (m *KPITemplate) SaveData()

func (KPITemplate) ViewTableName

func (m KPITemplate) ViewTableName() string

type Methods

type Methods []string

type ParameterNotifications

type ParameterNotifications map[string]int

func (ParameterNotifications) GetValue

func (m ParameterNotifications) GetValue(n string) int

func (ParameterNotifications) SetValue

func (m ParameterNotifications) SetValue(n string, v int)

func (ParameterNotifications) SetValues

func (m ParameterNotifications) SetValues(values map[string]int)

type ParameterTypes

type ParameterTypes map[string]string

func (ParameterTypes) GetValue

func (m ParameterTypes) GetValue(n string) string

func (ParameterTypes) GetValues

func (m ParameterTypes) GetValues() map[string]string

func (ParameterTypes) SetValue

func (m ParameterTypes) SetValue(n, v string)

func (ParameterTypes) SetValues

func (m ParameterTypes) SetValues(values map[string]string)

type ParameterValues

type ParameterValues map[string]string

func (ParameterValues) GetValue

func (m ParameterValues) GetValue(n string) string

func (ParameterValues) GetValues

func (m ParameterValues) GetValues() map[string]string

func (ParameterValues) SetValue

func (m ParameterValues) SetValue(n, v string)

func (ParameterValues) SetValues

func (m ParameterValues) SetValues(values map[string]string)

type ParameterWritables

type ParameterWritables map[string]bool

func (ParameterWritables) GetValue

func (m ParameterWritables) GetValue(n string) bool

func (ParameterWritables) RemoveValue

func (m ParameterWritables) RemoveValue(n string)

func (ParameterWritables) SetValue

func (m ParameterWritables) SetValue(n string, v bool)

func (ParameterWritables) SetValues

func (m ParameterWritables) SetValues(values map[string]bool)

type Product

type Product struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema        string `json:"Schema" gorm:"uniqueIndex:idx_product_class_unique;uniqueIndex:idx_product_model_unique"`
	ModelName     string `json:"ModelName" gorm:"uniqueIndex:idx_product_model_unique"`
	Oui           string `json:"Oui" gorm:"uniqueIndex:idx_product_class_unique"`
	ProductClass  string `json:"ProductClass" gorm:"uniqueIndex:idx_product_class_unique"`
	ProductType   string `json:"ProductType" gorm:"index"`
	Enable        bool   `json:"Enable" gorm:"index"`
	Default       bool   `json:"Default" gorm:"index"`
	ParameterPath string `json:"ParameterPath"`

	Manufacturer string                            `json:"Manufacturer"`
	MetaDataRaw  jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData     *jsontype.Tags                    `json:"MetaData" gorm:"-"`
	// ParameterTypesRaw          jsontype.JSONType[*ParameterTypes] `json:"-" gorm:"column:parameter_types"`
	// ParameterTypes             *ParameterTypes                 `json:"ParameterTypes" gorm:"-"`
	PerformanceValueDefinesRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:performance_value_defines"`
	PerformanceValueDefines    *jsontype.Tags                    `json:"PerformanceValueDefines" gorm:"-"`

	SupportedAlarms []*ProductSupportedAlarm `json:"SupportedAlarms"`
	Firmwares       []*Firmware              `json:"Firmwares" gorm:"many2many:firmware_products;"`
}

func CreateProduct

func CreateProduct(db *gorm.DB, schema string, id uint,
	productType string,
	modelName string,
	oui string,
	productClass string,
	manufacturer string,
	parameterPath string,
	isDefault bool,
) (*Product, error)

func GetProduct

func GetProduct(schema string, oui string, productClass string) *Product

func GetProductByModelName

func GetProductByModelName(db *gorm.DB, schema string, modelName string) *Product

func (*Product) AfterFind

func (m *Product) AfterFind(tx *gorm.DB) (err error)

func (*Product) AfterSave

func (m *Product) AfterSave(tx *gorm.DB) error

func (*Product) BeforeSave

func (m *Product) BeforeSave(tx *gorm.DB) (err error)

func (*Product) GetDataModel

func (m *Product) GetDataModel() acs.DataModel

func (*Product) LoadData

func (m *Product) LoadData()

func (*Product) SaveData

func (m *Product) SaveData()

type ProductSupportedAlarm

type ProductSupportedAlarm struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`

	Schema    string   `json:"Schema" gorm:"uniqueIndex:idx_product_support_alarm_unique;not null"`
	ProductID uint     `json:"ProductId" gorm:"uniqueIndex:idx_product_support_alarm_unique;not null"`
	Product   *Product `json:"Product"`

	Oui          string `json:"Oui"`
	ProductClass string `json:"ProductClass"`
	SerialNumber string `json:"SerialNumber"`
	ProductType  string `json:"ProductType" gorm:"index"`

	AlarmIdentifier   string `json:"AlarmIdentifier" gorm:"uniqueIndex:idx_product_support_alarm_unique;not null"`
	EventType         string `json:"EventType"`
	ProbableCause     string `json:"ProbableCause"`
	SpecificProblem   string `json:"SpecificProblem"`
	PerceivedSeverity string `json:"PerceivedSeverity"`
}

type Task

type Task struct {
	ID      uint              `json:"Id" gorm:"primarykey"`
	Updated jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`
	Created jsontype.JSONTime `json:"Created" gorm:"autoCreateTime"`
	Deleted gorm.DeletedAt    `json:"Deleted" gorm:"index"`

	Schema   string `json:"Schema" gorm:"uniqueIndex:idx_task_unique"`
	TaskName string `json:"TaskName" gorm:"uniqueIndex:idx_task_unique"`
	TaskType string `json:"TaskType" gorm:"index"`
	Enable   bool   `json:"Enable" gorm:"index"`
	Default  bool   `json:"Default" gorm:"index"`

	ExecMode      TaskExecMode                      `json:"ExecMode"`
	ExecStartTime jsontype.JSONTime                 `json:"ExecStartTime"`
	ExecEndTime   jsontype.JSONTime                 `json:"ExecEndTime"`
	ExecInterval  int                               `json:"ExecInterval"`
	ExecTimes     int                               `json:"ExecTimes"`
	ExecRate      int                               `json:"ExecRate"`
	RetryInterval int                               `json:"RetryInterval"`
	RetryTimes    int                               `json:"RetryTimes"`
	RangesRaw     jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:ranges"`
	Ranges        *jsontype.Tags                    `json:"DeviceIds" gorm:"-"`

	Creater     string                            `json:"Creater"`
	MetaDataRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:meta_data"`
	MetaData    *jsontype.Tags                    `json:"MetaData" gorm:"-"`

	TaskStatus   TaskStatus        `json:"TaskStatus" gorm:"index"`
	ExecProcess  int               `json:"ExecProcess"`
	ExecLastTime jsontype.JSONTime `json:"ExecLastTime"`
	ExecNextTime jsontype.JSONTime `json:"ExecNextTime"`
}

func CreateNBITask

func CreateNBITask(db *gorm.DB,
	schema string,
	taskName string,
	protocol string, method string, source string,
	serverUrl string,
	execRate int, retryInterval int, retryTimes int,
	enable bool,
	isDefault bool,
) (*Task, error)

func LoadAllTasks

func LoadAllTasks(db *gorm.DB, schema string) ([]*Task, error)

func (*Task) AfterFind

func (m *Task) AfterFind(tx *gorm.DB) (err error)

func (*Task) BeforeSave

func (m *Task) BeforeSave(tx *gorm.DB) (err error)

type TaskDeviceLog

type TaskDeviceLog struct {
	Time     jsontype.JSONTime `json:"Time" gorm:"autoCreateTime;uniqueIndex:idx_task_log_unique;not null"`
	Schema   string            `json:"Schema" gorm:"uniqueIndex:idx_task_log_unique;not null"`
	TaskID   uint              `json:"TaskId" gorm:"uniqueIndex:idx_task_log_unique;not null"`
	Task     *Task             `json:"Task" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	DeviceID uint              `json:"DeviceId" gorm:"uniqueIndex:idx_task_log_unique;not null"`
	Device   *Device           `json:"Device" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Updated  jsontype.JSONTime `json:"Updated" gorm:"autoUpdateTime"`

	TaskName string `json:"TaskName"`
	TaskType string `json:"TaskType"`
	ExecMode int    `json:"ExecMode"`

	StartTime jsontype.JSONTime                 `json:"StartTime"`
	EndTime   jsontype.JSONTime                 `json:"EndTime"`
	Code      int                               `json:"Code"`
	Info      string                            `json:"Info"`
	RangesRaw jsontype.JSONType[*jsontype.Tags] `json:"-" gorm:"column:ranges"`
	Ranges    *jsontype.Tags                    `json:"DeviceIds" gorm:"-"`
}

func (*TaskDeviceLog) AfterFind

func (m *TaskDeviceLog) AfterFind(tx *gorm.DB) (err error)

func (*TaskDeviceLog) BeforeSave

func (m *TaskDeviceLog) BeforeSave(tx *gorm.DB) (err error)

type TaskExecMode

type TaskExecMode int
const (
	TaskExecModeImmediately TaskExecMode = 0
	TaskExecModeSchedule    TaskExecMode = 1
)

type TaskHandleFunc

type TaskHandleFunc func(task *Task, data []any) error

type TaskJob

type TaskJob struct {
	Data any
}

type TaskServer

type TaskServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetTaskServer

func GetTaskServer() *TaskServer

func NewTaskServer

func NewTaskServer() *TaskServer

func (*TaskServer) ClearTask

func (s *TaskServer) ClearTask(task *Task)

func (*TaskServer) Close

func (s *TaskServer) Close()

func (*TaskServer) GetTaskSessionsBySource

func (s *TaskServer) GetTaskSessionsBySource(source string) []*TaskSession

func (*TaskServer) PushDeviceAlarm

func (s *TaskServer) PushDeviceAlarm(alarm *DeviceAlarm)

func (*TaskServer) Run

func (s *TaskServer) Run()

func (*TaskServer) StartTask

func (s *TaskServer) StartTask(task *Task)

func (*TaskServer) StopTask

func (s *TaskServer) StopTask(task *Task)

type TaskSession

type TaskSession struct {
	sync.Mutex
	Key string

	Task   *Task
	Status TaskStatus

	Process     int64
	LastTime    int64
	NextTime    int64
	CurrentRate int64
	Timeout     int64
	// contains filtered or unexported fields
}

func CreateTaskSession

func CreateTaskSession(db *gorm.DB, task *Task, f TaskHandleFunc) *TaskSession

func (*TaskSession) PushJob

func (s *TaskSession) PushJob(data any)

func (*TaskSession) Start

func (s *TaskSession) Start()

func (*TaskSession) Stop

func (s *TaskSession) Stop()

type TaskStatus

type TaskStatus int
const (
	TaskStatusInit    TaskStatus = 0
	TaskStatusWaiting TaskStatus = 1
	TaskStatusRunning TaskStatus = 2
	TaskStatusFinish  TaskStatus = 3
	TaskStatusCancel  TaskStatus = 4
)

Directories

Path Synopsis
define
igd
pm

Jump to

Keyboard shortcuts

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