From 84de1ac5f71d69453168e6b8ff9d9f7ff210dcbd Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Thu, 15 Feb 2024 09:57:10 +0100 Subject: [PATCH 01/10] update --- docs/lsm/allocation/allocation.rst | 2 - docs/lsm/index.rst | 59 +++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/docs/lsm/allocation/allocation.rst b/docs/lsm/allocation/allocation.rst index 904416f811..e70160af5f 100644 --- a/docs/lsm/allocation/allocation.rst +++ b/docs/lsm/allocation/allocation.rst @@ -10,8 +10,6 @@ In the network, this virtual wire is implemented as a VXlan tunnel, tied to both Each such tunnel requires a "VXLAN Network Identifier (VNI)" that uniquely identifies the tunnel. In the allocation phase, the orchestrator selects a VNI and ensures no other customer is assigned the same VNI. -.. todo: add picture of service - Correct allocation is crucial for the correct functioning of automated services. However, when serving multiple customers at once or when mediating between multiple inventories, correct allocation can be challenging, due to concurrency and distribution effects. diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index 2a30689d36..ba382c147b 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -1,4 +1,4 @@ -.. only:: iso +.. only:: oss Inmanta Lifecycle Service Manager ********************************* @@ -47,9 +47,9 @@ - The name of the service entity - A list of attributes that have a name, a type (number, string, ...) and a modifier. This modifier determines whether the attribute is: - - r / readonly: readonly from the client perspective and allocated server side by the LSM - - rw / read-write: Attributes can be set at creation time, but are readonly after the creation - - rw+ / read-write always: Attribute can be set at creation time and modified when the service state allows it + - ``r`` / readonly: readonly from the client perspective and allocated server side by the LSM + - ``rw`` / read-write: Attributes can be set at creation time, but are readonly after the creation + - ``rw+`` / read-write always: Attribute can be set at creation time and modified when the service state allows it - The :ref:`fsm` that defines the lifecycle of the service. For each service entity the lifecycle service manager will create an REST API endpoint on the service inventory to perform create, @@ -57,16 +57,50 @@ Creating service entities ========================= + Service entities are :ref:`entities ` that extend ``lsm::ServiceEntity`` + We define attributes for the service entity the same way as for entities. We can also define a modifier for the attribute. + If no modifier is defined for an attribute, it will be ``rw`` by default. + Here is an example of an entity definition where the modifier of the ``address`` attribute is set to ``rw+``. - TODO: - How to define a new service entity. "Exported" entity is high level entity in a service model. + .. code-block:: inmanta + + entity InterfaceIPAssignment extends lsm::ServiceEntity: + """ + Interface details. + + :attr router_ip: The IP address of the SR linux router that should be configured. + :attr router_name: The name of the SR linux router that should be configured. + :attr interface_name: The name of the interface of the router that should be configured. + :attr address: The IP-address to assign to the given interface. + """ + + std::ipv_any_address router_ip + string router_name + string interface_name + + std::ipv_any_interface address + lsm::attribute_modifier address__modifier="rw+" + end + + implement InterfaceIPAssignment using parents + + We also need to add a lifecycle to the entity. This is done by using ``ServiceEntityBinding``. By using the ``ServiceEntityBinding`` + we can add a lifecycle to the entity and give it a name: + + .. code-block:: inmanta + + binding = lsm::ServiceEntityBinding( + service_entity="__config__::InterfaceIPAssignment", + lifecycle=lsm::fsm::simple, + service_entity_name="interface-ip-assignment", + ) It's also possible to define a service identity for a service. For more information, see :ref:`service_identity`. +.. + TODO: Updating service entities ========================= - - TODO: How to update the definition of a service entity and keeping the instance in the inventory stable Service Inventory @@ -89,11 +123,18 @@ The state machine attached to the lifecycle will determine whether the API call is successful or not. - TODO: Three set of attributes + Each service instance defines 3 sets of its attributes that are used in different situations: + + - ``candidate_attributes``: The set of attributes used when the service instance model state is candidate or designed. + - ``active_attributes``: The set of attributes when the model is evaluated with only active instances. + - ``rollback_attributes``: The set of attributes that can be used to rollback active attributes that result in an error + state. + Lifecycle Manager ----------------- +.. TODO: add example/default lifecycle From a134fbb7978a40c0490092a97d67590cc31e7ffe Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Thu, 15 Feb 2024 17:25:48 +0100 Subject: [PATCH 02/10] update --- docs/lsm/index.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index ba382c147b..f662383ddb 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -97,11 +97,11 @@ It's also possible to define a service identity for a service. For more information, see :ref:`service_identity`. -.. - TODO: - Updating service entities - ========================= - How to update the definition of a service entity and keeping the instance in the inventory stable + .. + TODO: + Updating service entities + ========================= + How to update the definition of a service entity and keeping the instance in the inventory stable Service Inventory ----------------- @@ -134,8 +134,8 @@ Lifecycle Manager ----------------- -.. - TODO: add example/default lifecycle + .. + TODO: add example/default lifecycle .. _fsm: From 521759b8e0e32016ff666a9d7e8fd27c7e862c90 Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Thu, 15 Feb 2024 17:26:06 +0100 Subject: [PATCH 03/10] update --- docs/lsm/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index f662383ddb..c93df1ac0f 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -1,4 +1,4 @@ -.. only:: oss +.. only:: iso Inmanta Lifecycle Service Manager ********************************* From fffbe4184653db58af817504e4708eba93ac1b35 Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Thu, 15 Feb 2024 17:30:41 +0100 Subject: [PATCH 04/10] update --- changelogs/unreleased/7134-remove-todo-lsm-docs.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/7134-remove-todo-lsm-docs.yml diff --git a/changelogs/unreleased/7134-remove-todo-lsm-docs.yml b/changelogs/unreleased/7134-remove-todo-lsm-docs.yml new file mode 100644 index 0000000000..5e5dc0000d --- /dev/null +++ b/changelogs/unreleased/7134-remove-todo-lsm-docs.yml @@ -0,0 +1,5 @@ +description: Update lsm annotation documentation +change-type: patch +destination-branches: + - master + - iso7 From ae846a2cc3be3c4761c2fd7aa94bbfafcb32e634 Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Thu, 15 Feb 2024 17:32:05 +0100 Subject: [PATCH 05/10] update --- changelogs/unreleased/7134-remove-todo-lsm-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelogs/unreleased/7134-remove-todo-lsm-docs.yml b/changelogs/unreleased/7134-remove-todo-lsm-docs.yml index 5e5dc0000d..3449e84288 100644 --- a/changelogs/unreleased/7134-remove-todo-lsm-docs.yml +++ b/changelogs/unreleased/7134-remove-todo-lsm-docs.yml @@ -1,5 +1,6 @@ -description: Update lsm annotation documentation +description: Remove the visible todos from the lsm docs. change-type: patch destination-branches: - master - iso7 + - iso6 From a4d8414d8b46a96b4c9df9c72321e84355cf8d24 Mon Sep 17 00:00:00 2001 From: FloLey <95339363+FloLey@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:32:04 +0100 Subject: [PATCH 06/10] Update docs/lsm/index.rst Co-authored-by: arnaudsjs <2684622+arnaudsjs@users.noreply.github.com> --- docs/lsm/index.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index c93df1ac0f..af4bb668ad 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -84,8 +84,7 @@ implement InterfaceIPAssignment using parents - We also need to add a lifecycle to the entity. This is done by using ``ServiceEntityBinding``. By using the ``ServiceEntityBinding`` - we can add a lifecycle to the entity and give it a name: + We also need to add a lifecycle and a name to the service. This is done by creating an instance of the ``ServiceEntityBinding`` entity: .. code-block:: inmanta From 2ac6e3385472c6bbcb1068e87f85dee629d61880 Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Mon, 19 Feb 2024 09:42:08 +0100 Subject: [PATCH 07/10] update --- docs/lsm/index.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index af4bb668ad..68fee20def 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -124,10 +124,8 @@ Each service instance defines 3 sets of its attributes that are used in different situations: - - ``candidate_attributes``: The set of attributes used when the service instance model state is candidate or designed. - - ``active_attributes``: The set of attributes when the model is evaluated with only active instances. - - ``rollback_attributes``: The set of attributes that can be used to rollback active attributes that result in an error - state. + .. + TODO: Three set of attributes Lifecycle Manager From b0406ff9614d4712c9171f3e088e42e39e14bbba Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Mon, 19 Feb 2024 14:44:09 +0100 Subject: [PATCH 08/10] update --- docs/lsm/index.rst | 39 +++++--------------- docs/lsm/index_sources/service_creation.cf | 43 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 docs/lsm/index_sources/service_creation.cf diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index 68fee20def..81ad9eb50e 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -1,4 +1,4 @@ -.. only:: iso +.. only:: oss Inmanta Lifecycle Service Manager ********************************* @@ -62,37 +62,18 @@ If no modifier is defined for an attribute, it will be ``rw`` by default. Here is an example of an entity definition where the modifier of the ``address`` attribute is set to ``rw+``. - .. code-block:: inmanta - - entity InterfaceIPAssignment extends lsm::ServiceEntity: - """ - Interface details. - - :attr router_ip: The IP address of the SR linux router that should be configured. - :attr router_name: The name of the SR linux router that should be configured. - :attr interface_name: The name of the interface of the router that should be configured. - :attr address: The IP-address to assign to the given interface. - """ - - std::ipv_any_address router_ip - string router_name - string interface_name - - std::ipv_any_interface address - lsm::attribute_modifier address__modifier="rw+" - end - - implement InterfaceIPAssignment using parents + .. literalinclude:: index_sources/service_creation.cf + :linenos: + :language: inmanta + :lines: 1-29 We also need to add a lifecycle and a name to the service. This is done by creating an instance of the ``ServiceEntityBinding`` entity: - .. code-block:: inmanta - - binding = lsm::ServiceEntityBinding( - service_entity="__config__::InterfaceIPAssignment", - lifecycle=lsm::fsm::simple, - service_entity_name="interface-ip-assignment", - ) + .. literalinclude:: index_sources/service_creation.cf + :linenos: + :language: inmanta + :lines: 30-36 + :lineno-start: 25 It's also possible to define a service identity for a service. For more information, see :ref:`service_identity`. diff --git a/docs/lsm/index_sources/service_creation.cf b/docs/lsm/index_sources/service_creation.cf new file mode 100644 index 0000000000..78da3f857e --- /dev/null +++ b/docs/lsm/index_sources/service_creation.cf @@ -0,0 +1,43 @@ +import lsm +import lsm::fsm +import ip + +entity InterfaceIPAssignment extends lsm::ServiceEntity: + """ + Interface details. + + :attr service_id: A unique ID for this service. + + :attr router_ip: The IP address of the SR linux router that should be configured. + :attr router_name: The name of the SR linux router that should be configured. + :attr interface_name: The name of the interface of the router that should be configured. + :attr address: The IP-address to assign to the given interface. + """ + string service_id + + string router_ip + string router_name + string interface_name + + string address + lsm::attribute_modifier address__modifier="rw+" + +end + +index InterfaceIPAssignment(service_id) + +implement InterfaceIPAssignment using parents + +binding = lsm::ServiceEntityBindingV2( + service_entity="__config__::InterfaceIPAssignment", + lifecycle=lsm::fsm::service, + service_entity_name="service_simple", +) + +for instance in lsm::all(binding): + InterfaceIPAssignment( + instance_id=instance["id"], + entity_binding=binding, + **instance["attributes"], + ) +end From 4835d20ff6f1b822d7046cc7f0387d8c91aef9c9 Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Mon, 19 Feb 2024 15:04:36 +0100 Subject: [PATCH 09/10] update --- docs/lsm/index.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index 81ad9eb50e..c534fde42d 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -103,8 +103,6 @@ The state machine attached to the lifecycle will determine whether the API call is successful or not. - Each service instance defines 3 sets of its attributes that are used in different situations: - .. TODO: Three set of attributes From bb72db59adbfcb35aef0ee92de625637a16d829e Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Mon, 19 Feb 2024 15:04:57 +0100 Subject: [PATCH 10/10] update --- docs/lsm/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/lsm/index.rst b/docs/lsm/index.rst index c534fde42d..19e73507ea 100644 --- a/docs/lsm/index.rst +++ b/docs/lsm/index.rst @@ -1,4 +1,4 @@ -.. only:: oss +.. only:: iso Inmanta Lifecycle Service Manager *********************************