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
3bfdaad0
Commit
3bfdaad0
authored
Oct 19, 2013
by
Paul Durivage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement @cchurch suggestions
parent
859c6c6d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
plugins/inventory/rax.py
+22
-14
No files found.
plugins/inventory/rax.py
View file @
3bfdaad0
...
...
@@ -101,10 +101,10 @@ except ImportError:
sys
.
exit
(
1
)
def
host
(
hostname
):
def
host
(
regions
,
hostname
):
hostvars
=
{}
for
region
in
pyrax
.
regions
:
for
region
in
regions
:
# Connect to the region
cs
=
pyrax
.
connect_to_cloudservers
(
region
=
region
)
for
server
in
cs
.
servers
.
list
():
...
...
@@ -125,16 +125,12 @@ def host(hostname):
print
(
json
.
dumps
(
hostvars
,
sort_keys
=
True
,
indent
=
4
))
def
_list
(
region
):
def
_list
(
region
s
):
groups
=
collections
.
defaultdict
(
list
)
hostvars
=
collections
.
defaultdict
(
dict
)
if
region
and
region
.
upper
()
in
pyrax
.
regions
:
pyrax
.
regions
=
(
region
.
upper
()
for
region
in
region
.
split
(
','
))
# Go through all the regions looking for servers
for
region
in
pyrax
.
regions
:
for
region
in
regions
:
# Connect to the region
cs
=
pyrax
.
connect_to_cloudservers
(
region
=
region
)
for
server
in
cs
.
servers
.
list
():
...
...
@@ -196,7 +192,18 @@ def setup():
%
(
e
.
message
,
default_creds_file
))
sys
.
exit
(
1
)
region
=
os
.
getenv
(
'RAX_REGION'
)
regions
=
[]
for
region
in
os
.
getenv
(
'RAX_REGION'
,
'all'
)
.
split
(
','
):
region
=
region
.
strip
()
.
upper
()
if
region
==
'ALL'
:
regions
=
pyrax
.
regions
break
elif
region
not
in
pyrax
.
regions
:
sys
.
stderr
.
write
(
'Unsupported region
%
s'
%
region
)
sys
.
exit
(
1
)
elif
region
not
in
regions
:
regions
.
append
(
region
)
pyrax
.
set_setting
(
'identity_type'
,
'rackspace'
)
try
:
...
...
@@ -205,17 +212,17 @@ def setup():
sys
.
stderr
.
write
(
"
%
s:
%
s
\n
"
%
(
e
,
e
.
message
))
sys
.
exit
(
1
)
return
region
return
region
s
def
main
():
args
=
parse_args
()
region
=
setup
()
region
s
=
setup
()
if
args
.
list
:
_list
(
region
)
_list
(
region
s
)
elif
args
.
host
:
host
(
args
.
host
)
host
(
regions
,
args
.
host
)
sys
.
exit
(
0
)
if
__name__
==
'__main__'
:
main
()
main
()
\ No newline at end of file
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