Skip to content

Device Model


Bases: CenturionModel

Attributes

config

config = JSONField(
    blank=True,
    help_text="Configuration for this device",
    null=True,
    validators=[validate_config_keys_not_reserved],
    verbose_name="Host Configuration",
)

device_model

device_model = ForeignKey(
    DeviceModel,
    blank=True,
    help_text="Model of the device.",
    null=True,
    on_delete=PROTECT,
    verbose_name="Model",
)

device_type

device_type = ForeignKey(
    DeviceType,
    blank=True,
    help_text="Type of device.",
    null=True,
    on_delete=PROTECT,
    verbose_name="Type",
)

get_configuration

get_configuration

inventorydate

inventorydate = DateTimeField(
    blank=True,
    help_text="Date and time of the last inventory",
    null=True,
    verbose_name="Last Inventory Date",
)

is_virtual

is_virtual = BooleanField(
    blank=True,
    default=False,
    help_text="Is this device a virtual machine",
    null=False,
    verbose_name="Is Virtual",
)

model_tag

model_tag = 'device'

modified

modified = AutoLastModifiedField()

name

name = CharField(
    blank=False,
    help_text="Hostname of this device",
    max_length=50,
    unique=True,
    validators=[validate_hostname_format],
    verbose_name="Name",
)

page_layout

page_layout: dict = [
    {
        "name": "Details",
        "slug": "details",
        "sections": [
            {
                "layout": "double",
                "left": [
                    "organization",
                    "device_type",
                    "device_model",
                    "name",
                    "serial_number",
                    "uuid",
                    "inventorydate",
                    "created",
                    "modified",
                ],
                "right": ["model_notes", "is_virtual"],
            },
            {
                "layout": "table",
                "name": "Operating System",
                "field": "operating_system",
            },
            {
                "layout": "table",
                "name": "Dependent Services",
                "field": "service",
            },
            {"layout": "single", "fields": ["config"]},
        ],
    },
    {
        "name": "Software",
        "slug": "software",
        "sections": [
            {"layout": "table", "field": "software"}
        ],
    },
    {
        "name": "Tickets",
        "slug": "tickets",
        "sections": [
            {"layout": "table", "field": "tickets"}
        ],
    },
    {
        "name": "Knowledge Base",
        "slug": "kb_articles",
        "sections": [
            {"layout": "table", "field": "knowledge_base"}
        ],
    },
    {"name": "Notes", "slug": "notes", "sections": []},
    {
        "name": "Config Management",
        "slug": "config_management",
        "sections": [
            {
                "layout": "single",
                "fields": ["rendered_config"],
            }
        ],
    },
]

reserved_config_keys

reserved_config_keys: list = ['software']

serial_number

serial_number = CharField(
    blank=True,
    help_text="Serial number of the device.",
    max_length=50,
    null=True,
    unique=True,
    verbose_name="Serial Number",
)

status

status: str

Fetch Device status

Returns:

Name Type Description
str str

Current status of the item

status_icon

status_icon: list([Icon])

table_fields

table_fields: list = [
    "status_icon",
    "name",
    "device_model",
    "device_type",
    "organization",
    "created",
    "modified",
    "model",
    "nbsp",
]

uuid

uuid = UUIDField(
    blank=True,
    help_text="System GUID/UUID.",
    max_length=50,
    null=True,
    unique=True,
    validators=[validate_uuid_format],
    verbose_name="UUID",
)

Classes

Meta

Attributes

ordering
ordering = ['name', 'organization']
verbose_name
verbose_name = 'Device'
verbose_name_plural
verbose_name_plural = 'Devices'

Functions

__str__

__str__()

clean_fields

clean_fields(exclude=None)

save

save(
    force_insert=False,
    force_update=False,
    using=None,
    update_fields=None,
)

Save Device Model

After saving the device update the related items so that they are a part of the same organization as the device.

validate_config_keys_not_reserved

validate_config_keys_not_reserved()

validate_hostname_format

validate_hostname_format()

validate_uuid_format

validate_uuid_format()

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-06-16
Date Edited: 2024-07-13

Contribution:

Would You like to contribute to our Centurion ERP project? You can assist in the following ways:

 

ToDo: Add the page list of contributors