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
bf251e3d
Commit
bf251e3d
authored
Mar 07, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct overly broad import from chube in linode inventory script
Fixes #4875
parent
b8f627d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
plugins/inventory/linode.py
+26
-8
No files found.
plugins/inventory/linode.py
View file @
bf251e3d
...
...
@@ -71,21 +71,39 @@ just adapted that for Linode.
######################################################################
# Standard imports
import
os
import
re
import
sys
import
argparse
from
time
import
time
try
:
import
json
except
ImportError
:
import
simplejson
as
json
# chube imports 'yaml', which is also the name of an inventory plugin,
# so we remove the plugins dir from sys.path before importing it.
old_path
=
sys
.
path
sys
.
path
=
[
d
for
d
in
sys
.
path
if
"ansible/plugins"
not
in
d
]
from
chube
import
*
sys
.
path
=
old_path
try
:
from
chube
import
load_chube_config
from
chube
import
api
as
chube_api
from
chube.datacenter
import
Datacenter
from
chube.linode_obj
import
Linode
except
:
try
:
# remove local paths and other stuff that may
# cause an import conflict, as chube is sensitive
# to name collisions on importing
old_path
=
sys
.
path
sys
.
path
=
[
d
for
d
in
sys
.
path
if
d
not
in
(
''
,
os
.
getcwd
(),
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)))]
from
chube
import
load_chube_config
from
chube
import
api
as
chube_api
from
chube.datacenter
import
Datacenter
from
chube.linode_obj
import
Linode
sys
.
path
=
old_path
except
Exception
,
e
:
raise
Exception
(
"could not import chube"
)
load_chube_config
()
# Imports for ansible
...
...
@@ -166,7 +184,7 @@ class LinodeInventory(object):
try
:
for
node
in
Linode
.
search
(
status
=
Linode
.
STATUS_RUNNING
):
self
.
add_node
(
node
)
except
api
.
linode_api
.
ApiError
,
e
:
except
chube_
api
.
linode_api
.
ApiError
,
e
:
print
"Looks like Linode's API is down:"
print
print
e
...
...
@@ -176,7 +194,7 @@ class LinodeInventory(object):
"""Gets details about a specific node."""
try
:
return
Linode
.
find
(
api_id
=
linode_id
)
except
api
.
linode_api
.
ApiError
,
e
:
except
chube_
api
.
linode_api
.
ApiError
,
e
:
print
"Looks like Linode's API is down:"
print
print
e
...
...
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