GithubHelp home page GithubHelp logo

falkowich / pyise-ers Goto Github PK

View Code? Open in Web Editor NEW
27.0 9.0 31.0 821 KB

Python module to manage Cisco ISE via the ERS API

License: GNU General Public License v2.0

Python 99.51% Makefile 0.49%
cisco-ise ers api python3

pyise-ers's People

Contributors

c-thornton avatar ciscohank avatar dependabot[bot] avatar falkowich avatar jasonbarbee avatar jonasks avatar joshand avatar karrots avatar nebriv avatar pyup-bot avatar rasmusthing avatar snyk-bot avatar sweickge avatar the-captain8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyise-ers's Issues

paging of results

Attempting to get a list of all network devices (to then enumerate the location for each of them).

But i can't find any information on expanding or even paging the results.

TIA

Help with maintenance of this repo.

Hi,

I am having some real life time issues for the moment ™️
Work is taking almost all my "free time" as well.
And there are so many good PR's that has been merged, and many waiting to be merged.

So if anyone out there wish to help out, I would be really thankful.

It would be great to have a core group of maintainers to get this up to speed.
Make it a community project more, with community discussions and descisions.

But one step at a time :)

--
Kind Regards Falk

Add filter to get_device_groups

get_device_groups should support the filter variable.
Cisco ISE supports contains and ncontains as filters.
Searching for Network Device Groups by name, can only use the 'contains' or 'ncontains' filters

`def get_device_groups(self, filter=None):
"""
Get a list tuples of device groups.

    :return:
    """
    return self._get_groups(
        "{0}/config/networkdevicegroup".format(self.url_base),
        filter=filter
    )`

Library doesn't use timeout in all requests library function calls

This library doesn't include the timeout attribute when self.ise.get() is called. Timeout is only used for self.ise.request() in the internal _request() function. That function also includes an earlier call to self.ise.get() without a timeout before calling self.ise.request() with a timeout. Thus, the configured timeout seldom has any effect that I have seen.

The argument "timeout=self.timeout" should be added to every self.ise.get() call

When using "faulty" credentials we get a JSONDecodeError.

Seems like a regression.

(ise) falk@broekn-home:~/dev/ise$ /home/falk/.local/share/virtualenvs/ise-B3LG4bZL/bin/python /home/falk/dev/ise/test/test_ers.py
{'success': False, 'response': '', 'error': ''} <Response [401]>
<Response [401]>
Traceback (most recent call last):
  File "/home/falk/dev/ise/test/test_ers.py", line 187, in <module>
    add_endpoint(endpoint)
  File "/home/falk/dev/ise/test/test_ers.py", line 24, in add_endpoint
    test = ise.add_endpoint(endpoint['name'], endpoint['mac'], endpoint['group-id'])  # noqa: E501
  File "./ise.py", line 353, in add_endpoint
    return ERS._pass_ersresponse(result, resp)
  File "./ise.py", line 77, in _pass_ersresponse
    print(resp.json())
  File "/home/falk/.local/share/virtualenvs/ise-B3LG4bZL/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Pages and Sizes

Hello, I am not sure if this is an issue or not, but I have a need to query around 2000 devices. There seems to be a page/size option that you can specify:
device_list_1 = ise.get_devices(size=20, page=1)['response']

I believe the max size is 100, so to get to 2000, I'd make requests for 20 pages. Is there another mechanism to follow the next page?
For example, using Postman to make a request, I see this at the end of the output:

"nextPage": {
"rel": "next",
"href": "https://x.x.x.x:9060/ers/config/networkdevice?size=45&page=2",
"type": "application/json"

However, in the output of using ise.get request, the output never shows the next page.

Thanks

add get_endpoint_byname

Tried to do this tonight..
Remembered that it isn't implemented yet.

Method:	GET
URI:	https://servername:9060/ers/config/endpoint/name/{name}

Bulk support

Hi,

Great module, really helped to bring up the connection.
Need to support bulk endpoint addition, any plans for it ?

Thanks, @falkowich !

On ISE 3.0 a faulty connection doesn't return "response": Unauthorized

(pyise-ers) falk@broekn-home ~/dev/pyise-ers (master ✭ ✗) » pytest --record-mode=rewrite
========================== test session starts =========================
platform linux -- Python 3.7.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/falk/dev/pyise-ers, configfile: pytest.ini
plugins: cov-3.0.0, recording-0.12.0
collected 188 items

test/test_ise_27.py .............................................................................................. [ 50%]
test/test_ise_30.py F............................................................................................. [100%]

========================= FAILURES =========================
___________________________________________________________________________________________ test_fail_connection_401 ___________________________________________________________________________________________

@pytest.mark.vcr
def test_fail_connection_401():  # noqa D103

    r1 = fail_ise.add_endpoint(endpoint["name"], endpoint["mac"], endpoint["group-id"])
  assert r1["response"] == "Unauthorized"

E AssertionError: assert '' == 'Unauthorized'
E - Unauthorized

test/test_ise_30.py:50: AssertionError
========================= short test summary info =========================
FAILED test/test_ise_30.py::test_fail_connection_401 - AssertionError: assert '' == 'Unauthorized'
=========================1 failed, 187 passed in 59.39s =========================

looking for some suggestion to implement some ISE commands

Hi,

Thanks for the library, I was going over documentation and found a naive way to do things. I want to improve the performance of what I want to accomplish so wondering if any of you can suggest something. Thank you very much:

  1. I am looking for an API call to add Mac addresses(could be 100s/1000s too)to certain identity group. I get a duplicate error, so looks like ISE throws an error if the endpoint/mac address is already present in a different identity group. Seems like in such cases I need to reassign them to the appropriate identity group instead of using the add_endpoint function. Is there any function for it or should I delete the endpoint and then add? Ideally, to have this process efficient, I am looking for an endpoint to get all the Mac addresses with their affiliated identity group so that I can make an update as needed by calling an update function. Also, seems I should do it one Mac address after another, Is there any other good way of doing it?

I see we could update the metadata affiliated i.e identity group for endpoint by using PUT request, example: https://ciscoisesdk.readthedocs.io/en/latest/_modules/ciscoisesdk/api/v3_1_0/endpoint.html#Endpoint.update_endpoint_by_id
and it works,

  1. I am looking at bulk endpoint for the above action and seems it's suggested to be done outside the library. Any reason why, it can be just a new argument with bulk=True to existing endpoints? By doing it outside, All I need to do is have a derived class and have a few new methods right?

Defork and namechange to get compliance against Cisco DevNet policies.

After an suggestion to publish this library in the Cisco DevNet community I have started a discussion with Github Support to defork from the original forks. And mpenning had no concerns about that » discussion here

But the libraryname is sadly to generic today to get it published in DevNet, so there if we shall publish it there the repo must change name. Perhaps to something like easy like iselibrary, iselib or suggestions. All the names I can come up with is.. perhaps not so enterprisy. :)
Like SNISEL (SuperNextgenerationISELibrary) :D

Any Ideas about namechange, reponame and such. Pls comment or reach out to me in a DM .

Plan as of 2021-10-20..

  • contact github support about this.
  • defork with the help of github support
  • rename repository to pyise-ers
  • rename module to pyiseers
  • Start with the PR's
  • Recommit the package on PyPI as pyise-ers

--
Regards Falk

Dynamic pagination for _get_groups and _get_objects

Remove the size and page variables for the _get_groups and _get_objects functions and add dynamic pagination in the library itself.

This will avoid users of the library to make duplicate code to paginate the endpoints themselves.

It's even written in the library as a TODO :)
# TODO add dynamic paging?

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.