Sha256: 11930b3287895e56e78bbe4838bc811c18e8ed6a36b929474cad4a616c663ba3

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

#include <internal/facts/posix/xen_resolver.hpp>
#include <leatherman/execution/execution.hpp>
#include <leatherman/logging/logging.hpp>
#include <boost/filesystem.hpp>

using namespace std;
using namespace facter::facts;
using namespace leatherman::execution;
using namespace boost::filesystem;
namespace bs = boost::system;

namespace facter { namespace facts { namespace posix {

    string xen_resolver::xen_command()
    {
        constexpr char const* xen_toolstack = "/usr/lib/xen-common/bin/xen-toolstack";

        bs::error_code ec;
        if (exists(xen_toolstack, ec) && !ec) {
            auto exec = execute(xen_toolstack);
            if (exec.success) {
                return exec.output;
            } else {
                LOG_DEBUG("failure executing {1}: {2}", xen_toolstack, exec.error);
                return {};
            }
        } else {
            LOG_TRACE("xen toolstack command not found: {1}", ec.message());

            static vector<string> xen_commands{"/usr/sbin/xl", "/usr/sbin/xm"};
            for (auto const& cmd : xen_commands) {
                auto cmd_path = which(cmd);
                if (!cmd_path.empty()) {
                    return cmd_path;
                }
            }

            LOG_TRACE("no xen commands found");
            return {};
        }
    }

}}}  // namespace facter::facts::posix

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/src/facts/posix/xen_resolver.cc