Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit aa2c3f1

Browse files
author
Michael Smith
committed
2 parents b61e0c5 + e35e0b4 commit aa2c3f1

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

docs/source/applications.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Applications
1111
visualizations
1212
eventfeeds
1313
intersite
14+
fakeapic

docs/source/fakeapic.rst

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Fake APIC
2+
=========
3+
4+
5+
Purpose
6+
--------
7+
8+
- The Fake APIC is designed for users to view Managed Objects (and
9+
their properties) based on JSON configuration files
10+
- The Fake APIC works as an **offline-tool** for users who may not have
11+
access to the APIC, but still want to see certain (or all) Managed
12+
Objects on the network.
13+
14+
Usage
15+
-----
16+
17+
1. To generate JSON configuration files, use the snapback application
18+
located at ``acitoolkit/applications/snapback``
19+
2. Run the ``aciconfigdb.py`` file
20+
21+
.. code:: python
22+
23+
python aciconfigdb.py -u <APIC url> -l <login> -p <password> -s -a
24+
25+
- The ``-s`` option takes the snapshot of the configuration from the
26+
APIC
27+
- The ``-a`` option ensures the configuration includes all properities
28+
of the class objects
29+
30+
- It's **very important** to give the ``-a`` because the Fake APIC
31+
depends on the all properities of the class objects
32+
33+
- The JSON files will be located at:
34+
``acitoolkit/applications/snapback/apic-config-db``
35+
- Depending on the APIC, getting all the data may take around 5 - 8
36+
seconds
37+
38+
- Modify a sample file such as ``aci-show-epgs.py`` to use the FakeSession class
39+
from the Fake APIC
40+
41+
- Pass in the JSON files to the FakeSession
42+
constructor
43+
44+
.. code-block:: python
45+
46+
from os import lisdir
47+
from acitoolkit.acifakeapic import FakeSession
48+
...
49+
...
50+
# Set the directory to the location of the JSON files
51+
directory = 'applications/snapback/apic-config-db/'
52+
filenames = [directory + file for file in listdir(directory)
53+
if file.endswith('.json')]
54+
55+
# Create the session
56+
session = FakeSession(filenames)
57+
58+
- Run the file
59+
60+
.. code:: python
61+
62+
python aci-show-epgs.py -u <dummy url> -l <dummy login> -p <dummy password>
63+
64+
- Since this file will be using the Fake APIC, you can pass in *any*
65+
value for the url, login, and password
66+
- The Fake APIC works by retrieving data from the JSON files to mimick
67+
responses from the real APIC
68+
- Users can pass in queries such as
69+
``/api/mo/uni/tn-tenant1/BD-Br1.json?query-target=children``
70+
to get back responses.
71+
72+
How to pass in queries to the Fake APIC
73+
---------------------------------------
74+
75+
.. code-block:: python
76+
77+
...
78+
...
79+
# to print the data nicely
80+
import json
81+
82+
session = FakeSession(filenames)
83+
query = '/api/mo/uni/tn-tenant1/BD-1.json?query-target=children'
84+
fake_ret = fake_session.get(query)
85+
fake_data = fake_ret.json()['imdata']
86+
data = fake_ret.json()['imdata']
87+
# print the data from the Fake APIC
88+
print json.dumps(data, indent=4)
89+
90+
91+
What queries the Fake APIC supports
92+
-----------------------------------
93+
94+
- Any queries starting with ``api/mo/`` can have the **scoping
95+
filters** of
96+
- query-target
97+
- rsp-subtree
98+
- target-subtree-class
99+
- Queries starting with ``api/node/class`` can only have the
100+
``query-target`` with the value of ``self``
101+
102+
- values of rsp-subtree and target-subtree-class are supported
103+
104+
- For more information regarding **scoping filters** see page 12 of the
105+
`Cisco APIC REST API User Guide <http://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/1-x/api/rest/b_APIC_RESTful_API_User_Guide.pdf>`__
106+
under the section "Applying Query Scoping Filters"
107+
108+
Dependencies
109+
------------
110+
111+
- Python 2.7
112+
- Data in the JSON configuration files
113+
- The Fake APIC can **only** retrieve data that are in the JSON files,
114+
it cannot retrieve any data from the real APIC
115+
- The Fake APIC does **not** check for bad queries

0 commit comments

Comments
 (0)