Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
1152c732
Commit
1152c732
authored
May 06, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix serialization bug for plugins (v2)
parent
4f28a814
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
lib/ansible/plugins/__init__.py
+20
-10
No files found.
lib/ansible/plugins/__init__.py
View file @
1152c732
...
@@ -88,6 +88,9 @@ class PluginLoader:
...
@@ -88,6 +88,9 @@ class PluginLoader:
subdir
=
data
.
get
(
'subdir'
)
subdir
=
data
.
get
(
'subdir'
)
aliases
=
data
.
get
(
'aliases'
)
aliases
=
data
.
get
(
'aliases'
)
PATH_CACHE
[
class_name
]
=
data
.
get
(
'PATH_CACHE'
)
PLUGIN_PATH_CACHE
[
class_name
]
=
data
.
get
(
'PLUGIN_PATH_CACHE'
)
self
.
__init__
(
class_name
,
package
,
config
,
subdir
,
aliases
)
self
.
__init__
(
class_name
,
package
,
config
,
subdir
,
aliases
)
self
.
_extra_dirs
=
data
.
get
(
'_extra_dirs'
,
[])
self
.
_extra_dirs
=
data
.
get
(
'_extra_dirs'
,
[])
self
.
_searched_paths
=
data
.
get
(
'_searched_paths'
,
set
())
self
.
_searched_paths
=
data
.
get
(
'_searched_paths'
,
set
())
...
@@ -98,13 +101,15 @@ class PluginLoader:
...
@@ -98,13 +101,15 @@ class PluginLoader:
'''
'''
return
dict
(
return
dict
(
class_name
=
self
.
class_name
,
class_name
=
self
.
class_name
,
package
=
self
.
package
,
package
=
self
.
package
,
config
=
self
.
config
,
config
=
self
.
config
,
subdir
=
self
.
subdir
,
subdir
=
self
.
subdir
,
aliases
=
self
.
aliases
,
aliases
=
self
.
aliases
,
_extra_dirs
=
self
.
_extra_dirs
,
_extra_dirs
=
self
.
_extra_dirs
,
_searched_paths
=
self
.
_searched_paths
,
_searched_paths
=
self
.
_searched_paths
,
PATH_CACHE
=
PATH_CACHE
[
self
.
class_name
],
PLUGIN_PATH_CACHE
=
PLUGIN_PATH_CACHE
[
self
.
class_name
],
)
)
def
print_paths
(
self
):
def
print_paths
(
self
):
...
@@ -258,12 +263,14 @@ class PluginLoader:
...
@@ -258,12 +263,14 @@ class PluginLoader:
path
=
self
.
find_plugin
(
name
)
path
=
self
.
find_plugin
(
name
)
if
path
is
None
:
if
path
is
None
:
return
None
return
None
elif
kwargs
.
get
(
'class_only'
,
False
):
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)
if
path
not
in
self
.
_module_cache
:
if
path
not
in
self
.
_module_cache
:
self
.
_module_cache
[
path
]
=
imp
.
load_source
(
'.'
.
join
([
self
.
package
,
name
]),
path
)
self
.
_module_cache
[
path
]
=
imp
.
load_source
(
'.'
.
join
([
self
.
package
,
name
]),
path
)
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)(
*
args
,
**
kwargs
)
if
kwargs
.
get
(
'class_only'
,
False
):
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)
else
:
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)(
*
args
,
**
kwargs
)
def
all
(
self
,
*
args
,
**
kwargs
):
def
all
(
self
,
*
args
,
**
kwargs
):
''' instantiates all plugins with the same arguments '''
''' instantiates all plugins with the same arguments '''
...
@@ -275,12 +282,15 @@ class PluginLoader:
...
@@ -275,12 +282,15 @@ class PluginLoader:
name
,
ext
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))
name
,
ext
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))
if
name
.
startswith
(
"_"
):
if
name
.
startswith
(
"_"
):
continue
continue
if
path
not
in
self
.
_module_cache
:
if
path
not
in
self
.
_module_cache
:
self
.
_module_cache
[
path
]
=
imp
.
load_source
(
'.'
.
join
([
self
.
package
,
name
]),
path
)
self
.
_module_cache
[
path
]
=
imp
.
load_source
(
'.'
.
join
([
self
.
package
,
name
]),
path
)
if
kwargs
.
get
(
'class_only'
,
False
):
if
kwargs
.
get
(
'class_only'
,
False
):
obj
=
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)
obj
=
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)
else
:
else
:
obj
=
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)(
*
args
,
**
kwargs
)
obj
=
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)(
*
args
,
**
kwargs
)
# set extra info on the module, in case we want it later
# set extra info on the module, in case we want it later
setattr
(
obj
,
'_original_path'
,
path
)
setattr
(
obj
,
'_original_path'
,
path
)
yield
obj
yield
obj
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment