Git Product home page Git Product logo

Comments (9)

jasonking3 avatar jasonking3 commented on August 29, 2024

Just for a little background on this repo, we have not taken the view that the SDK should simply be Python bindings for the vManage API, rather that it is OK to put additional logic in places where it makes sense. That said, this repo also houses the CLI and the Ansible modules and they are probably the most widely used abstractions of the SDK. The poll-for-action-completion logic could be moved there instead (and would need to be completed and tested for any PR that changes the attach logic due to the way we version things at the moment.)

On the other hand, will it be a common use case that we would want to attach a device to a template and not know whether it completed or not? I don't really know the answer to that and could certainly be convinced that it would be a common use case. In our use case (primarily automation for DevOps CI/CD) it is not something we need.

from python-viptela.

jeremypng avatar jeremypng commented on August 29, 2024

I guess I want a snappy API call that doesn't block. I'm using this in a function passed to a Django-RQ worker. The default rqworker timeout on Netbox where I'm using this is 300 seconds. Most of the time the actions on VManage complete in that time, but I don't want to depend on it and not get the actionId back so I can easily go check it later. Once I have the actionId, an RQ-Scheduler job runs periodically to pull the status of any outstanding actions (on DNA Center or Vmanage). If no one else has that need, I can just modify it before I install it. It's a small change.

from python-viptela.

jlothian avatar jlothian commented on August 29, 2024

What about just adding a new parameter wait that defaults to true and does the waitfor_action_completion - that way your code can still use the library without modification, but none of the existing code needs to be changed.

from python-viptela.

jasonking3 avatar jasonking3 commented on August 29, 2024

That approach works for me. If we do this PR, we should probably look at all areas waitfor_action_completion is used and do something similar. @jeremypng - are you up for submitting a PR that adds a wait parameter with default true in these places?

from python-viptela.

jeremypng avatar jeremypng commented on August 29, 2024

Sure, I'll look through and find the other spots it is used and add wait to those as well.

I also need to be able to query the actionId's status on demand. I could add that function to utilities alongside the current waitfor_action_completion. Would you guys rather have that in a separate PR?

from python-viptela.

jasonking3 avatar jasonking3 commented on August 29, 2024

Would you guys rather have that in a separate PR?

I'm OK with it being in the same PR because it is something we should have for when wait is false. But @jlothian might have other feelings on that.

from python-viptela.

jlothian avatar jlothian commented on August 29, 2024

I'm with @jasonking3 - the changes are pretty well related, and I don't think it would make the review unwieldy to have it all lumped together.

from python-viptela.

jeremypng avatar jeremypng commented on August 29, 2024

Ok, I found several to add wait to but found these 3 where it doesn't make sense:

  1. ansible\vmanage.py - This already has a vmanage_params which defines wait and takes care of this from Ansible
  2. apps\clean.py - This would fail to delete the policy if the action didn't complete. So no need to add it here.
  3. data\template_data.py - The import_attachment_list is a long running batch job that wants the results. So no need to add it here.

There are the spots I am adding it:

  1. api\certificate.py - install_device_cert, push_certificates
  2. api\device_templates.py - reattach_device_template, attach_to_template

Then add a function called get_action_status that returns the same data structure as waitfor_action_completion, but instead of looping will just return whatever it gets on the first request.

Let me know if that sounds good and I'll test the changes and then submit a PR.

from python-viptela.

jasonking3 avatar jasonking3 commented on August 29, 2024

This sounds reasonable to me. It makes sense that the only place we should need this is in the api methods. I'm fine with the get_action_status name. 👍

from python-viptela.

Related Issues (20)

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.