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

Remove visible todos from lsm doc #7201

Closed
wants to merge 14 commits into from
6 changes: 6 additions & 0 deletions changelogs/unreleased/7134-remove-todo-lsm-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Remove the visible todos from the lsm docs.
change-type: patch
destination-branches:
- master
- iso7
- iso6
2 changes: 0 additions & 2 deletions docs/lsm/allocation/allocation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO is not mentioned in the follow-up ticket that was created.


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.

Expand Down
41 changes: 29 additions & 12 deletions docs/lsm/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,41 @@

- 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,
read, update and delete (CRUD) service instances of service entities.

Creating service entities
=========================
Service entities are :ref:`entities <lang-entity>` 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.
.. literalinclude:: index_sources/service_creation.cf
:linenos:
:language: inmanta
:lines: 1-29

It's also possible to define a service identity for a service. For more information, see :ref:`service_identity`.
We also need to add a lifecycle and a name to the service. This is done by creating an instance of the ``ServiceEntityBinding`` entity:

Updating service entities
=========================
.. literalinclude:: index_sources/service_creation.cf
:linenos:
:language: inmanta
:lines: 30-36
:lineno-start: 25

TODO:
How to update the definition of a service entity and keeping the instance in the inventory stable
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

Service Inventory
-----------------
Expand All @@ -89,12 +103,15 @@

The state machine attached to the lifecycle will determine whether the API call is successful or not.

TODO: Three set of attributes
..
TODO: Three set of attributes


Lifecycle Manager
-----------------

TODO: add example/default lifecycle
..
TODO: add example/default lifecycle


.. _fsm:
Expand Down
43 changes: 43 additions & 0 deletions docs/lsm/index_sources/service_creation.cf
Original file line number Diff line number Diff line change
@@ -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