From 79b1b57045e86d9845e352c3f2aa0efbab6111a9 Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 14 3月 2020 10:19:09 +0800 Subject: [PATCH] tests and improvements --- src/library/os/execution_environment.hpp | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/library/os/execution_environment.hpp b/src/library/os/execution_environment.hpp index 1c15ab4..97172e4 100644 --- a/src/library/os/execution_environment.hpp +++ b/src/library/os/execution_environment.hpp @@ -8,10 +8,21 @@ #ifndef SRC_LIBRARY_OS_VIRTUALIZATION_HPP_ #define SRC_LIBRARY_OS_VIRTUALIZATION_HPP_ +#include <string> + namespace license { namespace os { + +/* + * windows bios sometimes reports vm names add execution environment detection from bios +const char *vmVendors[] = { + "VMware", "Microsoft Corporation", "Virtual Machine", "innotek GmbH", "PowerVM", "Bochs", "KVM"}; +*/ + typedef enum { NONE, CONTAINER, VM } VIRTUALIZATION; + typedef enum { + PROV_UNKNOWN, ON_PREMISE, GOOGLE_CLOUD, AZURE_CLOUD, @@ -26,14 +37,26 @@ } CLOUD_PROVIDER; class ExecutionEnvironment { +private: + std::string m_sys_vendor; + std::string m_bios_vendor; + std::string m_bios_description; + public: - ExecutionEnvironment(){}; - virtual ~ExecutionEnvironment(){}; - VIRTUALIZATION getVirtualization(); - bool is_cloud(); - bool is_docker(); - CLOUD_PROVIDER getCloudProvider(); + ExecutionEnvironment(); + ~ExecutionEnvironment(){}; + VIRTUALIZATION getVirtualization() const; + bool is_cloud() const; + bool is_docker() const; + // detect if it's a kind of container technology (docker or lxc) + bool is_container() const; + CLOUD_PROVIDER getCloudProvider() const; + const std::string& bios_vendor() const { return m_bios_vendor; }; + const std::string& sys_vendor() const { return m_sys_vendor; }; + const std::string& bios_description() const { return m_bios_description; }; + // VIRTUALIZATION_DETAIL getVirtualizationDetail() const; //as reported by the bios }; + } // namespace os } // namespace license -- Gitblit v1.9.1