inmanta-module-std 5.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. inmanta_module_std-5.2.8/MANIFEST.in +5 -0
  2. inmanta_module_std-5.2.8/PKG-INFO +8 -0
  3. inmanta_module_std-5.2.8/README.md +119 -0
  4. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/PKG-INFO +8 -0
  5. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/SOURCES.txt +31 -0
  6. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/dependency_links.txt +1 -0
  7. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/not-zip-safe +1 -0
  8. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/requires.txt +4 -0
  9. inmanta_module_std-5.2.8/inmanta_module_std.egg-info/top_level.txt +1 -0
  10. inmanta_module_std-5.2.8/inmanta_plugins/std/__init__.py +1292 -0
  11. inmanta_module_std-5.2.8/inmanta_plugins/std/model/_init.cf +649 -0
  12. inmanta_module_std-5.2.8/inmanta_plugins/std/model/testing.cf +35 -0
  13. inmanta_module_std-5.2.8/inmanta_plugins/std/resources.py +696 -0
  14. inmanta_module_std-5.2.8/inmanta_plugins/std/setup.cfg +45 -0
  15. inmanta_module_std-5.2.8/inmanta_plugins/std/templates/host_uri.j2 +1 -0
  16. inmanta_module_std-5.2.8/inmanta_plugins/std/types.py +36 -0
  17. inmanta_module_std-5.2.8/pyproject.toml +6 -0
  18. inmanta_module_std-5.2.8/setup.cfg +49 -0
  19. inmanta_module_std-5.2.8/tests/test_agent.py +41 -0
  20. inmanta_module_std-5.2.8/tests/test_agentconfig.py +69 -0
  21. inmanta_module_std-5.2.8/tests/test_facts.py +35 -0
  22. inmanta_module_std-5.2.8/tests/test_file.py +132 -0
  23. inmanta_module_std-5.2.8/tests/test_get_attribute.py +62 -0
  24. inmanta_module_std-5.2.8/tests/test_in_docker.py +43 -0
  25. inmanta_module_std-5.2.8/tests/test_model.py +73 -0
  26. inmanta_module_std-5.2.8/tests/test_mutables.py +73 -0
  27. inmanta_module_std-5.2.8/tests/test_plugins.py +188 -0
  28. inmanta_module_std-5.2.8/tests/test_resources.py +494 -0
  29. inmanta_module_std-5.2.8/tests/test_template.py +372 -0
  30. inmanta_module_std-5.2.8/tests/test_types.py +213 -0
  31. inmanta_module_std-5.2.8/tests/test_unknown.py +53 -0
  32. inmanta_module_std-5.2.8/tests/test_warnings.py +53 -0
