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
edx
configuration
Commits
f3e12cd8
Commit
f3e12cd8
authored
Nov 04, 2013
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a dns name to the rds.
parent
6e68f071
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
util/vpc-tools/vpc_dns.py
+20
-5
No files found.
util/vpc-tools/vpc_dns.py
View file @
f3e12cd8
...
...
@@ -78,8 +78,14 @@ def elbs_for_stack_name(stack_name):
if
elb
.
vpc_id
==
vpc_id
:
yield
elb
def
rdss_for_stack_name
(
stack_name
):
vpc_id
=
vpc_for_stack_name
(
stack_name
)
rds
=
boto
.
connect_rds
()
for
instance
in
rds
.
get_all_dbinstances
():
if
hasattr
(
instance
,
'VpcId'
)
and
instance
.
VpcId
==
vpc_id
:
yield
instance
def
ensure_service_dns
(
elb
,
prefix
,
zone
):
def
ensure_service_dns
(
generated_dns_name
,
prefix
,
zone
):
dns_template
=
"{prefix}.{zone_name}"
# Have to remove the trailing period that is on zone names.
...
...
@@ -87,7 +93,7 @@ def ensure_service_dns(elb, prefix, zone):
dns_name
=
dns_template
.
format
(
prefix
=
prefix
,
zone_name
=
zone_name
)
add_or_update_record
(
zone
,
dns_name
,
'CNAME'
,
600
,
[
elb
.
dns_name
])
add_or_update_record
(
zone
,
dns_name
,
'CNAME'
,
600
,
[
generated_
dns_name
])
if
__name__
==
"__main__"
:
...
...
@@ -102,7 +108,7 @@ if __name__ == "__main__":
stack_name
=
args
.
stackname
# Create DNS for edxapp and xqueue.
dns_settings
=
{
elb_
dns_settings
=
{
'edxapp'
:
[
'courses'
,
'studio'
],
'xqueue'
:
[
'xqueue'
],
'rabbit'
:
[
'rabbit'
],
...
...
@@ -118,9 +124,18 @@ if __name__ == "__main__":
stack_elbs
=
elbs_for_stack_name
(
stack_name
)
for
elb
in
stack_elbs
:
for
role
,
dns_prefixes
in
dns_settings
.
items
():
for
role
,
dns_prefixes
in
elb_
dns_settings
.
items
():
#FIXME this breaks when the service name is in the stack name ie. testforumstack.
# Get the tags for the instances in this elb and compare the service against the role tag.
if
role
in
elb
.
dns_name
.
lower
():
for
prefix
in
dns_prefixes
:
ensure_service_dns
(
elb
,
prefix
,
zone
)
ensure_service_dns
(
elb
.
dns_name
,
prefix
,
zone
)
# Add a DNS name for the RDS
stack_rdss
=
list
(
rdss_for_stack_name
(
stack_name
))
if
len
(
stack_rdss
)
!=
1
:
msg
=
"Didn't find exactly one RDS in this VPC(Found {})"
raise
Exception
(
msg
.
format
(
len
(
stack_rdss
)))
else
:
ensure_service_dns
(
stack_rdss
[
0
]
.
endpoint
[
0
],
'rds'
,
zone
)
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