Skip to content

Package

nautobot_floor_plan

App declaration for nautobot_floor_plan.

FloorPlanConfig

Bases: NautobotAppConfig

App configuration for the nautobot_floor_plan app.

Source code in nautobot_floor_plan/__init__.py
class FloorPlanConfig(NautobotAppConfig):
    """App configuration for the nautobot_floor_plan app."""

    name = "nautobot_floor_plan"
    verbose_name = "Floor Plans"
    version = __version__
    author = "Network to Code, LLC"
    description = "Nautobot App for representing rack positions on per-location floor plan grids."
    base_url = "floor-plan"
    required_settings = []
    min_version = "2.0.0"
    max_version = "2.9999"
    default_settings = {
        "default_x_axis_labels": AxisLabelsChoices.NUMBERS,
        "default_y_axis_labels": AxisLabelsChoices.NUMBERS,
    }
    caching_config = {}

    def validate_config_options(self):
        """Validates app configuration options."""
        x_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_x_axis_labels")
        y_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_y_axis_labels")
        valid_choices = AxisLabelsChoices.values()
        if x_axis_labels not in valid_choices or y_axis_labels not in valid_choices:
            msg = f"nautobot_floor_plan improperly configured. Valid config options for default_x_axis_labels or default_y_axis_labels are: {', '.join(valid_choices)}, plugin config is: default_x_axis_labels: {x_axis_labels}, default_y_axis_labels: {y_axis_labels}"
            raise ImproperlyConfigured(msg)

    def ready(self):
        """Callback after app is loaded."""
        super().ready()
        self.validate_config_options()

ready()

Callback after app is loaded.

Source code in nautobot_floor_plan/__init__.py
def ready(self):
    """Callback after app is loaded."""
    super().ready()
    self.validate_config_options()

validate_config_options()

Validates app configuration options.

Source code in nautobot_floor_plan/__init__.py
def validate_config_options(self):
    """Validates app configuration options."""
    x_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_x_axis_labels")
    y_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_y_axis_labels")
    valid_choices = AxisLabelsChoices.values()
    if x_axis_labels not in valid_choices or y_axis_labels not in valid_choices:
        msg = f"nautobot_floor_plan improperly configured. Valid config options for default_x_axis_labels or default_y_axis_labels are: {', '.join(valid_choices)}, plugin config is: default_x_axis_labels: {x_axis_labels}, default_y_axis_labels: {y_axis_labels}"
        raise ImproperlyConfigured(msg)