Coder Social home page Coder Social logo

Comments (17)

mrgohin avatar mrgohin commented on July 24, 2024 2

I'll have a look into it. Give me few hours.

from icingaweb2-module-netboximport.

luto avatar luto commented on July 24, 2024

The stack trace seem to be missing the actual error/exception message. Can you take another look and get the full one, please?

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

This is the only other message I can see:
image

from icingaweb2-module-netboximport.

luto avatar luto commented on July 24, 2024

What does the content of https://my-netbox-instance.de/api/ipam/ip-addresses/ look like?

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

it looks like this, at least the first 50 lines:

# curl -H "Authorization: Token XXX" "https://my-netbox-instance.de/api/ipam/ip-addresses/"  | jq . | head -50
{
  "count": 453,
  "next": "https://my-netbox-instance.de/api/ipam/ip-addresses/?limit=50&offset=50",
  "previous": null,
  "results": [
    {
      "id": 348,
      "family": {
        "value": 4,
        "label": "IPv4"
      },
      "address": "10.0.0.23/32",
      "vrf": null,
      "tenant": null,
      "status": {
        "value": "active",
        "label": "Active",
        "id": 1
      },
      "role": null,
      "interface": {
        "id": 3169,
        "url": "https://my-netbox-instance.de/api/virtualization/interfaces/3169/",
        "device": null,
        "virtual_machine": {
          "id": 15,
          "url": "https://my-netbox-instance.de/api/virtualization/virtual-machines/15/",
          "name": "XYZ"
        },
        "name": "Port1"
      },
      "nat_inside": null,
      "nat_outside": null,
      "dns_name": "",
      "description": "",
      "tags": [],
      "custom_fields": {},
      "created": "2019-12-13",
      "last_updated": "2019-12-13T14:45:53.230998Z"
    },
    {
      "id": 274,
      "family": {
        "value": 4,
        "label": "IPv4"
      },
      "address": "10.0.0.42/32",
      "vrf": null,
      "tenant": null,
      "status": {
      ..........

from icingaweb2-module-netboximport.

mrgohin avatar mrgohin commented on July 24, 2024

May I just give the hint that I have already created a pull request fixing this specific issue a while ago. If I'm not mistaken its related to the fact that Netbox project had renamed various things in their api which result in the given error.

from icingaweb2-module-netboximport.

luto avatar luto commented on July 24, 2024

close as per #12.

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

thank you for looking into this.
I checked out 277794d but the behavior hasn't changed.

Do you have a setup running which uses NetBox >= 2.9?

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

Today I was working on a different project which uses the NetBox API and I found out that the API ip-addresses model change in => 2.9

It is now separated in dcim.interface and virtualization.interface. Ip-address has no atteibute "interface" anymore.

https://netbox.readthedocs.io/release-notes/

Their "documentation" of API changes is horrible. Also API schema versioning seems to be an unknown concept.

To be compatible with different versions you either need an autodetction by first querying the API version or add a switch to the settings menu to let the user select the correct version.

Juat writing this hurts my brain.

from icingaweb2-module-netboximport.

luto avatar luto commented on July 24, 2024

we're fine with only supporting the latest netbox version, if anyone is up for creating a PR.

from icingaweb2-module-netboximport.

mrgohin avatar mrgohin commented on July 24, 2024

I'm sorry was traveling all day long today. I have almost my netbox instance running and will look into it tomorrow. If it is not a total nightmare I'll also provide an PR.

There is just one more question, should legacy support be included or just the newest netbox api version?

from icingaweb2-module-netboximport.

luto avatar luto commented on July 24, 2024

we're fine with only supporting the latest version.

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

we're fine with only supporting the latest version.

I think so too. Maybe the git commits which support a certain NetBox version should be tagged accordingly and then you just need to use the correct tag to be able to work with older versions.

from icingaweb2-module-netboximport.

mrgohin avatar mrgohin commented on July 24, 2024

So I'm already about to fix this mess which latest netbox release had brought to us...

There was also a point where I fixed a fix because they changed object active status again.... First it was just "status=1" then "status.id=1" now its "status.value:active" ... I don't know but lets skip this...

Now I'm stuck at the point that I don't see any error in the code anymore but director import is still running in this particular error:

Undefined property: stdClass::$device

#0 /usr/share/webapps/icingaweb2/modules/netboximport/library/Netboximport/ProvidedHook/Director/ImportSource.php(171): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(Integer, String, String, Integer, Array)
#1 /usr/share/webapps/icingaweb2/modules/netboximport/library/Netboximport/ProvidedHook/Director/ImportSource.php(260): Icinga\Module\Netboximport\ProvidedHook\Director\ImportSource->fetchInterfaces()
#2 /usr/share/webapps/icingaweb2/modules/director/library/Director/Web/Table/ImportsourceHookTable.php(100): Icinga\Module\Netboximport\ProvidedHook\Director\ImportSource->fetchData()
#3 /usr/share/webapps/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/SimpleQueryBasedTable.php(29): Icinga\Module\Director\Web\Table\ImportsourceHookTable->prepareQuery()
#4 /usr/share/webapps/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/SimpleQueryBasedTable.php(15): gipfl\IcingaWeb2\Table\SimpleQueryBasedTable->getQuery()
#5 /usr/share/webapps/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(56): gipfl\IcingaWeb2\Table\SimpleQueryBasedTable->getPaginationAdapter()
#6 /usr/share/webapps/icingaweb2/modules/incubator/vendor/gipfl/icingaweb2/src/Table/QueryBasedTable.php(255): gipfl\IcingaWeb2\Table\QueryBasedTable->getPaginator(Object(gipfl\IcingaWeb2\Url))
#7 /usr/share/webapps/icingaweb2/modules/director/application/controllers/ImportsourceController.php(149): gipfl\IcingaWeb2\Table\QueryBasedTable->renderTo(Object(Icinga\Module\Director\Controllers\ImportsourceController))
#8 /usr/share/webapps/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Director\Controllers\ImportsourceController->previewAction()
#9 /usr/share/webapps/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch(String)
#10 /usr/share/webapps/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#11 /usr/share/webapps/icingaweb2/library/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#12 /usr/share/webapps/icingaweb2/library/Icinga/Application/webrouter.php(99): Icinga\Application\Web->dispatch()
#13 /usr/share/webapps/icingaweb2/public/index.php(4): require_once(String)
#14 {main}

My current point of view is this commit: m4k5ym/icingaweb2-module-netboximport@3b646c87c3789485fbbebd106b17c7e99569d5eb

My current conclusion is that netbox api is somehow.. I don't know if they ever came on the idea to implement a thing its called version control in their api...

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

Oh boy I feel you.

Thank you for looking into this.

I had the same felling. Why don't they use API schema versioning? /api/v1/dcim.devices?

I just assume It's tied so close to the Django data model that it would be a lot of pain to keep backwards compatibility.

I really would like to help you but I struggle with two issues:

  • how can I debug the code easier then doing a reload in the browser and getting stack trace? This seems quite painful.
  • my PHP coding skills are quite rusty. had to look up what the ...$something operator actually means.

from icingaweb2-module-netboximport.

mrgohin avatar mrgohin commented on July 24, 2024

Its a total nightmare what they have changed and how it adapts to the module code.

So I reworked the whole fetchInterfaces() function and its works!

I'd like to address three issues I was facing actually:

  1. They changed for the thrid time how the status value now (...)
  2. They changed the behavior how a referenced object is referenced means you get the full path (http://ac.me:8000/api/ipam/blabla) instead of endpoint path only (/ipam/blabla) now (preg_match)
  3. For whatever reason php couldn't handle the dynamic path for objects anymore. (switch_case)

I will save my conclusion this time. I'll end this with two words: "GRAPHQL" and "VERSIONING" and

Good night, good fight!

from icingaweb2-module-netboximport.

bb-Ricardo avatar bb-Ricardo commented on July 24, 2024

Wow, thank you very much. You spent all night fixing it?

I will check it out on Monday it give you feedback.

from icingaweb2-module-netboximport.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.