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
3a635d2d
Commit
3a635d2d
authored
May 24, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lots of formatting fixes
parent
9c5d6f11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
88 additions
and
89 deletions
+88
-89
lib/ansible/runner/action_plugins/fetch.py
+2
-2
library/cloud/glance_image
+22
-22
library/cloud/nova_compute
+1
-1
library/cloud/quantum_floating_ip
+2
-2
library/cloud/quantum_floating_ip_associate
+13
-13
library/cloud/quantum_network
+2
-2
library/cloud/quantum_router
+6
-9
library/cloud/quantum_router_gateway
+1
-1
library/cloud/quantum_router_interface
+4
-4
library/cloud/quantum_subnet
+32
-30
library/packaging/apt_repository
+3
-3
No files found.
lib/ansible/runner/action_plugins/fetch.py
View file @
3a635d2d
...
@@ -64,8 +64,8 @@ class ActionModule(object):
...
@@ -64,8 +64,8 @@ class ActionModule(object):
# if dest does not start with "/", we'll assume a relative path
# if dest does not start with "/", we'll assume a relative path
dest
=
utils
.
path_dwim
(
self
.
runner
.
basedir
,
dest
)
dest
=
utils
.
path_dwim
(
self
.
runner
.
basedir
,
dest
)
else
:
else
:
# files are saved in dest dir, with a subdir for each host, then the filename
# files are saved in dest dir, with a subdir for each host, then the filename
dest
=
"
%
s/
%
s/
%
s"
%
(
utils
.
path_dwim
(
self
.
runner
.
basedir
,
dest
),
conn
.
host
,
source
)
dest
=
"
%
s/
%
s/
%
s"
%
(
utils
.
path_dwim
(
self
.
runner
.
basedir
,
dest
),
conn
.
host
,
source
)
dest
=
dest
.
replace
(
"//"
,
"/"
)
dest
=
dest
.
replace
(
"//"
,
"/"
)
# calculate md5 sum for the remote file
# calculate md5 sum for the remote file
...
...
library/cloud/glance_image
View file @
3a635d2d
...
@@ -144,7 +144,7 @@ def _get_glance_client(module, kwargs):
...
@@ -144,7 +144,7 @@ def _get_glance_client(module, kwargs):
'token'
:
token
,
'token'
:
token
,
}
}
try
:
try
:
client
=
glanceclient
.
Client
(
'1'
,
endpoint
,
**
kwargs
)
client
=
glanceclient
.
Client
(
'1'
,
endpoint
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to glance:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to glance:
%
s"
%
e
.
message
)
return
client
return
client
...
@@ -179,7 +179,7 @@ def _glance_image_create(module, params, client):
...
@@ -179,7 +179,7 @@ def _glance_image_create(module, params, client):
break
break
time
.
sleep
(
5
)
time
.
sleep
(
5
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in creating image:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in creating image:
%
s"
%
e
.
message
)
if
image
.
status
==
'active'
:
if
image
.
status
==
'active'
:
module
.
exit_json
(
changed
=
True
,
result
=
image
.
status
,
id
=
image
.
id
)
module
.
exit_json
(
changed
=
True
,
result
=
image
.
status
,
id
=
image
.
id
)
else
:
else
:
...
@@ -197,38 +197,38 @@ def _glance_delete_image(module, params, client):
...
@@ -197,38 +197,38 @@ def _glance_delete_image(module, params, client):
def
main
():
def
main
():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
argument_spec
=
dict
(
argument_spec
=
dict
(
login_username
=
dict
(
default
=
'admin'
),
login_username
=
dict
(
default
=
'admin'
),
login_password
=
dict
(
required
=
True
),
login_password
=
dict
(
required
=
True
),
login_tenant_name
=
dict
(
required
=
True
),
login_tenant_name
=
dict
(
required
=
True
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
region_name
=
dict
(
default
=
None
),
region_name
=
dict
(
default
=
None
),
name
=
dict
(
required
=
True
),
name
=
dict
(
required
=
True
),
disk_format
=
dict
(
default
=
'qcow2'
,
choices
=
[
'aki'
,
'vhd'
,
'vmdk'
,
'raw'
,
'qcow2'
,
'vdi'
,
'iso'
]),
disk_format
=
dict
(
default
=
'qcow2'
,
choices
=
[
'aki'
,
'vhd'
,
'vmdk'
,
'raw'
,
'qcow2'
,
'vdi'
,
'iso'
]),
container_format
=
dict
(
default
=
'bare'
,
choices
=
[
'aki'
,
'ari'
,
'bare'
,
'ovf'
]),
container_format
=
dict
(
default
=
'bare'
,
choices
=
[
'aki'
,
'ari'
,
'bare'
,
'ovf'
]),
owner
=
dict
(
default
=
None
),
owner
=
dict
(
default
=
None
),
min_disk
=
dict
(
default
=
None
),
min_disk
=
dict
(
default
=
None
),
min_ram
=
dict
(
default
=
None
),
min_ram
=
dict
(
default
=
None
),
is_public
=
dict
(
default
=
True
),
is_public
=
dict
(
default
=
True
),
copy_from
=
dict
(
default
=
None
),
copy_from
=
dict
(
default
=
None
),
timeout
=
dict
(
default
=
180
),
timeout
=
dict
(
default
=
180
),
file
=
dict
(
default
=
None
),
file
=
dict
(
default
=
None
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
])
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
])
),
),
mutually_exclusive
=
[[
'file'
,
'copy_from'
]],
mutually_exclusive
=
[[
'file'
,
'copy_from'
]],
)
)
if
module
.
params
[
'state'
]
==
'present'
:
if
module
.
params
[
'state'
]
==
'present'
:
if
not
module
.
params
[
'file'
]
and
not
module
.
params
[
'copy_from'
]:
if
not
module
.
params
[
'file'
]
and
not
module
.
params
[
'copy_from'
]:
module
.
fail_json
(
msg
=
"Either file or copy_from variable should be set to create the image"
)
module
.
fail_json
(
msg
=
"Either file or copy_from variable should be set to create the image"
)
client
=
_get_glance_client
(
module
,
module
.
params
)
client
=
_get_glance_client
(
module
,
module
.
params
)
id
=
_glance_image_present
(
module
,
module
.
params
,
client
)
id
=
_glance_image_present
(
module
,
module
.
params
,
client
)
if
not
id
:
if
not
id
:
_glance_image_create
(
module
,
module
.
params
,
client
)
_glance_image_create
(
module
,
module
.
params
,
client
)
module
.
exit_json
(
changed
=
False
,
id
=
id
,
result
=
"success"
)
module
.
exit_json
(
changed
=
False
,
id
=
id
,
result
=
"success"
)
if
module
.
params
[
'state'
]
==
'absent'
:
if
module
.
params
[
'state'
]
==
'absent'
:
client
=
_get_glance_client
(
module
,
module
.
params
)
client
=
_get_glance_client
(
module
,
module
.
params
)
id
=
_glance_image_present
(
module
,
module
.
params
,
client
)
id
=
_glance_image_present
(
module
,
module
.
params
,
client
)
if
not
id
:
if
not
id
:
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
module
.
exit_json
(
changed
=
False
,
result
=
"Success"
)
else
:
else
:
...
...
library/cloud/nova_compute
View file @
3a635d2d
...
@@ -152,7 +152,7 @@ def _create_server(module, nova):
...
@@ -152,7 +152,7 @@ def _create_server(module, nova):
if
not
module
.
params
[
'key_name'
]:
if
not
module
.
params
[
'key_name'
]:
del
bootkwargs
[
'key_name'
]
del
bootkwargs
[
'key_name'
]
try
:
try
:
server
=
nova
.
servers
.
create
(
*
bootargs
,
**
bootkwargs
)
server
=
nova
.
servers
.
create
(
*
bootargs
,
**
bootkwargs
)
server
=
nova
.
servers
.
get
(
server
.
id
)
server
=
nova
.
servers
.
get
(
server
.
id
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in creating instance:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in creating instance:
%
s "
%
e
.
message
)
...
...
library/cloud/quantum_floating_ip
View file @
3a635d2d
...
@@ -107,7 +107,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -107,7 +107,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
@@ -214,7 +214,7 @@ def main():
...
@@ -214,7 +214,7 @@ def main():
fixed_ip
,
port_id
=
_get_port_info
(
quantum
,
module
,
server_info
[
'id'
])
fixed_ip
,
port_id
=
_get_port_info
(
quantum
,
module
,
server_info
[
'id'
])
if
not
port_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
)
floating_id
,
floating_ip
=
_get_floating_ip
(
module
,
quantum
,
fixed_ip
)
if
module
.
params
[
'state'
]
==
'present'
:
if
module
.
params
[
'state'
]
==
'present'
:
if
floating_ip
:
if
floating_ip
:
module
.
exit_json
(
changed
=
False
,
public_ip
=
floating_ip
)
module
.
exit_json
(
changed
=
False
,
public_ip
=
floating_ip
)
...
...
library/cloud/quantum_floating_ip_associate
View file @
3a635d2d
...
@@ -107,7 +107,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -107,7 +107,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
@@ -119,30 +119,30 @@ def _get_server_state(module, nova):
...
@@ -119,30 +119,30 @@ def _get_server_state(module, nova):
for
server
in
nova
.
servers
.
list
():
for
server
in
nova
.
servers
.
list
():
if
server
:
if
server
:
info
=
server
.
_info
info
=
server
.
_info
if
info
[
'name'
]
==
module
.
params
[
'instance_name'
]:
if
info
[
'name'
]
==
module
.
params
[
'instance_name'
]:
if
info
[
'status'
]
!=
'ACTIVE'
and
module
.
params
[
'state'
]
==
'present'
:
if
info
[
'status'
]
!=
'ACTIVE'
and
module
.
params
[
'state'
]
==
'present'
:
module
.
fail_json
(
msg
=
"The VM is available but not Active. state:"
+
info
[
'status'
])
module
.
fail_json
(
msg
=
"The VM is available but not Active. state:"
+
info
[
'status'
])
server_info
=
info
server_info
=
info
break
break
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in getting the server list:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in getting the server list:
%
s"
%
e
.
message
)
return
server_info
,
server
return
server_info
,
server
def
_get_port_id
(
quantum
,
module
,
instance_id
):
def
_get_port_id
(
quantum
,
module
,
instance_id
):
kwargs
=
{
kwargs
=
{
device_id
': instance_id,
device_id
': instance_id,
}
}
try:
try:
ports = quantum.list_ports(**kwargs)
ports = quantum.list_ports(**kwargs)
except Exception as e:
except Exception as e:
module.fail_json( msg = "Error in listing ports:
%
s"
%
e.message)
module.fail_json( msg = "Error in listing ports:
%
s"
%
e.message)
if not ports['
ports
']:
if not ports['
ports
']:
return None
return None
return ports['
ports
'][0]['
id
']
return ports['
ports
'][0]['
id
']
def _get_floating_ip_id(module, quantum):
def _get_floating_ip_id(module, quantum):
kwargs = {
kwargs = {
'
floating_ip_address
': module.params['
ip_address
']
'
floating_ip_address
': module.params['
ip_address
']
}
}
try:
try:
ips = quantum.list_floatingips(**kwargs)
ips = quantum.list_floatingips(**kwargs)
...
@@ -152,14 +152,14 @@ def _get_floating_ip_id(module, quantum):
...
@@ -152,14 +152,14 @@ def _get_floating_ip_id(module, quantum):
module.fail_json(msg = "
Could
find
the
ip
specified
in
parameter
,
Please
check
")
module.fail_json(msg = "
Could
find
the
ip
specified
in
parameter
,
Please
check
")
ip = ips['floatingips'][0]['id']
ip = ips['floatingips'][0]['id']
if not ips['floatingips'][0]['port_id']:
if not ips['floatingips'][0]['port_id']:
state =
"
detached
"
state = "
detached
"
else:
else:
state = "
attached
"
state = "
attached
"
return state, ip
return state, ip
def _update_floating_ip(quantum, module, port_id, floating_ip_id):
def _update_floating_ip(quantum, module, port_id, floating_ip_id):
kwargs = {
kwargs = {
'port_id': port_id
'port_id': port_id
}
}
try:
try:
result = quantum.update_floatingip(floating_ip_id, {'floatingip': kwargs})
result = quantum.update_floatingip(floating_ip_id, {'floatingip': kwargs})
...
...
library/cloud/quantum_network
View file @
3a635d2d
...
@@ -139,7 +139,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -139,7 +139,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
" Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
" Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
@@ -154,7 +154,7 @@ def _set_tenant_id(module):
...
@@ -154,7 +154,7 @@ def _set_tenant_id(module):
for
tenant
in
_os_keystone
.
tenants
.
list
():
for
tenant
in
_os_keystone
.
tenants
.
list
():
if
tenant
.
name
==
tenant_name
:
if
tenant
.
name
==
tenant_name
:
_os_tenant_id
=
tenant
.
id
_os_tenant_id
=
tenant
.
id
break
;
break
if
not
_os_tenant_id
:
if
not
_os_tenant_id
:
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
...
...
library/cloud/quantum_router
View file @
3a635d2d
...
@@ -112,7 +112,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -112,7 +112,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
@@ -127,7 +127,7 @@ def _set_tenant_id(module):
...
@@ -127,7 +127,7 @@ def _set_tenant_id(module):
for
tenant
in
_os_keystone
.
tenants
.
list
():
for
tenant
in
_os_keystone
.
tenants
.
list
():
if
tenant
.
name
==
login_tenant_name
:
if
tenant
.
name
==
login_tenant_name
:
_os_tenant_id
=
tenant
.
id
_os_tenant_id
=
tenant
.
id
break
;
break
if
not
_os_tenant_id
:
if
not
_os_tenant_id
:
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
...
@@ -152,9 +152,9 @@ def _create_router(module, quantum):
...
@@ -152,9 +152,9 @@ def _create_router(module, quantum):
'admin_state_up'
:
module
.
params
[
'admin_state_up'
],
'admin_state_up'
:
module
.
params
[
'admin_state_up'
],
}
}
try
:
try
:
new_router
=
quantum
.
create_router
({
'router'
:
router
}
)
new_router
=
quantum
.
create_router
(
dict
(
router
=
router
)
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in creating router:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in creating router:
%
s"
%
e
.
message
)
return
new_router
[
'router'
][
'id'
]
return
new_router
[
'router'
][
'id'
]
def
_delete_router
(
module
,
quantum
,
router_id
):
def
_delete_router
(
module
,
quantum
,
router_id
):
...
@@ -191,14 +191,11 @@ def main():
...
@@ -191,14 +191,11 @@ def main():
else
:
else
:
router_id
=
_get_router_id
(
module
,
quantum
)
router_id
=
_get_router_id
(
module
,
quantum
)
if
not
router_id
:
if
not
router_id
:
module
.
exit_json
(
changed
=
False
,
result
=
"success"
)
module
.
exit_json
(
changed
=
False
,
result
=
"success"
)
else
:
else
:
_delete_router
(
module
,
quantum
,
router_id
)
_delete_router
(
module
,
quantum
,
router_id
)
module
.
exit_json
(
changed
=
True
,
result
=
"deleted"
)
module
.
exit_json
(
changed
=
True
,
result
=
"deleted"
)
# this is magic, see lib/ansible/module.params['common.py
# this is magic, see lib/ansible/module.params['common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main
()
main
()
...
...
library/cloud/quantum_router_gateway
View file @
3a635d2d
...
@@ -105,7 +105,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -105,7 +105,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
...
library/cloud/quantum_router_interface
View file @
3a635d2d
...
@@ -112,7 +112,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -112,7 +112,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
module
.
fail_json
(
msg
=
"Error in connecting to quantum:
%
s "
%
e
.
message
)
return
quantum
return
quantum
...
@@ -126,15 +126,15 @@ def _set_tenant_id(module):
...
@@ -126,15 +126,15 @@ def _set_tenant_id(module):
for
tenant
in
_os_keystone
.
tenants
.
list
():
for
tenant
in
_os_keystone
.
tenants
.
list
():
if
tenant
.
name
==
login_tenant_name
:
if
tenant
.
name
==
login_tenant_name
:
_os_tenant_id
=
tenant
.
id
_os_tenant_id
=
tenant
.
id
break
;
break
if
not
_os_tenant_id
:
if
not
_os_tenant_id
:
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
def
_get_router_id
(
module
,
quantum
):
def
_get_router_id
(
module
,
quantum
):
kwargs
=
{
kwargs
=
{
'name'
:
module
.
params
[
'router_name'
],
'name'
:
module
.
params
[
'router_name'
],
}
}
try
:
try
:
routers
=
quantum
.
list_routers
(
**
kwargs
)
routers
=
quantum
.
list_routers
(
**
kwargs
)
...
...
library/cloud/quantum_subnet
View file @
3a635d2d
...
@@ -140,7 +140,7 @@ def _get_quantum_client(module, kwargs):
...
@@ -140,7 +140,7 @@ def _get_quantum_client(module, kwargs):
'endpoint_url'
:
endpoint
'endpoint_url'
:
endpoint
}
}
try
:
try
:
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
quantum
=
client
.
Client
(
'2.0'
,
**
kwargs
)
except
Exception
as
e
:
except
Exception
as
e
:
module
.
fail_json
(
msg
=
" Error in connecting to quantum:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
" Error in connecting to quantum:
%
s"
%
e
.
message
)
return
quantum
return
quantum
...
@@ -155,7 +155,7 @@ def _set_tenant_id(module):
...
@@ -155,7 +155,7 @@ def _set_tenant_id(module):
for
tenant
in
_os_keystone
.
tenants
.
list
():
for
tenant
in
_os_keystone
.
tenants
.
list
():
if
tenant
.
name
==
tenant_name
:
if
tenant
.
name
==
tenant_name
:
_os_tenant_id
=
tenant
.
id
_os_tenant_id
=
tenant
.
id
break
;
break
if
not
_os_tenant_id
:
if
not
_os_tenant_id
:
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
module
.
fail_json
(
msg
=
"The tenant id cannot be found, please check the paramters"
)
...
@@ -204,17 +204,19 @@ def _create_subnet(module, quantum):
...
@@ -204,17 +204,19 @@ def _create_subnet(module, quantum):
'cidr'
:
module
.
params
[
'cidr'
],
'cidr'
:
module
.
params
[
'cidr'
],
}
}
if
module
.
params
[
'allocation_pool_start'
]
and
module
.
params
[
'allocation_pool_end'
]:
if
module
.
params
[
'allocation_pool_start'
]
and
module
.
params
[
'allocation_pool_end'
]:
allocation_pools
=
[
allocation_pools
=
[
{
'start'
:
module
.
params
[
'allocation_pool_start'
],
{
'end'
:
module
.
params
[
'allocation_pool_end'
]}
'start'
:
module
.
params
[
'allocation_pool_start'
],
]
'end'
:
module
.
params
[
'allocation_pool_end'
]
subnet
.
update
({
'allocation_pools'
:
allocation_pools
})
}
]
subnet
.
update
({
'allocation_pools'
:
allocation_pools
})
if
not
module
.
params
[
'gateway_ip'
]:
if
not
module
.
params
[
'gateway_ip'
]:
subnet
.
pop
(
'gateway_ip'
)
subnet
.
pop
(
'gateway_ip'
)
try
:
try
:
new_subnet
=
quantum
.
create_subnet
({
'subnet'
:
subnet
}
)
new_subnet
=
quantum
.
create_subnet
(
dict
(
subnet
=
subnet
)
)
except
Exception
as
e
:
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"Failure in creating subnet:
%
s"
%
e
.
message
)
module
.
fail_json
(
msg
=
"Failure in creating subnet:
%
s"
%
e
.
message
)
return
new_subnet
[
'subnet'
][
'id'
]
return
new_subnet
[
'subnet'
][
'id'
]
...
@@ -229,22 +231,22 @@ def _delete_subnet(module, quantum, subnet_id):
...
@@ -229,22 +231,22 @@ def _delete_subnet(module, quantum, subnet_id):
def
main
():
def
main
():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
argument_spec
=
dict
(
argument_spec
=
dict
(
login_username
=
dict
(
default
=
'admin'
),
login_username
=
dict
(
default
=
'admin'
),
login_password
=
dict
(
required
=
True
),
login_password
=
dict
(
required
=
True
),
login_tenant_name
=
dict
(
required
=
'True'
),
login_tenant_name
=
dict
(
required
=
'True'
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
auth_url
=
dict
(
default
=
'http://127.0.0.1:35357/v2.0/'
),
region_name
=
dict
(
default
=
None
),
region_name
=
dict
(
default
=
None
),
name
=
dict
(
required
=
True
),
name
=
dict
(
required
=
True
),
network_name
=
dict
(
required
=
True
),
network_name
=
dict
(
required
=
True
),
cidr
=
dict
(
required
=
True
),
cidr
=
dict
(
required
=
True
),
tenant_name
=
dict
(
default
=
None
),
tenant_name
=
dict
(
default
=
None
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
]),
state
=
dict
(
default
=
'present'
,
choices
=
[
'absent'
,
'present'
]),
ip_version
=
dict
(
default
=
'4'
,
choices
=
[
'4'
,
'6'
]),
ip_version
=
dict
(
default
=
'4'
,
choices
=
[
'4'
,
'6'
]),
enable_dhcp
=
dict
(
default
=
'true'
,
choices
=
BOOLEANS
),
enable_dhcp
=
dict
(
default
=
'true'
,
choices
=
BOOLEANS
),
gateway_ip
=
dict
(
default
=
None
),
gateway_ip
=
dict
(
default
=
None
),
allocation_pool_start
=
dict
(
default
=
None
),
allocation_pool_start
=
dict
(
default
=
None
),
allocation_pool_end
=
dict
(
default
=
None
),
allocation_pool_end
=
dict
(
default
=
None
),
),
),
)
)
quantum
=
_get_quantum_client
(
module
,
module
.
params
)
quantum
=
_get_quantum_client
(
module
,
module
.
params
)
...
@@ -259,10 +261,10 @@ def main():
...
@@ -259,10 +261,10 @@ def main():
else
:
else
:
subnet_id
=
_get_subnet_id
(
module
,
quantum
)
subnet_id
=
_get_subnet_id
(
module
,
quantum
)
if
not
subnet_id
:
if
not
subnet_id
:
module
.
exit_json
(
changed
=
False
,
result
=
"success"
)
module
.
exit_json
(
changed
=
False
,
result
=
"success"
)
else
:
else
:
_delete_subnet
(
module
,
quantum
,
subnet_id
)
_delete_subnet
(
module
,
quantum
,
subnet_id
)
module
.
exit_json
(
changed
=
True
,
result
=
"deleted"
)
module
.
exit_json
(
changed
=
True
,
result
=
"deleted"
)
# this is magic, see lib/ansible/module.params['common.py
# this is magic, see lib/ansible/module.params['common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
...
...
library/packaging/apt_repository
View file @
3a635d2d
...
@@ -112,9 +112,9 @@ def main():
...
@@ -112,9 +112,9 @@ def main():
# deb http://myserver/path/to/repo free non-free
# deb http://myserver/path/to/repo free non-free
for
i
in
repo_url
.
split
():
for
i
in
repo_url
.
split
():
for
prot
in
[
'http'
,
'file'
,
'ftp'
]:
for
prot
in
[
'http'
,
'file'
,
'ftp'
]:
if
prot
in
i
:
if
prot
in
i
:
repo_url
=
i
repo_url
=
i
break
break
exists
=
repo_exists
(
module
,
repo_url
)
exists
=
repo_exists
(
module
,
repo_url
)
rc
=
0
rc
=
0
...
...
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