Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wils0ns/saltypie
Saltstack API wrapper and state return parser.
https://github.com/wils0ns/saltypie
salt salt-api saltstack table
Last synced: 25 days ago
JSON representation
Saltstack API wrapper and state return parser.
- Host: GitHub
- URL: https://github.com/wils0ns/saltypie
- Owner: wils0ns
- License: mit
- Created: 2020-08-28T08:44:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-28T08:45:14.000Z (over 4 years ago)
- Last Synced: 2023-02-28T15:52:17.745Z (almost 2 years ago)
- Topics: salt, salt-api, saltstack, table
- Language: Python
- Homepage:
- Size: 530 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Saltypie - salt-api client and state return parser.
## Installation
```bash
pip install saltypie
```## Local client example
Code:
```python
from saltypie import Salt
from saltypie.output import StateOutputsalt = Salt(
url='https://192.168.70.11:8000',
username='saltapiuser',
passwd='abc123',
trust_host=True
)ret = salt.execute(
client=Salt.CLIENT_LOCAL,
target='*',
fun='state.apply',
pillar={'sleep': 1}
)sout = StateOutput(ret)
print(sout)
```Output:
```
+ minion01 ---------------------------------------------------------+
| State Plot % ms Result |
+-------------------------------------------------------------------+
| test succeed with changes |||||||||||| 42.13% 0.404 True |
| test succeed without changes |||||||| 29.61% 0.284 True |
| test no operation |||||||| 28.26% 0.271 True |
+-------------------------------------------------------------------+
| Total elapsed time: 0.96ms |
+-------------------------------------------------------------------+
```## Runner client example
Code:
```python
from saltypie import Salt
from saltypie.output import OrchestrationOutputsalt = Salt(
url='https://192.168.70.10:8000',
username='saltapiuser',
passwd='abc123',
trust_host=True
)
salt.eauth = 'pam'ret = salt.execute(
client=Salt.CLIENT_RUNNER,
fun='state.orch',
args=['orch_fail'],
pillar={'sleep': 1}
)orchout = OrchestrationOutput(ret, salt)
print(orchout.summary_table(max_bar_size=100, time_unit='s'))
```Output:
```
+ Orchestration -----------------------------------------------------------------+
| Step Plot % Time(s) Result |
+--------------------------------------------------------------------------------+
| Step01 ||||||||||||||||||||||||| 25.20% 5.13 True |
| Step02 |||||||||||||||||||||||| 24.69% 5.03 True |
| Step03 |||||||||||||||||||||||| 24.79% 5.05 True |
| Step04 ||||||||||||||||||||||||| 25.32% 5.16 False |
+--------------------------------------------------------------------------------+
| Total elapsed time: 20.37s |
+--------------------------------------------------------------------------------+
```## Terminal safe mode
All output classes have the `safe` property that is set to `False` if the terminal encoding is dectected to be *utf-8*. To always use safe mode set it to `True`:
Example:
```python
from saltypie import Salt
from saltypie.output import StateOutput, OrchestrationOutputsout = StateOutput(ret)
sout.safe = True
# play with the tables here ...orchout = OrchestrationOutput(ret, salt)
orchout.safe = True
# play with the tables here ...
```## Disable table coloring
Set the output object `colored` property to `False`:Example:
```python
from saltypie import Salt
from saltypie.output import OrchestrationOutputorchout = OrchestrationOutput(ret, salt)
orchout.colored = False
# play with the tables here ...
```More examples
=============https://gitlab.com/cathaldallan/saltypie/tree/master/examples
Documentation
=============https://cathaldallan.gitlab.io/saltypie/