Clark Boylan 276d31d2dd Fix rax reverse DNS setup in launch
The launch node script didn't call the method in dns.py to setup rax
reverse dns. This means we didn't attempt to set up reverse dns at all
even when booting in rax. Fix this by calling the appropriate method.

Note we do some refactoring too in order to keep dns.py in the business
of dealing only with forward dns. All of the rax reverse dns content is
kept in rax_rdns.py.

Change-Id: I86091f4e5c56d38bb2d25b983f8b77ec1cd5b7b5
2023-04-03 17:01:43 -07:00

84 lines
2.7 KiB
Python
Executable File

#!/usr/bin/env python3
# Launch a new OpenStack project infrastructure node.
# Copyright (C) 2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from .sshfp import sshfp_print_records
from .ssh_knownhosts import generate_known_hosts
def print_dns(cloud, server):
ip4 = server.public_v4
ip6 = server.public_v6
if server.name.endswith('opendev.org'):
print_dns_opendev(server.name.rsplit('.', 2)[0], ip4, ip6)
else:
print("Login to manage.rackspace.com and setup DNS manually.")
print_inventory_yaml(server, ip4, ip6)
def print_dns_opendev(name, ip4, ip6):
print("\n")
print("Put the following into zone-opendev.org:zones/opendev.org/zone.db")
print("{name} IN A {ip4}".format(name=name, ip4=ip4))
if ip6:
print("{name} IN AAAA {ip6}".format(name=name, ip6=ip6))
sshfp_print_records(name, ip4)
def print_inventory_yaml(server, ip4, ip6):
known_hosts = generate_known_hosts(ip4)
print("\n")
print("Put the following into system-config:inventory/base/hosts.yaml")
print("\n")
print(" {name}:".format(name=server.name))
print(" ansible_host: {ip}".format(ip=ip4 or ip6))
print(" location:")
print(" cloud: {cloud}".format(cloud=server.location['cloud']))
print(" region_name: {region_name}".format(
region_name=server.location['region_name']))
print(" public_v4: {ip4}".format(ip4=ip4))
if ip6:
print(" public_v6: {ip6}".format(ip6=ip6))
print(" host_keys:")
for (key, fingerprint) in known_hosts:
print(" - '%s %s'" % (key, fingerprint))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("name", help="server name")
options = parser.parse_args()
import openstack
cloud = openstack.connect()
# Get the server using the shade layer so that we have server.public_v4
# and server.public_v6
try:
server = cloud.get_server(options.name)
except AttributeError:
print("Please update your version of shade/openstacksdk."
" openstacksdk >= 0.12 is required")
raise
print_dns(cloud, server)