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
f5d2f8e3
Commit
f5d2f8e3
authored
Jan 09, 2015
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add integration tests for the rax module
parent
1544dde9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
6 deletions
+93
-6
test/integration/Makefile
+1
-2
test/integration/cleanup_rax.py
+75
-0
test/integration/credentials.template
+5
-0
test/integration/rackspace.yml
+9
-4
test/integration/roles/test_rax/defaults/main.yml
+3
-0
test/integration/roles/test_rax/tasks/main.yml
+0
-0
No files found.
test/integration/Makefile
View file @
f5d2f8e3
...
...
@@ -94,8 +94,7 @@ gce_cleanup:
python cleanup_gce.py
-y
--match
=
"^
$(CLOUD_RESOURCE_PREFIX)
"
rackspace_cleanup
:
@
echo
"FIXME - cleanup_rax.py not yet implemented"
@
# python cleanup_rax.py -y --match="^
$(CLOUD_RESOURCE_PREFIX)
"
python cleanup_rax.py
-y
--match
=
"^
$(CLOUD_RESOURCE_PREFIX)
"
$(CREDENTIALS_FILE)
:
@
echo
"No credentials file found. A file named '
$(CREDENTIALS_FILE)
' is needed to provide credentials needed to run cloud tests. See sample 'credentials.template' file."
...
...
test/integration/cleanup_rax.py
0 → 100644
View file @
f5d2f8e3
#!/usr/bin/env python
import
os
import
yaml
import
argparse
try
:
import
pyrax
HAS_PYRAX
=
True
except
ImportError
:
HAS_PYRAX
=
False
def
parse_args
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-y'
,
'--yes'
,
action
=
'store_true'
,
dest
=
'assumeyes'
,
default
=
False
,
help
=
"Don't prompt for confirmation"
)
parser
.
add_argument
(
'--match'
,
dest
=
'match_re'
,
default
=
'^ansible-testing'
,
help
=
'Regular expression used to find resources '
'(default:
%(default)
s)'
)
return
parser
.
parse_args
()
def
authenticate
():
try
:
with
open
(
os
.
path
.
realpath
(
'./credentials.yml'
))
as
f
:
credentials
=
yaml
.
load
(
f
)
except
Exception
as
e
:
raise
SystemExit
(
e
)
try
:
pyrax
.
set_credentials
(
credentials
.
get
(
'rackspace_username'
),
credentials
.
get
(
'rackspace_api_key'
))
except
Exception
as
e
:
raise
SystemExit
(
e
)
def
prompt_and_delete
(
item
,
prompt
,
assumeyes
):
if
not
assumeyes
:
assumeyes
=
raw_input
(
prompt
)
.
lower
()
==
'y'
assert
(
hasattr
(
item
,
'delete'
)
or
hasattr
(
item
,
'terminate'
),
"Class <
%
s> has no delete or terminate attribute"
%
item
.
__class__
)
if
assumeyes
:
if
hasattr
(
item
,
'delete'
):
item
.
delete
()
print
(
"Deleted
%
s"
%
item
)
if
hasattr
(
item
,
'terminate'
):
item
.
terminate
()
print
(
"Terminated
%
s"
%
item
)
def
delete_rax
(
args
):
"""Function for deleting CloudServers"""
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
))
for
server
in
servers
:
prompt_and_delete
(
server
,
'Delete matching
%
s? [y/n]: '
%
server
,
args
.
assumeyes
)
def
main
():
if
not
HAS_PYRAX
:
raise
SystemExit
(
'The pyrax python module is required for this script'
)
args
=
parse_args
()
authenticate
()
delete_rax
(
args
)
if
__name__
==
'__main__'
:
main
()
test/integration/credentials.template
View file @
f5d2f8e3
---
# Rackspace Credentials
rackspace_username:
rackspace_api_key:
rackspace_region:
# AWS Credentials
ec2_access_key:
ec2_secret_key:
...
...
test/integration/rackspace.yml
View file @
f5d2f8e3
-
hosts
:
testhost
gather_facts
:
True
roles
:
[]
---
-
hosts
:
localhost
connection
:
local
gather_facts
:
false
tags
:
-
rackspace
roles
:
-
role
:
test_rax
tags
:
test_rax
test/integration/roles/test_rax/defaults/main.yml
0 → 100644
View file @
f5d2f8e3
---
rackspace_region
:
IAD
resource_prefix
:
ansible-testing
test/integration/roles/test_rax/tasks/main.yml
0 → 100644
View file @
f5d2f8e3
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