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
7d0eba19
Commit
7d0eba19
authored
Aug 06, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dedupe PTR record related code in rax_dns_record
parent
28fcdec2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
32 deletions
+34
-32
lib/ansible/module_common.py
+0
-1
lib/ansible/module_utils/rax.py
+23
-0
library/cloud/rax
+2
-2
library/cloud/rax_dns_record
+9
-29
No files found.
lib/ansible/module_common.py
View file @
7d0eba19
...
...
@@ -33,7 +33,6 @@ REPLACER_COMPLEX = "\"<<INCLUDE_ANSIBLE_MODULE_COMPLEX_ARGS>>\""
REPLACER_WINDOWS
=
"# POWERSHELL_COMMON"
REPLACER_VERSION
=
"
\"
<<ANSIBLE_VERSION>>
\"
"
class
ModuleReplacer
(
object
):
"""
...
...
lib/ansible/module_utils/rax.py
View file @
7d0eba19
...
...
@@ -170,6 +170,29 @@ def rax_find_server(module, rax_module, server):
return
server
def
rax_find_loadbalancer
(
module
,
rax_module
,
loadbalancer
):
clb
=
rax_module
.
cloud_loadbalancers
try
:
UUID
(
loadbalancer
)
found
=
clb
.
get
(
loadbalancer
)
except
:
for
lb
in
clb
.
list
():
if
loadbalancer
==
lb
.
name
:
found
.
append
(
lb
)
if
not
found
:
module
.
fail_json
(
msg
=
'No loadbalancer was matched'
)
if
len
(
found
)
>
1
:
module
.
fail_json
(
msg
=
'Multiple loadbalancers matched'
)
# We made it this far, grab the first and hopefully only item
# in the list
found
=
found
[
0
]
return
found
def
rax_argument_spec
():
return
dict
(
api_key
=
dict
(
type
=
'str'
,
aliases
=
[
'password'
],
no_log
=
True
),
...
...
library/cloud/rax
View file @
7d0eba19
...
...
@@ -219,7 +219,7 @@ def create(module, names=[], flavor=None, image=None, meta={}, key_name=None,
except
Exception
,
e
:
module
.
fail_json
(
msg
=
'Failed to load
%
s'
%
user_data
)
# Handle the file contents
# Handle the file contents
for
rpath
in
files
.
keys
():
lpath
=
os
.
path
.
expanduser
(
files
[
rpath
])
try
:
...
...
@@ -707,5 +707,5 @@ def main():
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.rax
import
*
#
##
invoke the module
# invoke the module
main
()
library/cloud/rax_dns_record
View file @
7d0eba19
...
...
@@ -120,43 +120,23 @@ except ImportError:
HAS_PYRAX
=
False
def
rax_dns_record
(
module
,
data
=
None
,
comment
=
None
,
loadbalancer
=
None
,
name
=
None
,
server
=
None
,
state
=
'present'
,
ttl
=
7200
):
def
rax_dns_record
_ptr
(
module
,
data
=
None
,
comment
=
None
,
loadbalancer
=
None
,
name
=
None
,
server
=
None
,
state
=
'present'
,
ttl
=
7200
):
changed
=
False
results
=
[]
cs
=
pyrax
.
cloudservers
clb
=
pyrax
.
cloud_loadbalancers
dns
=
pyrax
.
cloud_dns
if
not
cs
or
not
clb
or
not
dns
:
if
not
dns
:
module
.
fail_json
(
msg
=
'Failed to instantiate client. This '
'typically indicates an invalid region or an '
'incorrectly capitalized region name.'
)
if
loadbalancer
:
try
:
UUID
(
loadbalancer
)
found
=
[
clb
.
get
(
loadbalancer
)]
except
:
for
lb
in
clb
.
list
():
if
loadbalancer
==
lb
.
name
:
found
.
append
(
lb
)
if
len
(
found
)
!=
1
:
module
.
fail_json
(
msg
=
'Could not match a loadbalancer with
%
s'
%
loadbalancer
)
item
=
rax_find_loadbalancer
(
module
,
pyrax
,
loadbalancer
)
elif
server
:
try
:
UUID
(
server
)
found
=
[
cs
.
servers
.
get
(
server
)]
except
:
found
=
cs
.
servers
.
list
(
search_opts
=
dict
(
name
=
'^
%
s$'
%
server
))
if
len
(
found
)
!=
1
:
module
.
fail_json
(
msg
=
'Could not match a server with
%
s'
%
server
)
item
=
found
[
0
]
item
=
rax_find_server
(
module
,
pyrax
,
server
)
if
state
==
'present'
:
current
=
dns
.
list_ptr_records
(
item
)
for
record
in
current
:
...
...
@@ -169,10 +149,10 @@ def rax_dns_record(module, data=None, comment=None, loadbalancer=None,
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
message
)
record
.
ttl
=
ttl
record
.
name
=
name
results
.
append
(
to_dict
(
record
))
results
.
append
(
rax_
to_dict
(
record
))
break
else
:
results
.
append
(
to_dict
(
record
))
results
.
append
(
rax_
to_dict
(
record
))
break
if
not
results
:
...
...
@@ -190,7 +170,7 @@ def rax_dns_record(module, data=None, comment=None, loadbalancer=None,
current
=
dns
.
list_ptr_records
(
item
)
for
record
in
current
:
if
record
.
data
==
data
:
results
.
append
(
to_dict
(
record
))
results
.
append
(
rax_
to_dict
(
record
))
break
if
results
:
...
...
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