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
9ae66a7f
Commit
9ae66a7f
authored
Aug 27, 2015
by
Marius Gedminas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use 'except ... as' syntax in contrib/ and test/ too
parent
eb99aa8c
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
25 additions
and
25 deletions
+25
-25
contrib/inventory/abiquo.py
+5
-5
contrib/inventory/cloudstack.py
+1
-1
contrib/inventory/consul_io.py
+1
-1
contrib/inventory/digital_ocean.py
+1
-1
contrib/inventory/gce.py
+1
-1
contrib/inventory/linode.py
+3
-3
contrib/inventory/rax.py
+1
-1
contrib/inventory/spacewalk.py
+4
-4
contrib/inventory/vmware.py
+2
-2
contrib/inventory/zabbix.py
+1
-1
test/integration/cleanup_ec2.py
+1
-1
test/integration/cleanup_gce.py
+1
-1
test/integration/roles/test_service/files/ansible_test_service
+2
-2
test/integration/setup_gce.py
+1
-1
No files found.
contrib/inventory/abiquo.py
View file @
9ae66a7f
...
...
@@ -76,7 +76,7 @@ def save_cache(data, config):
cache
=
open
(
'/'
.
join
([
dpath
,
'inventory'
]),
'w'
)
cache
.
write
(
json
.
dumps
(
data
))
cache
.
close
()
except
IOError
,
e
:
except
IOError
as
e
:
pass
# not really sure what to do here
...
...
@@ -88,7 +88,7 @@ def get_cache(cache_item, config):
cache
=
open
(
'/'
.
join
([
dpath
,
'inventory'
]),
'r'
)
inv
=
cache
.
read
()
cache
.
close
()
except
IOError
,
e
:
except
IOError
as
e
:
pass
# not really sure what to do here
return
inv
...
...
@@ -172,7 +172,7 @@ def generate_inv_from_api(enterprise_entity,config):
else
:
vm_metadata
=
metadata
[
'metadata'
][
'metadata'
]
inventory
[
'_meta'
][
'hostvars'
][
vm_nic
]
=
vm_metadata
except
Exception
,
e
:
except
Exception
as
e
:
pass
inventory
[
vm_vapp
][
'children'
]
.
append
(
vmcollection
[
'name'
])
...
...
@@ -183,7 +183,7 @@ def generate_inv_from_api(enterprise_entity,config):
inventory
[
vmcollection
[
'name'
]]
.
append
(
vm_nic
)
return
inventory
except
Exception
,
e
:
except
Exception
as
e
:
# Return empty hosts output
return
{
'all'
:
{
'hosts'
:
[]},
'_meta'
:
{
'hostvars'
:
{}
}
}
...
...
@@ -214,7 +214,7 @@ if __name__ == '__main__':
try
:
login
=
api_get
(
None
,
config
)
enterprise
=
next
(
link
for
link
in
(
login
[
'links'
])
if
(
link
[
'rel'
]
==
'enterprise'
))
except
Exception
,
e
:
except
Exception
as
e
:
enterprise
=
None
if
cache_available
(
config
):
...
...
contrib/inventory/cloudstack.py
View file @
9ae66a7f
...
...
@@ -98,7 +98,7 @@ class CloudStackInventory(object):
options
=
parser
.
parse_args
()
try
:
self
.
cs
=
CloudStack
(
**
read_config
())
except
CloudStackException
,
e
:
except
CloudStackException
as
e
:
print
>>
sys
.
stderr
,
"Error: Could not connect to CloudStack API"
project_id
=
''
...
...
contrib/inventory/consul_io.py
View file @
9ae66a7f
...
...
@@ -136,7 +136,7 @@ except ImportError:
try
:
import
consul
except
ImportError
,
e
:
except
ImportError
as
e
:
print
"""failed=True msg='python-consul required for this module. see
http://python-consul.readthedocs.org/en/latest/#installation'"""
sys
.
exit
(
1
)
...
...
contrib/inventory/digital_ocean.py
View file @
9ae66a7f
...
...
@@ -145,7 +145,7 @@ except ImportError:
try
:
from
dopy.manager
import
DoError
,
DoManager
except
ImportError
,
e
:
except
ImportError
as
e
:
print
"failed=True msg='`dopy` library required for this script'"
sys
.
exit
(
1
)
...
...
contrib/inventory/gce.py
View file @
9ae66a7f
...
...
@@ -237,7 +237,7 @@ class GceInventory(object):
'''Gets details about a specific instance '''
try
:
return
self
.
driver
.
ex_get_node
(
instance_name
)
except
Exception
,
e
:
except
Exception
as
e
:
return
None
def
group_instances
(
self
):
...
...
contrib/inventory/linode.py
View file @
9ae66a7f
...
...
@@ -101,7 +101,7 @@ except:
from
chube.linode_obj
import
Linode
sys
.
path
=
old_path
except
Exception
,
e
:
except
Exception
as
e
:
raise
Exception
(
"could not import chube"
)
load_chube_config
()
...
...
@@ -184,7 +184,7 @@ class LinodeInventory(object):
try
:
for
node
in
Linode
.
search
(
status
=
Linode
.
STATUS_RUNNING
):
self
.
add_node
(
node
)
except
chube_api
.
linode_api
.
ApiError
,
e
:
except
chube_api
.
linode_api
.
ApiError
as
e
:
print
"Looks like Linode's API is down:"
print
print
e
...
...
@@ -194,7 +194,7 @@ class LinodeInventory(object):
"""Gets details about a specific node."""
try
:
return
Linode
.
find
(
api_id
=
linode_id
)
except
chube_api
.
linode_api
.
ApiError
,
e
:
except
chube_api
.
linode_api
.
ApiError
as
e
:
print
"Looks like Linode's API is down:"
print
print
e
...
...
contrib/inventory/rax.py
View file @
9ae66a7f
...
...
@@ -412,7 +412,7 @@ def setup():
pyrax
.
keyring_auth
(
keyring_username
,
region
=
region
)
else
:
pyrax
.
set_credential_file
(
creds_file
,
region
=
region
)
except
Exception
,
e
:
except
Exception
as
e
:
sys
.
stderr
.
write
(
"
%
s:
%
s
\n
"
%
(
e
,
e
.
message
))
sys
.
exit
(
1
)
...
...
contrib/inventory/spacewalk.py
View file @
9ae66a7f
...
...
@@ -132,7 +132,7 @@ try:
for
group
in
spacewalk_report
(
'system-groups'
):
org_groups
[
group
[
'spacewalk_group_id'
]]
=
group
[
'spacewalk_org_id'
]
except
(
OSError
)
,
e
:
except
(
OSError
)
as
e
:
print
>>
sys
.
stderr
,
'Problem executing the command "
%
s system-groups":
%
s'
%
\
(
SW_REPORT
,
str
(
e
))
sys
.
exit
(
2
)
...
...
@@ -148,7 +148,7 @@ if options.list:
for
item
in
spacewalk_report
(
'inventory'
):
host_vars
[
item
[
'spacewalk_profile_name'
]
]
=
dict
(
(
key
,
(
value
.
split
(
';'
)
if
';'
in
value
else
value
)
)
for
key
,
value
in
item
.
items
()
)
except
(
OSError
)
,
e
:
except
(
OSError
)
as
e
:
print
>>
sys
.
stderr
,
'Problem executing the command "
%
s inventory":
%
s'
%
\
(
SW_REPORT
,
str
(
e
))
sys
.
exit
(
2
)
...
...
@@ -185,7 +185,7 @@ if options.list:
if
system
[
'spacewalk_server_name'
]
in
host_vars
and
not
system
[
'spacewalk_server_name'
]
in
meta
[
"hostvars"
]:
meta
[
"hostvars"
][
system
[
'spacewalk_server_name'
]
]
=
host_vars
[
system
[
'spacewalk_server_name'
]
]
except
(
OSError
)
,
e
:
except
(
OSError
)
as
e
:
print
>>
sys
.
stderr
,
'Problem executing the command "
%
s system-groups-systems":
%
s'
%
\
(
SW_REPORT
,
str
(
e
))
sys
.
exit
(
2
)
...
...
@@ -212,7 +212,7 @@ elif options.host:
host_details
=
system
break
except
(
OSError
)
,
e
:
except
(
OSError
)
as
e
:
print
>>
sys
.
stderr
,
'Problem executing the command "
%
s inventory":
%
s'
%
\
(
SW_REPORT
,
str
(
e
))
sys
.
exit
(
2
)
...
...
contrib/inventory/vmware.py
View file @
9ae66a7f
...
...
@@ -164,7 +164,7 @@ class VMwareInventory(object):
obj_info
=
self
.
_get_obj_info
(
val
,
depth
-
1
,
seen
)
if
obj_info
!=
():
d
[
attr
]
=
obj_info
except
Exception
,
e
:
except
Exception
as
e
:
pass
return
d
elif
isinstance
(
obj
,
SudsObject
):
...
...
@@ -207,7 +207,7 @@ class VMwareInventory(object):
host_info
[
k
]
=
v
try
:
host_info
[
'ipAddress'
]
=
host
.
config
.
network
.
vnic
[
0
]
.
spec
.
ip
.
ipAddress
except
Exception
,
e
:
except
Exception
as
e
:
print
>>
sys
.
stderr
,
e
host_info
=
self
.
_flatten_dict
(
host_info
,
prefix
)
if
(
'
%
s_ipAddress'
%
prefix
)
in
host_info
:
...
...
contrib/inventory/zabbix.py
View file @
9ae66a7f
...
...
@@ -109,7 +109,7 @@ class ZabbixInventory(object):
try
:
api
=
ZabbixAPI
(
server
=
self
.
zabbix_server
)
api
.
login
(
user
=
self
.
zabbix_username
,
password
=
self
.
zabbix_password
)
except
BaseException
,
e
:
except
BaseException
as
e
:
print
>>
sys
.
stderr
,
"Error: Could not login to Zabbix server. Check your zabbix.ini."
sys
.
exit
(
1
)
...
...
test/integration/cleanup_ec2.py
View file @
9ae66a7f
...
...
@@ -175,5 +175,5 @@ if __name__ == '__main__':
filters
=
{
"tag:Name"
:
opts
.
match_re
.
replace
(
'^'
,
''
),
"instance-state-name"
:
[
'running'
,
'pending'
,
'stopped'
]}
delete_aws_instances
(
aws
.
get_all_instances
(
filters
=
filters
),
opts
)
except
KeyboardInterrupt
,
e
:
except
KeyboardInterrupt
as
e
:
print
"
\n
Exiting on user command."
test/integration/cleanup_gce.py
View file @
9ae66a7f
...
...
@@ -73,5 +73,5 @@ if __name__ == '__main__':
delete_gce_resources
(
get_snapshots
,
'name'
,
opts
)
# Delete matching disks
delete_gce_resources
(
gce
.
list_volumes
,
'name'
,
opts
)
except
KeyboardInterrupt
,
e
:
except
KeyboardInterrupt
as
e
:
print
"
\n
Exiting on user command."
test/integration/roles/test_service/files/ansible_test_service
View file @
9ae66a7f
...
...
@@ -20,7 +20,7 @@ else:
def
createDaemon
():
try
:
pid
=
os
.
fork
()
except
OSError
,
e
:
except
OSError
as
e
:
raise
Exception
,
"
%
s [
%
d]"
%
(
e
.
strerror
,
e
.
errno
)
if
(
pid
==
0
):
...
...
@@ -28,7 +28,7 @@ def createDaemon():
try
:
pid
=
os
.
fork
()
except
OSError
,
e
:
except
OSError
as
e
:
raise
Exception
,
"
%
s [
%
d]"
%
(
e
.
strerror
,
e
.
errno
)
if
(
pid
==
0
):
...
...
test/integration/setup_gce.py
View file @
9ae66a7f
...
...
@@ -38,5 +38,5 @@ if __name__ == '__main__':
gce
.
create_volume_snapshot
(
base_volume
,
name
=
prefix
+
'-snapshot'
)
gce
.
create_volume
(
size
=
10
,
name
=
prefix
+
'-extra'
,
location
=
'us-central1-a'
)
except
KeyboardInterrupt
,
e
:
except
KeyboardInterrupt
as
e
:
print
"
\n
Exiting on user command."
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