From 42a0d3a4b0e7228a28675fc6a6315654914f8c10 Mon Sep 17 00:00:00 2001 From: "Dave Walker (Daviey)" Date: Wed, 29 Feb 2012 13:48:56 +0000 Subject: [PATCH] Option expose IP instead of dnshost in ec2 desc' As documented in bug 901594, previous nova releases, the IP address was exposed as the DNS hostname, which worked well with euca-tools. This is unfortunately not always ideal for private clouds. Whilst it is expected to be able to euca-describe-instances --ipv4 in newer euca2ools releases, this behaviour is not always desired. This patchset allows the nova admin to set a global flag of: --ec2_private_dns_show_ip=True, to restore legacy nova behaviour. This does not change the current default behaviour of nova. Change-Id: I7c71ffe63929d90d45d9c724ab3409dcdee52b44 --- .mailmap | 1 + Authors | 2 +- nova/api/ec2/__init__.py | 4 ++++ nova/api/ec2/cloud.py | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 5807e0eebefc..468fe89df2bc 100644 --- a/.mailmap +++ b/.mailmap @@ -18,6 +18,7 @@ + diff --git a/Authors b/Authors index 06416bf4bc0b..54a3cbfa793d 100644 --- a/Authors +++ b/Authors @@ -40,7 +40,7 @@ Dan Prince Dan Wendlandt Daniel P. Berrange Dave Lapsley -Dave Walker +Dave Walker David Pravec David Subiros Dean Troyer diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 87fea6b2cc07..6566ab7a9253 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -56,6 +56,10 @@ ec2_opts = [ cfg.StrOpt('keystone_ec2_url', default='http://localhost:5000/v2.0/ec2tokens', help='URL to get token from ec2 request.'), + cfg.BoolOpt('ec2_private_dns_show_ip', + default=False, + help='Return the IP address as private dns hostname in ' + 'describe instances'), ] FLAGS = flags.FLAGS diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 352ba02a5d85..5240af0163f4 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1148,7 +1148,10 @@ class CloudController(object): floating_ip = ip_info['floating_ips'][0] if ip_info['fixed_ip6s']: i['dnsNameV6'] = ip_info['fixed_ip6s'][0] - i['privateDnsName'] = instance['hostname'] + if FLAGS.ec2_private_dns_show_ip: + i['privateDnsName'] = fixed_ip + else: + i['privateDnsName'] = instance['hostname'] i['privateIpAddress'] = fixed_ip i['publicDnsName'] = floating_ip i['ipAddress'] = floating_ip or fixed_ip