lsm module

This module provides lifecycle and service management capabilities.

For quickstart, see LSM Quickstart. For full documentation, see LSM documenation. For the associated testing framework, see pytest-inmanta-lsm.

Example

This example shows how to define a service (and its API), that puts IP addresses on routers. The actual deployment to the router is not present here. For the more complete version, look at the LSM Quickstart.

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

Environment Variables

This module responds to the following environment variables, that are automatically set by the server:

Env variable name

Description

Type

inmanta_model_state

Indicate if this is a validation compile or not

[“candidate”, “active”]

inmanta_instance_id

The IDs of the instances for which this compile runs

space separated list of UUID

lsm_partial_compile

Indicate if this is a partial compile or full compile

[“True”, “False”]

lsm_no_instances

Force lsm::all to return no instances

[“True”, “False”]