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
fec255a3
Commit
fec255a3
authored
Apr 25, 2014
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding play mappings for the commoncluster
parent
9af1878a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
util/vpc-tools/vpc_dns.py
+32
-17
No files found.
util/vpc-tools/vpc_dns.py
View file @
fec255a3
...
@@ -35,9 +35,19 @@ import sys
...
@@ -35,9 +35,19 @@ import sys
# up the dns name to be unique
# up the dns name to be unique
ELB_BAN_LIST
=
[
ELB_BAN_LIST
=
[
'
prod-mcki-AprosELB-887241654.us-east-1.elb.amazonaws.com
'
,
'
Apros
'
,
]
]
# If the ELB name has the key in its name these plays
# will be used for the DNS CNAME tuple. This is used for
# commoncluster.
ELB_PLAY_MAPPINGS
=
{
'RabbitMQ'
:
'rabbitmq'
,
'Xqueue'
:
'xqueue'
,
'Elastic'
:
'elasticsearch'
,
}
class
DNSRecord
():
class
DNSRecord
():
...
@@ -88,8 +98,8 @@ def add_or_update_record(dns_records):
...
@@ -88,8 +98,8 @@ def add_or_update_record(dns_records):
if
record
.
record_name
in
old_records
.
keys
():
if
record
.
record_name
in
old_records
.
keys
():
if
record
.
record_name
+
"."
==
old_records
[
record
.
record_name
]
.
name
and
\
if
record
.
record_name
+
"."
==
old_records
[
record
.
record_name
]
.
name
and
\
record
.
record_type
==
old_records
[
record
.
record_name
]
.
type
:
record
.
record_type
==
old_records
[
record
.
record_name
]
.
type
:
print
"Record for {} already exists and is identical, skipping.
\n
"
.
format
(
print
(
"Record for {} already exists and is identical, skipping.
\n
"
.
format
(
record
.
record_name
)
record
.
record_name
)
)
continue
continue
if
args
.
force
:
if
args
.
force
:
...
@@ -119,7 +129,7 @@ def add_or_update_record(dns_records):
...
@@ -119,7 +129,7 @@ def add_or_update_record(dns_records):
if
args
.
noop
:
if
args
.
noop
:
print
(
"Would have submitted the following change set:
\n
"
)
print
(
"Would have submitted the following change set:
\n
"
)
xml_doc
=
xml
.
dom
.
minidom
.
parseString
(
change_set
.
to_xml
())
xml_doc
=
xml
.
dom
.
minidom
.
parseString
(
change_set
.
to_xml
())
print
xml_doc
.
toprettyxml
(
newl
=
''
)
# newl='' to remove extra newlines
print
(
xml_doc
.
toprettyxml
(
newl
=
''
)
)
# newl='' to remove extra newlines
else
:
else
:
r53
.
change_rrsets
(
zone_id
,
change_set
.
to_xml
())
r53
.
change_rrsets
(
zone_id
,
change_set
.
to_xml
())
print
(
"Updated DNS record:
\n
{}"
.
format
(
status_msg
))
print
(
"Updated DNS record:
\n
{}"
.
format
(
status_msg
))
...
@@ -170,7 +180,6 @@ def get_security_group_dns(group_name):
...
@@ -170,7 +180,6 @@ def get_security_group_dns(group_name):
def
get_dns_from_instances
(
elb
):
def
get_dns_from_instances
(
elb
):
for
inst
in
elb
.
instances
:
for
inst
in
elb
.
instances
:
try
:
try
:
instance
=
ec2_con
.
get_all_instances
(
instance
=
ec2_con
.
get_all_instances
(
...
@@ -186,7 +195,6 @@ def get_dns_from_instances(elb):
...
@@ -186,7 +195,6 @@ def get_dns_from_instances(elb):
else
:
else
:
# deprecated, for backwards compatibility
# deprecated, for backwards compatibility
play_tag
=
instance
.
tags
[
'role'
]
play_tag
=
instance
.
tags
[
'role'
]
break
# only need the first instance for tag info
break
# only need the first instance for tag info
except
KeyError
:
except
KeyError
:
print
(
"Instance {}, attached to elb {} does not "
print
(
"Instance {}, attached to elb {} does not "
...
@@ -218,17 +226,25 @@ def update_elb_rds_dns(zone):
...
@@ -218,17 +226,25 @@ def update_elb_rds_dns(zone):
stack_elbs
=
[
elb
for
elb
in
elb_con
.
get_all_load_balancers
()
stack_elbs
=
[
elb
for
elb
in
elb_con
.
get_all_load_balancers
()
if
elb
.
vpc_id
==
vpc_id
]
if
elb
.
vpc_id
==
vpc_id
]
for
elb
in
stack_elbs
:
for
elb
in
stack_elbs
:
env_tag
,
deployment_tag
,
play_tag
=
get_dns_from_instances
(
elb
)
if
"RabbitMQ"
in
elb
.
source_security_group
.
name
or
"ElasticSearch"
in
elb
.
source_security_group
.
name
:
# Override the play tag if a substring of the elb name
env_tag
,
deployment_tag
,
play_tag
=
get_security_group_dns
(
elb
.
source_security_group
.
name
)
# is in ELB_PLAY_MAPPINGS
fqdn
=
"{}-{}-{}.{}"
.
format
(
env_tag
,
play_tag
,
deployment_tag
,
zone_name
)
if
elb
.
dns_name
not
in
ELB_BAN_LIST
:
for
key
in
ELB_PLAY_MAPPINGS
.
keys
():
dns_records
.
add
(
DNSRecord
(
zone
,
fqdn
,
'CNAME'
,
600
,
[
elb
.
dns_name
]))
if
key
in
elb
.
name
:
else
:
play_tag
=
ELB_PLAY_MAPPINGS
[
key
]
env_tag
,
deployment_tag
,
play_tag
=
get_dns_from_instances
(
elb
)
break
fqdn
=
"{}-{}-{}.{}"
.
format
(
env_tag
,
deployment_tag
,
play_tag
,
zone_name
)
fqdn
=
"{}-{}-{}.{}"
.
format
(
env_tag
,
deployment_tag
,
play_tag
,
zone_name
)
if
elb
.
dns_name
not
in
ELB_BAN_LIST
:
dns_records
.
add
(
DNSRecord
(
zone
,
fqdn
,
'CNAME'
,
600
,
[
elb
.
dns_name
]))
# Skip over ELBs if a substring of the ELB name is in
# the ELB_BAN_LIST
if
any
(
name
in
elb
.
name
for
name
in
ELB_BAN_LIST
):
print
(
"Skipping {} because it is on the ELB ban list"
.
format
(
elb
.
name
))
continue
dns_records
.
add
(
DNSRecord
(
zone
,
fqdn
,
'CNAME'
,
600
,
[
elb
.
dns_name
]))
stack_rdss
=
[
rds
for
rds
in
rds_con
.
get_all_dbinstances
()
stack_rdss
=
[
rds
for
rds
in
rds_con
.
get_all_dbinstances
()
if
hasattr
(
rds
.
subnet_group
,
'vpc_id'
)
and
if
hasattr
(
rds
.
subnet_group
,
'vpc_id'
)
and
...
@@ -288,6 +304,5 @@ if __name__ == "__main__":
...
@@ -288,6 +304,5 @@ if __name__ == "__main__":
# Connect to route53 using the user's .boto file
# Connect to route53 using the user's .boto file
r53
=
boto
.
connect_route53
()
r53
=
boto
.
connect_route53
()
zone
=
get_or_create_hosted_zone
(
args
.
zone_name
)
zone
=
get_or_create_hosted_zone
(
args
.
zone_name
)
update_elb_rds_dns
(
zone
)
update_elb_rds_dns
(
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