/
index.txt
214 lines (151 loc) · 4.32 KB
/
index.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
###
xal
###
This document contains contents of xal poster session at `EuroPython 2013 in
Florence, Italy <https://ep2013.europython.eu/>`_.
* Poster as PDF:
https://github.com/benoitbryon/xal/raw/master/docs/presentations/2013-europython/poster.pdf
* Sources:
https://github.com/benoitbryon/xal/tree/master/docs/presentations/2013-europython
********
Abstract
********
XAL is a proof of concept designed to write high-level scripts you can reuse
within various tools such as Fabric, zc.buildout, Salt…
Python has strong features for sysadmin scripts: portability, a shell and great
libraries. But, currently, you develop using tool’s specific implementation. As
a consequence, users of each project develop different tools that do similar
things.
XAL proposes a new approach for system-related scripts: develop to a session.
Write scripts that get a session as argument. That session is an abstraction
layer for system resources such as files, users, packages… It is just like an
ORM abstracts the database implementation. This design makes it possible to
share sysadmin scripts that you can use within all those great Python tools
related to system and deployment. Reduced cost of change and improved
collaboration!
This poster will present the concepts of XAL. This project is a
proof-of-concept, so the author will be glad to get feedback, discuss the ideas
and, if you are interested in, sprint on it!
***
xal
***
xal
execution abstraction layer
for high-level system scripts
********************
Develop to a session
********************
.. code:: python
def greetings(session):
"""Write 'Hello world!' in 'greetings.txt' file relative to user's home."""
home = session.user.home
file_path = session.file.join(home, u'greetings.txt')
file_resource = session.file(file_path)
with file_resource.open('w'):
file_resource.write(u'Hello world!')
.. raw:: pdf
PageBreak
***************
Run it anywhere
***************
Shell
=====
In an interactive shell:
.. code:: pycon
>>> from europython import greetings
>>> import xal
>>> session = xal.LocalSession()
>>> greetings(session)
Fabric
======
In a fabfile:
.. code:: python
from europython import greetings
import xal
def hello_fabric():
session = xal.FabricSession(sudoer=True)
greetings(session)
zc.buildout
===========
In a buildout recipe:
.. code:: python
from europython import greetings
import xal
class HelloBuildout(object):
def __init__(self, buildout, name, options):
self.session = xal.BuildoutSession(buildout, name, options)
def install(self):
greetings(self.session)
Salt
====
In a salt module:
.. code:: python
from europython import greetings
import xal
def hello_salt():
session = xal.SaltSession(__salt__)
greetings(session)
***************
Share libraries
***************
xal enables wider cooperation in Python community
*********************
Improve your workflow
*********************
* Do not wait for full provisioning stack, enter your project ASAP
* First focus on what your script does
* Then configure execution environment
* Build the provisioning stack incrementally
* Change provisioner, keep deployment recipes
*****************************
Exit the subprocess labyrinth
*****************************
* subprocess
* async_subprocess
* chut
* clom
* Command
* commandwrapper
* cpopen
* desub
* EasyProcess
* envoy
* execute
* extcmd
* extproc
* gevent_subprocess
* iterpipes
* pbs
* pipeline
* pyutilib.subprocess
* sarge
* seminode.utils.command
* sh
* shellout
* spur
* subwrap
* ... and more...
* ... and maybe yours
Could xal help APIs converge?
**********
Challenges
**********
* xal needs strong APIs:
* run commands (subprocess wrapper)
* consistent set of resources (files, users...)
=> PEPs?
* Efficient and comprehensive session registry
* Preconfigured registries: fabric, salt, buildout, local session...
* Resolution of session's dependencies
* Smart handling of NotImplementedError
* Unit tests with mocks, integration tests
*************************
xal is a proof of concept
*************************
https://xal.readthedocs.org
****************
Credits, license
****************
xal is released under BSD license
|copy| 2012-2013, Benoît Bryon
.. |copy| unicode:: 0xA9 .. copyright sign