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
6db1b4df
Commit
6db1b4df
authored
Oct 03, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP on refactoring changes
parent
b9223e59
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
42 deletions
+7
-42
test/units/inventory_test_data/inventory_api.py
+0
-0
test/v2/playbook/test_task.py
+0
-0
v2/ansible/playbook/attribute.py
+4
-26
v2/ansible/playbook/base.py
+1
-1
v2/ansible/playbook/task.py
+2
-15
No files found.
test/units/inventory_test_data/inventory_api.py
100644 → 100755
View file @
6db1b4df
File mode changed from 100644 to 100755
test/v2/playbook/task.py
→
test/v2/playbook/t
est_t
ask.py
View file @
6db1b4df
File moved
v2/ansible/playbook/attribute.py
View file @
6db1b4df
...
...
@@ -17,36 +17,14 @@
#from ansible.common.errors import AnsibleError
class
MyMeta
(
type
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
obj
=
type
.
__call__
(
self
,
*
args
)
for
name
,
value
in
kwargs
.
items
():
setattr
(
obj
,
name
,
value
)
return
obj
class
Attribute
(
object
):
__metaclass__
=
MyMeta
def
load
(
self
,
data
,
base_object
):
''' the loader is called to store the attribute from a datastructure when key names match. The default is very basic '''
self
.
_validate
(
base_object
,
data
)
setattr
(
base_object
,
self
.
name
,
data
)
def
_validate
(
self
,
data
,
base_object
):
''' validate is called after loading an object data structure to massage any input or raise errors on any incompatibilities '''
if
self
.
validator
:
self
.
validator
(
base_object
)
def
post_validate
(
self
,
base_object
):
''' post validate is called after templating the context of a Task (usually in Runner) to validate the types of arguments '''
if
self
.
post_validator
:
self
.
post_validator
(
base_object
)
def
__init__
(
self
,
isa
=
None
,
validator
=
None
,
post_validator
=
None
):
self
.
isa
=
isa
self
.
validator
=
validator
self
.
post_validator
=
post_validator
class
FieldAttribute
(
Attribute
):
__metaclass__
=
MyMeta
pass
v2/ansible/playbook/base.py
View file @
6db1b4df
...
...
@@ -34,4 +34,4 @@ class Base(object):
for
attribute
in
self
.
attributes
:
attribute
.
validate
(
self
)
v2/ansible/playbook/task.py
View file @
6db1b4df
...
...
@@ -61,7 +61,8 @@ class Task(Base):
# FIXME: this should not be a Task
meta
=
FieldAttribute
(
isa
=
'string'
)
name
=
FieldAttribute
(
isa
=
'string'
,
post_validate
=
'_set_name'
)
name
=
FieldAttribute
(
isa
=
'string'
,
validate
=
self
.
_set_name
)
no_log
=
FieldAttribute
(
isa
=
'bool'
)
notify
=
FieldAttribute
(
isa
=
'list'
)
poll
=
FieldAttribute
(
isa
=
'integer'
)
...
...
@@ -103,20 +104,6 @@ class Task(Base):
''' returns a human readable representation of the task '''
return
"TASK:
%
s"
%
self
.
get_name
()
@classmethod
def
load
(
self
,
block
=
None
,
role
=
None
,
data
=
None
):
self
=
Task
(
block
=
block
,
role
=
role
)
self
.
_load_field_attributes
(
data
)
# from BaseObject
self
.
_load_plugin_attributes
(
data
)
# from here, becuase of lookupPlugins
return
self
def
_load_plugin_attributes
(
self
,
data
):
module_names
=
self
.
_module_names
()
for
(
k
,
v
)
in
data
.
iteritems
():
if
k
in
module_names
:
self
.
module
=
k
self
.
args
=
v
# ==================================================================================
# BELOW THIS LINE
...
...
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