Module lsm

Typedefs

typedef lsm::attribute_modifier
  • Base type string

  • Type constraint (self in ['r','rw','rw+'])

typedef lsm::attribute_set_opt
  • Base type string

  • Type constraint (self in ['candidate','active'])

typedef lsm::labels
  • Base type string

  • Type constraint ((((self == 'success') or (self == 'info')) or (self == 'warning')) or (self == 'danger'))

typedef lsm::operation
  • Base type string

  • Type constraint /^(clear (candidate|active|rollback)|promote|rollback)$/

Entities

entity lsm::EmbeddedEntity

Parents: std::Entity

An entity containing attributes that should be embedded into a ServiceEntity or another EmbeddedEntity.

The following implements statements select implementations for this entity:

entity lsm::LifecycleStateMachine

Parents: std::Entity

The lifecylce statemachine definition.

attribute string name

The name of the lifecycle used for reporting on the lifecycle

attribute bool render_graph=false

When set to true the state machine is renderd to a dot graph for debug purposes.

relation lsm::State initial_state [1]
relation lsm::StateTransfer transfers [0:*]

The following implements statements select implementations for this entity:

entity lsm::LifecycleTransfer

Parents: std::PurgeableResource

This resource reports the result of all events its receives to the LSM for handling transfers

attribute string service_entity

The service entity from the service catalog.

attribute string instance_id

The id of the service instance.

attribute number next_version

The next version of the instance in the LSM

attribute bool purge_on_delete=false
attribute string agent='internal'
relation std::Resource resources [0:*]

The following implements statements select implementations for this entity:

entity lsm::RelationshipMetadata

Parents: std::Entity

The metadata belonging to the relationship to an embedded entity.

attribute lsm::attribute_modifier modifier='rw'

The following implements statements select implementations for this entity:

entity lsm::ServiceBase

Parents: std::Entity

A baseclass used for entities that refine a service instance to resources.

attribute bool purge_resources

Remove the resources associated with this service

relation lsm::ServiceBase children [0:*]

This relation connects an entity to the entities that are refined from it. This relation is required to collect all resources a service consists off.

other end: lsm::ServiceBase.parent [0:1]

relation lsm::ServiceBase parent [0:1]

This relation connects an entity to the entities that are refined from it. This relation is required to collect all resources a service consists off.

other end: lsm::ServiceBase.children [0:*]

relation std::Resource resources [0:*]

A list of resources that this entity refines to. This relation will also contain all resources from entities collected through child service base entities.

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity lsm::ServiceEntity

Parents: lsm::ServiceBase

A high level service that become available in the service catalog of the LSM. Based on this definition a service entity is generated in the catalog and an API endpoint becomes available in the service inventory.

Attributes starting with ‘_’ are excluded from the API specification. Attributes starting with ‘__’ are treated as metadata for the ServiceEntity. The values are taken from the defaults.

Service attributes are defined by adding an attribute to this entity. Metadata is specified by adding attributes with default values that start with the name of the attribute, a double underscore and then the name of the metadata. For example, for the attribute service_id, service_id__modifier provides the modifier of the service_id attribute. The following metadata is available. - modifier: Defines when the attribute can be set. See the type definition for more information.

attribute std::uuid instance_id

A unique id allocated by the LSM for each service instance.

relation lsm::State current_state [1]

A reference to the current state the state machine is in.

relation lsm::ServiceEntityBinding entity_binding [1]

The binding of the service entity to the LSM service

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity lsm::ServiceEntityBinding

Parents: std::Entity

Instances of this entity are used to bind entities to the service catalog

attribute string service_entity

The fully qualified named of the entity to register in the catalog

attribute string service_entity_name

The name of the service instance. This name is used to register the service in the serivce catalog and generate the REST API on the LSM

attribute string? allocation_spec=null

name of the allocation specification for this ServiceEntityBinding, check the product documentation for more information

attribute string? service_identity=null

name of the attribute to be used as a service identity

attribute string? service_identity_display_name=null

The display name of the service identity, to be used by the frontend

relation lsm::LifecycleStateMachine lifecycle [1]

The statemachine that represents the lifecycle

The following implements statements select implementations for this entity:

entity lsm::ServiceInstance

Parents: std::PurgeableResource

Instances of this entity are instances of a service entity in the catalog

attribute string service_entity

The name of the service entity this instance belongs to

attribute std::uuid instance_id

ID of this instance

attribute dict attributes

The desired attributes of this instance. The attribute names and types are determined by the service entity

attribute string[] skip_update_states

The Lifecycle States where updating the service instance is not possible, and should be marked as skipped

attribute string[] rejected_states

A list of unrecoverable states. The ServiceInstance resource will end up in the failed state when the service instance is in one of these rejected_states. In a rejected state the resource can only be purged.

attribute bool purge_on_delete=false
attribute string agent='internal'

The following implements statements select implementations for this entity:

entity lsm::State

Parents: std::Entity

A state in the state machine

attribute string name

The name of a state

attribute lsm::labels? label=null

A label that is used in the UI

attribute bool export_resources

Indicates whether the resources of a service instance should be exported when that service instance is in this state.

attribute lsm::attribute_set_opt? validate_self=null

The attribute set of a service instance that should be taken into account when that service instance is being validated while it is in this state of the its lifecycle.

attribute lsm::attribute_set_opt? validate_others=null

The attribute set of a service instance that should be taken into account when that service instance is involved in the validation of another service instance while it is in this state of the its lifecycle.

attribute bool purge_resources=false

Should the service purge resources

attribute bool deleted=false

The service is marked as deleted. This indicates the lifeycle has ended.

attribute dict values=Dict()

A dictionary with values associated with this state. Use the api::fsmvalue plugin to access a value.

The following implements statements select implementations for this entity:

entity lsm::StateTransfer

Parents: std::Entity

Configure an allowed state transfer. In a state machine transfers have to adhere to the following rules:
  • if multiple transfers between two states, only one active transfer can have auto set to true

attribute bool on_update=false

Trigger this state transfer when the service is updated (API)

attribute bool on_delete=false

Trigger this state transfer when the service is deleted (API)

attribute bool api_set_state=false

Allow this state transfer using the API.

attribute bool resource_based=false

Do the state transfer using a StateParam resource. The state transfer either happens always, or when there are requires, when these requires are deployed.

attribute bool auto=false

The lifecycle manager executes this step automatically when it gets to the from state. Used often in combination with validate

attribute bool validate=false

Run a compiler validation step when following this state transfer.

attribute string? description=null

name of description to aid debugging

attribute string? config_name=null

An optional configuration name that determines wether this transfer is enabled or not.

attribute lsm::operation? target_operation=null

The operation to perform on the attribute sets when the transfer goes to the target state.

attribute lsm::operation? error_operation=null

The operation to perform on the attribute sets when the transfer goes to the error state.

relation lsm::State source [1]

The start of the transfer edge

relation lsm::State target [1]

The end of the transfer edge

relation lsm::State error [0:1]

The target state in cause of failure. There is an implicit error edge for each statetransfer to this error state.

The following implements statements select implementations for this entity:

Implementations

implementation lsm::serviceBase
implementation lsm::stateConfig

This implementation configures the state machine

Plugins

lsm.all(binding: lsm::ServiceEntityBinding) list

Returns a list of records for the given binding.

Parameters

binding – The entity binding

Returns

A list of dict with all the defined records.

lsm.context_v2_unwrapper(assignments: dict[], fallback_attribute: string, track_deletes: bool=False) dict[]

This plugin can be used to wrap the instances coming out of lsm::all and place all allocated values in :param fallback_attribute: where they should go. The returned value is what has been given as input, except for the allocated values being set where they should. :param track_deletes: drop deleted embedded entities, even if they still exist in the fallback set.

This should be used together with ContextV2Wrapper allocator.

Each assignment is an attribute dict containing a fallback attribute assigned with allocated values as produced by the ContextV2 (one-level deep, keys are string representation of the paths, values are allocated values) and update the dict placing values where their key-path would reach them.

Parameters
  • assignments – The list of service instance dictionaries as returned by lsm::all

  • fallback_attributes – The attribute name at the root of the instance attributes that contains all the allocated values

e.g.:

context_v2_unwrapper(
    [
        {
            "environment": "8f7bf3a5-d655-4bcb-bbd4-6222407be999",
            "id": "f93acfad-7894-4a12-9770-b27cbdd85c74",
            "service_entity": "carrierEthernetEvc",
            "version": 4,
            "config": {},
            "state": "allocating",
            "attributes": {
                "allocated": {
                    "evcEndPoints[identifier=my-evc-ep-1].uni": {
                        "uniref": "inmanta:456-852-789",
                        "test_value": "test_value",
                    },
                    "evcEndPoints[identifier=my-evc-ep-2].uni": {
                        "uniref": "inmanta:123-852-456",
                        "test_value": "test_value",
                    },
                },
                "another_key": "any value",
            },
            "candidate_attributes": {
                "allocated": {
                    "evcEndPoints[identifier=my-evc-ep-1].uni": {
                        "uniref": "inmanta:456-852-789",
                        "test_value": "test_value",
                    },
                    "evcEndPoints[identifier=my-evc-ep-2].uni": {
                        "uniref": "inmanta:123-852-456",
                        "test_value": "test_value",
                    },
                },
                "another_key": "any value",
            },
            "active_attributes": {},
            "rollback_attributes": {},
        }
    ],
    "allocated",
)

will return:

[
    {
        "environment": "8f7bf3a5-d655-4bcb-bbd4-6222407be999",
        "id": "f93acfad-7894-4a12-9770-b27cbdd85c74",
        "service_entity": "carrierEthernetEvc",
        "version": 4,
        "config": {},
        "state": "allocating",
        "attributes": {
            "allocated": {
                "evcEndPoints[identifier=my-evc-ep-1].uni": {
                    "uniref": "inmanta:456-852-789",
                    "test_value": "test_value",
                },
                "evcEndPoints[identifier=my-evc-ep-2].uni": {
                    "uniref": "inmanta:123-852-456",
                    "test_value": "test_value",
                },
            },
            "evcEndPoints": [
                {
                    "identifier": "my-evc-ep-1",
                    "uni": {
                        "uniref": "inmanta:456-852-789",
                        "test_value": "test_value",
                    },
                },
                {
                    "identifier": "my-evc-ep-2",
                    "uni": {
                        "uniref": "inmanta:123-852-456",
                        "test_value": "test_value",
                    },
                },
            ],
            "another_key": "any value",
        },
        "candidate_attributes": {
            "allocated": {
                "evcEndPoints[identifier=my-evc-ep-1].uni": {
                    "uniref": "inmanta:456-852-789",
                    "test_value": "test_value",
                },
                "evcEndPoints[identifier=my-evc-ep-2].uni": {
                    "uniref": "inmanta:123-852-456",
                    "test_value": "test_value",
                },
            },
            "evcEndPoints": [
                {
                    "identifier": "my-evc-ep-1",
                    "uni": {
                        "uniref": "inmanta:456-852-789",
                        "test_value": "test_value",
                    },
                },
                {
                    "identifier": "my-evc-ep-2",
                    "uni": {
                        "uniref": "inmanta:123-852-456",
                        "test_value": "test_value",
                    },
                },
            ],
            "another_key": "any value",
        },
        "active_attributes": {},
        "rollback_attributes": {},
    }

]
lsm.current_state(fsm: lsm::ServiceEntity) dict

Returns the current state from the lifecycle and the next version of the instance

lsm.fsm_to_dot(config: lsm::LifecycleStateMachine) string

Generate a dot representation of the state machine

lsm.has_current_state(service_instance: lsm::ServiceEntity, state_name: string) bool

Check whether the given service instance is currently in the given state of its lifecycle.

Parameters
  • service_instance – The ServiceEntity object.

  • state_name – The name of the lifecycle state

lsm.render_dot(fsm: lsm::LifecycleStateMachine)

Render a dot graph in the current directory

Resources

class lsm.LifecycleTransferResource

A resource that collects deploy events and send them to the lsm

class lsm.ServiceInstanceResource

Handlers

class lsm.LifecycleTransferHandler

A handler that collects all resource statuses from resources that are part of a service instance. For legacy reasons, this handler uses two different mechanisms to determine whether the resources of a service instance are deployed successfully or not. Depending on the version of the agent, one of both mechanisms is used:

  • When the deploy() method is supported by the agent, that method is used to determine whether the resources of a service instance are deployed successfully or not.

  • When the deploy() method is not supported by the agent (this is the case on older Inmanta versions), the *_resource() methods are used together with the events mechanism (process_events() method). The *_resource() methods are only called when all resources deployed successfully. The process_events() method is also called when the one of the resources failed to deploy.

class lsm.ServiceInstanceHandler