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
7ba7e3bd
Commit
7ba7e3bd
authored
Jan 15, 2015
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for rax_clb
parent
78888922
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletions
+34
-1
test/integration/cleanup_rax.py
+28
-1
test/integration/rackspace.yml
+3
-0
test/integration/roles/test_rax_clb/defaults/main.yml
+3
-0
test/integration/roles/test_rax_clb/tasks/main.yml
+0
-0
No files found.
test/integration/cleanup_rax.py
View file @
7ba7e3bd
#!/usr/bin/env python
import
os
import
re
import
yaml
import
argparse
...
...
@@ -11,6 +12,19 @@ except ImportError:
HAS_PYRAX
=
False
def
rax_list_iterator
(
svc
,
*
args
,
**
kwargs
):
method
=
kwargs
.
pop
(
'method'
,
'list'
)
items
=
getattr
(
svc
,
method
)(
*
args
,
**
kwargs
)
while
items
:
retrieved
=
getattr
(
svc
,
method
)(
*
args
,
marker
=
items
[
-
1
]
.
id
,
**
kwargs
)
if
items
and
retrieved
and
items
[
-
1
]
.
id
==
retrieved
[
0
]
.
id
:
del
items
[
-
1
]
items
.
extend
(
retrieved
)
if
len
(
retrieved
)
<
2
:
break
return
items
def
parse_args
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-y'
,
'--yes'
,
action
=
'store_true'
,
dest
=
'assumeyes'
,
...
...
@@ -53,15 +67,27 @@ def prompt_and_delete(item, prompt, assumeyes):
def
delete_rax
(
args
):
"""Function for deleting CloudServers"""
search_opts
=
dict
(
name
=
'^
%
s'
%
args
.
match_re
)
for
region
in
pyrax
.
identity
.
services
.
compute
.
regions
:
cs
=
pyrax
.
connect_to_cloudservers
(
region
=
region
)
servers
=
cs
.
servers
.
list
(
search_opts
=
dict
(
name
=
'^
%
s'
%
args
.
match_re
)
)
servers
=
rax_list_iterator
(
cs
.
servers
,
search_opts
=
search_opts
)
for
server
in
servers
:
prompt_and_delete
(
server
,
'Delete matching
%
s? [y/n]: '
%
server
,
args
.
assumeyes
)
def
delete_rax_clb
(
args
):
"""Function for deleting Cloud Load Balancers"""
for
region
in
pyrax
.
identity
.
services
.
load_balancer
.
regions
:
clb
=
pyrax
.
connect_to_cloud_loadbalancers
(
region
=
region
)
for
lb
in
rax_list_iterator
(
clb
):
if
re
.
search
(
args
.
match_re
,
lb
.
name
):
prompt_and_delete
(
lb
,
'Delete matching
%
s? [y/n]: '
%
lb
,
args
.
assumeyes
)
def
main
():
if
not
HAS_PYRAX
:
raise
SystemExit
(
'The pyrax python module is required for this script'
)
...
...
@@ -69,6 +95,7 @@ def main():
args
=
parse_args
()
authenticate
()
delete_rax
(
args
)
delete_rax_clb
(
args
)
if
__name__
==
'__main__'
:
...
...
test/integration/rackspace.yml
View file @
7ba7e3bd
...
...
@@ -7,3 +7,6 @@
roles
:
-
role
:
test_rax
tags
:
test_rax
-
role
:
test_rax_clb
tags
:
test_rax_clb
test/integration/roles/test_rax_clb/defaults/main.yml
0 → 100644
View file @
7ba7e3bd
---
rackspace_region
:
IAD
resource_prefix
:
ansible-testing
test/integration/roles/test_rax_clb/tasks/main.yml
0 → 100644
View file @
7ba7e3bd
This diff is collapsed.
Click to expand it.
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