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','rollback'])

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.

attribute string[]? __lsm_key_attributes=null#

list of attributes that uniquely identify the embedded entity. The embedded entity must have an index defined on these attribute.

attribute dict __annotations=Dict()#

The annotations that should be associated with this ServiceEntity. The key-value pairs in this dictionary represent respectively the name and the value of the annotation.

The following implements statements select implementations for this entity:

entity lsm::InterServiceRelation#

Parents: std::Entity

An Entity used to create relations between different services. This Entity should be used as an annotation on a relationship definition and should only be used through the __service__ variable

The following implements statements select implementations for this entity:

entity lsm::LifecycleStateMachine#

Parents: std::Entity

The lifecycle 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::RelationAnnotations#

Parents: std::Entity

An entity that holds the annotations set on a relationship.

attribute dict annotations#

Annotations that should be associated with a relationship.

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 a parent entity to its children entities. These children can be:
  • entities that are refined from the parent entity.

  • entities that are owned by the parent entity.

  • embedded entities that are part of the parent entity.

This relation is required to collect all resources a service consists of.

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

relation lsm::ServiceBase parent [0:1]#
This relation connects a parent entity to its children entities. These children can be:
  • entities that are refined from the parent entity.

  • entities that are owned by the parent entity.

  • embedded entities that are part of the parent entity.

This relation is required to collect all resources a service consists of.

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.

relation std::Resource owned_resources [0:*]#

A sublist of ServiceBase.resources containing only those resources that are exclusively used by this service instance. This list is used when the lsm_partial_compile environment option is enabled to determine the resources for the resource set of this service.

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.

attribute dict __annotations=Dict()#

Annotations that should be associated with this ServiceEntity. The key-value pairs in this dictionary represent respectively the name and the value of the annotation.

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 service 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

attribute string? relation_to_owner=null#

the name of the InterServiceRelation to use to find the owning instance

attribute bool strict_modifier_enforcement=false#

Boolean value to control if strict validation of embedded entities’ attributes with respect to modifiers is on or off

relation lsm::LifecycleStateMachine lifecycle [1]#

The statemachine that represents the lifecycle

relation lsm::ServiceEntityBinding owned [0:*]#

The ServiceEntityBinding in whose ResourceSet the resources for this entity should be placed in case of partial compile

other end: lsm::ServiceEntityBinding.owner [0:1]

relation lsm::ServiceEntityBinding owner [0:1]#

The ServiceEntityBinding in whose ResourceSet the resources for this entity should be placed in case of partial compile

other end: lsm::ServiceEntityBinding.owned [0:*]

The following implements statements select implementations for this entity:

entity lsm::ServiceEntityBindingV2#

Parents: lsm::ServiceEntityBinding

Version 2 of the ServiceEntityBinding entity. In contrast to the ServiceEntityBinding entity, this entity enabled strict_modifier_enforcement by default.

attribute bool strict_modifier_enforcement=true#

The following implements statements select implementations for this entity:

  • constraint true

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::setResourceSet#

Associate a resource set with this ServiceEntity.

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.format(__string: 'string', args: 'list', kwargs: 'dict') 'string'#

Format a string using python string formatter, and accepting statements which native inmanta f-string doesn’t support (such as accessing dict values)

Parameters:
  • __string – The string to apply formatting to

  • args – The positional arguments to feed into the str.format method

  • kwargs – The keyword arguments to feed into the str.format method

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.is_validating(instance_id: 'string') 'bool'#

Return true if the current compile is a validating compile and the instance being validated has the given id.

Parameters:

instance_id – The id of the instance we want to check for validation.

lsm.render_dot(fsm: 'lsm::LifecycleStateMachine')#

Render a dot graph in the current directory

lsm::allocators.get_first_free_integer(service: 'lsm::ServiceEntity', attribute_path: 'string', *, range_start: 'int', range_end: 'int', used_values: 'any') -> 'int'

Get the first free integer in the given range.

Check all services of the same type as the provided service for the value at attribute_path. Services can be filtered out by using the filters parameter. The filters parameters take as key the path to an attribute in the service and as value the attribute value that the service is expected at this path. If the value is no match, the service is ignored.

Parameters:
  • range_start – The lowest value that can be allocated.

  • range_end – The highest value that can be allocated.

  • used_values – A UsedValues object, as defined in inmanta_plugins.lsm.allocators.

lsm::allocators.get_service_used_values(service: 'lsm::ServiceEntity', attributes_path: 'string', *, attribute_sets: 'string[]?' = None, attribute_sets_matching: 'dict?' = None) -> 'any'

Get all the values used by this service at the given attribute path. The path can be a wild dict path, making use of wild cards to select multiple values within this service.

The values are checked in each resource set of the service. Some attributes sets can be excluded by providing a value to the attribute_sets param. When this is provided, we will only consider the attributes sets which are provided in the parameter.

The value returned by this plugin can not be used within the model. It can only be used as input for a V3 allocator.

Parameters:
  • service – The service in which we should look for the values.

  • attributes_path – The wild dict path that points to the attributes we want to get the values of.

  • attribute_sets – A list of attribute sets to consider when looking for a value. By default, check all attribute sets.

  • attribute_sets_matching – A dict taking as key dict_path expressions, and as values literals. The dict will then be used to filter the instances in which we should look for the usage of values. Any attribute set for which any of the value at the given path doesn’t match the value in this dict, will be left out.

lsm::allocators.get_used_values(binding: 'lsm::ServiceEntityBindingV2', attributes_path: 'string', *, states: 'string[]?' = None, attribute_sets: 'string[]?' = None, attribute_sets_matching: 'dict?' = None) -> 'any'

Get all the values used by the services of this binding at the given attribute path. The path can be a wild dict path, making use of wild cards to select multiple values within one service.

The values are checked in each resource set of each service in the inventory. Some attributes sets can be excluded by providing a value to the attribute_sets param. Some states can be excluded by providing a value to the states param. When those parameters are provided, we will only consider the attributes sets or states which are provided in the parameter.

The value returned by this plugin can not be used within the model. It can only be used as input for a V3 allocator.

Parameters:
  • binding – The binding defining the service in the catalog.

  • attributes_path – The wild dict path that points to the attributes we want to get the values of.

  • attribute_sets – A list of attribute sets to consider when looking for a value. By default, check all attribute sets.

  • attribute_sets_matching – A dict taking as key dict_path expressions, and as values literals. The dict will then be used to filter the instances in which we should look for the usage of values. Any attribute set for which any of the value at the given path doesn’t match the value in this dict, will be left out.

  • states – A list of states to consider when looking for a value. By default, check all states. Any service that is not in one of the provided states is skipped.

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. The deploy() method is used to determine whether the resources of a service instance are deployed successfully or not.

class lsm.ServiceInstanceHandler#