Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm_tenant_relation #206

Closed
akurach opened this issue Jun 28, 2022 · 12 comments
Closed

vm_tenant_relation #206

akurach opened this issue Jun 28, 2022 · 12 comments
Labels
awaiting reply Awaiting reply from issue owner
Milestone

Comments

@akurach
Copy link

akurach commented Jun 28, 2022

issue with assigning vm with Tenant if vm_tenant_relation is exist

INFO: Tenant 'NAME' attribute 'slug' changed from 'u0002-slug' to '-'

So if tenant already exists - its rewrite slug to '-'

@bb-Ricardo
Copy link
Owner

Hi,

It would be helpful to get some more information. How does the config look like? can you run the tool with -l DEBUG2 and post the output around the issue here?

The tenant exists in NetBox? How does it look like?

@akurach
Copy link
Author

akurach commented Jun 30, 2022

Here is existing Tenant

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 84,
      "url": "https://netbox.site/api/tenancy/tenants/84/",
      "display": "test",
      "name": "test",
      "slug": "test-sync",
      "group": null,
      "description": "",
      "comments": "",
      "tags": [
        {
          "id": 2,
          "url": "https://netbox.site/api/extras/tags/2/",
          "display": "Development",
          "name": "Development",
          "slug": "development",
          "color": "9e9e9e"
        }
      ],
      "custom_fields": {
        "documentation": null,
        "git": null
      },
      "created": "2022-06-30T13:20:02.496277Z",
      "last_updated": "2022-06-30T13:20:02.496307Z",
      "circuit_count": 0,
      "device_count": 0,
      "ipaddress_count": 0,
      "prefix_count": 0,
      "rack_count": 0,
      "site_count": 0,
      "virtualmachine_count": 0,
      "vlan_count": 0,
      "vrf_count": 0,
      "cluster_count": 0
    }
  ]
}

Logs from DEBUG2:

INFO: Updating NetBox 'tenant' object 'test' with data: {'slug': 'test', 'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: i.local'}, {'name': 'Development'}]}
2022-06-30 16:23:57,125 - DEBUG2: Sending PATCH to 'https://netbox.site/api/tenancy/tenants/84/' with data 'b'{"slug": "test", "tags": [{"name": "NetBox-synced"}, {"name": "Source: i.local"}, {"name": "Development"}]}''.

Tenant after sync:

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 84,
      "url": "https://netbox.site/api/tenancy/tenants/84/",
      "display": "test",
      "name": "test",
      "slug": "test",
      "group": null,
      "description": "",
      "comments": "",
      "tags": [
        {
          "id": 2,
          "url": "https://netbox.site/api/extras/tags/2/",
          "display": "Development",
          "name": "Development",
          "slug": "development",
          "color": "9e9e9e"
        },
        {
          "id": 16,
          "url": "https://netbox.site/api/extras/tags/16/",
          "display": "NetBox-synced",
          "name": "NetBox-synced",
          "slug": "netbox-synced",
          "color": "9e9e9e"
        },
        {
          "id": 20,
          "url": "https://netbox.site/api/extras/tags/20/",
          "display": "Source: i.local",
          "name": "Source: i.local",
          "slug": "source-i-local",
          "color": "9e9e9e"
        }
      ],
      "custom_fields": {
        "documentation": null,
        "git": null
      },
      "created": "2022-06-30T13:20:02.496277Z",
      "last_updated": "2022-06-30T13:23:57.289743Z",
      "circuit_count": 0,
      "device_count": 0,
      "ipaddress_count": 0,
      "prefix_count": 0,
      "rack_count": 0,
      "site_count": 0,
      "virtualmachine_count": 6,
      "vlan_count": 0,
      "vrf_count": 0,
      "cluster_count": 0
    }
  ]
}

Config string:

vm_tenant_relation = u* = test

@bb-Ricardo
Copy link
Owner

Ok, looks good. Any reason why you changed the tenant slug in NetBox?

Otherwise the update seemed to work fine.

@akurach
Copy link
Author

akurach commented Jun 30, 2022

thats the main issue - slug was changed by sync update.
It sent PATH with slug = name

Updating NetBox 'tenant' object 'test' with data: {'slug': 'test',

@bb-Ricardo
Copy link
Owner

Can you explain why this causes an issue?

@akurach
Copy link
Author

akurach commented Jun 30, 2022

If question is about why I've created Tenant by hands:

I've got ansible playbook that creates all the tenants, and in our env we have different names and slug, including cyrillic names.

If talk more globally about our case:
tenant name = Information System Short Name ( usually cyrillic)
tenant slug = Infornation System Code ( from our register)

@bb-Ricardo
Copy link
Owner

Alright. I have to come up with a general solution to solve this. Currently the slug is created on demand from the name.

Will look into it next week.

@akurach
Copy link
Author

akurach commented Jun 30, 2022

Example:

Tenant Name: Simple_IS
Tenant Slug: u001-simpl

after sync slug will be 'simple-is'

Example2:
Tenant Name: Простая ИС
Tenant slug: u002-simpl2

after sync slug will be '-'

@bb-Ricardo
Copy link
Owner

True, it is pretty ignorant to assume objects are named using roman letters.

@akurach
Copy link
Author

akurach commented Jun 30, 2022

So expected behaviour for me look like
If tenant exists - just assosiate VM with it, do not rewrite tenant
if tenant not exists - create tenant with autoslug and assosiate vm with tenant

additional idea:
add to settings slug? so it will look like
vm_tenant_relation = vmregex = [name,slug] ,...

OR use slug in config insted of name?

@akurach
Copy link
Author

akurach commented Jun 30, 2022

True, it is pretty ignorant to assume objects are named using roman letters.

Agree, but Managers wants to see 'TRUE NAMES' in RU. Nevertheless the case is not about Cyrilic symbols :)

@bb-Ricardo bb-Ricardo added this to the 1.3.0 milestone Aug 24, 2022
bb-Ricardo added a commit that referenced this issue Aug 25, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@bb-Ricardo
Copy link
Owner

Hi,

Sorry it took quite a while. I just pushed a new commit to the development branch. Would you mind to test it and see if this fixes your issue?

Thank you

@bb-Ricardo bb-Ricardo added the awaiting reply Awaiting reply from issue owner label Aug 25, 2022
andreiKuznets0v pushed a commit to andreiKuznets0v/netbox-sync_try_vcloud that referenced this issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Awaiting reply from issue owner
Projects
None yet
Development

No branches or pull requests

2 participants