Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: adds some nautobot docs and examples #563

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions docs/user-guide/nautobot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Nautobot

## Nautobot Django shell

You can access the Nautobot Django shell by connecting to the pod and running the
`nautobot-server shell` command.

``` bash
# find one of the nautobot app pods
kubectl get pod -l app.kubernetes.io/component=nautobot-default
NAME READY STATUS RESTARTS AGE
nautobot-default-598bddbc79-kbr72 1/1 Running 0 2d4h
nautobot-default-598bddbc79-lnjj6 1/1 Running 0 2d4h
```

``` bash
# use the nautobot-server shell
kubectl exec -it nautobot-default-598bddbc79-kbr72 -- nautobot-server shell
```

## Nautobot GraphQL Queries

### Query for all servers in a specific rack

This queries devices with the role `server` located in rack `rack-123`
and includes the iDRAC/iLO BMC IP address.

``` graphql
query {
devices(role: "server", rack: "rack-123") {
id
name
interfaces(name: ["iDRAC", "iLO"]) {
ip_addresses {
host
}
}
}
}
```

Output example:

``` json title="rack-123-devices-output.json"
{
"data": {
"devices": [
{
"id": "4933fb3d-aa7c-4569-ae25-0af879a11291",
"name": "server-1",
"interfaces": [
{
"ip_addresses": [
{
"host": "10.0.0.1"
}
]
}
]
},
{
"id": "f6be9302-96b0-47e9-ad63-6056a5e9a8f5",
"name": "server-2",
"interfaces": [
{
"ip_addresses": [
{
"host": "10.0.0.2"
}
]
}
]
}
]
}
}
```

Some jq to help parse the output:

``` bash
cat rack-123-devices-output.json | jq -r '.data.devices[] | "\(.id) \(.interfaces[0]["ip_addresses"][0]["host"])"'
```

Output:

``` text
4933fb3d-aa7c-4569-ae25-0af879a11291 10.0.0.1
f6be9302-96b0-47e9-ad63-6056a5e9a8f5 10.0.0.2
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ nav:
- user-guide/openstack-ironic.md
- user-guide/openstack-placement.md
- user-guide/rook-ceph.md
- user-guide/nautobot.md
- Workflows: workflows/
Loading