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
b9b3c0de
Commit
b9b3c0de
authored
Nov 03, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support boot from volume discovery
parent
1e92aadb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletions
+26
-1
plugins/inventory/rax.py
+26
-1
No files found.
plugins/inventory/rax.py
View file @
b9b3c0de
...
@@ -160,6 +160,7 @@ except ImportError:
...
@@ -160,6 +160,7 @@ except ImportError:
try
:
try
:
import
pyrax
import
pyrax
from
pyrax.utils
import
slugify
except
ImportError
:
except
ImportError
:
print
(
'pyrax is required for this module'
)
print
(
'pyrax is required for this module'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
@@ -215,6 +216,8 @@ def _list(regions):
...
@@ -215,6 +216,8 @@ def _list(regions):
groups
=
collections
.
defaultdict
(
list
)
groups
=
collections
.
defaultdict
(
list
)
hostvars
=
collections
.
defaultdict
(
dict
)
hostvars
=
collections
.
defaultdict
(
dict
)
images
=
{}
images
=
{}
cbs_attachments
=
collections
.
defaultdict
(
dict
)
prefix
=
get_config
(
p
,
'rax'
,
'meta_prefix'
,
'RAX_META_PREFIX'
,
'meta'
)
prefix
=
get_config
(
p
,
'rax'
,
'meta_prefix'
,
'RAX_META_PREFIX'
,
'meta'
)
network
=
get_config
(
p
,
'rax'
,
'access_network'
,
'RAX_ACCESS_NETWORK'
,
network
=
get_config
(
p
,
'rax'
,
'access_network'
,
'RAX_ACCESS_NETWORK'
,
...
@@ -258,11 +261,33 @@ def _list(regions):
...
@@ -258,11 +261,33 @@ def _list(regions):
hostvars
[
server
.
name
][
'rax_region'
]
=
region
hostvars
[
server
.
name
][
'rax_region'
]
=
region
for
key
,
value
in
server
.
metadata
.
iteritems
():
for
key
,
value
in
server
.
metadata
.
iteritems
():
prefix
=
os
.
getenv
(
'RAX_META_PREFIX'
,
'meta'
)
groups
[
'
%
s_
%
s_
%
s'
%
(
prefix
,
key
,
value
)]
.
append
(
server
.
name
)
groups
[
'
%
s_
%
s_
%
s'
%
(
prefix
,
key
,
value
)]
.
append
(
server
.
name
)
groups
[
'instance-
%
s'
%
server
.
id
]
.
append
(
server
.
name
)
groups
[
'instance-
%
s'
%
server
.
id
]
.
append
(
server
.
name
)
groups
[
'flavor-
%
s'
%
server
.
flavor
[
'id'
]]
.
append
(
server
.
name
)
groups
[
'flavor-
%
s'
%
server
.
flavor
[
'id'
]]
.
append
(
server
.
name
)
# Handle boot from volume
if
not
server
.
image
:
if
not
cbs_attachments
[
region
]:
cbs
=
pyrax
.
connect_to_cloud_blockstorage
(
region
)
for
vol
in
cbs
.
list
():
if
mk_boolean
(
vol
.
bootable
):
for
attachment
in
vol
.
attachments
:
metadata
=
vol
.
volume_image_metadata
server_id
=
attachment
[
'server_id'
]
cbs_attachments
[
region
][
server_id
]
=
{
'id'
:
metadata
[
'image_id'
],
'name'
:
slugify
(
metadata
[
'image_name'
])
}
image
=
cbs_attachments
[
region
]
.
get
(
server
.
id
)
if
image
:
server
.
image
=
{
'id'
:
image
[
'id'
]}
hostvars
[
server
.
name
][
'rax_image'
]
=
server
.
image
hostvars
[
server
.
name
][
'rax_boot_source'
]
=
'volume'
images
[
image
[
'id'
]]
=
image
[
'name'
]
else
:
hostvars
[
server
.
name
][
'rax_boot_source'
]
=
'local'
try
:
try
:
imagegroup
=
'image-
%
s'
%
images
[
server
.
image
[
'id'
]]
imagegroup
=
'image-
%
s'
%
images
[
server
.
image
[
'id'
]]
groups
[
imagegroup
]
.
append
(
server
.
name
)
groups
[
imagegroup
]
.
append
(
server
.
name
)
...
...
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