'Checks to see if the placement API is ready for scheduling.
Checks to see that the placement API service is registered in the
service catalog and that we can make requests against it. Also checks
that there are compute nodes registered with the placement service
as resource providers so that when the Ocata nova-scheduler code starts
handling requests it has somewhere to send those builds.'

def _check_placement(self):

    try:
        versions = self._placement_get('/')
        max_version = pkg_resources.parse_version(versions['versions'][0]['max_version'])
        needs_version = pkg_resources.parse_version('1.4')
        if (max_version < needs_version):
            msg = (_('Placement    API    version    %(needed)s    needed,    you    have    %(current)s.') % {'needed': needs_version, 'current': max_version})
            return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    except ks_exc.MissingAuthPlugin:
        msg = _('No    credentials    specified    for    placement    API    in    nova.conf.')
        return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    except ks_exc.Unauthorized:
        msg = _('Placement    service    credentials    do    not    work.')
        return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    except ks_exc.EndpointNotFound:
        msg = _('Placement    API    endpoint    not    found.')
        return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    except ks_exc.DiscoveryFailure:
        msg = _('Discovery    for    placement    API    URI    failed.')
        return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    except ks_exc.NotFound:
        msg = _('Placement    API    does    not    seem    to    be    running.')
        return UpgradeCheckResult(UpgradeCheckCode.FAILURE, msg)
    return UpgradeCheckResult(UpgradeCheckCode.SUCCESS)
