'Get the server fixed or floating IP.
Based on the configuration we\'re in, return a correct ip
address for validating that a guest is up.'

def get_server_ip(self, server):

    if (CONF.validation.connect_method == 'floating'):
        return self.create_floating_ip(server)['ip']
    elif (CONF.validation.connect_method == 'fixed'):
        if CONF.validation.network_for_ssh:
            addresses = server['addresses'][CONF.validation.network_for_ssh]
        else:
            creds_provider = self._get_credentials_provider()
            net_creds = creds_provider.get_primary_creds()
            network = getattr(net_creds, 'network', None)
            addresses = (server['addresses'][network['name']] if network else [])
        for address in addresses:
            if ((address['version'] == CONF.validation.ip_version_for_ssh) and (address['OS-EXT-IPS:type'] == 'fixed')):
                return address['addr']
        raise exceptions.ServerUnreachable(server_id=server['id'])
    else:
        raise lib_exc.InvalidConfiguration()
