Skip to content

Cant use "." symbols in site name #95

@TawR1024

Description

@TawR1024
ISSUE TYPE
  • Bug Report
  • Feature Idea
SUMMARY

Cant use "." symbols in site name

STEPS TO REPRODUCE
- name: "Create Site"
  connection: local
  hosts: localhost
  collections:
   - netbox_community.ansible_modules
  gather_facts: False
  tasks:
    - name: Create site within Netbox with only required information
      netbox_site:
        netbox_url: "{{ url }}"
        netbox_token: "{{ token }}"
        data:
          name: test-1.one.two.org
          tenant: VPC
        state: present
EXPECTED RESULTS

expected slug is test_1_one_two_org

ACTUAL RESULTS

Got an error

But have message:
`"msg": "{\"slug\":[\"Enter a valid \\\"slug\\\" consisting of letters, numbers, underscores or hyphens.\"]}",`

To fix this bug:

def _to_slug(self, value):
        """
        :returns slug (str): Slugified value
        :params value (str): Value that needs to be changed to slug format
        """
        if value is None:
            return value
        elif isinstance(value, int):
            return value
        if " " in value:
            value = value.replace(" ", "_")
        if "." in value:
            value = value.replace(".", "_")
        value = value.lower()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions