Module std

  • License: Apache 2.0

  • Version: 8.0.0

Typedefs

typedef std::alfanum
  • Base type string

  • Type constraint std::validate_type('pydantic.constr',self,{'regex': '^[a-zA-Z0-9]*$', 'strict': True})

typedef std::any_http_url
  • Base type string

  • Type constraint std::validate_type('pydantic.AnyHttpUrl',self)

typedef std::any_url
  • Base type string

  • Type constraint std::validate_type('pydantic.AnyUrl',self)

typedef std::ascii_word
  • Base type string

  • Type constraint std::validate_type('pydantic.constr',self,{'regex': '^[!-~]*$', 'strict': True})

typedef std::base64
  • Base type string

  • Type constraint std::is_base64_encoded(self)

typedef std::config_agent
  • Base type string

  • Type constraint (self != 'internal')

typedef std::date
  • Base type string

  • Type constraint std::validate_type('datetime.date',self)

typedef std::datetime
  • Base type string

  • Type constraint std::validate_type('datetime.datetime',self)

typedef std::email_str
  • Base type string

  • Type constraint std::validate_type('pydantic.EmailStr',self)

typedef std::hoststring
  • Base type string

  • Type constraint /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*$/

typedef std::http_url
  • Base type string

  • Type constraint std::validate_type('pydantic.HttpUrl',self)

typedef std::ipv4_address
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv4Address',self)

typedef std::ipv4_interface
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv4Interface',self)

typedef std::ipv4_network
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv4Network',self)

typedef std::ipv6_address
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv6Address',self)

typedef std::ipv6_interface
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv6Interface',self)

typedef std::ipv6_network
  • Base type string

  • Type constraint std::validate_type('ipaddress.IPv6Network',self)

typedef std::ipv_any_address
  • Base type string

  • Type constraint std::validate_type('pydantic.IPvAnyAddress',self)

typedef std::ipv_any_interface
  • Base type string

  • Type constraint std::validate_type('pydantic.IPvAnyInterface',self)

typedef std::ipv_any_network
  • Base type string

  • Type constraint std::validate_type('pydantic.IPvAnyNetwork',self)

typedef std::name_email
  • Base type string

  • Type constraint std::validate_type('pydantic.NameEmail',self)

typedef std::negative_float
  • Base type float

  • Type constraint std::validate_type('pydantic.NegativeFloat',self)

typedef std::negative_int
  • Base type int

  • Type constraint std::validate_type('pydantic.NegativeInt',self)

typedef std::non_empty_string
  • Base type string

  • Type constraint /^(.*\S.*)$/

typedef std::port
  • Base type int

  • Type constraint ((self >= 0) and (self < 65536))

typedef std::positive_float
  • Base type float

  • Type constraint std::validate_type('pydantic.PositiveFloat',self)

typedef std::positive_int
  • Base type int

  • Type constraint std::validate_type('pydantic.PositiveInt',self)

typedef std::printable_ascii
  • Base type string

  • Type constraint std::validate_type('pydantic.constr',self,{'regex': '^[ -~]*$', 'strict': True})

typedef std::time
  • Base type string

  • Type constraint std::validate_type('datetime.time',self)

typedef std::uuid
  • Base type string

  • Type constraint std::validate_type('uuid.UUID',self)

Entities

entity std::AgentConfig

Parents: std::PurgeableResource

Control agent settings. Currently these settings are only applied to autostarted agents

attribute bool autostart=false

When this flag is set to true, the resource will be exported and set the agent map on the orchestrator. When false, this instance is ignored but can be used to generate agent configuration files.

attribute std::config_agent agentname

The name of the agent to which this config applies.

attribute string agent='internal'

If a resource is exported, agent manages the resource.

attribute string uri='local:'

The uri that indicates how the agent should execute. Currently the following uri are supported: * “” An empty string. This is the same as running it locally * local: Manage resource locally * ssh://[user@]hostname[:port] Login using ssh. When user is left out, root is assumed. For port, the system default is used. * host The actual hostname or ip to use. Although this is not a valid host in uri form it is supported. * A query string can be used to set the properties: * python: The python interpreter to use. The default value is python * retries: The number of retries before giving up. The default number of retries 10 * retry_wait: The time to wait between retries for the remote target to become available. The default wait is 30s. Example: ssh://centos@centos-machine/?python=python3 (This would connect to a the centos machine and use python3 as it’s interpreter)

The following implements statements select implementations for this entity:

entity std::DiscoveryResource

Parents: std::Resource

A resource that scans the infrastructure for a certain type of deployment. This resource can be used to facilitate the onboarding of resources that are not yet managed by the orchestrator.

entity std::Entity

The entity all other entities inherit from.

relation std::Entity requires [0:*]

other end: std::Entity.provides [0:*]

relation std::Entity provides [0:*]

other end: std::Entity.requires [0:*]

The following implementations are defined for this entity:

entity std::Host

Parents: std::ManagedDevice

A host models a server or computer in the managed infrastructure that has an ip address.

attribute std::ipv_any_address? ip=null

The ipaddress of this node.

attribute bool remote_agent=false

Start the mgmt agent for this node on the server and use remote io (ssh).

attribute string remote_user='root'

The remote user for the remote agent to login with.

attribute std::port remote_port=22

The remote port for this remote agent to use.

relation std::OS os [1]

Each host has an OS defined. This values is mostly used to select implementation in the where clause of an implement statement. The familyof() plugin can be used for this.

relation std::HostConfig host_config [1]

other end: std::HostConfig.host [1]

relation std::HostGroup host_groups [0:*]

other end: std::HostGroup.hosts [0:*]

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity std::HostConfig

Parents: std::Entity

This represents generic configuration for a host. This entity is used by other modules to include their host specific configuration. This should be instantiated in the implementation of std::Host or subclasses. This host specific configuration cannot be included by just implementing std::Host because possibly subclasses of std::Host are instantiated and implementations are not inherited.

relation std::Host host [1]

other end: std::Host.host_config [1]

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity std::HostGroup

Parents: std::Entity

This entity represents a group of hosts. For example a cluster of machines.

attribute string name
relation std::Host hosts [0:*]

other end: std::Host.host_groups [0:*]

The following implements statements select implementations for this entity:

entity std::ManagedDevice

Parents: std::Entity

This interface represents all devices that can be managed

attribute std::hoststring name
entity std::ManagedResource

Parents: std::Resource

A base class for a resource that can be ignored/unmanaged by Inmanta.

attribute bool managed=true

This determines whether this resource is managed by Inmanta or not.

entity std::MutableBool

Parents: std::Entity

Wrapper for boolean values, used to pass a boolean out of an if statement.

Example:

attr_a = std::MutableBool()
if some_condition:
    attr_a.value = True
else:
    attr_a.value = Null
end
attribute bool? value

The following implements statements select implementations for this entity:

entity std::MutableFloat

Parents: std::Entity

Wrapper for float values, used to pass a float out of an if statement or to use relations to create a mutable set of float.

Example:

attr_a = std::MutableFloat()
if some_condition:
    attr_a.value = 3.0
else:
    attr_a.value = 4.0
end
Example:

entity Test:
end

Test.string_list [0:] -- std::MutableFloat

a = Test()
a.string_list += std::MutableFloat(value=3.0)
a.string_list += std::MutableFloat(value=7.0)
attribute float? value

The following implements statements select implementations for this entity:

entity std::MutableInt

Parents: std::Entity

Wrapper for int values, used to pass a int out of an if statement or to use relations to create a mutuable set of int.

Example:

attr_a = std::MutableInt()
if some_condition:
    attr_a.value = 3
else:
    attr_a.value = 4
end
Example:

entity Test:
end

Test.string_list [0:] -- std::MutableInt

a = Test()
a.string_list += std::MutableInt(value=3)
a.string_list += std::MutableInt(value=7)
attribute int? value

The following implements statements select implementations for this entity:

entity std::MutableString

Parents: std::Entity

Wrapper for string values. It can be used to pass a string out of an if statement, or to use relations to create a mutable set of strings.

Example:

attr_a = std::MutableString()
if some_condition:
    attr_a.value = "a"
else:
    attr_a.value = "b"
end
Example:

entity Test:
end

Test.string_list [0:] -- std::MutableString

a = Test()
a.string_list += std::MutableString(value="value1")
a.string_list += std::MutableString(value="value2")
attribute string? value

The following implements statements select implementations for this entity:

entity std::OS

Parents: std::Entity

Defines an operating system

attribute string name

The name of the operating system or family of operating systems

attribute float version=0.0

A specific version

attribute string? python_cmd='python'

Specifies what command should be used to launch the python interpreter on the other end

relation std::OS member [0:*]

other end: std::OS.family [0:1]

relation std::OS family [0:1]

other end: std::OS.member [0:*]

The following implements statements select implementations for this entity:

entity std::PurgeableResource

Parents: std::Resource

A base class for a resource that can be purged and can be purged by Inmanta whenever the resource is no longer managed.

attribute bool purged=false

Set whether this resource should exist or not.

attribute bool purge_on_delete=false

Purge the resource when it is deleted from the configuration model. When this attribute is true, the server will include a resource with purged=true when this resource is no longer included in the configuration model.

entity std::Resource

Parents: std::Entity

