david-caro / python-foreman

Small low level python wrapper around Foreman API
GNU General Public License v2.0
58 stars 37 forks source link

Unable to list environments #26

Closed avi3tal closed 9 years ago

avi3tal commented 9 years ago

Hi, I am using python-foreman version 0.2.2 against Foreman 1.7.2-v2.json

Default environments.index() is mapped to index_puppetclasses instead to /environments/ and actually makes it impossible to list all environments.

See attached bpython output.

c.environments.index( ┌───────────────────────────────────────────── │ c.environments.index: (self, puppetclass_id, search=None, order=None, page=None, per_page=None)
│ │ index index_hosts index_puppetclasses │ │ index_smart_class_parameters │ │ List environments of Puppet class │ │ :param puppetclass_id: ID of Puppet class; Must be String (OPTIONAL) │ :param search: filter results; Must be String (OPTIONAL) │ :param order: sort results; Must be String (OPTIONAL) │ :param page: paginate results; Must be String (OPTIONAL) │ :param per_page: number of entries per request; Must be String (OPTIONAL) └─────────────────────────────────────────────

avi3tal commented 9 years ago

It also appears in operatingsystem.index and maybe more objects

lukas-bednar commented 9 years ago

I can take a look at it could you please send me your 1.7.x.json file ?

avi3tal commented 9 years ago

sent by email

lukas-bednar commented 9 years ago

I was able to reproduce your problem. let me try to solve it.

avi3tal commented 9 years ago

Found another problematic object: hostgroups.indext() required mandatory puppetclass_id

lukas-bednar commented 9 years ago

I tracked it down and discover root cause, also it occurs on older versions of foreman as well (different resource objects). I am working on fix of this issue, and also on tests to avoid regression in future.

lukas-bednar commented 9 years ago

@avi3tal I am almost done, I am testing my changes across foreman versions. And I noticed diff between api.json you sent me and the one I downloaded from theforeman.org. some of them are related to compute resources, some of them related to LDAP, and so on which are ok ... but I can find this sample:

            "config_templates": {
                "api_url": "/api",
                "doc_url": "../apidoc/v2/config_templates",
                "formats": null,
                "full_description": null,
                "metadata": null,
                "methods": [
                    {
                        "apis": [
                            {
                                "api_url": "/api/config_templates",
                                "deprecated": null,
                                "http_method": "GET",
                                "short_description": "List provisioning templates"
                            },
                            {
                                "api_url": "/api/operatingsystem/:operatingsystem_id/config_templates",
                                "deprecated": null,
                                "http_method": "GET",
                                "short_description": "List provisioning templates per operating system"
                            },

which leads to failures ...

where '"api_url": "/api/operatingsystem/:operatingsystem_id/config_templates",' is not valid to me ... there should be "/api/operatingsystems/" instead of "/api/operatingsystem/" .

what do you think about it ? could it be related to some changes you made on your instance ? or bug in foreman ?

avi3tal commented 9 years ago

Hi Lukas, Thanks for the commitment, I really appreciate it. I haven't done any changes in my environment except upgrading from 1.5 to 1.7.2

Seams like a bug in foreman. Can you reproduce it in your environment? On Mar 1, 2015 5:47 PM, "Lukas Bednar" notifications@github.com wrote:

@avi3tal https://github.com/avi3tal I am almost done, I am testing my changes across foreman versions. And I noticed diff between api.json you sent me and the one I downloaded from theforeman.org. some of them are related to compute resources, some of them related to LDAP, and so on which are ok ... but I can find this sample:

        "config_templates": {
            "api_url": "/api",
            "doc_url": "../apidoc/v2/config_templates",
            "formats": null,
            "full_description": null,
            "metadata": null,
            "methods": [
                {
                    "apis": [
                        {
                            "api_url": "/api/config_templates",
                            "deprecated": null,
                            "http_method": "GET",
                            "short_description": "List provisioning templates"
                        },
                        {
                            "api_url": "/api/operatingsystem/:operatingsystem_id/config_templates",
                            "deprecated": null,
                            "http_method": "GET",
                            "short_description": "List provisioning templates per operating system"
                        },

which leads to failures ...

where '"api_url": "/api/operatingsystem/:operatingsystem_id/config_templates",' is not valid to me ... there should be "/api/operatingsystems/" instead of "/api/operatingsystem/" .

what do you think about it ? could it be related to some changes you made on your instance ? or bug in foreman ?

— Reply to this email directly or view it on GitHub https://github.com/david-caro/python-foreman/issues/26#issuecomment-76602812 .

lukas-bednar commented 9 years ago

Actually I don't have running instance of 1.7.2 foreman. so I can not reproduce it. Anyway, I sent pull request https://github.com/david-caro/python-foreman/pull/31 you can try to use it. Please let me know whether it solved your problem.

avi3tal commented 9 years ago

I'll take a look and update you, Thanks On Mar 3, 2015 10:40 AM, "Lukas Bednar" notifications@github.com wrote:

Actually I don't have running instance of 1.7.2 foreman. so I can not reproduce it. Anyway, I sent pull request #31 https://github.com/david-caro/python-foreman/pull/31 you can try to use it. Please let me know whether it solved your problem.

— Reply to this email directly or view it on GitHub https://github.com/david-caro/python-foreman/issues/26#issuecomment-76906577 .

david-caro commented 9 years ago

This should be fixed on #37