diff --git a/Contrib-Inspur/OR-web/README.md b/Contrib-Inspur/OR-web/README.md index 4bf36325..8cb2a899 100644 --- a/Contrib-Inspur/OR-web/README.md +++ b/Contrib-Inspur/OR-web/README.md @@ -1,9 +1,29 @@ -# OR-web - -## Install +# antd-ob +## Project setup ``` npm install +``` + +### Compiles and hot-reloads for development +``` +npm run serve +``` + +### Compiles and minifies for production +``` npm run build -scp -r ./dist/* root@bmcIP:/usr/share/www/ -```` +``` + +### Run your tests +``` +npm run test +``` + +### Lints and fixes files +``` +npm run lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/Contrib-Inspur/OR-web/package.json b/Contrib-Inspur/OR-web/package.json index 78e0ffeb..bec57cb3 100644 --- a/Contrib-Inspur/OR-web/package.json +++ b/Contrib-Inspur/OR-web/package.json @@ -10,7 +10,7 @@ "dependencies": { "animate.css": "^3.7.0", "ant-design-vue": "^1.3.1", - "axios": "^0.19.0", + "axios": "^0.18.0", "dayjs": "^1.8.0", "epic-spinners": "^1.0.4", "vue": "^2.5.21", diff --git a/Contrib-Inspur/OR-web/src/service/i18n/en-US/psu.js b/Contrib-Inspur/OR-web/src/service/i18n/en-US/psu.js index 8ad34193..2a0906ca 100644 --- a/Contrib-Inspur/OR-web/src/service/i18n/en-US/psu.js +++ b/Contrib-Inspur/OR-web/src/service/i18n/en-US/psu.js @@ -1,9 +1,20 @@ +/* + * @Author: your name + * @Date: 2020-02-20 10:26:29 + * @LastEditTime: 2020-03-01 19:21:02 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: /bmcweb/home/mengyaohui/work/openbmc/openbmc/build/workspace/sources/phosphor-webui/src/service/i18n/en-US/psu.js + */ export default { title: 'Power Supply', sub_title: 'Display all nodes\' information', - vendor: 'Vendor:', - model: 'Model:', - sn: 'SN:', - pn: 'PN:', - fw: 'Firmware Version:' + status: 'Status', + vendor: 'Vendor', + model: 'Model', + sn: 'SN', + pn: 'PN', + fw: 'Firmware Version', + enable: 'enable', + disable: 'disable', } diff --git a/Contrib-Inspur/OR-web/src/service/i18n/zh-CN/psu.js b/Contrib-Inspur/OR-web/src/service/i18n/zh-CN/psu.js index 2285b894..59398b67 100644 --- a/Contrib-Inspur/OR-web/src/service/i18n/zh-CN/psu.js +++ b/Contrib-Inspur/OR-web/src/service/i18n/zh-CN/psu.js @@ -1,9 +1,20 @@ +/* + * @Author: your name + * @Date: 2020-02-20 10:26:29 + * @LastEditTime: 2020-03-01 19:20:37 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: /bmcweb/home/mengyaohui/work/openbmc/openbmc/build/workspace/sources/phosphor-webui/src/service/i18n/zh-CN/psu.js + */ export default { title: '电源模块', sub_title: '展示节点电源模块信息', - vendor: '生产商:', - model: '型号:', - sn: '序列号:', - pn: '部分编号:', - fw: '固件版本:' + status: '状态', + vendor: '生产商', + model: '型号', + sn: '序列号', + pn: '部分编号', + fw: '固件版本', + enable: '在位', + disable: '不在位', } diff --git a/Contrib-Inspur/OR-web/src/views/psu/psu.vue b/Contrib-Inspur/OR-web/src/views/psu/psu.vue index fcd78f9b..a1697e88 100644 --- a/Contrib-Inspur/OR-web/src/views/psu/psu.vue +++ b/Contrib-Inspur/OR-web/src/views/psu/psu.vue @@ -1,40 +1,32 @@ + - - - - - - {{'node ' + index}} - - - - - - - {{$t('message.psu.vendor')}} - {{currentPsuInfo.vendor}} - - - {{$t('message.psu.model')}} - {{currentPsuInfo.model}} - - - {{$t('message.psu.sn')}} - {{currentPsuInfo.sn}} - - - {{$t('message.psu.pn')}} - {{currentPsuInfo.pn}} - - - {{$t('message.psu.fw')}} - {{currentPsuInfo.fw}} + + + + + + + + + {{$t('message.psu.enable')}} + + + {{$t('message.psu.disable')}} + + diff --git a/Contrib-Inspur/bmcweb/CMakeLists.txt b/Contrib-Inspur/bmcweb/CMakeLists.txt index 6756575c..b0e8f36d 100644 --- a/Contrib-Inspur/bmcweb/CMakeLists.txt +++ b/Contrib-Inspur/bmcweb/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.5 FATAL_ERROR) +project (bmc-webserver CXX) + cmake_policy (SET CMP0054 NEW) set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) @@ -8,47 +10,128 @@ option (BUILD_STATIC_LIBS "Built static libraries" ON) option (YOCTO_DEPENDENCIES "Use YOCTO dependencies system" OFF) -option (BMCWEB_ENABLE_KVM "Enable the KVM host video WebSocket. Path is - '/kvmws'. Video is from the BMC's '/dev/video' device." ON) -option (BMCWEB_ENABLE_DBUS_REST "Enable Phosphor REST (D-Bus) APIs. Paths - directly map Phosphor D-Bus object paths, for example, - '/xyz/openbmc_project/logging/entry/enumerate'. See - https://github.com/openbmc/docs/blob/master/rest-api.md." ON) -option (BMCWEB_ENABLE_REDFISH "Enable Redfish APIs. Paths are under - '/redfish/v1/'. See - https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish." - ON) -option (BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET "Enable host serial console - WebSocket. Path is '/console0'. See - https://github.com/openbmc/docs/blob/master/console.md." ON) -option (BMCWEB_ENABLE_STATIC_HOSTING "Enable serving files from the - '/usr/share/www' directory as paths under '/'." ON) -option (BMCWEB_ENABLE_REDFISH_BMC_JOURNAL "Enable BMC journal access through - Redfish. Paths are under - '/redfish/v1/Managers/bmc/LogServices/Journal'." OFF) -option (BMCWEB_ENABLE_REDFISH_RAW_PECI "Enable PECI transactions through - Redfish. Paths are under '/redfish/v1/Systems/system/LogServices/CpuLog/ - Actions/Oem/CpuLog.SendRawPeci'." OFF) -option (BMCWEB_ENABLE_REDFISH_CPU_LOG "Enable CPU log service transactions - through Redfish. Paths are under - '/redfish/v1/Systems/system/LogServices/CpuLog'." OFF) +option ( + BMCWEB_ENABLE_KVM + "Enable the KVM host video WebSocket. Path is '/kvm/0'. Video is from the + BMC's '/dev/video' device." + ON +) +option ( + BMCWEB_ENABLE_VM_WEBSOCKET + "Enable the Virtual Media WebSocket. Path is '/vm/0/0'to open the websocket. + See https://github.com/openbmc/jsnbd/blob/master/README." + ON +) +option ( + BMCWEB_ENABLE_VM_NBDPROXY + "Enable the Virtual Media WebSocket." + OFF +) +option ( + BMCWEB_ENABLE_DBUS_REST + "Enable Phosphor REST (D-Bus) APIs. Paths directly map Phosphor D-Bus + object paths, for example, '/xyz/openbmc_project/logging/entry/enumerate'. + See https://github.com/openbmc/docs/blob/master/rest-api.md." + ON +) +option ( + BMCWEB_ENABLE_REDFISH + "Enable Redfish APIs. Paths are under '/redfish/v1/'. See + https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish." + ON +) +option ( + BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET + "Enable host serial console WebSocket. Path is '/console0'. See + https://github.com/openbmc/docs/blob/master/console.md." + ON +) +option ( + BMCWEB_ENABLE_STATIC_HOSTING + "Enable serving files from the '/usr/share/www' directory as paths under + '/'." + ON +) +option ( + BMCWEB_ENABLE_REDFISH_BMC_JOURNAL + "Enable BMC journal access through Redfish. Paths are under + '/redfish/v1/Managers/bmc/LogServices/Journal'." + OFF +) +option ( + BMCWEB_ENABLE_REDFISH_RAW_PECI + "Enable PECI transactions through Redfish. Paths are under + '/redfish/v1/Systems/system/LogServices/CpuLog/Actions/Oem/CpuLog.SendRawPeci'." + OFF +) +option ( + BMCWEB_ENABLE_REDFISH_CPU_LOG + "Enable CPU log service transactions through Redfish. Paths are under + '/redfish/v1/Systems/system/LogServices/Crashdump'." + OFF +) +option ( + BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES + "Enable DBUS log service transactions through Redfish. Paths are under + '/redfish/v1/Systems/system/LogServices/EventLog/Entries'." + OFF +) +option ( + BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE + "Enable provisioning feature support in redfish. Paths are under + '/redfish/v1/Systems/system/'." + OFF +) +option ( + BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION + "Enables authenticating users through TLS client certificates. + The BMCWEB_INSECURE_DISABLE_SSL must be OFF for this option to take effect." + ON +) # Insecure options. Every option that starts with a BMCWEB_INSECURE flag should # not be enabled by default for any platform, unless the author fully # comprehends the implications of doing so. In general, enabling these options # will cause security problems of varying degrees -option (BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION "Disable CSRF prevention checks. - Should be set to OFF for production systems." OFF) +option ( + BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION + "Disable CSRF prevention checks. Should be set to OFF for production + systems." + OFF +) -option (BMCWEB_INSECURE_DISABLE_SSL "Disable SSL ports. Should be set to OFF for - production systems." OFF) +option (BMCWEB_INSECURE_DISABLE_SSL + "Disable SSL ports. Should be set to OFF for production systems." OFF) -option (BMCWEB_INSECURE_DISABLE_AUTHENTICATION "Disable authentication on all - ports. Should be set to OFF for production systems" OFF) +option ( + BMCWEB_INSECURE_DISABLE_AUTHENTICATION + "Disable authentication on all ports. Should be set to OFF for production + systems" + OFF +) option (BMCWEB_INSECURE_DISABLE_XSS_PREVENTION "Disable XSS preventions" OFF) -project (bmc-webserver CXX) +option ( + BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE + "Enable TFTP based firmware update transactions through Redfish + UpdateService.SimpleUpdate." + OFF +) + + +option (BMCWEB_ENABLE_REDFISH_RMC "enable rmc redfish in bmc webserver" OFF) + +set (BMCWEB_HTTP_REQ_BODY_LIMIT_MB "30" CACHE STRING + "The max HTTP request body size in MB") + +configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h) + +if (BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION AND BMCWEB_INSECURE_DISABLE_SSL) + message("SSL Must be enabled to allow SSL authentication") + set(BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION OFF) +endif() + include (CTest) @@ -59,25 +142,67 @@ set (CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -fno-rtti \ +") + +set ( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} \ + -Wall \ + -Wextra \ + -Wnon-virtual-dtor \ + -Wold-style-cast \ + -Wcast-align \ + -Wunused \ + -Woverloaded-virtual \ + -Wpedantic \ + -Wconversion \ + -Wsign-conversion \ + -Wnull-dereference \ + -Wdouble-promotion \ + -Wformat=2 \ + -Wno-unused-parameter \ +" +) + +# only set -Werror if we're on a compiler that we know passes +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) + set ( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} \ + -Werror \ + -Wduplicated-cond \ + -Wduplicated-branches \ + -Wlogical-op \ + -Wnull-dereference \ + -Wdouble-promotion \ + -Wformat=2 \ + -Wno-unused-parameter \ + " + ) + endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) +endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") # general option (BMCWEB_BUILD_UT "Enable Unit test" OFF) # security flags -set (SECURITY_FLAGS "\ - -fstack-protector-strong \ +set ( + SECURITY_FLAGS + "-fstack-protector-strong \ -fPIE \ -fPIC \ -D_FORTIFY_SOURCE=2 \ -Wformat \ - -Wformat-security") -set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SECURITY_FLAGS}") -set ( - CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SECURITY_FLAGS}" + -Wformat-security" ) +set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SECURITY_FLAGS}") +set (CMAKE_CXX_FLAGS_RELWITHDEBINFO + "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SECURITY_FLAGS}") set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${SECURITY_FLAGS}") # Enable link time optimization This is a temporary workaround because @@ -87,57 +212,59 @@ set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${SECURITY_FLAGS}") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if (NOT CMAKE_BUILD_TYPE MATCHES Debug) string (REGEX REPLACE "ar$" "gcc-ar" CMAKE_AR ${CMAKE_AR}) - string ( - REGEX - REPLACE "ranlib$" "gcc-ranlib" CMAKE_RANLIB ${CMAKE_RANLIB} - ) + string (REGEX + REPLACE "ranlib$" "gcc-ranlib" CMAKE_RANLIB ${CMAKE_RANLIB}) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fno-fat-lto-objects") # Reduce the binary size by removing unnecessary dynamic symbol table # entries - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + set ( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} \ -fvisibility=hidden \ -fvisibility-inlines-hidden \ - -Wl,--exclude-libs,ALL") + -Wl,--exclude-libs,ALL" + ) endif (NOT CMAKE_BUILD_TYPE MATCHES Debug) endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if (NOT ${YOCTO_DEPENDENCIES}) # Download and unpack googletest at configure # time configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) - execute_process ( - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty - ) - execute_process ( - COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty - ) + execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) + execute_process (COMMAND ${CMAKE_COMMAND} --build . + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) endif () +find_package (Boost 1.71 REQUIRED) +include_directories (SYSTEM ${BOOST_SRC_DIR}) + # add_definitions(-DBOOST_ASIO_ENABLE_HANDLER_TRACKING) add_definitions (-DBOOST_ASIO_DISABLE_THREADS) +add_definitions (-DBOOST_BEAST_USE_STD_STRING_VIEW) add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) +message (BOOST_VERSION = ${Boost_VERSION}) +if ("${Boost_VERSION}" STREQUAL "107100") + add_definitions (-DBOOST_ASIO_NO_DEPRECATED) +endif () add_definitions (-DBOOST_ALL_NO_LIB) add_definitions (-DBOOST_NO_RTTI) add_definitions (-DBOOST_NO_TYPEID) add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) -find_package (Boost 1.66 REQUIRED) -include_directories (${BOOST_SRC_DIR}) - # sdbusplus if (NOT ${YOCTO_DEPENDENCIES}) - include_directories (${CMAKE_BINARY_DIR}/sdbusplus-src) + include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) endif () # Openssl find_package (OpenSSL REQUIRED) -include_directories (${OPENSSL_INCLUDE_DIR}) +include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) message ("OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}") # bmcweb @@ -151,11 +278,11 @@ endif (CMAKE_BUILD_TYPE MATCHES Debug) if (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") add_definitions (-DBMCWEB_ENABLE_SSL) endif (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/crow/include) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/http) # Zlib find_package (ZLIB REQUIRED) -include_directories (${ZLIB_INCLUDE_DIRS}) +include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS}) # PAM option (WEBSERVER_ENABLE_PAM "enable pam authentication" ON) @@ -167,52 +294,50 @@ endif () add_definitions ("-Wno-attributes") # Copy pam-webserver to etc/pam.d -install ( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/pam-webserver - DESTINATION /etc/pam.d/ - RENAME webserver -) +install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/pam-webserver DESTINATION /etc/pam.d/ + RENAME webserver) # tinyxml2 find_package (tinyxml2 REQUIRED) +# libevdev +#link_libraries(“/home/server/third/lib/libcommon.a”) +#find_library (libevdev) + set (WEBSERVER_MAIN src/webserver_main.cpp) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/include) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/lib) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/lib/rmc) file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/bmcweb) include_directories (${CMAKE_BINARY_DIR}/include) -set ( - SRC_FILES redfish-core/src/error_messages.cpp - redfish-core/src/utils/json_utils.cpp ${GENERATED_SRC_FILES} -) +set (SRC_FILES redfish-core/src/error_messages.cpp + redfish-core/src/utils/json_utils.cpp ${GENERATED_SRC_FILES}) file (COPY src/test_resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # Unit Tests if (${BMCWEB_BUILD_UT}) - set ( - UT_FILES src/crow_test.cpp src/gtest_main.cpp - src/token_authorization_middleware_test.cpp - src/security_headers_middleware_test.cpp src/webassets_test.cpp - src/crow_getroutes_test.cpp src/ast_jpeg_decoder_test.cpp - src/kvm_websocket_test.cpp src/msan_test.cpp - src/ast_video_puller_test.cpp src/openbmc_jtag_rest_test.cpp - redfish-core/ut/privileges_test.cpp - ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp - ) # big list of naughty strings - add_custom_command ( - OUTPUT ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp - COMMAND - xxd -i ${CMAKE_CURRENT_SOURCE_DIR}/src/test_resources/blns - ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp - ) - - set_source_files_properties ( - ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp PROPERTIES GENERATED TRUE - ) + set (UT_FILES src/crow_test.cpp src/gtest_main.cpp + src/token_authorization_middleware_test.cpp + src/security_headers_middleware_test.cpp src/webassets_test.cpp + src/crow_getroutes_test.cpp src/ast_jpeg_decoder_test.cpp + src/kvm_websocket_test.cpp src/msan_test.cpp + src/ast_video_puller_test.cpp src/openbmc_jtag_rest_test.cpp + redfish-core/ut/privileges_test.cpp + ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) # big list of naughty + # strings + add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp + COMMAND + xxd -i + ${CMAKE_CURRENT_SOURCE_DIR}/src/test_resources/blns + ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) + + set_source_files_properties (${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp + PROPERTIES GENERATED TRUE) enable_testing () add_executable (webtest ${SRC_FILES} ${UT_FILES}) @@ -230,6 +355,7 @@ if (${BMCWEB_BUILD_UT}) target_link_libraries (webtest sdbusplus) target_link_libraries (webtest -lsystemd) target_link_libraries (webtest -lstdc++fs) + target_link_libraries (webtest -levdev) add_test (webtest webtest "--gtest_output=xml:webtest.xml") endif (${BMCWEB_BUILD_UT}) @@ -246,22 +372,44 @@ target_link_libraries (bmcweb -lsystemd) target_link_libraries (bmcweb -lstdc++fs) target_link_libraries (bmcweb sdbusplus) target_link_libraries (bmcweb tinyxml2) +target_link_libraries (bmcweb -levdev) install (TARGETS bmcweb DESTINATION bin) -add_executable (getvideo src/getvideo_main.cpp) -target_link_libraries (getvideo pthread) - target_compile_definitions ( - bmcweb PRIVATE - $<$: -DBMCWEB_ENABLE_KVM> + bmcweb PRIVATE $<$: -DBMCWEB_ENABLE_KVM> + $<$: -DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION> + $<$: -DBMCWEB_ENABLE_VM_WEBSOCKET> + $<$: -DBMCWEB_ENABLE_VM_NBDPROXY> $<$: -DBMCWEB_ENABLE_DBUS_REST> $<$: -DBMCWEB_ENABLE_REDFISH> $<$: -DBMCWEB_ENABLE_STATIC_HOSTING> - $<$: -DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET> - $<$: -DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION> + $<$: + -DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET> + $<$: + -DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION> $<$: -DBMCWEB_INSECURE_DISABLE_SSL> - $<$: -DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION> - $<$: -DBMCWEB_ENABLE_REDFISH_RAW_PECI> - $<$: -DBMCWEB_ENABLE_REDFISH_CPU_LOG> - $<$: -DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL> + $<$: + -DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION> + $<$: + -DBMCWEB_ENABLE_REDFISH_RAW_PECI> + $<$: + -DBMCWEB_ENABLE_REDFISH_CPU_LOG> + $<$: + -DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL> + $<$: + -DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES> + $<$: + -DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE> + $<$: + -DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE> + $<$: -DBMCWEB_ENABLE_REDFISH_RMC> ) + +# configure and install systemd unit files +configure_file (bmcweb.socket bmcweb.socket COPYONLY) +configure_file (bmcweb.service.in bmcweb.service) +pkg_get_variable (SYSTEMD_SYSTEMUNITDIR systemd systemdsystemunitdir) +install (FILES ${PROJECT_BINARY_DIR}/bmcweb.socket DESTINATION + ${SYSTEMD_SYSTEMUNITDIR}) +install (FILES ${PROJECT_BINARY_DIR}/bmcweb.service DESTINATION + ${SYSTEMD_SYSTEMUNITDIR}) diff --git a/Contrib-Inspur/bmcweb/CMakeLists.txt.in b/Contrib-Inspur/bmcweb/CMakeLists.txt.in index a964e2d5..ae2155a4 100644 --- a/Contrib-Inspur/bmcweb/CMakeLists.txt.in +++ b/Contrib-Inspur/bmcweb/CMakeLists.txt.in @@ -9,7 +9,7 @@ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/prefix/include) externalproject_add ( sdbusplus-project PREFIX ${CMAKE_BINARY_DIR}/sdbusplus-project GIT_REPOSITORY https://github.com/openbmc/sdbusplus.git GIT_TAG - bed15f0cee4784acdf151cca14efdfb98cb9d397 SOURCE_DIR + 4212292bcf136d04b38ba5116aa568b0fa312798 SOURCE_DIR ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND "" BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src && ./bootstrap.sh && ./configure @@ -36,8 +36,8 @@ externalproject_add ( externalproject_add ( Boost URL - https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz - URL_MD5 5d8b4503582fffa9eefdb9045359c239 SOURCE_DIR + https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.gz + URL_MD5 5f521b41b79bf8616582c4a8a2c10177 SOURCE_DIR "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR "${CMAKE_BINARY_DIR}/boost-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R @@ -46,7 +46,7 @@ externalproject_add ( externalproject_add ( nlohmann-json GIT_REPOSITORY "https://github.com/nlohmann/json.git" GIT_TAG - aafad2be1f3cd259a1e79d2f6fcf267d1ede9ec7 SOURCE_DIR + ea60d40f4a60a47d3be9560d8f7bc37c163fe47b SOURCE_DIR "${CMAKE_BINARY_DIR}/nlohmann-json-src" BINARY_DIR "${CMAKE_BINARY_DIR}/nlohmann-json-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/nlohmann" && diff --git a/Contrib-Inspur/bmcweb/DEVELOPING.md b/Contrib-Inspur/bmcweb/DEVELOPING.md index 6a920bc8..b8a2a26a 100644 --- a/Contrib-Inspur/bmcweb/DEVELOPING.md +++ b/Contrib-Inspur/bmcweb/DEVELOPING.md @@ -109,11 +109,24 @@ implement a concrete interface. 11. ### phosphor webui - The webserver should be capable of hosting phosphor-webui, and impelmenting + The webserver should be capable of hosting phosphor-webui, and implementing the required flows to host the application. In general, all access methods should be available to the webui. -12. ### Developing and Testing +12. ### Redfish + bmcweb's Redfish implementation, including Redfish OEM Resources, shall + conform to the Redfish specification. Please keep bmcweb's [Redfish support + document](https://github.com/openbmc/bmcweb/blob/master/Redfish.md) updated. + Before adding a Redfish OEM schema or property first engage the DMTF's + Redfish working group to see if they are interested in adding the new + feature. The [Redfish Specification Forum](https://redfishforum.com/) is a + public Redfish forum to ask questions and request features. Redfish + "Supporter" and "Promoter" companies, which many companies working on OpenBMC + are, can request features via the Redfish code repository or via Redfish + meetings. For more information on Redfish and supported schemas visit + [Redfish.md](https://github.com/openbmc/bmcweb/blob/master/Redfish.md). + +13. ### Developing and Testing There are a variety of ways to develop and test bmcweb software changes. Here are the steps for using the SDK and QEMU. @@ -197,463 +210,26 @@ See the [REST](https://github.com/openbmc/docs/blob/master/REST-cheatsheet.md) and [Redfish](https://github.com/openbmc/docs/blob/master/REDFISH-cheatsheet.md) cheatsheets for valid commands. -13. ### Redfish + Please test all Redfish changes with the + [Redfish Service Validator](https://github.com/DMTF/Redfish-Service-Validator). + Your change should not introduce any new validator errors. Please include + the Redfish Service Validator results as part of the commit message + ["Tested" field](https://github.com/openbmc/docs/blob/master/CONTRIBUTING.md#testing). + +## clang-tidy + +clang-tidy is a tool that can be used to identify coding style violations, bad +design patterns, and bug prone contructs. It's not guaranteed that all tests +pass, but ideally should be run on new code to find issues. To run, make sure +you have clang++-9 installed, and clang-tidy-9 installed, and run. the -checks +field can be modified to enable or disable which clang-tidy checks are run. +The below enables everything in the cert namespace. + +``` +mkdir build +cd build +cmake .. -DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON +make -j +run-clang-tidy-9 -p . -header-filter=".*" -checks="-*,cert-*" +``` - The redfish implementation shall pass the [Redfish Service - Validator](https://github.com/DMTF/Redfish-Service-Validator "Validator") with - no warnings or errors - - The following redfish schemas and fields are targeted for OpenBMC. This is a - living document, and these schemas are subject to change. - - The latest Redfish schemas can be found [here](https://redfish.dmtf.org/schemas/) - - Fields common to all schemas - - - @odata.context - - @odata.id - - @odata.type - - Id - - Name - - - #### /redfish/v1/ - ##### ServiceRoot - - - RedfishVersion - - UUID - - - #### /redfish/v1/AccountService/ - ##### AccountService - - - Description - - ServiceEnabled - - MinpasswordLength - - MaxPasswordLength - - Accounts - - Roles - - #### /redfish/v1/AccountService/Accounts/ - ##### AccountCollection - - - Description - - Members@odata.count - - Members - - #### /redfish/v1/AccountService/Accounts/ - ##### Account - - - Description - - Enabled - - Password - - UserName - - RoleId - - Links/Role - - #### /redfish/v1/AccountService/Roles/ - ##### RoleCollection - - - Description - - Members@odata.count - - Members - - By default will contain 3 roles, "Administrator", "Operator", and "User" - - #### /redfish/v1/AccountService/Roles/ - ##### Role - - - Description - - IsPredefined - - Will be set to true for all default roles. If the given role is - non-default, or has been modified from default, will be marked as false. - - AssignedPrivileges - - For the default roles, the following privileges will be assigned by - default - - Administrator: Login, ConfigureManager, ConfigureUsers, ConfigureSelf, - ConfigureComponents - - Operator: Login, ConfigureComponents - - User: Login - - - #### /redfish/v1/Chassis - ##### ChassisCollection - - - Members@odata.count - - Members - - #### /redfish/v1/Chassis/ - ##### Chassis - - - ChassisType - - Manufacturer - - Model - - SerialNumber - - PartNumber - - PowerState - - Thermal - - Shall be included if component contains temperature sensors, otherwise - shall be omitted. - - Power - - Shall be included if component contains voltage/current sensing - components, otherwise will be omitted. - - #### /redfish/v1/Chassis//Thermal - ##### Thermal - Temperatures Fans Redundancy - - #### /redfish/v1/Chassis//Thermal#/Temperatures/ - ##### Temperature - - MemberId - - Status - - ReadingCelsius - - UpperThresholdNonCritical - - UpperThresholdCritical - - LowerThresholdNonCritical - - LowerThresholdCritical - - MinReadingRange - - MaxReadingRange - - *threshold fields only present if defined for sensor, otherwise absent* - - #### /redfish/v1/Chassis//Thermal#/Fans/ - ##### Fan - - MemberId - - Status - - Reading - - ReadingUnits - - UpperThresholdNonCritical - - UpperThresholdCritical - - LowerThresholdNonCritical - - LowerThresholdCritical - - MinReadingRange - - MaxReadingRange - - Redundancy - - *threshold fields only present if defined for sensor, otherwise absent* - - #### /redfish/v1/Chassis//Thermal#/Redundancy/ - ##### Fan - - MemberId - - RedundancySet - - Mode - - Status - - MinNumNeeded - - MaxNumSupported - - - #### /redfish/v1/Chassis//Power/ - ##### Thermal - PowerControl Voltages PowerSupplies Redundancy - - #### /redfish/v1/Chassis//Power#/PowerControl/ - ##### PowerControl - - MemberId - - PowerConsumedWatts - - PowerMetrics/IntervalInMin - - PowerMetrics/MinConsumedWatts - - PowerMetrics/MaxConsumedWatts - - PowerMetrics/AverageConsumedWatts - - RelatedItem - - Should list systems and related chassis - - #### /redfish/v1/Chassis//Power#/Voltages/ - ##### Voltage - - MemberId - - Status - - ReadingVolts - - UpperThresholdNonCritical - - UpperThresholdCritical - - LowerThresholdNonCritical - - LowerThresholdCritical - - MinReadingRange - - MaxReadingRange - - PhysicalContext - - RelatedItem - - #### /redfish/v1/Chassis//Power#/PowerSupplies/ - ##### PowerSupply - - MemberId - - Status - - LininputVoltage - - Model - - manufacturer - - FirmwareVersion - - SerialNumber - - PartNumber - - RelatedItem - - Redundancy - - #### /redfish/v1/Chassis/{ChassisName}/Power#/Redundancy/ - ##### Redundancy - - MemberId - - RedundancySet - - Mode - - Status - - MinNumNeeded - - MaxNumSupported - - - #### /redfish/v1/EventService - ##### EventService - - Id - - ServiceEnabled - - DeliveryRetryAttempts - - Defaults to 3 - - EventTypesForSubscription - - Defaults to "Alert" - - Actions - - Subscriptions - - #### /redfish/v1/EventService/Subscriptions - ##### EventDestinationCollection - - Members@odata.count - - Members - - #### /redfish/v1/EventService/Subscriptions/{EventName}/ - ##### EventDestination - - Id - - Destination - - EventTypes - - Context - - OriginResources - - Protocol - - - #### /redfish/v1/Managers - ##### ManagerCollection - - Members - - Members@odata.count - - #### /redfish/v1/Managers/BMC - ##### Manager - - Description - - LogServices - - GraphicalConsole - - UUID - - Model - - Links - - PowerState - - FirmwareVersion - - ManagerType - - ServiceEntryPointUUID - - DateTime - - NetworkProtocol - - Actions - - Status - - SerialConsole - - VirtualMedia - - EthernetInterfaces - - #### /redfish/v1/Managers/BMC/EthernetInterfaces - ##### EthernetInterfaceCollection - - Members - - Members@odata.count - - Description - - #### /redfish/v1/Managers/BMC/EthernetInterfaces/{InterfaceName} - ##### EthernetInterface - - Description - - VLAN - - MaxIPv6StaticAddresses - - #### /redfish/v1/Managers/BMC/LogServices - ##### LogServiceCollection - - Members - - Members@odata.count - - Description - - #### /redfish/v1/Managers/BMC/LogServices/RedfishLog - ##### LogService - - Entries - - OverWritePolicy - - Actions - - Status - - DateTime - - MaxNumberOfRecords - - #### /redfish/v1/Managers/BMC/LogServices/RedfishLog/Entries/{entry} - ##### LogEntry - - Message - - Created - - EntryType - - #### /redfish/v1/Managers/BMC/NetworkProtocol - ##### ManagerNetworkProtocol - - Description - - SSDP - - HTTPS - - SSH - - VirtualMedia - - KVMIP - - Status - - - #### /redfish/v1/Registries - ##### MessageRegistryFileCollection - - Members - - Should support Base, CommonMessages, and EventingMessages - - Members@odata.count - - Description - - #### /redfish/v1/Registries/ - ##### MessageRegistryFile - - Location - - Description - - Location@odata.count - - Languages@odata.count - - Languages - - Registry - - - #### /redfish/v1/SessionService - ##### SessionService - - Description - - ServiceEnabled - - Status - - SessionTimeout - - Sessions - - #### /redfish/v1/SessionService/Sessions - ##### SessionCollection - - Members - - Members@odata.count - - Description - - - #### /redfish/v1/Systems - ##### ComputerSystemCollection - - Members - - Should support one system - - Members@odata.count - - #### /redfish/v1/Systems/{SystemName} - ##### ComputerSystem - - Boot - - PartNumber - - IndicatorLED - - UUID - - LogServices - - SystemType - - Manufacturer - - Description - - Model - - Links - - PowerState - - BiosVersion - - Storage - - SerialNumber - - Processors - - ProcessorSummary - - Memory - - Actions - - Status - - EthernetInterfaces - - MemorySummary - - #### /redfish/v1/Systems/{SystemName}/EthernetInterfaces - ##### EthernetInterfaceCollection - - Members - - Members@odata.count - - Description - - #### /redfish/v1/Systems/{SystemName}/LogServices - ##### LogServiceCollection - - Members - - Should default to one member, named SEL - - Members@odata.count - - Description - - #### /redfish/v1/Systems/{SystemName}/LogServices/SEL/Entries - ##### LogEntryCollection - - Members - - Members@odata.count - - Description - - @odata.nextLink - - #### /redfish/v1/Systems/{SystemName}/LogServices/SEL/Entries/{entryNumber} - ##### LogEntry - - MessageArgs - - Severity - - SensorType - - Message - - MessageId - - Created - - EntryCode - - EntryType - - #### /redfish/v1/Systems/{SystemName}/Memory - ##### MemoryCollection - - Members - - Members@odata.count - - #### /redfish/v1/Systems/{SystemName}/Memory/Memory1 - ##### Memory - - MemoryType - - Description - - DeviceLocator - - Oem - - Metrics - - BaseModuleType - - Manufacturer - - MemoryDeviceType - - RankCount - - AllowedSpeedsMHz - - CapacityMiB - - DataWidthBits - - SerialNumber - - OperatingSpeedMhz - - ErrorCorrection - - PartNumber - - Status - - BusWidthBits - - MemoryMedia - - #### /redfish/v1/Systems/{SystemName}/Memory/Memory1/MemoryMetrics - ##### MemoryMetrics - - Description - - HealthData - - #### /redfish/v1/Systems/{SystemName}/Processors - ##### ProcessorCollection - - Members - - Should Support CPU1 and CPU2 for dual socket systems - - Members@odata.count - - #### /redfish/v1/Systems/{SystemName}/Processors/{CPUName} - ##### Processor - - ProcessorArchitecture - - TotalCores - - ProcessorId - - MaxSpeedMHz - - Manufacturer - - Status - - Socket - - InstructionSet - - Model - - ProcessorType - - TotalThreads - - #### /redfish/v1/Systems/{SystemName}/Storage - ##### StorageCollection - - Members - - Members@odata.count - - #### /redfish/v1/Systems/{SystemName}/Storage/{storageIndex> - ##### Storage - - Drives - - Links - - - #### /redfish/v1/UpdateService - ##### UpdateService - - SoftwareInventory - - #### /redfish/v1/UpdateService/SoftwareInventory - ##### SoftwareInventoryCollection - - Members - - Should Support BMC, ME, CPLD and BIOS - - Members@odata.count - - #### /redfish/v1/UpdateService/SoftwareInventory/{MemberName} - ##### SoftwareInventory - - Version diff --git a/Contrib-Inspur/bmcweb/MAINTAINERS b/Contrib-Inspur/bmcweb/MAINTAINERS index 6b59c2f5..1c252d17 100644 --- a/Contrib-Inspur/bmcweb/MAINTAINERS +++ b/Contrib-Inspur/bmcweb/MAINTAINERS @@ -42,6 +42,6 @@ Description of section entries: START OF MAINTAINERS LIST ------------------------- -M: Ed Tanous -M: James Feist -M: Vernon Mauery +M: James Feist +M: Vernon Mauery +M: Jason Bills diff --git a/Contrib-Inspur/bmcweb/README.md b/Contrib-Inspur/bmcweb/README.md index e5e8ca1f..93660ed6 100644 --- a/Contrib-Inspur/bmcweb/README.md +++ b/Contrib-Inspur/bmcweb/README.md @@ -29,29 +29,8 @@ When BMCWeb SSL support is enabled and a usable certificate is not found, it will generate a self-sign a certificate before launching the server. The keys are generated by the `prime256v1` algorithm. The certificate - - is issued by `C=US, O=Intel BMC, CN=testhost`, + - is issued by `C=US, O=OpenBMC, CN=testhost`, - is valid for 10 years, - has a random serial number, and - is signed using the `SHA-256` algorithm. -## Crow patches ## -The crow project has had a number of additions to make it more useful for use in the OpenBmc Project. A non-exhaustive list is below. At the time of this writing, the crow project is not accepting patches, so for the time being crow will simply be checked in as is. - -+ Applied clang-format to the whole crow tree. This was done without regard for arrays and fixed data structures, but was deemed to be overall better than the inconsistent formatting that existed in upstream previously. -+ Crow server now calls stop before destruction of the Crow app object. -+ Fixed a bug where timed out websockets would seg fault the system by accessing a destroyed socket object without null checks when in SSL mode. -+ Added a TestSocketAdapter class that could be used to unit test server behavior without utilizing a socket. -+ Added the "getRoutes" call to both the app and the routing Trie class that allows consumers to poll the server for all (or a subset of) registered web routes in the system. -+ Hardcoded the websocket implementation for binary mode, instead of leaving protocol unspecified. -+ Move most uses of std::unordered_map to boost::flat_map to lower memory consumption, and (in some cases) to improve memory locality. -+ Adjust the addHeaders mechanism to use a fixed string instead of a full map implementation to avoid unnecessary mallocs and reduce the number of scatter gather buffers on an http response. -+ Change server name header from Crow/0.1 to iBMC -+ Starts the http server io_context inside the main thread, instead of creating a new thread. -+ Removes all BMCWEB_MSVC_WORKAROUND flags. -+ Removes the behavior that causes a 301 redirect for paths that end in "/", and simply returns the endpoint requested. This was done for redfish compatibility. -+ Removes the built in crow/json.hpp package and adds nlohmann json package as the first class json package for crow. -+ Move uses of boost::array to std::array where possible. -+ Add the ability to get a reference to the crow::Request object on websocket connection to allow checking header values. -+ Patch http handler to call middlewares on websocket connections to allow authentication to be applied appropriately. -+ Adds an is_secure flag to provide information about whether or not the payload was delivered over ssl. - diff --git a/Contrib-Inspur/bmcweb/Redfish.md b/Contrib-Inspur/bmcweb/Redfish.md new file mode 100644 index 00000000..1f7b6606 --- /dev/null +++ b/Contrib-Inspur/bmcweb/Redfish.md @@ -0,0 +1,507 @@ +# Redfish # + +bmcweb provides an implementation of the [Redfish][1] API. This document +details the Redfish schemas supported by bmcweb. This document also discusses +some of the details of that implementation and different implementations +available for certain areas. + +## Redfish Schema + +The redfish implementation shall pass the [Redfish Service +Validator](https://github.com/DMTF/Redfish-Service-Validator "Validator") with +no warnings or errors + +The following redfish schemas and fields are targeted for OpenBMC. This is a +living document, and these schemas are subject to change. + +The latest Redfish schemas can be found [here](https://redfish.dmtf.org/schemas/) + +Fields common to all schemas + +- @odata.context +- @odata.id +- @odata.type +- Id +- Name + + +#### /redfish/v1/ +##### ServiceRoot + +- AccountService +- CertificateService +- Chassis +- JsonSchemas +- Managers +- RedfishVersion +- SessionService +- Systems +- UUID +- UpdateService + +#### /redfish/v1/AccountService/ +##### AccountService + +- Description +- ServiceEnabled +- MinpasswordLength +- MaxPasswordLength +- Accounts +- Roles + +#### /redfish/v1/AccountService/Accounts/ +##### AccountCollection + +- Description +- Members@odata.count +- Members + +#### /redfish/v1/AccountService/Accounts/{ManagerAccountId} +##### ManagerAccount + +- Description +- Enabled +- Password +- UserName +- RoleId +- Links/Role + +#### /redfish/v1/AccountService/Roles/ +##### RoleCollection + +- Description +- Members@odata.count +- Members + - By default will contain 3 roles, "Administrator", "Operator", and "ReadOnly" + +#### /redfish/v1/AccountService/Roles/{RoleId} +##### Role + +- Description +- IsPredefined + - Will be set to true for all default roles. If the given role is + non-default, or has been modified from default, will be marked as false. +- AssignedPrivileges + - For the default roles, the following privileges will be assigned by + default + - Administrator: Login, ConfigureManager, ConfigureUsers, ConfigureSelf, + ConfigureComponents + - Operator: Login, ConfigureComponents, ConfigureSelf + - ReadOnly: Login, ConfigureSelf + + +#### /redfish/v1/Chassis +##### ChassisCollection + +- Members@odata.count +- Members + +#### /redfish/v1/Chassis/{ChassisId} +##### Chassis + +- ChassisType +- Manufacturer +- Model +- SerialNumber +- PartNumber +- PowerState +- Thermal + - Shall be included if component contains temperature sensors, otherwise + shall be omitted. +- Power + - Shall be included if component contains voltage/current sensing + components, otherwise will be omitted. + +#### /redfish/v1/Chassis/{ChassisId}/Thermal +##### Thermal +Temperatures Fans Redundancy + +#### /redfish/v1/Chassis/{ChassisId}/Thermal#/Temperatures/{SensorName} +##### Temperature +- MemberId +- Status +- ReadingCelsius +- UpperThresholdNonCritical +- UpperThresholdCritical +- LowerThresholdNonCritical +- LowerThresholdCritical +- MinReadingRange +- MaxReadingRange + +*threshold fields only present if defined for sensor, otherwise absent* + +#### /redfish/v1/Chassis/{ChassisId}/Thermal#/Fans/{FanName} +##### Fan +- MemberId +- Status +- Reading +- ReadingUnits +- UpperThresholdNonCritical +- UpperThresholdCritical +- LowerThresholdNonCritical +- LowerThresholdCritical +- MinReadingRange +- MaxReadingRange +- Redundancy + +*threshold fields only present if defined for sensor, otherwise absent* + +#### /redfish/v1/Chassis/{ChassisId}/Thermal#/Redundancy/{RedundancyName} +##### Redundancy +- MemberId +- RedundancySet +- Mode +- Status +- MinNumNeeded +- MaxNumSupported + + +#### /redfish/v1/Chassis/{ChassisId}/Power/ +##### Power +PowerControl Voltages PowerSupplies Redundancy + +#### /redfish/v1/Chassis/{ChassisId}/Power#/PowerControl/{ControlName} +##### PowerControl +- MemberId +- PowerConsumedWatts +- PowerMetrics/IntervalInMin +- PowerMetrics/MinConsumedWatts +- PowerMetrics/MaxConsumedWatts +- PowerMetrics/AverageConsumedWatts +- RelatedItem + - Should list systems and related chassis + +#### /redfish/v1/Chassis/{ChassisId}/Power#/Voltages/{VoltageName} +##### Voltage +- MemberId +- Status +- ReadingVolts +- UpperThresholdNonCritical +- UpperThresholdCritical +- LowerThresholdNonCritical +- LowerThresholdCritical +- MinReadingRange +- MaxReadingRange +- PhysicalContext +- RelatedItem + +#### /redfish/v1/Chassis/{ChassisId}/Power#/PowerSupplies/{PSUName} +##### PowerSupply +- MemberId +- Status +- LininputVoltage +- Model +- manufacturer +- FirmwareVersion +- SerialNumber +- PartNumber +- RelatedItem +- Redundancy + +#### /redfish/v1/Chassis/{ChassisId}/Power#/Redundancy/{RedundancyName} +##### Redundancy +- MemberId +- RedundancySet +- Mode +- Status +- MinNumNeeded +- MaxNumSupported + + +#### /redfish/v1/EventService +##### EventService +- Id +- ServiceEnabled +- DeliveryRetryAttempts + - Defaults to 3 +- EventTypesForSubscription + - Defaults to "Alert" +- Actions +- Subscriptions + +#### /redfish/v1/EventService/Subscriptions +##### EventDestinationCollection +- Members@odata.count +- Members + +#### /redfish/v1/EventService/Subscriptions/{EventName} +##### EventDestination +- Id +- Destination +- EventTypes +- Context +- OriginResources +- Protocol + + +#### /redfish/v1/Managers +##### ManagerCollection +- Members +- Members@odata.count + +#### /redfish/v1/Managers/bmc +##### Manager +- Description +- LogServices +- GraphicalConsole +- UUID +- Model +- Links +- PowerState +- FirmwareVersion +- ManagerType +- ServiceEntryPointUUID +- DateTime +- NetworkProtocol +- Actions +- Status +- SerialConsole +- VirtualMedia +- EthernetInterfaces + +#### /redfish/v1/Managers/bmc/EthernetInterfaces +##### EthernetInterfaceCollection +- Members +- Members@odata.count +- Description + +#### /redfish/v1/Managers/bmc/EthernetInterfaces/{EthernetInterfaceId} +##### EthernetInterface +- Description +- VLAN +- MaxIPv6StaticAddresses + +#### /redfish/v1/Managers/bmc/LogServices + +The [LogService][2] resource provides properties for monitoring and configuring +events for the service or resource to which it is associated. + +Within bmcweb, the LogService object resides under the System resource. It +tracks all events for the system. + +The LogService supports multiple log entry types. bmcweb has support for +the `Event` type. This is the new Redfish-defined type. + +bmcweb supports two different implementations of the +`LogService/EventLog/Entries` URI. + +The default implementation uses rsyslog to write Redfish events from the journal +to the persistent /var/log/ filesystem. The bmcweb software then looks for these +files in /var/log/ and returns the appropriate Redfish EventLog Entries for +these. More details on adding events can be found [here][3] + +The other implementation of EventLog Entries can be enabled by compiling bmcweb +with the `-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES=ON` option. This will cause +bmcweb to look to [phosphor-logging][4] for any D-Bus log entries. These will +then be translated to Redfish EventLog Entries. + +These two implementations do not work together, so choosing one will disable +the other. + +#### /redfish/v1/Managers/bmc/LogServices +##### LogServiceCollection +- Members +- Members@odata.count +- Description + +#### /redfish/v1/Managers/bmc/LogServices/RedfishLog +##### LogService +- Entries +- OverWritePolicy +- Actions +- Status +- DateTime +- MaxNumberOfRecords + +#### /redfish/v1/Managers/bmc/LogServices/RedfishLog/Entries/{LogEntryId} +##### LogEntry +- Message +- Created +- EntryType + +#### /redfish/v1/Managers/bmc/NetworkProtocol +##### ManagerNetworkProtocol +- Description +- SSDP +- HTTPS +- SSH +- VirtualMedia +- KVMIP +- Status + + +#### /redfish/v1/Registries +##### MessageRegistryFileCollection +- Members + - Should support Base, CommonMessages, and EventingMessages +- Members@odata.count +- Description + +#### /redfish/v1/Registries/{MessageRegistryFileId} +##### MessageRegistryFile +- Location +- Description +- Location@odata.count +- Languages@odata.count +- Languages +- Registry + + +#### /redfish/v1/SessionService +##### SessionService +- Description +- ServiceEnabled +- Status +- SessionTimeout +- Sessions + +#### /redfish/v1/SessionService/Sessions +##### SessionCollection +- Members +- Members@odata.count +- Description + + +#### /redfish/v1/Systems +##### ComputerSystemCollection +- Members + - Should support one system +- Members@odata.count + +#### /redfish/v1/Systems/system +##### ComputerSystem +- Boot +- PartNumber +- IndicatorLED +- UUID +- LogServices +- SystemType +- Manufacturer +- Description +- Model +- Links +- PowerState +- BiosVersion +- Storage +- SerialNumber +- Processors +- ProcessorSummary +- Memory +- Actions +- Status +- EthernetInterfaces +- MemorySummary + +#### /redfish/v1/Systems/system/EthernetInterfaces +##### EthernetInterfaceCollection +- Members +- Members@odata.count +- Description + +#### /redfish/v1/Systems/system/LogServices +##### LogServiceCollection +- Members + - Should default to one member, named SEL +- Members@odata.count +- Description + +#### /redfish/v1/Systems/system/LogServices/SEL/Entries +##### LogEntryCollection +- Members +- Members@odata.count +- Description +- @odata.nextLink + +#### /redfish/v1/Systems/system/LogServices/SEL/Entries/{LogEntryId} +##### LogEntry +- MessageArgs +- Severity +- SensorType +- Message +- MessageId +- Created +- EntryCode +- EntryType + +#### /redfish/v1/Systems/system/Memory +##### MemoryCollection +- Members +- Members@odata.count + +#### /redfish/v1/Systems/system/Memory/{MemoryId} +##### Memory +- MemoryType +- Description +- DeviceLocator +- Oem +- Metrics +- BaseModuleType +- Manufacturer +- MemoryDeviceType +- RankCount +- AllowedSpeedsMHz +- CapacityMiB +- DataWidthBits +- SerialNumber +- OperatingSpeedMhz +- ErrorCorrection +- PartNumber +- Status +- BusWidthBits +- MemoryMedia + +#### /redfish/v1/Systems/system/Memory/{MemoryId}/MemoryMetrics +##### MemoryMetrics +- Description +- HealthData + +#### /redfish/v1/Systems/system/Processors +##### ProcessorCollection +- Members + - Should Support CPU1 and CPU2 for dual socket systems +- Members@odata.count + +#### /redfish/v1/Systems/system/Processors/{ProcessorId} +##### Processor +- ProcessorArchitecture +- TotalCores +- ProcessorId +- MaxSpeedMHz +- Manufacturer +- Status +- Socket +- InstructionSet +- Model +- ProcessorType +- TotalThreads + +#### /redfish/v1/Systems/system/Storage +##### StorageCollection +- Members +- Members@odata.count + +#### /redfish/v1/Systems/system/Storage/{StorageId} +##### Storage +- Drives +- Links + + +#### /redfish/v1/UpdateService +##### UpdateService +- SoftwareInventory + +#### /redfish/v1/UpdateService/FirmwareInventory +##### SoftwareInventoryCollection +- Members +- Should Support BMC, ME, CPLD and BIOS +- Members@odata.count + +#### /redfish/v1/UpdateService/FirmwareInventory/{SoftwareInventoryId} +##### SoftwareInventory +- Version +- Updateable + +[1]: https://www.dmtf.org/standards/redfish +[2]: https://redfish.dmtf.org/schemas/v1/LogService.json +[3]: https://github.com/openbmc/docs/blob/master/architecture/redfish-logging-in-bmcweb.md +[4]: https://github.com/openbmc/phosphor-logging diff --git a/Contrib-Inspur/bmcweb/aspeed_purley.cmake b/Contrib-Inspur/bmcweb/aspeed_purley.cmake deleted file mode 100644 index 2c48ed24..00000000 --- a/Contrib-Inspur/bmcweb/aspeed_purley.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# this one is important -SET(CMAKE_SYSTEM_NAME Linux) -#this one not so much -SET(CMAKE_SYSTEM_VERSION 1) -SET(CMAKE_SYSTEM_PROCESSOR "armv6") -set(ARCH "armv6") - -SET(CMAKE_CROSSCOMPILING True) - -# specify the cross compiler -#SET(CMAKE_C_COMPILER arm-linux-gnueabi-gcc-4.9) -#SET(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++-4.9) -#SET(CMAKE_C_LINK_EXECUTABLE "clang -o ") -#SET(CMAKE_CXX_LINK_EXECUTABLE "clang++ -o ") - -set(CMAKE_C_COMPILER /home/ed/deg-bmcfw-core/ToolChain/Host/AST2500/x-tools/arm-aspeed-linux-gnueabi/bin/arm-linux-gcc) -set(CMAKE_CXX_COMPILER /home/ed/deg-bmcfw-core/ToolChain/Host/AST2500/x-tools/arm-aspeed-linux-gnueabi/bin/arm-linux-g++) - - -set(triple arm-linux-gnueabi) -set(CMAKE_C_COMPILER_TARGET ${triple}) -set(CMAKE_CXX_COMPILER_TARGET ${triple}) - -# where is the target environment -SET(CMAKE_FIND_ROOT_PATH /home/ed/deg-bmcfw-core/_sysroot/AST2500) - -# search for programs in the build host directories -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# for libraries and headers in the target directories -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/Contrib-Inspur/bmcweb/bmcweb.service.in b/Contrib-Inspur/bmcweb/bmcweb.service.in new file mode 100644 index 00000000..fdb023b8 --- /dev/null +++ b/Contrib-Inspur/bmcweb/bmcweb.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=Start bmcweb server + +Wants=network.target +After=network.target + +[Service] +ExecReload=kill -s HUP $MAINPID +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/bmcweb +Type=simple +WorkingDirectory=/home/root + +[Install] +WantedBy=network.target diff --git a/Contrib-Inspur/bmcweb/bmcweb.socket b/Contrib-Inspur/bmcweb/bmcweb.socket new file mode 100644 index 00000000..8782e4dd --- /dev/null +++ b/Contrib-Inspur/bmcweb/bmcweb.socket @@ -0,0 +1,9 @@ +[Unit] +Description=BMC Webserver socket + +[Socket] +ListenStream=443 +ReusePort=true + +[Install] +WantedBy=sockets.target diff --git a/Contrib-Inspur/bmcweb/config.h.in b/Contrib-Inspur/bmcweb/config.h.in new file mode 100644 index 00000000..70b98c9a --- /dev/null +++ b/Contrib-Inspur/bmcweb/config.h.in @@ -0,0 +1 @@ +#cmakedefine BMCWEB_HTTP_REQ_BODY_LIMIT_MB @BMCWEB_HTTP_REQ_BODY_LIMIT_MB@ diff --git a/Contrib-Inspur/bmcweb/crow/README.md b/Contrib-Inspur/bmcweb/crow/README.md deleted file mode 100644 index 4fd44924..00000000 --- a/Contrib-Inspur/bmcweb/crow/README.md +++ /dev/null @@ -1,184 +0,0 @@ - - -Crow is C++ microframework for web. (inspired by Python Flask) - -[](https://travis-ci.org/ipkn/crow) -[](https://coveralls.io/r/ipkn/crow?branch=master) - -```c++ -#include "crow.h" - -int main() -{ - crow::SimpleApp app; - - BMCWEB_ROUTE(app, "/")([](){ - return "Hello world"; - }); - - app.port(18080).multithreaded().run(); -} -``` - -## Features - - - Easy routing - - Similiar to Flask - - Type-safe Handlers (see Example) - - Very Fast - -  - - More data on [crow-benchmark](https://github.com/ipkn/crow-benchmark) - - Fast built-in JSON parser (crow::json) - - You can also use [json11](https://github.com/dropbox/json11) or [rapidjson](https://github.com/miloyip/rapidjson) for better speed or readability - - [Mustache](http://mustache.github.io/) based templating library (crow::mustache) - - Header only - - Provide an amalgamated header file `BMCWEB_all.h' with every features - - Middleware support - - Websocket support - -## Still in development - - ~~Built-in ORM~~ - - Check [sqlpp11](https://github.com/rbock/sqlpp11) if you want one. - -## Examples - -#### JSON Response -```c++ -BMCWEB_ROUTE(app, "/json") -([]{ - crow::json::wvalue x; - x["message"] = "Hello, World!"; - return x; -}); -``` - -#### Arguments -```c++ -BMCWEB_ROUTE(app,"/hello/") -([](int count){ - if (count > 100) - return crow::Response(400); - std::ostringstream os; - os << count << " bottles of beer!"; - return crow::Response(os.str()); -}); -``` -Handler arguments type check at compile time -```c++ -// Compile error with message "Handler type is mismatched with URL paramters" -BMCWEB_ROUTE(app,"/another/") -([](int a, int b){ - return crow::Response(500); -}); -``` - -#### Handling JSON Requests -```c++ -BMCWEB_ROUTE(app, "/add_json") -.methods("POST"_method) -([](const crow::Request& req){ - auto x = crow::json::load(req.body); - if (!x) - return crow::Response(400); - int sum = x["a"].i()+x["b"].i(); - std::ostringstream os; - os << sum; - return crow::Response{os.str()}; -}); -``` - -## How to Build - -If you just want to use crow, copy amalgamate/BMCWEB_all.h and include it. - -### Requirements - - - C++ compiler with good C++11 support (tested with g++>=4.8) - - boost library - - CMake for build examples - - Linking with tcmalloc/jemalloc is recommended for speed. - - - Now supporting VS2013 with limited functionality (only run-time check for url is available.) - -### Building (Tests, Examples) - -Out-of-source build with CMake is recommended. - -``` -mkdir build -cd build -cmake .. -make -``` - -You can run tests with following commands: -``` -ctest -``` - - -### Installing missing dependencies - -#### Ubuntu - sudo apt-get install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so - -#### OSX - brew install boost google-perftools - -### Attributions - -Crow uses the following libraries. - - http-parser - - https://github.com/nodejs/http-parser - - http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright - Igor Sysoev. - - Additional changes are licensed under the same terms as NGINX and - copyright Joyent, Inc. and other Node contributors. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. - - - qs_parse - - https://github.com/bartgrantham/qs_parse - - Copyright (c) 2010 Bart Grantham - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - - TinySHA1 - - https://github.com/mohaps/TinySHA1 - - TinySHA1 - a header only implementation of the SHA1 algorithm. Based on the implementation in boost::uuid::details - - Copyright (c) 2012-22 SAURAV MOHAPATRA mohaps@gmail.com - Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Contrib-Inspur/bmcweb/crow/include/crow.h b/Contrib-Inspur/bmcweb/crow/include/crow.h deleted file mode 100644 index 7fe640aa..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "boost/beast/core.hpp" - -#include "crow/app.h" -#include "crow/common.h" -#include "crow/http_connection.h" -#include "crow/http_request.h" -#include "crow/http_response.h" -#include "crow/http_server.h" -#include "crow/logging.h" -#include "crow/middleware_context.h" -#include "crow/query_string.h" -#include "crow/routing.h" -#include "crow/timer_queue.h" -#include "crow/utility.h" -#include "crow/websocket.h" diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/app.h b/Contrib-Inspur/bmcweb/crow/include/crow/app.h deleted file mode 100644 index 9ce2f8bf..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/app.h +++ /dev/null @@ -1,251 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "crow/http_request.h" -#include "crow/http_server.h" -#include "crow/logging.h" -#include "crow/middleware_context.h" -#include "crow/routing.h" -#include "crow/utility.h" - -#define BMCWEB_ROUTE(app, url) \ - app.template route(url) - -namespace crow -{ -#ifdef BMCWEB_ENABLE_SSL -using ssl_context_t = boost::asio::ssl::context; -#endif -template class Crow -{ - public: - using self_t = Crow; - -#ifdef BMCWEB_ENABLE_SSL - using ssl_socket_t = boost::beast::ssl_stream; - using ssl_server_t = Server; -#else - using socket_t = boost::asio::ip::tcp::socket; - using server_t = Server; -#endif - - explicit Crow(std::shared_ptr io = - std::make_shared()) : - io(std::move(io)) - { - } - ~Crow() - { - this->stop(); - } - - template - void handleUpgrade(const Request& req, Response& res, Adaptor&& adaptor) - { - router.handleUpgrade(req, res, std::move(adaptor)); - } - - void handle(const Request& req, Response& res) - { - router.handle(req, res); - } - - DynamicRule& routeDynamic(std::string&& rule) - { - return router.newRuleDynamic(rule); - } - - template auto& route(std::string&& rule) - { - return router.newRuleTagged(std::move(rule)); - } - - self_t& socket(int existing_socket) - { - socketFd = existing_socket; - return *this; - } - - self_t& port(std::uint16_t port) - { - portUint = port; - return *this; - } - - self_t& bindaddr(std::string bindaddr) - { - bindaddrStr = bindaddr; - return *this; - } - - void validate() - { - router.validate(); - } - - void run() - { - validate(); -#ifdef BMCWEB_ENABLE_SSL - if (-1 == socketFd) - { - sslServer = std::move(std::make_unique( - this, bindaddrStr, portUint, &middlewares, &sslContext, io)); - } - else - { - sslServer = std::move(std::make_unique( - this, socketFd, &middlewares, &sslContext, io)); - } - sslServer->setTickFunction(tickInterval, tickFunction); - sslServer->run(); - -#else - - if (-1 == socketFd) - { - server = std::move(std::make_unique( - this, bindaddrStr, portUint, &middlewares, nullptr, io)); - } - else - { - server = std::move(std::make_unique( - this, socketFd, &middlewares, nullptr, io)); - } - server->setTickFunction(tickInterval, tickFunction); - server->run(); - -#endif - } - - void stop() - { - io->stop(); - } - - void debugPrint() - { - BMCWEB_LOG_DEBUG << "Routing:"; - router.debugPrint(); - } - - std::vector getRoutes() - { - // TODO(ed) Should this be /? - const std::string root(""); - return router.getRoutes(root); - } - std::vector getRoutes(const std::string& parent) - { - return router.getRoutes(parent); - } - -#ifdef BMCWEB_ENABLE_SSL - self_t& sslFile(const std::string& crt_filename, - const std::string& key_filename) - { - sslContext.set_verify_mode(boost::asio::ssl::verify_peer); - sslContext.use_certificate_file(crt_filename, ssl_context_t::pem); - sslContext.use_private_key_file(key_filename, ssl_context_t::pem); - sslContext.set_options(boost::asio::ssl::context::default_workarounds | - boost::asio::ssl::context::no_sslv2 | - boost::asio::ssl::context::no_sslv3); - return *this; - } - - self_t& sslFile(const std::string& pem_filename) - { - sslContext.set_verify_mode(boost::asio::ssl::verify_peer); - sslContext.load_verify_file(pem_filename); - sslContext.set_options(boost::asio::ssl::context::default_workarounds | - boost::asio::ssl::context::no_sslv2 | - boost::asio::ssl::context::no_sslv3); - return *this; - } - - self_t& ssl(boost::asio::ssl::context&& ctx) - { - sslContext = std::move(ctx); - return *this; - } - - ssl_context_t sslContext{boost::asio::ssl::context::sslv23}; - -#else - template self_t& ssl_file(T&&, Remain&&...) - { - // We can't call .ssl() member function unless BMCWEB_ENABLE_SSL is - // defined. - static_assert( - // make static_assert dependent to T; always false - std::is_base_of::value, - "Define BMCWEB_ENABLE_SSL to enable ssl support."); - return *this; - } - - template self_t& ssl(T&&) - { - // We can't call .ssl() member function unless BMCWEB_ENABLE_SSL is - // defined. - static_assert( - // make static_assert dependent to T; always false - std::is_base_of::value, - "Define BMCWEB_ENABLE_SSL to enable ssl support."); - return *this; - } -#endif - - // middleware - using context_t = detail::Context; - template typename T::Context& getContext(const Request& req) - { - static_assert(black_magic::Contains::value, - "App doesn't have the specified middleware type."); - auto& ctx = *reinterpret_cast(req.middlewareContext); - return ctx.template get(); - } - - template T& getMiddleware() - { - return utility::getElementByType(middlewares); - } - - template self_t& tick(Duration d, Func f) - { - tickInterval = std::chrono::duration_cast(d); - tickFunction = f; - return *this; - } - - private: - std::shared_ptr io; -#ifdef BMCWEB_ENABLE_SSL - uint16_t portUint = 443; -#else - uint16_t portUint = 80; -#endif - std::string bindaddrStr = "::"; - int socketFd = -1; - Router router; - - std::chrono::milliseconds tickInterval{}; - std::function tickFunction; - - std::tuple middlewares; - -#ifdef BMCWEB_ENABLE_SSL - std::unique_ptr sslServer; -#else - std::unique_ptr server; -#endif -}; -template using App = Crow; -using SimpleApp = Crow<>; -} // namespace crow diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/http_connection.h b/Contrib-Inspur/bmcweb/crow/include/crow/http_connection.h deleted file mode 100644 index 6f1dafde..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/http_connection.h +++ /dev/null @@ -1,639 +0,0 @@ -#pragma once -#include "http_utility.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "crow/http_response.h" -#include "crow/logging.h" -#include "crow/middleware_context.h" -#include "crow/timer_queue.h" -#include "crow/utility.h" - -#ifdef BMCWEB_ENABLE_SSL -#include -#include -#endif - -namespace crow -{ - -inline void prettyPrintJson(crow::Response& res) -{ - std::string value = res.jsonValue.dump(4, ' ', true); - utility::escapeHtml(value); - utility::convertToLinks(value); - res.body() = "\n" - "\n" - "Redfish API\n" - "\n" - "" - "" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" + - value + - "\n" - "\n" - "\n" - "\n" - "\n"; - res.addHeader("Content-Type", "text/html;charset=UTF-8"); -} - -using namespace boost; -using tcp = asio::ip::tcp; - -namespace detail -{ -template struct CheckBeforeHandleArity3Const -{ - template - struct Get - { - }; -}; - -template struct CheckBeforeHandleArity3 -{ - template - struct Get - { - }; -}; - -template struct CheckAfterHandleArity3Const -{ - template - struct Get - { - }; -}; - -template struct CheckAfterHandleArity3 -{ - template - struct Get - { - }; -}; - -template struct IsBeforeHandleArity3Impl -{ - template - static std::true_type - f(typename CheckBeforeHandleArity3Const::template Get*); - - template - static std::true_type - f(typename CheckBeforeHandleArity3::template Get*); - - template static std::false_type f(...); - - public: - static const bool value = decltype(f(nullptr))::value; -}; - -template struct IsAfterHandleArity3Impl -{ - template - static std::true_type - f(typename CheckAfterHandleArity3Const::template Get*); - - template - static std::true_type - f(typename CheckAfterHandleArity3::template Get*); - - template static std::false_type f(...); - - public: - static const bool value = decltype(f(nullptr))::value; -}; - -template -typename std::enable_if::value>::type - beforeHandlerCall(MW& mw, Request& req, Response& res, Context& ctx, - ParentContext& /*parent_ctx*/) -{ - mw.beforeHandle(req, res, ctx.template get(), ctx); -} - -template -typename std::enable_if::value>::type - beforeHandlerCall(MW& mw, Request& req, Response& res, Context& ctx, - ParentContext& /*parent_ctx*/) -{ - mw.beforeHandle(req, res, ctx.template get()); -} - -template -typename std::enable_if::value>::type - afterHandlerCall(MW& mw, Request& req, Response& res, Context& ctx, - ParentContext& /*parent_ctx*/) -{ - mw.afterHandle(req, res, ctx.template get(), ctx); -} - -template -typename std::enable_if::value>::type - afterHandlerCall(MW& mw, Request& req, Response& res, Context& ctx, - ParentContext& /*parent_ctx*/) -{ - mw.afterHandle(req, res, ctx.template get()); -} - -template -bool middlewareCallHelper(Container& middlewares, Request& req, Response& res, - Context& ctx) -{ - using parent_context_t = typename Context::template partial; - beforeHandlerCall( - std::get(middlewares), req, res, ctx, - static_cast(ctx)); - - if (res.isCompleted()) - { - afterHandlerCall( - std::get(middlewares), req, res, ctx, - static_cast(ctx)); - return true; - } - - if (middlewareCallHelper( - middlewares, req, res, ctx)) - { - afterHandlerCall( - std::get(middlewares), req, res, ctx, - static_cast(ctx)); - return true; - } - - return false; -} - -template -bool middlewareCallHelper(Container& /*middlewares*/, Request& /*req*/, - Response& /*res*/, Context& /*ctx*/) -{ - return false; -} - -template -typename std::enable_if<(N < 0)>::type - afterHandlersCallHelper(Container& /*middlewares*/, Context& /*Context*/, - Request& /*req*/, Response& /*res*/) -{ -} - -template -typename std::enable_if<(N == 0)>::type - afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, - Response& res) -{ - using parent_context_t = typename Context::template partial; - using CurrentMW = typename std::tuple_element< - N, typename std::remove_reference::type>::type; - afterHandlerCall( - std::get(middlewares), req, res, ctx, - static_cast(ctx)); -} - -template -typename std::enable_if<(N > 0)>::type - afterHandlersCallHelper(Container& middlewares, Context& ctx, Request& req, - Response& res) -{ - using parent_context_t = typename Context::template partial; - using CurrentMW = typename std::tuple_element< - N, typename std::remove_reference::type>::type; - afterHandlerCall( - std::get(middlewares), req, res, ctx, - static_cast(ctx)); - afterHandlersCallHelper(middlewares, ctx, req, - res); -} -} // namespace detail - -#ifdef BMCWEB_ENABLE_DEBUG -static std::atomic connectionCount; -#endif - -// request body limit size: 30M -constexpr unsigned int httpReqBodyLimit = 1024 * 1024 * 30; - -template -class Connection -{ - public: - Connection(boost::asio::io_context& ioService, Handler* handler, - const std::string& server_name, - std::tuple* middlewares, - std::function& get_cached_date_str_f, - detail::TimerQueue& timerQueue, Adaptor adaptorIn) : - adaptor(std::move(adaptorIn)), - handler(handler), serverName(server_name), middlewares(middlewares), - getCachedDateStr(get_cached_date_str_f), timerQueue(timerQueue) - { - parser.emplace(std::piecewise_construct, std::make_tuple()); - // Temporarily changed to 30MB; Need to modify uploading/authentication - // mechanism - parser->body_limit(httpReqBodyLimit); - req.emplace(parser->get()); -#ifdef BMCWEB_ENABLE_DEBUG - connectionCount++; - BMCWEB_LOG_DEBUG << this << " Connection open, total " - << connectionCount; -#endif - } - - ~Connection() - { - res.completeRequestHandler = nullptr; - cancelDeadlineTimer(); -#ifdef BMCWEB_ENABLE_DEBUG - connectionCount--; - BMCWEB_LOG_DEBUG << this << " Connection closed, total " - << connectionCount; -#endif - } - - Adaptor& socket() - { - return adaptor; - } - - void start() - { - - startDeadline(); - // TODO(ed) Abstract this to a more clever class with the idea of an - // asynchronous "start" - if constexpr (std::is_same_v>) - { - adaptor.async_handshake( - boost::asio::ssl::stream_base::server, - [this](const boost::system::error_code& ec) { - if (ec) - { - checkDestroy(); - return; - } - doReadHeaders(); - }); - } - else - { - doReadHeaders(); - } - } - - void handle() - { - cancelDeadlineTimer(); - bool isInvalidRequest = false; - const boost::string_view connection = - req->getHeaderValue(boost::beast::http::field::connection); - - // Check for HTTP version 1.1. - if (req->version() == 11) - { - if (req->getHeaderValue(boost::beast::http::field::host).empty()) - { - isInvalidRequest = true; - res = Response(boost::beast::http::status::bad_request); - } - } - - std::string epName; - boost::system::error_code ec; - tcp::endpoint ep = adaptor.lowest_layer().remote_endpoint(ec); - if (!ec) - { - epName = boost::lexical_cast(ep); - } - - BMCWEB_LOG_INFO << "Request: " << epName << " " << this << " HTTP/" - << req->version() / 10 << "." << req->version() % 10 - << ' ' << req->methodString() << " " << req->target(); - - needToCallAfterHandlers = false; - - if (!isInvalidRequest) - { - res.completeRequestHandler = [] {}; - res.isAliveHelper = [this]() -> bool { - return adaptor.lowest_layer().is_open(); - }; - - ctx = detail::Context(); - req->middlewareContext = (void*)&ctx; - req->ioService = &adaptor.get_executor().context(); - detail::middlewareCallHelper< - 0, decltype(ctx), decltype(*middlewares), Middlewares...>( - *middlewares, *req, res, ctx); - - if (!res.completed) - { - if (req->isUpgrade() && - boost::iequals( - req->getHeaderValue(boost::beast::http::field::upgrade), - "websocket")) - { - handler->handleUpgrade(*req, res, std::move(adaptor)); - return; - } - res.completeRequestHandler = [this] { - this->completeRequest(); - }; - needToCallAfterHandlers = true; - handler->handle(*req, res); - } - else - { - completeRequest(); - } - } - else - { - completeRequest(); - } - } - - void completeRequest() - { - BMCWEB_LOG_INFO << "Response: " << this << ' ' << req->url << ' ' - << res.resultInt() << " keepalive=" << req->keepAlive(); - - if (needToCallAfterHandlers) - { - needToCallAfterHandlers = false; - - // call all afterHandler of middlewares - detail::afterHandlersCallHelper<((int)sizeof...(Middlewares) - 1), - decltype(ctx), - decltype(*middlewares)>( - *middlewares, ctx, *req, res); - } - - // auto self = this->shared_from_this(); - res.completeRequestHandler = res.completeRequestHandler = [] {}; - - if (!adaptor.lowest_layer().is_open()) - { - // BMCWEB_LOG_DEBUG << this << " delete (socket is closed) " << - // isReading - // << ' ' << isWriting; - // delete this; - return; - } - if (res.body().empty() && !res.jsonValue.empty()) - { - if (http_helpers::requestPrefersHtml(*req)) - { - prettyPrintJson(res); - } - else - { - res.jsonMode(); - res.body() = res.jsonValue.dump(2, ' ', true); - } - } - - if (res.resultInt() >= 400 && res.body().empty()) - { - res.body() = std::string(res.reason()); - } - res.addHeader(boost::beast::http::field::server, serverName); - res.addHeader(boost::beast::http::field::date, getCachedDateStr()); - - res.keepAlive(req->keepAlive()); - - doWrite(); - } - - private: - void doReadHeaders() - { - // auto self = this->shared_from_this(); - isReading = true; - BMCWEB_LOG_DEBUG << this << " doReadHeaders"; - - // Clean up any previous Connection. - boost::beast::http::async_read_header( - adaptor, buffer, *parser, - [this](const boost::system::error_code& ec, - std::size_t bytes_transferred) { - isReading = false; - BMCWEB_LOG_ERROR << this << " async_read_header " - << bytes_transferred << " Bytes"; - bool errorWhileReading = false; - if (ec) - { - errorWhileReading = true; - BMCWEB_LOG_ERROR - << this << " Error while reading: " << ec.message(); - } - else - { - // if the adaptor isn't open anymore, and wasn't handed to a - // websocket, treat as an error - if (!adaptor.lowest_layer().is_open() && !req->isUpgrade()) - { - errorWhileReading = true; - } - } - - if (errorWhileReading) - { - cancelDeadlineTimer(); - adaptor.lowest_layer().close(); - BMCWEB_LOG_DEBUG << this << " from read(1)"; - checkDestroy(); - return; - } - - // Compute the url parameters for the request - req->url = req->target(); - std::size_t index = req->url.find("?"); - if (index != boost::string_view::npos) - { - req->url = req->url.substr(0, index); - } - req->urlParams = QueryString(std::string(req->target())); - doRead(); - }); - } - - void doRead() - { - // auto self = this->shared_from_this(); - isReading = true; - BMCWEB_LOG_DEBUG << this << " doRead"; - - boost::beast::http::async_read( - adaptor, buffer, *parser, - [this](const boost::system::error_code& ec, - std::size_t bytes_transferred) { - BMCWEB_LOG_ERROR << this << " async_read " << bytes_transferred - << " Bytes"; - isReading = false; - - bool errorWhileReading = false; - if (ec) - { - BMCWEB_LOG_ERROR << "Error while reading: " << ec.message(); - errorWhileReading = true; - } - else - { - if (!adaptor.lowest_layer().is_open()) - { - errorWhileReading = true; - } - } - if (errorWhileReading) - { - cancelDeadlineTimer(); - adaptor.lowest_layer().close(); - BMCWEB_LOG_DEBUG << this << " from read(1)"; - checkDestroy(); - return; - } - handle(); - }); - } - - void doWrite() - { - // auto self = this->shared_from_this(); - isWriting = true; - BMCWEB_LOG_DEBUG << "Doing Write"; - res.preparePayload(); - serializer.emplace(*res.stringResponse); - boost::beast::http::async_write( - adaptor, *serializer, - [&](const boost::system::error_code& ec, - std::size_t bytes_transferred) { - isWriting = false; - BMCWEB_LOG_DEBUG << this << " Wrote " << bytes_transferred - << " bytes"; - - if (ec) - { - BMCWEB_LOG_DEBUG << this << " from write(2)"; - checkDestroy(); - return; - } - if (!res.keepAlive()) - { - adaptor.lowest_layer().close(); - BMCWEB_LOG_DEBUG << this << " from write(1)"; - checkDestroy(); - return; - } - - serializer.reset(); - BMCWEB_LOG_DEBUG << this << " Clearing response"; - res.clear(); - parser.emplace(std::piecewise_construct, std::make_tuple()); - parser->body_limit(httpReqBodyLimit); // reset body limit for - // newly created parser - buffer.consume(buffer.size()); - - req.emplace(parser->get()); - doReadHeaders(); - }); - } - - void checkDestroy() - { - BMCWEB_LOG_DEBUG << this << " isReading " << isReading << " isWriting " - << isWriting; - if (!isReading && !isWriting) - { - BMCWEB_LOG_DEBUG << this << " delete (idle) "; - delete this; - } - } - - void cancelDeadlineTimer() - { - BMCWEB_LOG_DEBUG << this << " timer cancelled: " << &timerQueue << ' ' - << timerCancelKey; - timerQueue.cancel(timerCancelKey); - } - - void startDeadline() - { - cancelDeadlineTimer(); - - timerCancelKey = timerQueue.add([this] { - if (!adaptor.lowest_layer().is_open()) - { - return; - } - adaptor.lowest_layer().close(); - }); - BMCWEB_LOG_DEBUG << this << " timer added: " << &timerQueue << ' ' - << timerCancelKey; - } - - private: - Adaptor adaptor; - Handler* handler; - - // Making this a std::optional allows it to be efficiently destroyed and - // re-created on Connection reset - std::optional< - boost::beast::http::request_parser> - parser; - - boost::beast::flat_static_buffer<8192> buffer; - - std::optional> - serializer; - - std::optional req; - crow::Response res; - - const std::string& serverName; - - int timerCancelKey{-1}; - - bool isReading{}; - bool isWriting{}; - bool needToCallAfterHandlers{}; - bool needToStartReadAfterComplete{}; - - std::tuple* middlewares; - detail::Context ctx; - - std::function& getCachedDateStr; - detail::TimerQueue& timerQueue; -}; -} // namespace crow diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/http_request.h b/Contrib-Inspur/bmcweb/crow/include/crow/http_request.h deleted file mode 100644 index ac5f78d0..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/http_request.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "crow/common.h" -#include "crow/query_string.h" - -namespace crow -{ - -struct Request -{ - boost::string_view url{}; - QueryString urlParams{}; - bool isSecure{false}; - - const std::string& body; - - void* middlewareContext{}; - boost::asio::io_context* ioService{}; - - Request(boost::beast::http::request& req) : - req(req), body(req.body()) - { - } - - const boost::beast::http::verb method() const - { - return req.method(); - } - - const boost::string_view getHeaderValue(boost::string_view key) const - { - return req[key]; - } - - const boost::string_view getHeaderValue(boost::beast::http::field key) const - { - return req[key]; - } - - const boost::string_view methodString() const - { - return req.method_string(); - } - - const boost::string_view target() const - { - return req.target(); - } - - unsigned version() - { - return req.version(); - } - - bool isUpgrade() - { - return boost::beast::websocket::is_upgrade(req); - } - - bool keepAlive() - { - return req.keep_alive(); - } - - boost::beast::http::request& req; -}; - -} // namespace crow diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/http_server.h b/Contrib-Inspur/bmcweb/crow/include/crow/http_server.h deleted file mode 100644 index e8cb762e..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/http_server.h +++ /dev/null @@ -1,222 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "crow/http_connection.h" -#include "crow/logging.h" -#include "crow/timer_queue.h" -#ifdef BMCWEB_ENABLE_SSL -#include -#include -#endif - -namespace crow -{ -using namespace boost; -using tcp = asio::ip::tcp; - -template -class Server -{ - public: - Server(Handler* handler, std::unique_ptr&& acceptor, - std::tuple* middlewares = nullptr, - boost::asio::ssl::context* adaptor_ctx = nullptr, - std::shared_ptr io = - std::make_shared()) : - ioService(std::move(io)), - acceptor(std::move(acceptor)), signals(*ioService, SIGINT, SIGTERM), - tickTimer(*ioService), handler(handler), middlewares(middlewares), - adaptorCtx(adaptor_ctx) - { - } - - Server(Handler* handler, const std::string& bindaddr, uint16_t port, - std::tuple* middlewares = nullptr, - boost::asio::ssl::context* adaptor_ctx = nullptr, - std::shared_ptr io = - std::make_shared()) : - Server(handler, - std::make_unique( - *io, - tcp::endpoint( - boost::asio::ip::address::from_string(bindaddr), port)), - middlewares, adaptor_ctx, io) - { - } - - Server(Handler* handler, int existing_socket, - std::tuple* middlewares = nullptr, - boost::asio::ssl::context* adaptor_ctx = nullptr, - std::shared_ptr io = - std::make_shared()) : - Server(handler, - std::make_unique(*io, boost::asio::ip::tcp::v6(), - existing_socket), - middlewares, adaptor_ctx, io) - { - } - - void setTickFunction(std::chrono::milliseconds d, std::function f) - { - tickInterval = d; - tickFunction = f; - } - - void onTick() - { - tickFunction(); - tickTimer.expires_from_now( - boost::posix_time::milliseconds(tickInterval.count())); - tickTimer.async_wait([this](const boost::system::error_code& ec) { - if (ec) - { - return; - } - onTick(); - }); - } - - void updateDateStr() - { - auto lastTimeT = time(0); - tm myTm{}; - -#ifdef _MSC_VER - gmtime_s(&my_tm, &last_time_t); -#else - gmtime_r(&lastTimeT, &myTm); -#endif - dateStr.resize(100); - size_t dateStrSz = - strftime(&dateStr[0], 99, "%a, %d %b %Y %H:%M:%S GMT", &myTm); - dateStr.resize(dateStrSz); - }; - - void run() - { - updateDateStr(); - - getCachedDateStr = [this]() -> std::string { - static std::chrono::time_point - lastDateUpdate = std::chrono::steady_clock::now(); - if (std::chrono::steady_clock::now() - lastDateUpdate >= - std::chrono::seconds(10)) - { - lastDateUpdate = std::chrono::steady_clock::now(); - updateDateStr(); - } - return this->dateStr; - }; - - boost::asio::deadline_timer timer(*ioService); - timer.expires_from_now(boost::posix_time::seconds(1)); - - std::function handler; - handler = [&](const boost::system::error_code& ec) { - if (ec) - { - return; - } - timerQueue.process(); - timer.expires_from_now(boost::posix_time::seconds(1)); - timer.async_wait(handler); - }; - timer.async_wait(handler); - - if (tickFunction && tickInterval.count() > 0) - { - tickTimer.expires_from_now( - boost::posix_time::milliseconds(tickInterval.count())); - tickTimer.async_wait([this](const boost::system::error_code& ec) { - if (ec) - { - return; - } - onTick(); - }); - } - - BMCWEB_LOG_INFO << serverName << " server is running, local endpoint " - << acceptor->local_endpoint(); - - signals.async_wait([&](const boost::system::error_code& /*error*/, - int /*signal_number*/) { stop(); }); - - doAccept(); - } - - void stop() - { - ioService->stop(); - } - - void doAccept() - { - std::optional adaptorTemp; - if constexpr (std::is_same>::value) - { - adaptorTemp = Adaptor(*ioService, *adaptorCtx); - } - else - { - adaptorTemp = Adaptor(*ioService); - } - - Connection* p = - new Connection( - *ioService, handler, serverName, middlewares, getCachedDateStr, - timerQueue, std::move(adaptorTemp.value())); - - acceptor->async_accept(p->socket().lowest_layer(), - [this, p](boost::system::error_code ec) { - if (!ec) - { - this->ioService->post( - [p] { p->start(); }); - } - else - { - delete p; - } - doAccept(); - }); - } - - private: - std::shared_ptr ioService; - detail::TimerQueue timerQueue; - std::function getCachedDateStr; - std::unique_ptr acceptor; - boost::asio::signal_set signals; - boost::asio::deadline_timer tickTimer; - - std::string dateStr; - - Handler* handler; - std::string serverName = "iBMC"; - - std::chrono::milliseconds tickInterval{}; - std::function tickFunction; - - std::tuple* middlewares; - -#ifdef BMCWEB_ENABLE_SSL - bool useSsl{false}; -#endif - boost::asio::ssl::context* adaptorCtx; -}; // namespace crow -} // namespace crow diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/logging.h b/Contrib-Inspur/bmcweb/crow/include/crow/logging.h deleted file mode 100644 index 353a448c..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/logging.h +++ /dev/null @@ -1,145 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace crow -{ -enum class LogLevel -{ -#ifndef ERROR - DEBUG = 0, - INFO, - WARNING, - ERROR, - CRITICAL, -#endif - - Debug = 0, - Info, - Warning, - Error, - Critical, -}; - -class ILogHandler -{ - public: - virtual void log(std::string message, LogLevel level) = 0; -}; - -class CerrLogHandler : public ILogHandler -{ - public: - void log(std::string message, LogLevel /*level*/) override - { - std::cerr << message; - } -}; - -class logger -{ - private: - // - static std::string timestamp() - { - char date[32]; - time_t t = time(0); - - tm myTm{}; - -#ifdef _MSC_VER - gmtime_s(&my_tm, &t); -#else - gmtime_r(&t, &myTm); -#endif - - size_t sz = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", &myTm); - return std::string(date, date + sz); - } - - public: - logger(const std::string& prefix, LogLevel level) : level(level) - { -#ifdef BMCWEB_ENABLE_LOGGING - stringstream << "(" << timestamp() << ") [" << prefix << "] "; -#endif - } - ~logger() - { -#ifdef BMCWEB_ENABLE_LOGGING - if (level >= get_current_log_level()) - { - stringstream << std::endl; - getHandlerRef()->log(stringstream.str(), level); - } -#endif - } - - // - template logger& operator<<(T const& value) - { -#ifdef BMCWEB_ENABLE_LOGGING - if (level >= get_current_log_level()) - { - stringstream << value; - } -#endif - return *this; - } - - // - static void setLogLevel(LogLevel level) - { - getLogLevelRef() = level; - } - - static void setHandler(ILogHandler* handler) - { - getHandlerRef() = handler; - } - - static LogLevel get_current_log_level() - { - return getLogLevelRef(); - } - - private: - // - static LogLevel& getLogLevelRef() - { - static auto currentLevel = static_cast(1); - return currentLevel; - } - static ILogHandler*& getHandlerRef() - { - static CerrLogHandler defaultHandler; - static ILogHandler* currentHandler = &defaultHandler; - return currentHandler; - } - - // - std::ostringstream stringstream; - LogLevel level; -}; -} // namespace crow - -#define BMCWEB_LOG_CRITICAL \ - if (crow::logger::get_current_log_level() <= crow::LogLevel::Critical) \ - crow::logger("CRITICAL", crow::LogLevel::Critical) -#define BMCWEB_LOG_ERROR \ - if (crow::logger::get_current_log_level() <= crow::LogLevel::Error) \ - crow::logger("ERROR ", crow::LogLevel::Error) -#define BMCWEB_LOG_WARNING \ - if (crow::logger::get_current_log_level() <= crow::LogLevel::Warning) \ - crow::logger("WARNING ", crow::LogLevel::Warning) -#define BMCWEB_LOG_INFO \ - if (crow::logger::get_current_log_level() <= crow::LogLevel::Info) \ - crow::logger("INFO ", crow::LogLevel::Info) -#define BMCWEB_LOG_DEBUG \ - if (crow::logger::get_current_log_level() <= crow::LogLevel::Debug) \ - crow::logger("DEBUG ", crow::LogLevel::Debug) diff --git a/Contrib-Inspur/bmcweb/crow/include/crow/routing.h b/Contrib-Inspur/bmcweb/crow/include/crow/routing.h deleted file mode 100644 index 7ba51711..00000000 --- a/Contrib-Inspur/bmcweb/crow/include/crow/routing.h +++ /dev/null @@ -1,1197 +0,0 @@ -#pragma once - -#include "boost/container/flat_map.hpp" - -#include -#include -#include -#include -#include
\n" - "" + - value + - "\n" - "
" + - value + - "