mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 18:04:02 -07:00
Remove wildcard imports from amazon modules (#31451)
* Remove wildcard imports from amazon modules * Remove files from legacy pep8 that now pass
This commit is contained in:
parent
1037c211d9
commit
9c81257ce3
16 changed files with 205 additions and 345 deletions
|
@ -1,18 +1,10 @@
|
|||
#!/usr/bin/python
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['stableinterface'],
|
||||
|
@ -170,10 +162,12 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
try:
|
||||
import boto.ec2
|
||||
HAS_BOTO = True
|
||||
import boto.exception
|
||||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
pass # Taken care of by ec2.HAS_BOTO
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ec2 import HAS_BOTO, ec2_argument_spec, ec2_connect
|
||||
|
||||
|
||||
class EIPException(Exception):
|
||||
|
@ -338,12 +332,12 @@ def ensure_present(ec2, module, domain, address, private_ip_address, device_id,
|
|||
raise EIPException("You must set 'in_vpc' to true to associate an instance with an existing ip in a vpc")
|
||||
# Associate address object (provided or allocated) with instance
|
||||
assoc_result = associate_ip_and_device(ec2, address, private_ip_address, device_id, allow_reassociation,
|
||||
check_mode)
|
||||
check_mode)
|
||||
else:
|
||||
instance = find_device(ec2, module, device_id, isinstance=False)
|
||||
# Associate address object (provided or allocated) with instance
|
||||
assoc_result = associate_ip_and_device(ec2, address, private_ip_address, device_id, allow_reassociation,
|
||||
check_mode, isinstance=False)
|
||||
check_mode, isinstance=False)
|
||||
|
||||
if instance.vpc_id:
|
||||
domain = 'vpc'
|
||||
|
@ -361,10 +355,10 @@ def ensure_absent(ec2, domain, address, device_id, check_mode, isinstance=True):
|
|||
if device_id:
|
||||
if isinstance:
|
||||
return disassociate_ip_and_device(ec2, address, device_id,
|
||||
check_mode)
|
||||
check_mode)
|
||||
else:
|
||||
return disassociate_ip_and_device(ec2, address, device_id,
|
||||
check_mode, isinstance=False)
|
||||
check_mode, isinstance=False)
|
||||
# releasing address
|
||||
else:
|
||||
return release_address(ec2, address, check_mode)
|
||||
|
@ -432,7 +426,8 @@ def main():
|
|||
if state == 'present':
|
||||
if device_id:
|
||||
result = ensure_present(ec2, module, domain, address, private_ip_address, device_id,
|
||||
reuse_existing_ip_allowed, allow_reassociation, module.check_mode, isinstance=is_instance)
|
||||
reuse_existing_ip_allowed, allow_reassociation,
|
||||
module.check_mode, isinstance=is_instance)
|
||||
else:
|
||||
if address:
|
||||
changed = False
|
||||
|
@ -459,9 +454,6 @@ def main():
|
|||
result['warnings'] = warnings
|
||||
module.exit_json(**result)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import * # noqa
|
||||
from ansible.module_utils.ec2 import * # noqa
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue