devices.modelsΒΆ

This modules contains all models specific to the device abstractions.

Module ContentsΒΆ

class devices.models.DeviceModel(*args, **kwargs)[source]ΒΆ

Bases: util.db.CustomDeleteActionModel

The DeviceModel.

common_name[source]ΒΆ
serial_number[source]ΒΆ
ip_address[source]ΒΆ
opc_server_port[source]ΒΆ
domain[source]ΒΆ
onboarding_config[source]ΒΆ
no_onboarding_config[source]ΒΆ
class DeviceType(*args, **kwds)[source]ΒΆ

Bases: django.db.models.IntegerChoices

Enum for device type.

GENERIC_DEVICE[source]ΒΆ
OPC_UA_GDS[source]ΒΆ
OPC_UA_GDS_PUSH[source]ΒΆ
device_type[source]ΒΆ
created_at[source]ΒΆ
opc_gds_push_enable_periodic_update[source]ΒΆ
opc_gds_push_renewal_interval[source]ΒΆ
opc_gds_push_last_update_scheduled_at[source]ΒΆ
pre_delete()[source]ΒΆ

Delete all issued credentials for this device before deleting the device itself.

Return type:

None

property est_username: str[source]ΒΆ

Gets the EST username.

Return type:

str

clean()[source]ΒΆ

Validation before saving the model.

Return type:

None

schedule_next_gds_push_update()[source]ΒΆ

Schedule the next periodic GDS Push server certificate and trustlist update using Django-Q2.

Creates a one-off scheduled task in Django-Q2 that will execute at the calculated time based on the configured renewal interval. Does nothing when periodic updates are disabled or the device is not of type OPC UA GDS Push.

Return type:

None

class devices.models.RemoteDeviceCredentialDownloadModel(*args, **kwargs)[source]ΒΆ

Bases: django.db.models.Model

Model to associate a credential model with an OTP and token for unauthenticated remoted download.

BROWSER_MAX_OTP_ATTEMPTS = 3[source]ΒΆ
TOKEN_VALIDITY[source]ΒΆ
issued_credential_model[source]ΒΆ
otp[source]ΒΆ
device[source]ΒΆ
attempts[source]ΒΆ
download_token[source]ΒΆ
token_created_at[source]ΒΆ
class Meta[source]ΒΆ

Bases: django_stubs_ext.db.models.TypedModelMeta

Meta class configuration.

save(*args, **kwargs)[source]ΒΆ

Generates a new random OTP on initial save of the model.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

None

get_otp_display()[source]ΒΆ

Return the OTP in the format β€˜credential_id.otp’ for display within the admin view.

Returns:

The str to display.

Return type:

str

check_otp(otp)[source]ΒΆ

Check if the provided OTP matches the stored OTP.

Parameters:

otp (str) – The OTP to check.

Returns:

True if the OTP is valid, False otherwise.

Return type:

bool

check_token(token)[source]ΒΆ

Check if the provided token matches the stored token and whether it is still valid.

Parameters:

token (str) – The token to check.

Returns:

True if the token is valid, false otherwise.

Return type:

bool