# Visualizing Pulp3 data schema
## Tools
* pulpcore-manager
* talking directly to Django
* pulpcore-manager shell
* talking to Django interactively
* programming in python
* pulp-cli
* admin tool
* protects you from direct-REST-calls
* https://github.com/pulp/pulp-cli
* https://yum.theforeman.org/pulpcore/3.14/el7/x86_64/
* packaged in satellite-tools?
* need to check w/ build/release team
* jq
* Format/query JSON output
* esp useful for RESZT/pulp-cli output
* django-extensions graph_models
* https://django-extensions.readthedocs.io/en/latest/graph_models.html
* uses `graphviz` to create schema-graph
* A graphviz-visualizer
* pydot
* pygraphviz
* http://graphviz.it/
## Setup (Fedora34)
* dnf install graphviz python3-graphviz python3-pygraphviz
* pip install django-extensions pyparsing pydot
* these aren't available in RPMs (that I know of?)
## Recipes
### "Show me All Of Pulp3!"
* `pulpcore-manager graph_models --pydot -a -g -o all_pulp3.png`
* ERROR - this is...too much, at least for my machine
### "Create a dotfile for All Of Pulp3, I'll look at it in another tool"
* `pulpcore-manager graph_models -a > all_pulp3.dot`
* Hand it to a visualizer
* http://graphviz.it/
### "Show me...Just pulp_rpm?"
* Limit by django-application (ie plugin)
* `pulpcore-manager graph_models APPNAME --pydot -g -o APPNAME_visualized.png`
* APPNAME can be found from Pulp3 status output
* Example:
```
$ pulp status | jq '.versions[].component'
"core"
"file"
"rpm"
"container"
"deb"
"certguard"
"pulp_2to3_migration"
```
* `pulpcore-manager graph_models rpm --pydot -g -o rpm_visualized.png`
* file:///home/ggainey/github/Pulp3/graph_models/rpm_visualized.png
### "That's still...A Lot. How about just Package-related Stuff?"
* Use -I to select-by-model.
* Wildcards are supported
```
pulpcore-manager graph_models \
-a \
-I Content*,Artifact,Package,Repository,Remote,UpdateRecord, Rpm* \
--pydot -g -o package_stuff.png
```
* file:///home/ggainey/github/Pulp3/graph_models/package_stuff.png
### "Cool, cool - where do I get these model-names?"
* "core", below, is an APPNAME
```
$ pulpcore-manager shell
from django.apps import apps
app_models = apps.get_app_config("core").get_models()
names = [m.__name__ for m in app_models]
for name in sorted(names):
print(name)
```