netbox 2.10.3 cannot create site

21 views
Skip to first unread message

bgaz

unread,
Jan 18, 2021, 7:54:06 AM1/18/21
to NetBox

I am adding tenant and sites, to link a site to tenant i used to get tenant id. But something has changed in the new version and below code gives error AttributeError: 'NoneType' object has no attribute 'id'. It looks like ndev_tenant.id has no .id attribute. What should i use instead of id?

my code:

for [tenant,site,descr,descrSite] in f:

    try:

        ndev_tenant = nb.tenancy.tenants.get(slug=tenant)

        tenant_id=ndev_tenant.id

        nb.dcim.sites.create (

            name = site,

            slug = site,

            tenant = tenant_id,

            description = descrSite,

            )


Rob Duffy

unread,
Jan 18, 2021, 10:38:48 AM1/18/21
to bgaz, NetBox
The tenant slug likely doesn't exist or is just misspelled.  Try printing ndev_tenant to see what it returns. 

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/d05498a2-5bc5-4b83-872f-7f757b8c9385n%40googlegroups.com.

bgaz

unread,
Jan 18, 2021, 11:08:51 AM1/18/21
to NetBox
Thanks you were right!
Reply all
Reply to author
Forward
0 new messages