dgzlopes / cloud-detect

Module that determines a host's cloud provider.
https://pypi.org/project/cloud-detect/
MIT License
35 stars 13 forks source link

Add OpenStack provider #29

Closed nikhil-prabhu closed 5 months ago

nikhil-prabhu commented 5 months ago

I've added support for detecting OpenStack, based on the "Discovery" section specified here: https://cloudinit.readthedocs.io/en/latest/reference/datasources/openstack.html#discovery

Note that my code does not check /proc/1/environ as specified in the document, as reading this file requires superuser privileges.

I've tested these changes on an OpenStack VM (OpenMetal).

nikhil-prabhu commented 5 months ago
  1. Send a pull request and bug me until it gets merged and published.

@dgzlopes as specified in the README, I'm bugging you now to merge this PR ;)

kshivakumar commented 5 months ago

@nikhil-prabhu OpenStack is not a cloud computing vendor. cloud-detect package is meant for detecting cloud vendors, not the underlying stack/platform powering the vendor. It's difficult to identify or differentiate Huawei Cloud, Open Telekom Cloud and other OpenStack based vendors if we are just testing for 200 status from the metadata url. Similarly, the file test will pass for several vendors. I have to reject the PR.

If you are interested, I would suggest to create an abstract base class for vendors using OpenStack and then create concrete classes for each vendor. The base class should test for common identifiers that all OpenStack based vendors have and the concrete class should check for vendor specific identifiers.

nikhil-prabhu commented 5 months ago

Hi @kshivakumar,

Thank you for the confirmation. Sure, I could implement detection for the vendors leveraging the underlying OpenStack platform (will probably take some time for me to test, but shouldn't be too much of an issue).

Just to confirm, once I do add support for the individual vendors, is it fine for me to create a single PR for all the OpenStack vendors, or would you prefer if I create a separate PR for each?

kshivakumar commented 5 months ago

@nikhil-prabhu

is it fine for me to create a single PR for all the OpenStack vendors, or would you prefer if I create a separate PR for each?

It appears there are two categories of vendors leveraging OpenStack: those who exclusively use OpenStack for all their services and those who utilize OpenStack for a limited subset of their offerings

According to https://www.openstack.org/use-cases/#industry=cloud-hosting-msp-telco, only three vendors fall into the first category: "Open Telekom Cloud," "VEXXHOST," and "Enter CloudSuite." The other entities listed are not considered vendors, afaiu. Also, that case-study list is not exhaustive. Huawei Cloud, for example, leverages OpenStack for their VM instances but is not listed.

For vendors in the second category, it's advisable to disregard the OpenStack metadata URL/files and instead rely entirely on the vendor's metadata URL/files. However, it's worth noting that in some instances, these two sources may coincide.

To begin, I recommend raising a single PR containing the base class and one vendor, ideally the most commonly used one, from first category.