def _get_host_uuid_from_aggregate(self, context, hostname):
        aggregate_list = objects.AggregateList.get_by_host(
            context, CONF.host, key=pool_states.POOL_FLAG)

        reason = _('Destination host:%s must be in the same '
                   'aggregate as the source server') % hostname
        if len(aggregate_list) == 0:
            raise exception.MigrationPreCheckError(reason=reason)
        if hostname not in aggregate_list[0].metadata:
            raise exception.MigrationPreCheckError(reason=reason)

        return aggregate_list[0].metadata[hostname]
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._get_host_uuid_from_aggregate/original