A base entity for resources that can be exported. This type add specific attributes that are common for most handlers. It is not required to inherit from this entity at the moment but highly recommended for documentation purposes.

attribute bool send_event=false

This controls whether a resource should send its deploy state to the resources in its provides.

attribute bool receive_events=true

This controls whether a resource should receive events from other resources, i.e. its requires that have send_event=true. Resources with receive_events=true will always be deployed whenever a dependency produces an event. Set this to false for resources that do not rely on events (most practical resources) to reduce the amount of redundant deploys, thereby increasing performance (will not have any effect for inmanta-core<14).

entity std::ResourceSet

Parents: std::Entity

A ResourceSet describes resources that logically belong together, and can be manipulated independently from other managed resources.

attribute std::non_empty_string name

The name of the resource set.

relation std::Resource resources [0:*]

The following implements statements select implementations for this entity:

entity std::testing::NullResource

Parents: std::ManagedResource, std::PurgeableResource

A resource that does nothing, for use in tests and examples

attribute string name='null'

the name of this resource

attribute string agentname='internal'

the name of the agent to deploy this resource on

attribute bool send_event=true
attribute bool fail=false

when true, this resource will always fail on both dryrun and deploy

The following implements statements select implementations for this entity:

Implementations

implementation std::agentConfig
implementation std::hostDefaults
implementation std::none

An empty implementation that can be used as a safe default.

Plugins

std.add_to_ip(addr: 'std::ipv_any_address', n: 'int') 'std::ipv_any_address'

Add a number to the given ip.

std.assert(expression: 'bool', message: 'string' =) 'any'

Raise assertion error if expression is false

std.at(objects: 'list', index: 'int') 'any'

Get the item at index

std.attr(obj: 'any', attr: 'string') 'any'
std.capitalize(string: 'string') 'string'

Capitalize the given string

std.contains(dct: 'dict', key: 'string') 'bool'

Check if key exists in dct.

std.count(item_list: 'list') 'int'

Returns the number of elements in this list.

If any unknowns are present in the list, counts them like any other value. Depending on the unknown semantics in your model this may produce an inaccurate count. For a count that is conservative with respect to unknowns, see len.

std.dict_get(dct: 'dict', key: 'string') 'string'

Get an element from the dict. Raises an exception when the key is not found in the dict

std.environment() 'string'

Return the environment id

std.environment_name() 'string'

Return the name of the environment (as defined on the server)

std.environment_server() 'string'

Return the address of the management server

std.equals(arg1: 'any', arg2: 'any', desc: 'string' = None) 'any'

Compare arg1 and arg2

std.familyof(member: 'std::OS', family: 'string') 'bool'

Determine if member is a member of the given operating system family

std.file(path: 'string') 'string'

Return the textual contents of the given file

std.filter(values: 'list', not_item: 'std::Entity') 'list'

Filter not_item from values

std.flatten(item_list: 'list') 'list'

Flatten this list

std.generate_password(pw_id: 'string', length: 'int' = 20) 'string'

Generate a new random password and store it in the data directory of the project. On next invocations the stored password will be used.

Parameters:
  • pw_id – The id of the password to identify it.

  • length – The length of the password, default length is 20

std.get_env(name: 'string', default_value: 'string' = None) 'string'
std.get_env_int(name: 'string', default_value: 'int' = None) 'int'
std.getattr(entity: 'std::Entity', attribute_name: 'string', default_value: 'any' = None, no_unknown: 'bool' = True) 'any'

Return the value of the given attribute. If the attribute does not exist, return the default value.

Attr no_unknown:

When this argument is set to true, this method will return the default value when the attribute is unknown.

std.getfact(resource: 'any', fact_name: 'string', default_value: 'any' = None) 'any'

Retrieve a fact of the given resource

std.hostname(fqdn: 'string') 'string'

Return the hostname part of the fqdn

std.inlineif(conditional: 'bool', a: 'any', b: 'any') 'any'

An inline if

std.invert(value: 'bool') 'bool'

Invert a boolean value

std.ip_address_from_interface(ip_interface: 'std::ipv_any_interface') 'std::ipv_any_address'

Take an ip address with network prefix and only return the ip address

Parameters:

ip_interface – The interface from where we will extract the ip address

std.ipindex(addr: 'std::ipv_any_network', position: 'int', keep_prefix: 'bool' = False) 'string'

Return the address at position in the network.

Parameters:
  • addr – The network address

  • position – The desired position of the address

  • keep_prefix – If the prefix should be included in the result

std.is_base64_encoded(s: 'string') 'bool'

Check whether the given string is base64 encoded.

std.is_instance(obj: 'any', cls: 'string') 'bool'
std.is_unknown(value: 'any') 'bool'
std.isset(value: 'any') 'bool'