@@ -0,0 +1,5 @@
1
+ include inmanta_plugins/std/setup.cfg
2
+ include inmanta_plugins/std/py.typed
3
+ recursive-include inmanta_plugins/std/model *.cf
4
+ graft inmanta_plugins/std/files
5
+ graft inmanta_plugins/std/templates
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.2
2
+ Name: inmanta-module-std
3
+ Version: 5.2.8
4
+ License: Apache 2.0
5
+ Requires-Dist: Jinja2<4,>=3.1
6
+ Requires-Dist: email_validator<3,>=1.3
7
+ Requires-Dist: pydantic<3,>=1.10
8
+ Requires-Dist: inmanta-core<14,>=8.7.0.dev
@@ -0,0 +1,119 @@
1
+ # std Module
2
+
3
+ Inmanta base module that defines primitive types, entities and plugins regularly used when developing models.
4
+
5
+ ## Features
6
+
7
+ * Definition of Resource to define new resource:
8
+ * `Resource`/ `PurgeableResource` / `ManagedResource`: Base classes to define new resources
9
+ * `DiscoveryResource`: To define a resource that scans the infrastructure for a certain type of deployment
10
+ * Definition of `ResourceSet` (to manage resources in different sets) entities
11
+ * Create, Read, Update, Delete of ***Agent Configuration*** to manage the different settings of the agent
12
+ * Primitive type definitions such as:
13
+ * `Datetime`
14
+ * `IP`
15
+ * `Port`
16
+ * `URL`
17
+ * `UUID`
18
+ * `NullResource` entity mainly used for testing
19
+
20
+
21
+ ## Usage example
22
+
23
+ This simple example shows how to create an agent configuration. This configuration will try to update part of the agent configuration on the orchestrator. An agent configuration is mandatory to deploy the resource to the infrastructure because the orchestrator relies on an agent to do so.
24
+
25
+ ```inmanta
26
+ std::AgentConfig(
27
+ autostart=true,
28
+ agentname="http://example.com",
29
+ uri="local:",
30
+ )
31
+ ```
32
+
33
+ The name of this agent `http://example.com` can now be referred to when defining a python Resource
34
+
35
+ ```python
36
+ @inmanta.resources.resource(
37
+ "__config__::MyNewResource",
38
+ "uri",
39
+ "agentname" # This is the name of the field that will refer to the agent's name, in this case this field will contain `http://example.com`
40
+ )
41
+ class EntitlementResource(inmanta.resources.PurgeableResource):
42
+ pass
43
+ ```
44
+
45
+ More information about developing Python Resources and Handlers can be found [here](https://docs.inmanta.com/inmanta-service-orchestrator/7/model_developers/handlers.html#handler).
46
+
47
+ Another example would be to define a new resource that can be created / updated / removed. The following example is really basic
48
+ and should probably not be implemented, an inventory would be better for that. But for the sake of a basic example, let's suppose that
49
+ we want a resource that represent the reservation of an IP address from a particular user. We would also save the datetime at which the
50
+ request has been made.
51
+
52
+ ```inmanta
53
+ entity MyNewResource extends PurgeableResource:
54
+ """
55
+ A base class for a resource that can be purged and can be purged by Inmanta whenever the resource is no
56
+ longer managed.
57
+
58
+ :attr purged: Set whether this resource should exist or not.
59
+ """
60
+ ipv4_address reserved_ip
61
+ datetime since
62
+ name_email user
63
+ string agentname
64
+ end
65
+
66
+ implement MyNewResource using parents
67
+
68
+ new_resource = MyNewResource(
69
+ reserved_ip="192.168.1.1",
70
+ since="1970-01-01T00:00:00",
71
+ user="Fred Bloggs <fred.bloggs@example.com>",
72
+ agentname="http://example.com",
73
+ )
74
+ ```
75
+
76
+ If we wanted to remove ("purge" in inmanta terms) this resource, we would do the following:
77
+
78
+ ```inmanta
79
+ new_resource = MyNewResource(
80
+ reserved_ip="192.168.1.1",
81
+ since="1970-01-01T00:00:00",
82
+ user="Fred Bloggs <fred.bloggs@example.com>",
83
+ purged=true, # This is the diff
84
+ agentname="http://example.com",
85
+ )
86
+ ```
87
+
88
+ We can also define new types:
89
+ - Based on constraints on the type
90
+ - Provide a list of values (Enum)
91
+ - Use an existing pydantic type to enforce additional constraints
92
+ - Rely on regex
93
+ ```inmanta
94
+ typedef port as int matching self >= 1024 and self < 65536
95
+ """
96
+ A TCP/UDP port number that an user can use.
97
+ """
98
+
99
+ typedef protocol as string matching self in ["tcp", "udp"]
100
+ """
101
+ A protocol
102
+ """
103
+
104
+ typedef negative_float as number matching std::validate_type("pydantic.NegativeFloat", self)
105
+ """
106
+ A floating point number less than zero.
107
+ """
108
+
109
+ typedef alfanum as string matching std::validate_type("pydantic.constr", self, {"regex": "^[a-zA-Z0-9]*$", "strict": true})
110
+ """
111
+ An alfanumeric number (lower- and uppercase characters are allowed).
112
+ """
113
+ ```
114
+
115
+ ```{toctree}
116
+ :maxdepth: 1
117
+ autodoc.rst
118
+ CHANGELOG.md
119
+ ```
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.2
2
+ Name: inmanta-module-std
3
+ Version: 5.2.8
4
+ License: Apache 2.0
5
+ Requires-Dist: Jinja2<4,>=3.1
6
+ Requires-Dist: email_validator<3,>=1.3
7
+ Requires-Dist: pydantic<3,>=1.10
8
+ Requires-Dist: inmanta-core<14,>=8.7.0.dev
@@ -0,0 +1,31 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ setup.cfg
5
+ inmanta_module_std.egg-info/PKG-INFO
6
+ inmanta_module_std.egg-info/SOURCES.txt
7
+ inmanta_module_std.egg-info/dependency_links.txt
8
+ inmanta_module_std.egg-info/not-zip-safe
9
+ inmanta_module_std.egg-info/requires.txt
10
+ inmanta_module_std.egg-info/top_level.txt
11
+ inmanta_plugins/std/__init__.py
12
+ inmanta_plugins/std/resources.py
13
+ inmanta_plugins/std/setup.cfg
14
+ inmanta_plugins/std/types.py
15
+ inmanta_plugins/std/model/_init.cf
16
+ inmanta_plugins/std/model/testing.cf
17
+ inmanta_plugins/std/templates/host_uri.j2
18
+ tests/test_agent.py
19
+ tests/test_agentconfig.py
20
+ tests/test_facts.py
21
+ tests/test_file.py
22
+ tests/test_get_attribute.py
23
+ tests/test_in_docker.py
24
+ tests/test_model.py
25
+ tests/test_mutables.py
26
+ tests/test_plugins.py
27
+ tests/test_resources.py
28
+ tests/test_template.py
29
+ tests/test_types.py
30
+ tests/test_unknown.py
31
+ tests/test_warnings.py
@@ -0,0 +1,4 @@
1
+ Jinja2<4,>=3.1
2
+ email_validator<3,>=1.3
3
+ pydantic<3,>=1.10
4
+ inmanta-core<14,>=8.7.0.dev
@@ -0,0 +1 @@
1
+ inmanta_plugins