Comments (5)
This is a great idea, but we need to discuss further why and how to do it. I really like the object-based approach and the use of context managers, however two points conflict with the initial design of Cuisine:
- Single-file API (I want cuisine to be compact, not to spread in too many files)
- Simple C-style API (do not use too complex features so that anyone will feel at home with Cuisine)
One of the reason for that is that cuisine is a mere wrapper around shell scripts, and I don't want to be too clever and introduce a level of complexity. Basically, because cuisine is targetted to sysadmins who know just a little bit of Python (and of course, full-fledged Python programmers) I want to keep things as close to "old-school C style" as possible. It's something I don't usually do but I think it makes sense in this case.
However, we have one problem right now: how to easily write variants for different platforms (for instance, using yum instead of apt-get). Using tests like if platform == "Linux" and dist == "Ubuntu" sounds a bit too cumbersome as opposed to having DebPackage and YumPackage classes that are provide specific exists, insttall, ensure, etc methods.
Another thing to consider is that changing the API would break compatibility with existing scripts -- cuisine is still early, so we can probably affort it, but it's something that we have to carefully think about.
Do you see a particular direction that we should take?
from cuisine.
I like the idea of being as simple as possible, and having one file API is certainly very attractive for use cases you've mentioned in the original README. Here's what I propose:
-
If you ever tried
pytest
, you probably know that it has a--genscript
command, which collects allpytest
modules and puts them in a single script, how about we do the same for cuisine? For example, suppose we have a bunch of modules calledssh
,file
,dir
etc, here's what will be available in the generated script:file.open() --> file_open() dir.ensure() --> dir_ensure()
-
Second option is to provide a high level layer above context managers and objects:
from cusine.api import file_open, dir_ensure
As for the package managers, I really like puppet's approach using providers -- in fact we can have both providers and platform discovery:
- An abstract provider interface, and a bunch of platform-dependent implementation,
AptProvider
,YUMProvider
etc. - Runtime distro discovery with
platform.linux_distribution()
What do you think?
from cuisine.
I tend to think this would just over-complicate the project, and end up with the mess that Chef is. Overall, I really want to avoid having an API that abstracts various system elements (User,Group,Package,File,etc) -- I want it to simply offer smart functions that have a low-level API/shell scripting feel.
I understrand the temptation to have a more OO approach to the project, but I would restrain from that unless there is no other option. I think we should go with a very simple thing right now, like having an "if" that dispatches to specific implementations depending on the platform, or does-it in place, ie: package_install could delegate to apt_install or yum_install depending on the platform.
This might cause problem in the long run if we have many package mangers supported, but until this happens, it's better to keep things simple, I think.
from cuisine.
Problem is, a bunch of "smart" functions is harder to maintain and modify, at least when compared to the layering approach. Having different API layers allows routine tasks to be done with a few lines of code and makes non-trivial tasks still possible.
Can you please give an example of Chef
s "mess"? I've never used it myself, unfortunately.
from cuisine.
Yes, I defninitely agree with that, but I'd prefer to wait and let Cuisine to grow organically -- once the single-file, flat API approach will show its limits, it will be time to move in the direction you pointed out. Just like Fabric, I want cuisine to be minimal and avoid turning into the complicated mess that Chef is.
from cuisine.
Related Issues (20)
- group_user_ensure fails in suse 11 sp3 HOT 5
- `user_create` function appears in duplicate HOT 1
- cuisine.file_write fails with 7.6 and 7.7 HOT 2
- Why `apt_get` function executes a command twice?
- What is changed between version 0.7.6 and 0.7.7? HOT 6
- SyntaxError: 'invalid syntax' cuisine.py at 342 HOT 1
- how to set up attributes (chef like ) in cuisine HOT 1
- `dir_ensure` tries to create the directory even if it exists HOT 3
- Please rename "bsd" features "freebsd" HOT 2
- file_upload() behavior for lcd context incompatible with fabric put() HOT 4
- Using hashlib breaks compatibility with CentoOS 5 HOT 2
- package_ensure_apt(package_name, update=True) upgrade all package not only selected HOT 2
- Newline at end of updated text
- process_find can't find processes due to leading spaces. HOT 3
- trapping fabric.exceptions.NetworkError HOT 3
- NameError: name 'env' is not defined HOT 2
- README links
- Support for Fabric 2.x? HOT 1
- Fix simple typo: referes -> refers
- Python 3 support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuisine.