Skip to content

Commit

Permalink
refactor: ♻️ Change random color to pull from ColorChoices
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrew82 committed Jan 5, 2024
1 parent 564a127 commit a49582c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion nautobot_ssot/integrations/aci/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import random

from nautobot.core.choices import ColorChoices
from nautobot.core.signals import nautobot_database_ready
from nautobot.extras.choices import CustomFieldTypeChoices

Expand Down Expand Up @@ -42,7 +43,7 @@ def aci_create_tag(apps, **kwargs):
if ("SITE" in key or "STAGE" in key) and not tag.objects.filter(name=apics[key]).exists():
tag.objects.update_or_create(
name=apics[key],
color="".join([random.choice("ABCDEF0123456789") for i in range(6)]), # noqa: S311
color=random.choice(ColorChoices.values()), # noqa: S311
)


Expand Down
3 changes: 2 additions & 1 deletion nautobot_ssot/integrations/device42/utils/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from taggit.managers import TaggableManager

from nautobot.circuits.models import CircuitType
from nautobot.core.choices import ColorChoices
from nautobot.dcim.models import Device, Interface, Platform
from nautobot.extras.choices import CustomFieldTypeChoices
from nautobot.extras.models import CustomField, Relationship, Role, Tag
Expand All @@ -32,7 +33,7 @@ def get_random_color() -> str:
Returns:
str: Hex code value for a color with hash stripped.
"""
return f"{random.randint(0, 0xFFFFFF):06x}" # noqa: S311
return random.choice(ColorChoices.values()) # noqa: S311


def verify_device_role(diffsync, role_name: str, role_color: str = "") -> UUID:
Expand Down

0 comments on commit a49582c

Please sign in to comment.