New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detecting OpenVZ environment (hardware node or container) #582
Conversation
We need to think about proper names of classes and variables before merging such changes: there are lots of virtualization technologies, so we need a clear scheme for naming things. |
Is the wiki the right place for this kind of work ? |
Yes, it is. |
@vohi any progress on this one? Can I help? |
@tzz: Maybe you could draft up some basic guidelines for naming, like dottedmag suggests. Doesn't have to be very advanced, just something so that naming is not totally random. |
Also, note CFEngine already has something for Xen. Existing class will have to stay, but Xen will need to have it in the same scheme. I'd suggest 'guest_@name@', with the following @name@s: openvz, lxc, vmware (maybe also guest_vmware_@exacttype@), bochs, qemu, kvm, parallels (also maybe guest_parallels_@exacttype@), virtualbox, virtualpc. Also 'host_@name@', where appropriate (xen, openvz). Also, have a look at old bugtracker -- there is a bug with links on how to detect various virtualization technologies: https://cfengine.com/bugtracker/view.php?id=1192 |
It would be easier to support this if we had the ability to tag classes with their provenance. See https://cfengine.com/dev/issues/1895 I propose using namespaces, since they apply to classes as well. Then we can use e.g. following @dottedmag suggestion:
And similarly
and so on... basically box platform discovery into a namespace so it doesn't pollute the top namespace. We'll still have quite a few classes in the |
Sounds like a good idea! |
With #847 in the core, this can be rewritten as a module (shell script, ideally) and populate the My suggestion about namespacing classes under |
I must second @tzz on this suggestion. Having this kind of discovery code in shell/Perl/Python/other-simple-well-know-scripting-language is infinitely nicer than having it hardcoded in C. The advantages to my eyes are numerous: easier to hack, therefore encouraging more contributions to fix/extend it, also enabling users to change/fix/patch it without recompiling the whole agent, easier to debug/understand what is/isn't working... |
There's one little issue: issuing assembler instruction CPUID is a little bit non-trivial in shell/Perl/Python/whatever. |
@dottedmag, actually we have a script in Rudder to do just that: https://github.com/Normation/rudder-techniques/blob/master/tools/cpuid-linux-V1.0.sh. We're happy to contribute it to CFEngine, of course. |
Obviously some discovery code can still live in C. My proposal is only for things like this request, trivial in shell but harder in C (e.g. dealing with line endings, parsing |
The ideal implementation for me would be to have |
I can think of two issues:
|
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
I'd add that, on top of the discovery part, we also need to be able to change some hardcoded paths. |
Just a remark, this pull request scans the content of the file /proc/self/status for certains strings; however, it seems that it could be easier by:
This works for OpenVZ/Virtuozzo/Parallels Cloud Server |
Based on the discussions there, and inspired by @lpefferkorn 's code, I created the Pull Request #949 Thank you ! |
Can one of the admins verify this patch? |
Superseded by #949. |
Err... superseded by #956. |
Add hard classes _openvz_hardware_node_ and _openvz_container_ accordingly if we are in an OpenVZ environment:
On an hardware node:
Inside an OpenVZ container:
Tested on version 2.5 of OpenVZ