Returns true if a value has been set

std.item(objects: 'list', index: 'int') 'list'

Return a list that selects the item at index from each of the sublists

std.key_sort(items: 'list', key: 'any') 'list'

Sort an array of object on key

std.len(item_list: 'list') 'int'

Returns the number of elements in this list. Unlike count, this plugin is conservative when it comes to unknown values. If any unknown is present in the list, the result is also unknown.

std.length(value: 'string') 'int'

Return the length of the string

std.limit(string: 'string', length: 'int') 'string'

Limit the length for the string

Parameters:
  • string – The string to limit the length off

  • length – The max length of the string

std.list_files(path: 'string') 'list'

List files in a directory

std.lower(string: 'string') 'string'

Return a copy of the string with all the cased characters converted to lowercase.

std.netmask(addr: 'std::ipv_any_interface') 'std::ipv_any_address'

Return the netmask of the CIDR

For instance:
std::print(netmask(“192.168.1.100/24”)) –> 255.255.255.0
std.network_address(addr: 'std::ipv_any_interface') 'std::ipv_any_address'

Return the network address of the CIDR

For instance:
std::print(network_address(“192.168.1.100/24”)) –> 192.168.1.0
std.objid(value: 'any') 'string'
std.password(pw_id: 'string') 'string'

Retrieve the given password from a password file. It raises an exception when a password is not found

Parameters:

pw_id – The id of the password to identify it.

std.prefixlen(addr: 'std::ipv_any_interface') 'int'

Return the prefixlen of the CIDR

For instance:
std::print(prefixlen(“192.168.1.100/24”)) –> 24
std.prefixlength_to_netmask(prefixlen: 'int') 'std::ipv4_address'

Given the prefixlength, return the netmask

std.print(message: 'any') 'any'

Print the given message to stdout

std.replace(string: 'string', old: 'string', new: 'string') 'string'
std.select(objects: 'list', attr: 'string') 'list'

Return a list with the select attributes

std.sequence(i: 'int', start: 'int' = 0) 'list'

Return a sequence of i numbers, starting from zero or start if supplied.

Parameters:
  • i – The number of elements in the sequence.

  • start – The starting value for the sequence.

Returns:

A list containing the sequence of ints.

std.server_ca() 'string'
std.server_port() 'int'
std.server_ssl() 'bool'
std.server_token(client_types: 'string[]' = ['agent']) 'string'
std.source(path: 'string') 'string'

Return the textual contents of the given file

std.split(string_list: 'string', delim: 'string') 'list'

Split the given string into a list

Parameters:
  • string_list – The list to split into parts

  • delim – The delimeter to split the text by

std.template(path: 'string', **kwargs: 'any') 'string'

Execute the template in path in the current context. This function will generate a new statement that has dependencies on the used variables.

Parameters:
  • path – The path to the jinja2 template that should be resolved.

  • **kwargs

    A set of variables that should overwrite the context accessible to the template.

std.timestamp(dummy: 'any' = None) 'int'

Return an integer with the current unix timestamp

Parameters:

any – A dummy argument to be able to use this function as a filter

std.type(obj: 'any') 'any'
std.unique(item_list: 'list') 'bool'

Returns true if all items in this sequence are unique

std.unique_file(prefix: 'string', seed: 'string', suffix: 'string', length: 'int' = 20) 'string'
std.upper(string: 'string') 'string'

Return a copy of the string with all the cased characters converted to uppercase.

std.validate_type(fq_type_name: 'string', value: 'any', validation_parameters: 'dict' = None) 'bool'

Check whether value satisfies the constraints of type fq_type_name. When the given type (fq_type_name) requires validation_parameters, they can be provided using the optional validation_parameters argument.

The following types require validation_parameters:

  • pydantic.condecimal:

    gt: Decimal = None ge: Decimal = None lt: Decimal = None le: Decimal = None max_digits: int = None decimal_places: int = None multiple_of: Decimal = None

  • pydantic.confloat and pydantic.conint:

    gt: float = None ge: float = None lt: float = None le: float = None multiple_of: float = None,

  • pydantic.constr:

    min_length: int = None max_length: int = None curtail_length: int = None (Only verify the regex on the first curtail_length characters) regex: str = None (The regex is verified via Pattern.match())

Example usage:

  • Define a vlan_id type which represent a valid vlan ID (0-4,095):

    typedef vlan_id as number matching std::validate_type(“pydantic.conint”, self, {“ge”: 0, “le”: 4095})

Resources

class std.resources.AgentConfig

A resource that can modify the agentmap for autostarted agents

class std.resources.Null

Handlers

class std.resources.NullProvider

Does nothing at all

class std.resources.AgentConfigHandler