'Populate instance display_name and hostname.'

def _populate_instance_names(self, instance, num_instances):

    display_name = instance.get('display_name')
    if instance.obj_attr_is_set('hostname'):
        hostname = instance.get('hostname')
    else:
        hostname = None
    if (display_name is None):
        display_name = self._default_display_name(instance.uuid)
        instance.display_name = display_name
    if ((hostname is None) and (num_instances == 1)):
        hostname = display_name
        default_hostname = self._default_host_name(instance.uuid)
        instance.hostname = utils.sanitize_hostname(hostname, default_hostname)
