diff --git a/CHANGELOG.md b/CHANGELOG.md index ff3d068c7e..dd63e7c12f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,12 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang - Fixes an issue where docker compose would output ANSI control characters that don't support it - Prevent temporary directories generated by Docusaurus to be imported by Docker +## [0.16.4](https://github.com/opsmill/infrahub/tree/v0.16.4) - 2024-10-17 + +### Fixed + +- Fixed an issue on the UI where a new relationship was being added to the main branch instead of the current branch. ([#4598](https://github.com/opsmill/infrahub/issues/4598)) + ## [0.16.3](https://github.com/opsmill/infrahub/tree/v0.16.3) - 2024-10-10 ### Removed diff --git a/docs/docs/guides/create-schema.mdx b/docs/docs/guides/create-schema.mdx index 73137d4d56..9fc80fb7b5 100644 --- a/docs/docs/guides/create-schema.mdx +++ b/docs/docs/guides/create-schema.mdx @@ -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 @@ -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 @@ -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. diff --git a/docs/docs/guides/installation.mdx b/docs/docs/guides/installation.mdx index 1490c2ee0a..b7eaea2da3 100644 --- a/docs/docs/guides/installation.mdx +++ b/docs/docs/guides/installation.mdx @@ -64,7 +64,7 @@ cd ~/source/infrahub/ Next, clone the Infrahub GitHub repository into the current directory. ```shell -git clone --recursive -b stable --depth 1 https://github.com/opsmill/infrahub.git +git clone --recursive --depth 1 https://github.com/opsmill/infrahub.git ``` :::note diff --git a/docs/docs/guides/resource-manager.mdx b/docs/docs/guides/resource-manager.mdx index 237b283744..cb75dbe5d8 100644 --- a/docs/docs/guides/resource-manager.mdx +++ b/docs/docs/guides/resource-manager.mdx @@ -25,6 +25,12 @@ nodes: - "BuiltinIPPrefix" description: "IPv4 or IPv6 network" label: "IP Prefix" + relationships: + - name: vlan + peer: IpamVLAN + optional: true + cardinality: one + kind: Attribute - name: IPAddress namespace: Ipam include_in_menu: false @@ -32,11 +38,33 @@ nodes: - "BuiltinIPAddress" description: "IP Address" label: "IP Address" + - name: VLAN + namespace: Ipam + description: "A VLAN is isolated layer two domain" + label: "VLAN" + icon: "mdi:lan-pending" + include_in_menu: true + order_by: + - name__value + display_labels: + - name__value + attributes: + - name: name + kind: Text + - name: vlan_id + kind: Number + relationships: + - name: prefixes + peer: IpamIPPrefix + optional: true + cardinality: many - name: Device namespace: Infra description: "A Device" icon: "mdi:server" label: "Device" + display_labels: + - name__value attributes: - name: name kind: Text @@ -49,6 +77,25 @@ nodes: optional: false kind: Attribute cardinality: one + - name: Service + namespace: Customer + description: "A Customer service" + icon: "carbon:ibm-cloud-internet-services" + label: "Service" + display_labels: + - name__value + attributes: + - name: name + kind: Text + label: Name + optional: false + relationships: + - name: assigned_prefix + label: "Assigned prefix" + peer: IpamIPPrefix + optional: false + kind: Attribute + cardinality: one ``` Load the schema with the `infrahubctl` command. @@ -58,9 +105,13 @@ Load the schema with the `infrahubctl` command. 1 schema processed in 6.846 seconds. ``` -## Creating an IP Prefix object +## Using IP address pool -Next we will be creating an IP Prefix object, which the resource manager will use as a resource to allocate resources from. +A `CoreIPAddressPool` will allow you to dynamically allocate IP address from on or multiple source IP prefix. + +### Creating an IP Prefix object + +First we need to create an IP Prefix object, which the resource manager will use as a resource to allocate resources from. You can create a prefix `10.0.0.0/24` using the web interface, or by using this GraphQL mutation. ```graphql @@ -80,28 +131,27 @@ mutation { Take note of the id of the prefix, we will need id in the next step. -## Creating a resource manager +### Creating an IP address resource manager We can now create a resource manager of kind `CoreIPAddressPool`. The kind of the resource manager determines the kind of resource the manager will allocate. -We will create a `CoreIPaddressPool` with the following properties: +We will create a `CoreIPAddressPool` with the following properties: - Name: My IP address pool - Default Address Type: `IpamIPAddress` (the kind of the IP address node defined in our schema) -- Default Prefix Size: 32 +- Default Prefix Length: 24 - Resources: 10.0.0.0/24 - IP Namespace: Namespace > Default -The `CoreIPAddresPool` can be created using the web interface, or by using this GraphQL mutation. Replace the id of the resource with the id of the prefix of the previous step. +The `CoreIPAddressPool` can be created using the web interface, or by using this GraphQL mutation. Replace the id of the resource with the id of the prefix of the previous step. ```graphql mutation { CoreIPAddressPoolCreate(data: { name: {value: "My IP address pool"}, default_address_type: {value: "IpamIPAddress"}, - default_prefix_size: {value: 32}, + default_prefix_length: {value: 24}, resources: [{id: ""}], - is_pool: {value: true}, ip_namespace: {id: "default"} }) { @@ -115,18 +165,18 @@ mutation { Take note of the id of the `CoreIPAddressPool`, we will use it in the next steps. -## Allocating a resource out of the pool +### Allocating an IP address out of the pool -We can now start allocating resources out of the `CoreIPAddressPool` we created. +We can now start allocating IP addresses out of the `CoreIPAddressPool` we created. We can use the resource manager to allocate resources out of a pool in 2 different ways: 1. Directly allocate a resource out of a pool. This is typically used when you need to allocate a resource that has no relation to other nodes. For example, allocating an IP address out of a pool that will be assigned to something that is not stored in Infrahub. 2. Allocate a resource out of a pool to a relationship of a node. For example, create a device and allocate an IP address out of a pool and assign it to the device -### Direct allocation of a resource +Please refer to the [Resource Manager Topic](/topics/resource-manager) for further details. -At this stage we can only do this using GraphQL queries or specific methods in the Python SDK. Support for the web interface will come in future releases. +#### Direct allocation of an IP address Execute the following mutation to allocate an IP address out of the pool. Replace the id with the id of the `CoreIPAddressPool` we created previously. @@ -134,7 +184,7 @@ Execute the following mutation to allocate an IP address out of the pool. Replac mutation { IPAddressPoolGetResource( data: { - id: "", + id: "", data: { description: "my first allocated ip" } @@ -152,18 +202,18 @@ mutation { In the mutation we passed additional data to the allocated resource, in this case we passed a description attribute. This description attribute will be set on the IP address that was allocated. You can do this for any other attribute and relationship for the destination address type. +#### Idempotent allocation of an IP address + You can allocate resources in an idempotent way by specifying an identifier in the GraphQL mutation. This identifier links the resource pool with the allocated resource allowing us to create idempotent allocation behavior. This is crucial when you want to allocate resources in an idempotent way using [generators](/topics/generator). Execute this mutation twice, note the identifier. The resulting IP address should be the same, as well as the id. Replace the id with the id of the `CoreIPAddressPool` we created previously. ```graphql mutation { - IPAddressPoolGetResource( - data: { - id: "", - identifier: "my-allocated-ip", - } - ) + IPAddressPoolGetResource(data: { + id: "", + identifier: "my-allocated-ip", + }) { ok node { @@ -174,7 +224,7 @@ mutation { } ``` -### Allocating resources to a relationship of a node +#### Allocating an IP address to a relationship of a node Another way we can use resource managers is in situations where we create a node that has a relationship and we want to use a resource manager to allocate a new resource for that relationship. For example, we want to create a new device (or server) and assign an IP address to the device out of a pool. @@ -189,7 +239,8 @@ mutation { id: "" } } - }) { + }) + { ok object { display_label @@ -213,6 +264,220 @@ Next to the Primary IP Address dropdown menu, you can click on the Pools options ![Add a device](../media/guides/resource-manager-create-device.png) +## Using IP prefix pool + +A `CoreIPPrefixPool` will allow you to dynamically allocate IP prefix from one or multiple source IP prefix. + +### Creating an IP Prefix object + +First we need to create an IP Prefix object, which the resource manager will use as a resource to allocate resources from. +You can create a prefix `10.10.10.0/24` using the web interface, or by using this GraphQL mutation. + +```graphql +mutation { + IpamIPPrefixCreate(data: { + prefix: {value: "10.10.10.0/24"}, + member_type: {value: "prefix"}, + }) + { + ok + object { + id + } + } +} +``` + +Take note of the id of the prefix, we will need id in the next step. + +### Creating an IP prefix resource manager + +We can now create a resource manager of kind `CoreIPPrefixPool`. The kind of the resource manager determines the kind of resource the manager will allocate. + +We will create a `CoreIPPrefixPool` with the following properties: + +- Name: My IP prefix pool for point to point +- Default Prefix Length: 31 +- Resources: 10.10.10.0/24 +- IP Namespace: Namespace > Default + +The `CoreIPPrefixPool` can be created using the web interface, or by using this GraphQL mutation. Replace the id of the resource with the id of the prefix of the previous step. + +```graphql +mutation { + CoreIPPrefixPoolCreate(data: { + name: {value: "IP prefix pool for point to point"}, + default_prefix_length: {value: 31}, + default_prefix_type: {value: "IpamIPPrefix"}, + resources: [{id: ""}], + ip_namespace: {id: "default"} + }) + { + ok + object { + id + } + } +} +``` + +Take note of the id of the `CoreIPPrefixPool`, we will use it in the next steps. + +### Allocating an IP prefix out of the pool + +We can now start allocating IP prefix out of the `CoreIPPrefixPool` we created. + +We can use the resource manager to allocate resources out of a pool in 2 different ways: + +1. Directly allocate a resource out of a pool. This is typically used when you need to allocate a resource that has no relation to other nodes. For example, allocating an IP address out of a pool that will be assigned to something that is not stored in Infrahub. +2. Allocate a resource out of a pool to a relationship of a node. For example, create a device and allocate an IP address out of a pool and assign it to the device + +Please refer to the [Resource Manager Topic](/topics/resource-manager) for further details. + +#### Direct allocation of an IP prefix + +Execute the following mutation to allocate an IP prefix out of the pool. Replace the id with the id of the `CoreIPPrefixPool` we created previously. + +```graphql +mutation { + IPPrefixPoolGetResource(data: { + id: "", + data: { + description: "prefix allocated to point to point connection" + } + }) + { + ok + node { + id + display_label + } + } +} +``` + +In the mutation we passed additional data to the allocated resource, in this case we passed a description attribute. This description attribute will be set on the IP prefix that was allocated. You can do this for any other attribute and relationship for the destination address type. + +#### Allocating an IP prefix to a relationship of a node + +Another way we can use resource managers is in situations where we create a node that has a relationship and we want to use a resource manager to allocate a new resource for that relationship. For example, we want to create a new customer service and assign a prefix of a pool. + +In this mutation we use the `from_pool` resolver to indicate we want to allocate a `assigned_prefix` from a resource pool. Replace the id with the id of the `CoreIPPrefixPool` we created previously. + +```graphql +mutation { + CustomerServiceCreate(data: { + name: {value: "svc-123"}, + assigned_prefix: { + from_pool: { + id: "" + } + } + }) + { + ok + object { + display_label + assigned_prefix { + node { + prefix { + value + } + } + } + } + } +} +``` + +When you use the `from_pool` resolver, the resource allocation happens in an idempotent way, an identifier is automatically assigned to the resource allocation in this case. + +#### Idempotent allocation of an IP prefix + +You can allocate resources in an idempotent way by specifying an identifier in the GraphQL mutation. This identifier links the resource pool with the allocated resource allowing us to create idempotent allocation behavior. This is crucial when you want to allocate resources in an idempotent way using [generators](/topics/generator). + +Execute this mutation twice, note the identifier. The resulting IP prefix should be the same, as well as the id. Replace the id with the id of the `CoreIPPrefixPool` we created previously. + +```graphql +mutation { + IPPrefixPoolGetResource(data: { + id: "", + identifier: "my-allocated-prefix", + }) + { + ok + node { + id + display_label + } + } +} +``` + +## Using number pool + +A `CoreNumberPool` is connected to a node's numeric attribute. It lets you automatically assign numbers from a set range as values for that attribute. + +### Creating a number resource manager + +First we need to create a resource manager of kind `CoreNumberPool`. This resource manager will be linked to an attribute of type `Number` for a given node. + +We will create a `CoreNumberPool` with the following properties: + +- Name: My number pool +- Node: `IpamVLAN` +- Node attribute: `vlan_id` +- Start range: 100 +- End range: 200 + +The `CoreNumberPool` can be created using the web interface, or by using this GraphQL mutation. + +```graphql +mutation { + CoreNumberPoolCreate(data:{ + name: {value: "My number pool"}, + node: {value: "IpamVLAN"}, + node_attribute: {value: "vlan_id"}, + start_range: {value: 100}, + end_range: {value: 200} + }) + { + ok + object { + hfid + id + } + } +} +``` + +Take note of the id/hfid of the `CoreNumberPool`, we will use it in the next steps. + +### Allocating a number out of the pool + +In the following mutation we use the `from_pool` resolver to indicate that we want to allocate a `vlan_id` from a resource pool. + +```graphql +mutation { + IpamVLANCreate(data:{ + name: {value: "My vlan"}, + vlan_id: {from_pool: {id: "My number pool"}} # Here we could either put the ID or HFID + }) + { + ok + object { + name { + value + } + vlan_id { + value + } + id + } + } +} +``` + ## Branch agnostic resource allocation Resource managers have to allocate resources in a branch agnostic way. For example if we allocate a resource in a branch, then that resource should also be allocated in the main branch, even if the resource object does not yet exist in the main branch. @@ -231,7 +496,7 @@ Allocate a new IP address in the `test` branch using this mutation. Replace the mutation { IPAddressPoolGetResource( data: { - id: "", + id: "", } ) { diff --git a/docs/docs/media/guides/create_schema_1.png b/docs/docs/media/guides/create_schema_1.png new file mode 100644 index 0000000000..82a26559d8 Binary files /dev/null and b/docs/docs/media/guides/create_schema_1.png differ diff --git a/docs/docs/media/guides/create_schema_2.png b/docs/docs/media/guides/create_schema_2.png new file mode 100644 index 0000000000..01842be335 Binary files /dev/null and b/docs/docs/media/guides/create_schema_2.png differ diff --git a/docs/docs/media/guides/create_schema_3.png b/docs/docs/media/guides/create_schema_3.png new file mode 100644 index 0000000000..e621da2e84 Binary files /dev/null and b/docs/docs/media/guides/create_schema_3.png differ diff --git a/docs/docs/python-sdk/guides/store.mdx b/docs/docs/python-sdk/guides/store.mdx index 356e277f9b..f2d8546f0b 100644 --- a/docs/docs/python-sdk/guides/store.mdx +++ b/docs/docs/python-sdk/guides/store.mdx @@ -143,7 +143,7 @@ You can use a custom store, outside of the Infrahub SDK client. Storing or retri store = NodeStore() device = await client.get(kind="TestDevice", name__value="atl1-edge1") - store.set(key=device.name.value, node=store) + store.set(key=device.name.value, node=device) store.get(key=device.name.value) ``` @@ -155,7 +155,7 @@ You can use a custom store, outside of the Infrahub SDK client. Storing or retri store = NodeStoreSync() device = await client.get(kind="TestDevice", name__value="atl1-edge1") - store.set(key=device.name.value, node=store) + store.set(key=device.name.value, node=device) store.get(key=device.name.value) ``` diff --git a/docs/docs/release-notes/infrahub/release-0_16_4.mdx b/docs/docs/release-notes/infrahub/release-0_16_4.mdx new file mode 100644 index 0000000000..c1c69f1bf5 --- /dev/null +++ b/docs/docs/release-notes/infrahub/release-0_16_4.mdx @@ -0,0 +1,72 @@ +--- +title: Release 0.16.4 +--- + + + + + + + + + + + + + + + + + + + +
Release Number0.16.4
Release DateOctober 17th, 2024
Release CodenameBeta #5, Patch #4
Tag[infrahub-v0.16.4](https://github.com/opsmill/infrahub/releases/tag/infrahub-v0.16.4)
+ +# Release 0.16.4 + +We are thrilled to announce the latest release of Infrahub, version *0.16.4*! + +This release focuses largely on bug fixes and is driven by our Beta Test users, +and as always we greatly appreciate their feedback and time! + +## Main changes + +The complete list of changes can always be found in the `CHANGELOG.md` file in the Infrahub Git repository. + +### Fixed + +- Fixed an issue on the UI where a new relationship was being added to the main branch instead of the current branch. ([#4598](https://github.com/opsmill/infrahub/issues/4598)) + +## Migration guide + +To migrate your instance of Infrahub to the latest version, please run the following commands and restart all instances of Infrahub. + + +```shell +infrahub db migrate +infrahub db update-core-schema +``` + + +> if you are running in docker these commands need to run from the container where Infrahub is installed + +### Migration of the demo instance + +If you are using the demo environment, you can migrate to the latest version with the following commands + +```shell +invoke demo.stop +invoke demo.build +invoke demo.migrate +invoke demo.start +``` + +If you don't want to keep your data, you can start a clean instance with the following command + +```shell +invoke demo.destroy demo.build demo.start demo.load-infra-schema demo.load-infra-data +``` + +> All data will be lost, please make sure to backup everything you need before running this command. + +The repository https://github.com/opsmill/infrahub-demo-edge has also been updated, it's recommended to pull the latest changes into your fork. diff --git a/docs/docs/topics/resource-manager.mdx b/docs/docs/topics/resource-manager.mdx index 389802e46b..a7435118f2 100644 --- a/docs/docs/topics/resource-manager.mdx +++ b/docs/docs/topics/resource-manager.mdx @@ -11,7 +11,7 @@ Examples: - allocating the next available IP Prefix out of a IP Prefix pool - allocating the next available IP addresses out of a IP Address pool - allocating the next available VLAN ID out of a pool of valid VLAN ID's -- allocating the next available device ID out of a pool of valid Device ID's +- allocating the next available ASN (Autonomous System Number) out of a number pool A resource manager in Infrahub allocates resources in a branch agnostic way. When you allocate a resource out of a pool in a branch, then that allocation happens in all the branches. @@ -22,7 +22,4 @@ Resources can be allocated in 2 different ways: - Direct allocation: A direct allocation is typically used when you don't need the resource to be related to another node in Infrahub, or if you want establish such a relation at a later time. For example, you want to allocated an IP address out of a pool that is not going to be linked to another node in Infrahub. - Relationship resource allocation: A resource can be allocated to a relationship of a node, when you create a new node. For example, when you want to create a device and assign an IP address out of a pool to an interface at device creation time. -## Known limitations - -- We only support resource pools for IP Prefixes and IP Addresses, support for other resource pools will come in future releases -- Direct resource allocations can only happen from the GraphQL API or the Python SDK, support for allocating resources in the web UI will come in a future release. +See the [guide](/guides/resource-manager) for instructions on creating and using resource manager in Infrahub. diff --git a/docs/docs/tutorials/getting-started/branches.mdx b/docs/docs/tutorials/getting-started/branches.mdx index 00eba0cf35..fec2f8d442 100644 --- a/docs/docs/tutorials/getting-started/branches.mdx +++ b/docs/docs/tutorials/getting-started/branches.mdx @@ -12,7 +12,7 @@ The default branch is called `main`. To get started, let's create a new **branch** that we'll call `cr1234`. -You can create a new branch in the frontend by using the button with a `+ sign` in the top right corner, next to the name of the current branch, i.e., `main`. +You can create a new branch in the frontend by using the button with a `+ sign` in the top left corner, next to the name of the current branch, i.e., `main`. Branch names are fairly permissive, but must conform to [git ref format](https://git-scm.com/docs/git-check-ref-format). For example, slashes (`/`) are allowed, tildes (`~`) are not. @@ -65,7 +65,7 @@ Branch names are fairly permissive, but must conform to [git ref format](https:/ ## Modify an organization via the UI -The name of the active branch in the top right corner should now be `cr1234`. +The name of the active branch in the top left corner should now be `cr1234`. 1. Select `Organization` under Object in the left menu (near the top). @@ -167,4 +167,4 @@ Go back to the detailed page for the Organization `my-first-tenant`. For an in-depth understanding of Infrahub's approach to handling differences between branches and merging them, please consult the [proposed change topic](/topics/proposed-change). -::: \ No newline at end of file +::: diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 2245064598..22ff56b098 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -314,6 +314,7 @@ const sidebars: SidebarsConfig = { items: [ // 'release-notes/infrahub/release-1_0_1-DRAFT', 'release-notes/infrahub/release-1_0', + 'release-notes/infrahub/release-0_16_4', 'release-notes/infrahub/release-0_16_3', 'release-notes/infrahub/release-0_16_2', 'release-notes/infrahub/release-0_16_1',