Git Product home page Git Product logo

pyaci's Introduction

pyaci's People

Contributors

agccie avatar amney avatar arunksaha avatar camrossi avatar ceridwen avatar codacy-badger avatar giovannimeo avatar jrecuero avatar kprav33n avatar sapshah-cisco avatar sreebvar 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyaci's Issues

How to use ResolveClass with subtreeClass

I am trying to get the lldp neighbours on an interface.

Initially I tried to do this:
lldp_neighbours = apic.methods.ResolveClass('lldpIf').GET(**options.filter(filters.Eq('lldpIf.portDesc',path.tDn)) & options.subtreeClass('lldpAdjEp') )
But this does not work and I am not getting anything back no lldpIf nor lldpAdjEp.

As a work around I did:

lldp_neighbours = apic.methods.ResolveClass('lldpIf').GET(**options.filter(filters.Eq('lldpIf.portDesc',path.tDn)) & options.rspSubtreeChildren )

This works fine and I can then just access the ldp_neighbour.lldpAdjEp instance but can't understand why the first option does not work. In this case is not a big issue as there aren't that many child of lldpIf but I would like to understand how you should this be done.

How to Query ACL Permit and Deny Logs

Looking to get information about how to perform these queries with Pyaci. There are some information in the article below at the end of the page titled "Viewing ACL Permit and Deny Logs Using the REST API"
Here

When running something like this:

result = apic.mit.polUni().fvTenant('Enterprise').GET(**options.subtreeClass('acllogPermitL3Pkt'))
I get an empty list.
To perform the same thing in Cobra ACI would be:
result = self.cobramd.lookupByClass('acllogPermitL3Pkt')

How would i perform this action in Pyaci?

Also how would i pass in an and filters?

Something like this:
result = apic.mit.GET(**options.subtreeClass('acllogPermitL3Pkt') & options.filter(filters.Wcard('acllogDropL3Pkt.dn', f"ndbgs/acllog/tn-{tenant}" filters.Wcard('acllogDropL3Pkt.destination') & filters.Wcard('acllogDropL3Pkt.srcIp','10.71.0.164')))

insieme.pymit.pyaccess?

Hello,

scripts/metagen.py:

"from insieme.pymit.pyaccess import PyClassDirectory"

Is this something Cisco-internal? I can't find that package anywhere. Is it possible to add it to the repo?

Sebastian

Allow rmetagen.py to be imported and used without arguments

I may be missing something obvious in how to import this module, but it seems like it is designed to only work from the command line. I would like to import it into my application to automate the generation of the meta. Something like this:

from Scripts import rmetagen

# If an existing session wasn't supplied, make a new session
if not isinstance(apic, Node): 
    try: 
        apic = Node(config['ACI APIC']['url'])
    except MetaError:
        # This implies that the meta hasn't been downloaded yet
        rmetagen.generateMeta(host, username, password)

Request to support large POST scenario

APIC responds with an API link to check the post status as PD needs more time to validate

pol.POST()
File "/python3.6/site-packages/pyaci/core.py", line 92, in POST
'POST', format=format, needData=True, **kwargs)
File "//python3.6/site-packages/pyaci/core.py", line 154, in _performRequest
raise RestError(response.text)
Request in progress, please check state using URL: /api/checkRequestState.xml?id=9570149234507776

Follow your document and it can't work?

>>> from pyaci import Node
>>> apic = Node('https://fra01-apic03.webex.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xiaosyu/pyACI_tset/env/lib/python3.10/site-packages/pyaci/core.py", line 196, in __init__
    raise MetaError('ACI meta was not specified !')
pyaci.errors.MetaError: ACI meta was not specified !

rmetagen.py traceback

The following traceback is seen if the .aci-meta directory does not exist. It would be nice if it was automatically created instead.

APIC is running version 2.2(1.79a)
Copying metagen.py to APIC
Invoking metagen.py on APIC
Copying generated meta from APIC to /Users/michsmit/.aci-meta/aci-meta.2.2(1.79a).json
Traceback (most recent call last):
File "/usr/local/bin/rmetagen.py", line 86, in <module>
main()
File "/usr/local/bin/rmetagen.py", line 66, in main
scp.get('aci-meta.json', destination)
File "/Library/Python/2.7/site-packages/scp.py", line 198, in get
self._recv_all()
File "/Library/Python/2.7/site-packages/scp.py", line 346, in _recv_all
command[code](msg[1:])
File "/Library/Python/2.7/site-packages/scp.py", line 385, in _recv_file
file_hdl = open(path, 'wb')
IOError: [Errno 2] No such file or directory: '/Users/michsmit/.aci-meta/aci-meta.2.2(1.79a).json'

Autopage resolver method exception in Python3

method.GET(autoPage=True) #, **opt)

File "lib64/python3.6/site-packages/pyaci/core.py", line 1101, in GET
newKwargs = dict(pageOptions.items() + kwargs.items())
TypeError: unsupported operand type(s) for +: 'dict_items' and ‘dict_items’

Errors with multiple GET requests

If I do multiple GET requests, one after another, pyaci gives errors as below. If I do either GET request by itself, it works fine. Am I doing something wrong or is this a bug?

Code:

sbm = apic.mit.polUni().fvTenant('sbm')
y = sbm.GET(**options.subtreeClass('fvAEPg'))
x = sbm.GET(**options.subtreeClass('fvSubnet'))

Error:

File "C:\Users\user\scripts\user_interaction_ipam.py", line 313, in <module>
  x= sbm.GET(**options.subtreeClass('fvSubnet'))
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 579, in GET
  subscriptionIds=subscriptionIds)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 544, in ParseXmlResponse
  mo = self.FromDn(element.attrib['dn'])
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 392, in FromDn
  return reduce(reductionF, splitIntoRns(dn), self)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 390, in reductionF
  return acc._spawnChildFromRn(className, rn)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 693, in _spawnChildFromRn
  return moIter(*identifierArgs)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 345, in __call__
  .format(self._parentApi.Dn, rn))

pyaci.errors.MoError: Mo with DN uni/tn-sbm/ap-Ec/epg-Ec_uat_app does not contain a child with RN subnet-[10.48.11.97/28]

If I reverse the GET requests, the following happens:

File "C:\Users\user\scripts\user_interaction_ipam.py", line 306, in <module>
  y = sbm.GET(**options.subtreeClass('fvAEPg'))
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 579, in GET
  subscriptionIds=subscriptionIds)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 544, in ParseXmlResponse
  mo = self.FromDn(element.attrib['dn'])
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 392, in FromDn
  return reduce(reductionF, splitIntoRns(dn), self)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 390, in reductionF
  return acc._spawnChildFromRn(className, rn)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 693, in _spawnChildFromRn
  return moIter(*identifierArgs)
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\pyaci\core.py", line 345, in __call__
  .format(self._parentApi.Dn, rn))

pyaci.errors.MoError: Mo with DN uni/tn-sbm does not contain a child with RN ap-legacy

How to add childern to a MO object?

How do i get an object with a direct call, and than add it's childern after?

Should look something like this:

#get a direct epg
epg_request = apic.mit.polUni().fvTenant(tenant_name).fvAp(app_name).fvAEPg(epg_name).GET()[0]
#add the childern of that EPG
epg_request.GET(**options.subtree)

Fix unit tests under Python 3

Currently unit tests are failing on Python 3. Most of them seem to be some kind of keys ordering assumption that was made by the test. Consult the last circleci build for more information.

Support multiple versions of ACI from the same Python process

In the current design, there is one version of ACI metadata loaded when the module is imported. All Node instantiations share this global metadata. However, there have been asks from various people the ability to talk to multiple versions of ACI from the same process. This can be supported by still having a global metadata, and providing an option in the Node to override the version.

ApiOptions.__and__ generates exception in Python3

Hello,

In the file options.py, the inplementation of the method and in the class ApiOptions generates an exception in Python3. The reason for this exception is that dict_items can not be added in Py3. The alternative implementation for this method, which is Python 2 and 3 compliant (tested locally) is provided below:

class ApiOptions(dict):
    def __and__(self, other):
        d = self.copy()
        d.update(other)
        return ApiOptions(d)

Could you please apply this fix to the official code repo?

Thanks,
Sven.

Unable to get ACL permits/drops in pyaci

I have attempted to use all the solutions provided above for getting packets, and my query is returning an empty list.
result = apic.methods.ResolveClass('acllogPermitL3Pkt').GET() result2 = apic.mit.polUni().fvTenant(tenant).GET(**options.subtreeClass('acllogPermitL3Pkt')) result3 = apic.methods.ResolveClass('acllogPermitL3Pkt').GET(**options.filter( filters.Wcard('acllogDropL3Pkt.dn', f"ndbgs/acllog/tn-{tenant}") & filters.Wcard('acllogDropL3Pkt.srcIp', "10.71.0.164"))) test = apic.mit.polUni().fvTenant(tenant).GET()
Originally posted by @the-modern-leo in #44 (comment)

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.