-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Remove ansible.posix dependency #1157
Merged
felixfontein
merged 5 commits into
ansible-collections:main
from
felixfontein:drop-ansible.posix-dependency
Oct 28, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f13d6f1
Vendor plugins/module_utils/mount.py from ansible.posix, and drop ans…
felixfontein c626a04
Add ignore.txt entries.
felixfontein 831faf7
Install test requirements conditionally.
felixfontein 735fcb8
Apply suggestions from code review
felixfontein 31811e8
Bump to major changes.
felixfontein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
major_changes: | ||
- "The community.general collection no longer depends on the ansible.posix collection (https://github.com/ansible-collections/community.general/pull/1157)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# This code is part of Ansible, but is an independent component. | ||
# This particular file snippet, and this file snippet only, is based on | ||
# Lib/posixpath.py of cpython | ||
# It is licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 | ||
# | ||
# 1. This LICENSE AGREEMENT is between the Python Software Foundation | ||
# ("PSF"), and the Individual or Organization ("Licensee") accessing and | ||
# otherwise using this software ("Python") in source or binary form and | ||
# its associated documentation. | ||
# | ||
# 2. Subject to the terms and conditions of this License Agreement, PSF hereby | ||
# grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, | ||
# analyze, test, perform and/or display publicly, prepare derivative works, | ||
# distribute, and otherwise use Python alone or in any derivative version, | ||
# provided, however, that PSF's License Agreement and PSF's notice of copyright, | ||
# i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, | ||
# 2011, 2012, 2013, 2014, 2015 Python Software Foundation; All Rights Reserved" | ||
# are retained in Python alone or in any derivative version prepared by Licensee. | ||
# | ||
# 3. In the event Licensee prepares a derivative work that is based on | ||
# or incorporates Python or any part thereof, and wants to make | ||
# the derivative work available to others as provided herein, then | ||
# Licensee hereby agrees to include in any such work a brief summary of | ||
# the changes made to Python. | ||
# | ||
# 4. PSF is making Python available to Licensee on an "AS IS" | ||
# basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR | ||
# IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND | ||
# DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS | ||
# FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT | ||
# INFRINGE ANY THIRD PARTY RIGHTS. | ||
# | ||
# 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON | ||
# FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS | ||
# A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, | ||
# OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. | ||
# | ||
# 6. This License Agreement will automatically terminate upon a material | ||
# breach of its terms and conditions. | ||
# | ||
# 7. Nothing in this License Agreement shall be deemed to create any | ||
# relationship of agency, partnership, or joint venture between PSF and | ||
# Licensee. This License Agreement does not grant permission to use PSF | ||
# trademarks or trade name in a trademark sense to endorse or promote | ||
# products or services of Licensee, or any third party. | ||
# | ||
# 8. By copying, installing or otherwise using Python, Licensee | ||
# agrees to be bound by the terms and conditions of this License | ||
# Agreement. | ||
|
||
import os | ||
|
||
|
||
def ismount(path): | ||
"""Test whether a path is a mount point | ||
This is a copy of the upstream version of ismount(). Originally this was copied here as a workaround | ||
until Python issue 2466 was fixed. Now it is here so this will work on older versions of Python | ||
that may not have the upstream fix. | ||
https://github.com/ansible/ansible-modules-core/issues/2186 | ||
http://bugs.python.org/issue2466 | ||
""" | ||
try: | ||
s1 = os.lstat(path) | ||
except (OSError, ValueError): | ||
# It doesn't exist -- so not a mount point. :-) | ||
return False | ||
else: | ||
# A symlink can never be a mount point | ||
if os.path.stat.S_ISLNK(s1.st_mode): | ||
return False | ||
|
||
if isinstance(path, bytes): | ||
parent = os.path.join(path, b'..') | ||
else: | ||
parent = os.path.join(path, '..') | ||
parent = os.path.realpath(parent) | ||
try: | ||
s2 = os.lstat(parent) | ||
except (OSError, ValueError): | ||
return False | ||
|
||
dev1 = s1.st_dev | ||
dev2 = s2.st_dev | ||
if dev1 != dev2: | ||
return True # path/.. on a different device as path | ||
ino1 = s1.st_ino | ||
ino2 = s2.st_ino | ||
if ino1 == ino2: | ||
return True # path/.. is the same i-node as path | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we ensure that this file is kept in sync with
ansible.posix
? to preventplugins/modules/system/aix_filesystem.py
being exposed to a bug.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very good question. Maybe we could add an extra sanity test which compares whether the files are equal. Then we'll quickly find out when they update it. (Disadvantage: it will fail for every PR. But then it'll surface more quickly...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gundalow @Andersson007 as a short-term solution, how about creating an issue for this, and maybe have a column in a project where issues tracking similar problems are tracked? (We could also use a label, but that doesn't work well cross-repository.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me