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
1e0eed3f
Commit
1e0eed3f
authored
Apr 13, 2014
by
Chris Conway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes cleanup_gce.py to use gce_credentials module.
parent
2257a697
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
38 deletions
+5
-38
test/integration/cleanup_gce.py
+5
-38
No files found.
test/integration/cleanup_gce.py
View file @
1e0eed3f
...
...
@@ -21,6 +21,8 @@ except ImportError:
"msg='libcloud with GCE support (0.13.3+) required for this module'"
)
sys
.
exit
(
1
)
import
gce_credentials
def
delete_gce_resources
(
get_func
,
attr
,
opts
):
for
item
in
get_func
():
...
...
@@ -37,39 +39,9 @@ def prompt_and_delete(item, prompt, assumeyes):
print
(
"Deleted
%
s"
%
item
)
def
parse_args
():
default_service_account_email
=
None
default_pem_file
=
None
default_project_id
=
None
# Load details from credentials.yml
if
os
.
path
.
isfile
(
'credentials.yml'
):
credentials
=
yaml
.
load
(
open
(
'credentials.yml'
,
'r'
))
if
default_service_account_email
is
None
:
default_service_account_email
=
credentials
[
'gce_service_account_email'
]
if
default_pem_file
is
None
:
default_pem_file
=
credentials
[
'gce_pem_file'
]
if
default_project_id
is
None
:
default_project_id
=
credentials
[
'gce_project_id'
]
parser
=
optparse
.
OptionParser
(
usage
=
"
%
s [options]"
%
(
sys
.
argv
[
0
],),
description
=
__doc__
)
parser
.
add_option
(
"--service_account_email"
,
action
=
"store"
,
dest
=
"service_account_email"
,
default
=
default_service_account_email
,
help
=
"GCE service account email. Default is loaded from credentials.yml."
)
parser
.
add_option
(
"--pem_file"
,
action
=
"store"
,
dest
=
"pem_file"
,
default
=
default_pem_file
,
help
=
"GCE client key. Default is loaded from credentials.yml."
)
parser
.
add_option
(
"--project_id"
,
action
=
"store"
,
dest
=
"project_id"
,
default
=
default_project_id
,
help
=
"Google Cloud project ID. Default is loaded from credentials.yml."
)
parser
.
add_option
(
"--credentials"
,
"-c"
,
action
=
"store"
,
dest
=
"credential_file"
,
default
=
"credentials.yml"
,
help
=
"YAML file to read cloud credentials (default:
%
default)"
)
gce_credentials
.
add_credentials_options
(
parser
)
parser
.
add_option
(
"--yes"
,
"-y"
,
action
=
"store_true"
,
dest
=
"assumeyes"
,
default
=
False
,
...
...
@@ -80,10 +52,7 @@ def parse_args():
help
=
"Regular expression used to find GCE resources (default:
%
default)"
)
(
opts
,
args
)
=
parser
.
parse_args
()
for
required
in
[
'service_account_email'
,
'pem_file'
,
'project_id'
]:
if
getattr
(
opts
,
required
)
is
None
:
parser
.
error
(
"Missing required parameter: --
%
s"
%
required
)
gce_credentials
.
check_required
(
opts
,
parser
)
return
(
opts
,
args
)
if
__name__
==
'__main__'
:
...
...
@@ -91,9 +60,7 @@ if __name__ == '__main__':
(
opts
,
args
)
=
parse_args
()
# Connect to GCE
gce_cls
=
get_driver
(
Provider
.
GCE
)
gce
=
gce_cls
(
opts
.
service_account_email
,
opts
.
pem_file
,
project
=
opts
.
project_id
)
gce
=
gce_credentials
.
get_gce_driver
(
opts
)
try
:
# Delete matching instances
...
...
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