Add a Singleton metaclass, use it with Display (#48935)

* Add a Singleton class, use it with Display

* update six import

* Move remaining failes to display singleton

* Fix rebase issues

* Singleton improvements

* Add code-smell for 'from __main__ import display'. ci_complete

* s/self/cls/g

* Add docs for no-main-display

* Address linting issues

* Add changelog fragment. ci_complete

* Implement reentrant lock for class instantiation in Singleton

* Add Display singleton porting guide
This commit is contained in:
Matt Martz 2018-11-20 17:06:51 -06:00 committed by GitHub
commit 9773a1f289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
149 changed files with 407 additions and 766 deletions

View file

@ -133,12 +133,7 @@ from ansible.module_utils.six import string_types
from ansible.module_utils.ec2 import ansible_dict_to_boto3_filter_list, boto3_tag_list_to_ansible_dict
from ansible.module_utils.ec2 import camel_dict_to_snake_dict
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable, to_safe_group_name
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
from ansible.utils.display import Display
try:
import boto3
@ -146,6 +141,8 @@ try:
except ImportError:
raise AnsibleError('The ec2 dynamic inventory plugin requires boto3 and botocore.')
display = Display()
# The mappings give an array of keys to get from the filter name to the value
# returned by boto3's EC2 describe_instances method.