Skip to content
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

Fix verify_file check in Scaleway dynamic inventory #44384

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

remyleone
Copy link
Contributor

SUMMARY

Fix verify_file check in Scaleway dynamic inventory

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • scaleway_dynamic_inventory
ANSIBLE VERSION
ansible 2.7.0.dev0 (verify_file 3157bcf7c2) last updated 2018/08/20 12:19:08 (GMT +200)
  config file = None
  configured module search path = [u'/Users/sieben/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/sieben/workspace/ansible/lib/ansible
  executable location = /Users/sieben/workspace/ansible/bin/ansible
  python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]

@ansibot
Copy link
Contributor

ansibot commented Aug 20, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. cloud inventory Inventory category needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 20, 2018
@ansibot
Copy link
Contributor

ansibot commented Aug 20, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/plugins/inventory/scaleway.py:74:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 20, 2018
@ansibot ansibot added small_patch and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 20, 2018
with open(path) as f:
raw_file = f.read()
d = from_yaml(raw_file)
return d.get("plugin") == "scaleway"
Copy link
Contributor

@pilou- pilou- Aug 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InventoryModule._read_config_data perform the same things (reading the file, checking the plugin key), I don't see any reason to no reusing it. I propose something like:

def verify_file(self, path):
    if super(InventoryModule, self).verify_file(path):
        try:
            self._read_config_data(path)
            return True
        except Exception:
            pass

    return False

(comment edited: s/BaseInventoryFilePlugin/InventoryModule/)

@remyleone
Copy link
Contributor Author

@pilou- Updated could you check again :) ?

@ansibot
Copy link
Contributor

ansibot commented Aug 20, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/plugins/inventory/scaleway.py:159:11: bad-super-call Bad first argument 'BaseFileInventoryPlugin' given to super()

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed small_patch labels Aug 20, 2018
@remyleone
Copy link
Contributor Author

@pilou- fixed the typo

@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 20, 2018
@pilou-
Copy link
Contributor

pilou- commented Aug 20, 2018

This pull request makes #43714 obsolete.

@pilou-
Copy link
Contributor

pilou- commented Aug 21, 2018

Hum, it doesn't work because self.loader hasn't been set when verify_file is called.

A simpler way is to completely remove the verify_file method from this inventory plugin (then the base verify_file method will be called).

@remyleone
Copy link
Contributor Author

@pilou- Done

@webknjaz webknjaz removed the needs_triage Needs a first human triage before being processed. label Aug 21, 2018
@webknjaz webknjaz requested a review from bcoca August 21, 2018 15:14
@remyleone
Copy link
Contributor Author

shipit

@ansibot
Copy link
Contributor

ansibot commented Aug 27, 2018

@ansibot ansibot added scaleway support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 27, 2018
@maxamillion
Copy link
Contributor

shipit

@ansibot ansibot added the shipit This PR is ready to be merged by Core label Aug 27, 2018
@Spredzy
Copy link
Contributor

Spredzy commented Aug 28, 2018

shipit

@maxamillion
Copy link
Contributor

rebuild_merge

@ansibot ansibot merged commit ea0f722 into ansible:devel Aug 28, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. cloud inventory Inventory category scaleway shipit This PR is ready to be merged by Core small_patch support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants