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
15613de6
Commit
15613de6
authored
Nov 22, 2013
by
John Dewey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nova doesn't attempt to auth on obj instantiation
Need to call nova.authenticate() to validate credentials.
parent
32986c4d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
library/cloud/nova_compute
+10
-4
library/cloud/nova_keypair
+13
-4
No files found.
library/cloud/nova_compute
View file @
15613de6
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#coding: utf-8 -*-
#coding: utf-8 -*-
# (c) 2013, Benno Joy <benno@ansibleworks.com>
# (c) 2013, Benno Joy <benno@ansibleworks.com>
# (c) 2013, John Dewey <john@dewey.ws>
#
#
# This module is free software: you can redistribute it and/or modify
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -18,6 +19,7 @@
...
@@ -18,6 +19,7 @@
try
:
try
:
from
novaclient.v1_1
import
client
as
nova_client
from
novaclient.v1_1
import
client
as
nova_client
from
novaclient
import
exceptions
import
time
import
time
except
ImportError
:
except
ImportError
:
print
(
"failed=True msg='novaclient is required for this module'"
)
print
(
"failed=True msg='novaclient is required for this module'"
)
...
@@ -229,14 +231,18 @@ def main():
...
@@ -229,14 +231,18 @@ def main():
),
),
)
)
try
:
nova
=
nova_client
.
Client
(
module
.
params
[
'login_username'
],
nova
=
nova_client
.
Client
(
module
.
params
[
'login_username'
],
module
.
params
[
'login_password'
],
module
.
params
[
'login_password'
],
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'auth_url'
],
module
.
params
[
'auth_url'
],
service_type
=
'compute'
)
service_type
=
'compute'
)
except
Exception
as
e
:
try
:
module
.
fail_json
(
msg
=
"Error in authenticating to nova:
%
s"
%
e
.
message
)
nova
.
authenticate
()
except
exc
.
Unauthorized
as
e
:
module
.
fail_json
(
msg
=
"Invalid OpenStack Nova credentials.:
%
s"
%
e
.
message
)
except
exc
.
AuthorizationFailure
as
e
:
module
.
fail_json
(
msg
=
"Unable to authorize user:
%
s"
%
e
.
message
)
if
module
.
params
[
'state'
]
==
'present'
:
if
module
.
params
[
'state'
]
==
'present'
:
if
not
module
.
params
[
'image_id'
]:
if
not
module
.
params
[
'image_id'
]:
module
.
fail_json
(
msg
=
"Parameter 'image_id' is required if state == 'present'"
)
module
.
fail_json
(
msg
=
"Parameter 'image_id' is required if state == 'present'"
)
...
...
library/cloud/nova_keypair
View file @
15613de6
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#coding: utf-8 -*-
#coding: utf-8 -*-
# (c) 2013, Benno Joy <benno@ansibleworks.com>
# (c) 2013, Benno Joy <benno@ansibleworks.com>
# (c) 2013, John Dewey <john@dewey.ws>
#
#
# This module is free software: you can redistribute it and/or modify
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -18,6 +19,7 @@
...
@@ -18,6 +19,7 @@
try
:
try
:
from
novaclient.v1_1
import
client
from
novaclient.v1_1
import
client
from
novaclient
import
exceptions
import
time
import
time
except
ImportError
:
except
ImportError
:
print
(
"failed=True msg='novaclient is required for this module to work'"
)
print
(
"failed=True msg='novaclient is required for this module to work'"
)
...
@@ -98,11 +100,18 @@ def main():
...
@@ -98,11 +100,18 @@ def main():
),
),
)
)
nova
=
nova_client
.
Client
(
module
.
params
[
'login_username'
],
module
.
params
[
'login_password'
],
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'auth_url'
],
service_type
=
'compute'
)
try
:
try
:
nova
=
client
.
Client
(
module
.
params
[
'login_username'
],
module
.
params
[
'login_password'
],
nova
.
authenticate
()
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'auth_url'
],
service_type
=
'compute'
)
except
exc
.
Unauthorized
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Invalid OpenStack Nova credentials.:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
" Error in authenticating to nova:
%
s"
%
e
.
message
)
except
exc
.
AuthorizationFailure
as
e
:
module
.
fail_json
(
msg
=
"Unable to authorize user:
%
s"
%
e
.
message
)
if
module
.
params
[
'state'
]
==
'present'
:
if
module
.
params
[
'state'
]
==
'present'
:
for
key
in
nova
.
keypairs
.
list
():
for
key
in
nova
.
keypairs
.
list
():
if
key
.
name
==
module
.
params
[
'name'
]:
if
key
.
name
==
module
.
params
[
'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