def _get_nodes_in_env(self, env, api):
        """
        given a chef environment, find all nodes with that environment
        in their facts and return a list of node ids. Exclude containers,
        nodes without agents, and nodes that don't have the chef output
        module (just in case they get shoved into a nova cluster wrongly)
        """

        final_nodelist = []

        self.logger.debug('environment: %s' % env)

        query = 'facts.chef_environment = "%s"' % env
        nodelist = api.nodes_query(query)

        for node in nodelist:
            should_add = True
            if not 'backends' in node['facts']:
                should_add = False
            else:
                if 'container' in node['facts']['backends']:
                    should_add = False

                if not 'agent' in node['facts']['backends']:
                    should_add = False
                else:  # this is agent, make sure we have chef stuff
                    ocaom = 'opencenter_agent_output_modules'

                    if not ocaom in node['attrs'] and \
                            not 'chef' in node['attrs'][ocaom]:
                        should_add = False

            if should_add is True:
                node_id = node['id']
                final_nodelist.append(node_id)

        self.logger.debug('final nodelist: %s' % final_nodelist)
        return final_nodelist

    # README(shep): not executed on the server, skipping from code coverage
dataset/ETHPy150Open rcbops/opencenter/opencenter/backends/chef-client/__init__.py/ChefClientBackend._get_nodes_in_env/original