def __init__(self):
        self.utils = host_trust_utils.HostTrustUtils()
        self.compute_nodes = {}
        self.admin = context.get_admin_context()

        # Fetch compute node list to initialize the compute_nodes,
        # so that we don't need poll OAT service one by one for each
        # host in the first round that scheduler invokes us.
        self.compute_nodes = db.compute_node_get_all(self.admin)
    def truststatus(self, req, id):
        """Returns the trust status of compute node."""
        context = req.environ['nova.context']
        authorize(context)

        try:
            utils = host_trust_utils.HostTrustUtils()
            trust_report = utils.getTrustReport(id)
        except (Exception, exception.ComputeHostNotFound):
            msg = _(
                "Trust Report for compute node with ID '%s' could not be found."
            ) % id
            raise webob.exc.HTTPNotFound(explanation=msg)

        return {'trust_report': json.loads(trust_report)}
    def metadata(self, req, id):
        """Returns the trust status of compute node."""
        context = req.environ['nova.context']
        authorize(context)

        hv_specs = self.api.get_hv_specs_by_compute_node_id(context, id)
        result = defaultdict(list)
        result['id'] = id

        for hvspec in hv_specs:
            key = hvspec['key']
            if key == "trust_report":
                utils = host_trust_utils.HostTrustUtils()
                value = utils.getTrustReport(id)
            elif key == "signed_trust_report":
                value = ""
            else:
                value = hvspec['value']
            result[key] = value

        return {'hv_metadata': result}