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

edited creating a schema page #4785

Merged
merged 2 commits into from
Oct 30, 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
25 changes: 24 additions & 1 deletion docs/docs/guides/create-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ Load the schema into Infrahub in the `network-device-schema` branch
infrahubctl schema load --branch network-device-schema /tmp/schema_guide.yml
```

We can inspect the schema in the [Web UI](http://localhost:8000/schema?branch=network-device-schema) (Unified Storage > Schema)
We can inspect the schema in the [Web UI](http://localhost:8000/schema?branch=network-device-schema) (Unified Storage > Schema) as shown below.

![schema page screenshot](../media/guides/create_schema_1.png)

We'll create a device and an interface according to the schema, by executing the following GraphQL query

Expand All @@ -109,6 +111,25 @@ mutation {
}
```

Here is an example of using `curl` to make the query. Make sure to replace the `X-INFRAHUB-KEY` and the IP address with your actual details. Please also make sure to include the name of the branch in the URL. If you want to learn more about GraphQL, you can find more information [here](https://docs.infrahub.app/topics/graphql).

```graphql
curl -X POST http://localhost:8000/graphql/network-device-schema \
-H "Content-Type: application/json" \
-H "X-INFRAHUB-KEY: 1802eed5-eeb7-cc45-2e4d-c51de9d66cba" \
-d '{"query": "mutation { NetworkDeviceCreate(data: {hostname: {value: \"atl1-edge1\"}, model: {value: \"Cisco ASR1002-HX\"}}) { ok object { id } } NetworkInterfaceCreate(data: {name: {value: \"Ethernet1\"}, description: {value: \"WAN interface\"}}) { ok object { id } } }"}'
```

You can verify this in the GUI by navigating to 'Objects' and selecting 'Device' or 'Interface'.

![schema page screenshot](../media/guides/create_schema_2.png)

Finally, you can merge the `network-device-schema` branch to 'main' by running the following command.

```shell
infrahubctl branch merge network-device-schema
```

We have now successfully created our first schema, loaded into a branch into Infrahub, created the first nodes and merged the changes into the main branch of Infrahub.

## 2. Adding relationships to the nodes
Expand Down Expand Up @@ -191,6 +212,8 @@ mutation {

In the Web UI we can now see that the device has a relation to the Ethernet1 interface.

![schema page screenshot](../media/guides/create_schema_3.png)

## 3. Abstracting nodes into generics

We would like to add another interface `Vlan1` to our device `atl1-edge1`. We could add the interface as a `NetworkInterface` node, however this could cause some problems. The `Vlan1` interface is a logical interface, `Ethernet1` on the other hand is a physical interface. While physical interfaces a lot of properties in common with logical interfaces, they also have their differences. A cable can be plugged into a Physical interface, which you cannot do on a logical interface.
Expand Down
Binary file added docs/docs/media/guides/create_schema_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/media/guides/create_schema_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/media/guides/create_schema_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading