From d9663d476adaf220204ed95d6a118a73cac395c2 Mon Sep 17 00:00:00 2001 From: Haissam Kaj Date: Thu, 28 Apr 2016 12:48:37 +0000 Subject: [PATCH] Fix get_hostname for windows ec2 instances --- util.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util.py b/util.py index 5d2aac00b0..4e25a04d36 100644 --- a/util.py +++ b/util.py @@ -223,8 +223,11 @@ def _get_hostname_unix(): if unix_hostname and is_valid_hostname(unix_hostname): hostname = unix_hostname - # if we have an ec2 default hostname, see if there's an instance-id available - if (Platform.is_ecs_instance()) or (hostname is not None and True in [hostname.lower().startswith(p) for p in [u'ip-', u'domu']]): + # if the host is an ECS worker, or has an EC2 hostname, or no hostname but it's a windows machine + # try and find a EC2 instance ID + if (Platform.is_ecs_instance()) or \ + (hostname is not None and True in [hostname.lower().startswith(p) for p in [u'ip-', u'domu']]) or \ + (hostname is None and os_name == 'windows'): instanceid = EC2.get_instance_id(config) if instanceid: hostname = instanceid