-
Notifications
You must be signed in to change notification settings - Fork 27
Add NumberPool Documentation #6577
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
Merged
FragmentedPacket
merged 9 commits into
opsmill:release-1.3
from
FragmentedPacket:may-202505-numberpool-docs
Jun 6, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bfe6765
Initial addition of new topic to cover NumberPool attribute and updat…
FragmentedPacket cb5b26d
Add heading for removing the attribute.
FragmentedPacket 2e62c89
Initial topic for NumberPools attribute. Autogenerated screenshots, etc.
FragmentedPacket 8e93bd6
Fix formatting issue in JS.
FragmentedPacket 32b7caf
Added automated generation of schema kind parameters.
FragmentedPacket f193bfd
Fixing linting/formatting issues.
FragmentedPacket b6a2b51
Fixed acorn issue.
FragmentedPacket 482fda9
Remove required from optional parameters tables. Describe the paramet…
FragmentedPacket fd2baae
Change warning to info to advise the CoreNumberPool gets created on s…
FragmentedPacket File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
<!-- vale Infrahub.spelling = NO --> | ||
|
||
<Tabs> | ||
{%- for kind, params in kinds.items() | sort %} | ||
<TabItem value="{{ kind }}"> | ||
| Parameter | Default | | ||
| --------- | ------- | | ||
{% for name, info in params.items() -%} | ||
| {{ name }} | {{ info.default | default(False) }} | | ||
{% endfor -%} | ||
</TabItem> | ||
{%- endfor %} | ||
</Tabs> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
<!-- vale Infrahub.spelling = NO --> | ||
|
||
<Tabs> | ||
<TabItem value="Number"> | ||
| Parameter | Default | | ||
| --------- | ------- | | ||
| min_value | None | | ||
| max_value | None | | ||
| excluded_values | None | | ||
</TabItem> | ||
<TabItem value="NumberPool"> | ||
| Parameter | Default | | ||
| --------- | ------- | | ||
| end_range | 9223372036854775807 | | ||
| start_range | 1 | | ||
</TabItem> | ||
<TabItem value="Text"> | ||
| Parameter | Default | | ||
| --------- | ------- | | ||
| regex | None | | ||
| min_length | None | | ||
| max_length | None | | ||
</TabItem> | ||
<TabItem value="TextArea"> | ||
| Parameter | Default | | ||
| --------- | ------- | | ||
| regex | None | | ||
| min_length | None | | ||
| max_length | None | | ||
</TabItem> | ||
</Tabs> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
--- | ||
title: Attribute - NumberPool | ||
--- | ||
|
||
The `NumberPool` attribute kind enables the dynamic creation of a `CoreNumberPool` for the specific schema node and attribute rather than requiring users to define this after the schema is loaded. | ||
|
||
:::info Resource pool initial creation | ||
|
||
`NumberPool` kind creates the `CoreNumberPool` resource manager during schema initialization. | ||
|
||
::: | ||
|
||
## Defining a `NumberPool` attribute {#define-number-pool} | ||
|
||
When defining a `NumberPool` attribute, you'll have to define extra `parameters` on the attribute to define the `start_range` and `end_range` for the `CoreNumberPool` resource manager. | ||
|
||
We'll define a generic service schema that nodes will inherit from to provide a global service identifier among different schema node services. | ||
|
||
```yaml | ||
# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json | ||
--- | ||
version: "1.0" | ||
generics: | ||
- name: Service | ||
namespace: Infra | ||
description: "Services" | ||
default_filter: name__value | ||
order_by: | ||
- name__value | ||
display_labels: | ||
- name__value | ||
attributes: | ||
- name: name | ||
kind: Text | ||
label: Name | ||
optional: false | ||
order_weight: 1 | ||
- name: service_identifier | ||
kind: NumberPool | ||
read_only: true # Required | ||
parameters: | ||
start_range: 100 | ||
end_range: 10000 | ||
nodes: | ||
- name: BackBoneService | ||
namespace: Infra | ||
description: "Backbone Service" | ||
label: "Backbone Service" | ||
icon: "carbon:container-services" | ||
inherit_from: | ||
- InfraService | ||
uniqueness_constraints: | ||
- ["circuit_id__value", "internal_circuit_id__value"] | ||
attributes: | ||
- name: circuit_id | ||
kind: Text | ||
label: Circuit ID | ||
optional: false | ||
order_weight: 3 | ||
- name: internal_circuit_id | ||
kind: Text | ||
label: Internal Circuit ID | ||
optional: false | ||
order_weight: 2 | ||
relationships: | ||
- name: provider | ||
cardinality: one | ||
peer: OrganizationProvider | ||
optional: false | ||
kind: Attribute | ||
- name: site_a | ||
label: Site A | ||
cardinality: one | ||
peer: LocationSite | ||
optional: false | ||
identifier: infrabackboneservice__location_site_a | ||
kind: Attribute | ||
order_weight: 4 | ||
- name: site_b | ||
label: Site B | ||
cardinality: one | ||
peer: LocationSite | ||
optional: false | ||
identifier: infrabackboneservice__location_site_b | ||
kind: Attribute | ||
order_weight: 5 | ||
``` | ||
|
||
We can view the schema in the **Schema Visualizer**. | ||
|
||
 | ||
|
||
## Viewing the Resource Manager | ||
|
||
Once we create an initial `InfraBackBoneService`, we can navigate to the resource manager page and view the details of the created resource manager. | ||
|
||
The naming of the resource manager will be `Kind.attribute_name [uuid]`. | ||
|
||
 | ||
|
||
:::info Updating Parameters (Start/End Range) | ||
|
||
To update the **parameters** of a `NumberPool` attribute requires performing a schema update. | ||
|
||
::: | ||
|
||
## Deleting the Resource Manager | ||
|
||
To remove the resource manager, the attribute must be removed by defining `state: absent` on the attribute in the schema. The resource manager will then be removed during the schema loading. | ||
|
||
```yaml | ||
# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json | ||
--- | ||
version: "1.0" | ||
generics: | ||
- name: Service | ||
namespace: Infra | ||
description: "Services" | ||
default_filter: name__value | ||
order_by: | ||
- name__value | ||
display_labels: | ||
- name__value | ||
attributes: | ||
- name: name | ||
kind: Text | ||
label: Name | ||
optional: false | ||
order_weight: 1 | ||
- name: service_identifier | ||
state: absent | ||
kind: NumberPool | ||
read_only: true # Required | ||
parameters: | ||
start_range: 100 | ||
end_range: 10000 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR but I think we shouldn't require the user to define
read_only: true
for NumberPool and Computed Attribute, it should be automatic and we should raise an error if user is trying to enforceread_only: false
cc @ogenstad @wvandeun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now as the
read_only
attribute defaults toFalse
in the models I'm not sure we can do that. If we look at models for the schema generation we could change it so that it would default toNone
and get changed toFalse
if no choice has been made.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree that it would be nice to have this type of attribute (and computed attribtute) to be read-only by default.
If it is not possible to do it today, or if it is to involved the we should open an issue/feature request in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be part of
INFP-234
where we somewhere add a note that we want this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the information as a comment on it