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
e38a83e1
Commit
e38a83e1
authored
Jun 01, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs standardization/style
parent
548063a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
library/cloud/quantum_floating_ip
+23
-19
No files found.
library/cloud/quantum_floating_ip
View file @
e38a83e1
...
...
@@ -160,8 +160,8 @@ def _create_floating_ip(quantum, module, port_id, net_id):
try
:
result
=
quantum
.
create_floatingip
({
'floatingip'
:
kwargs
})
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"There was an error in updating the floating ip address:
%
s"
%
e
.
message
)
module
.
exit_json
(
changed
=
True
,
result
=
result
,
public_ip
=
result
[
'floatingip'
][
'floating_ip_address'
]
)
module
.
fail_json
(
msg
=
"There was an error in updating the floating ip address:
%
s"
%
e
.
message
)
module
.
exit_json
(
changed
=
True
,
result
=
result
,
public_ip
=
result
[
'floatingip'
][
'floating_ip_address'
]
)
def
_get_net_id
(
quantum
,
module
):
kwargs
=
{
...
...
@@ -177,44 +177,47 @@ def _get_net_id(quantum, module):
def
_update_floating_ip
(
quantum
,
module
,
port_id
,
floating_ip_id
):
kwargs
=
{
'port_id'
:
port_id
'port_id'
:
port_id
}
try
:
result
=
quantum
.
update_floatingip
(
floating_ip_id
,
{
'floatingip'
:
kwargs
})
result
=
quantum
.
update_floatingip
(
floating_ip_id
,
{
'floatingip'
:
kwargs
})
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"There was an error in updating the floating ip address:
%
s"
%
e
.
message
)
module
.
exit_json
(
changed
=
True
,
result
=
result
)
module
.
fail_json
(
msg
=
"There was an error in updating the floating ip address:
%
s"
%
e
.
message
)
module
.
exit_json
(
changed
=
True
,
result
=
result
)
def
main
():
module
=
AnsibleModule
(
argument_spec
=
dict
(
login_username
=
dict
(
default
=
'admin'
),
login_password
=
dict
(
required
=
True
),
login_tenant_name
=
dict
(
required
=
'True'
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
region_name
=
dict
(
default
=
None
),
network_name
=
dict
(
required
=
True
),
instance_name
=
dict
(
required
=
True
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
])
argument_spec
=
dict
(
login_username
=
dict
(
default
=
'admin'
),
login_password
=
dict
(
required
=
True
),
login_tenant_name
=
dict
(
required
=
'True'
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
region_name
=
dict
(
default
=
None
),
network_name
=
dict
(
required
=
True
),
instance_name
=
dict
(
required
=
True
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
])
),
)
try
:
nova
=
nova_client
.
Client
(
module
.
params
[
'login_username'
],
module
.
params
[
'login_password'
],
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'auth_url'
],
service_type
=
'compute'
)
module
.
params
[
'login_tenant_name'
],
module
.
params
[
'auth_url'
],
service_type
=
'compute'
)
quantum
=
_get_quantum_client
(
module
,
module
.
params
)
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"
Error in authenticating to nova:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"
Error in authenticating to nova:
%
s"
%
e
.
message
)
server_info
,
server_obj
=
_get_server_state
(
module
,
nova
)
if
not
server_info
:
module
.
fail_json
(
msg
=
" The instance name provided cannot be found"
)
module
.
fail_json
(
msg
=
"The instance name provided cannot be found"
)
fixed_ip
,
port_id
=
_get_port_info
(
quantum
,
module
,
server_info
[
'id'
])
if
not
port_id
:
module
.
fail_json
(
msg
=
"Cannot find a port for this instance, maybe fixed ip is not assigned"
)
module
.
fail_json
(
msg
=
"Cannot find a port for this instance, maybe fixed ip is not assigned"
)
floating_id
,
floating_ip
=
_get_floating_ip
(
module
,
quantum
,
fixed_ip
)
if
module
.
params
[
'state'
]
==
'present'
:
if
floating_ip
:
module
.
exit_json
(
changed
=
False
,
public_ip
=
floating_ip
)
...
...
@@ -227,6 +230,7 @@ def main():
if
floating_ip
:
_update_floating_ip
(
quantum
,
module
,
None
,
floating_id
)
module
.
exit_json
(
changed
=
False
)
# this is magic, see lib/ansible/module.params['common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main
()
...
...
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