Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
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
configuration
Commits
be124d7b
Commit
be124d7b
authored
Sep 13, 2013
by
Feanil Patel
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #255 from edx/feanil/vpc_tools
Feanil/vpc tools
parents
e9fb73c8
b6a18958
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
14 deletions
+23
-14
util/vpc-tools/vpc-dns.py
+9
-3
util/vpc-tools/vpc-tools.py
+5
-11
util/vpc-tools/vpcutil.py
+9
-0
No files found.
util/vpc-tools/vpc-dns.py
View file @
be124d7b
"""vpc-dns.py
Usage:
vpc-dns.py create-zone
vpc <vpc-id>
vpc-dns.py create-zone
(vpc <vpc_id> | stack-name <stack_name>)
vpc-dns.py (-h --help)
vpc-dns.py (-v --version)
...
...
@@ -12,6 +12,7 @@ Options:
import
boto
from
boto.route53.record
import
ResourceRecordSets
from
docopt
import
docopt
from
vpcutil
import
vpc_for_stack_name
class
VPCDns
:
BACKEND_ZONE
=
"Z4AI6ADZTL3HN"
...
...
@@ -106,8 +107,13 @@ class VPCDns:
VERSION
=
"0.1"
def
dispatch
(
args
):
vpc_id
=
args
.
get
(
"<vpc-id>"
)
if
args
.
get
(
"vpc"
):
vpc_id
=
args
.
get
(
"<vpc_id>"
)
elif
args
.
get
(
"stack-name"
):
stack_name
=
args
.
get
(
"<stack_name>"
)
vpc_id
=
vpc_for_stack_name
(
stack_name
)
else
:
raise
Exception
(
"No vpc_id or stack_name provided."
)
c
=
VPCDns
(
vpc_id
=
vpc_id
)
...
...
util/vpc-tools/vpc-tools.py
View file @
be124d7b
"""VPC Tools.
Usage:
vpc-tools.py ssh-config (vpc <vpc_id> | stack-name <stack_name>) identity-file <identity_file> user <user> [
config-file <config_file>] [strict-host-check <strict_host_check>
]
vpc-tools.py ssh-config (vpc <vpc_id> | stack-name <stack_name>) identity-file <identity_file> user <user> [
(config-file <config_file>)] [(strict-host-check <strict_host_check>)
]
vpc-tools.py (-h --help)
vpc-tools.py (-v --version)
...
...
@@ -12,11 +12,12 @@ Options:
"""
import
boto
from
docopt
import
docopt
from
vpcutil
import
vpc_for_stack_name
VERSION
=
"vpc tools 0.1"
DEFAULT_USER
=
"ubuntu"
DEFAULT_HOST_CHECK
=
"
yes
"
DEFAULT_HOST_CHECK
=
"
ask
"
JUMPBOX_CONFIG
=
"""
Host {jump_box}
...
...
@@ -43,13 +44,6 @@ def dispatch(args):
if
args
.
get
(
"ssh-config"
):
_ssh_config
(
args
)
def
vpc_for_stack_name
(
stack_name
):
cfn
=
boto
.
connect_cloudformation
()
resources
=
cfn
.
list_stack_resources
(
stack_name
)
for
resource
in
resources
:
if
resource
.
resource_type
==
'AWS::EC2::VPC'
:
return
resource
.
physical_resource_id
def
_ssh_config
(
args
):
if
args
.
get
(
"vpc"
):
vpc_id
=
args
.
get
(
"<vpc_id>"
)
...
...
@@ -57,7 +51,7 @@ def _ssh_config(args):
stack_name
=
args
.
get
(
"<stack_name>"
)
vpc_id
=
vpc_for_stack_name
(
stack_name
)
else
:
raise
Exception
(
"No
way to know which vpc to query
."
)
raise
Exception
(
"No
vpc_id or stack_name provided
."
)
vpc
=
boto
.
connect_vpc
()
...
...
@@ -75,7 +69,7 @@ def _ssh_config(args):
if
config_file
:
config_file
=
"-F {}"
.
format
(
config_file
)
else
:
config_file
=
"
nothing
"
config_file
=
""
jump_box
=
"{vpc_id}-jumpbox"
.
format
(
vpc_id
=
vpc_id
)
friendly
=
"{vpc_id}-{logical_id}-{instance_id}"
...
...
util/vpc-tools/vpcutil.py
0 → 100644
View file @
be124d7b
import
boto
def
vpc_for_stack_name
(
stack_name
):
cfn
=
boto
.
connect_cloudformation
()
resources
=
cfn
.
list_stack_resources
(
stack_name
)
for
resource
in
resources
:
if
resource
.
resource_type
==
'AWS::EC2::VPC'
:
return
resource
.
physical_resource_id
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