Server BMC compatible method and device
By parsing the web request of the server BMC and generating a function implementation strategy for regression testing, the problem of poor compatibility of the server BMC management tool in the existing technology is solved, achieving fast and accurate compatibility and more comprehensive functional coverage, reducing manual intervention and cost.
Patent Information
- Application Number
- CN202410703551.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-30
AI Technical Summary
Existing server BMC management tools have poor compatibility, mainly due to the slow development process of relying on BMC interface documents and the inconvenience of obtaining interface documents for servers from other manufacturers, resulting in insufficient compatibility.
By obtaining and parsing the web request of the server BMC, the initial data object is generated to match the target function, the function implementation strategy is generated, and regression testing is performed to achieve compatibility, avoiding reliance on the BMC interface document and redfish interface, and relying on the original BMC web request for development.
It achieves fast and accurate server BMC compatibility, ensuring that compatibility is accurate and available, with more comprehensive functions, reducing manual intervention, improving compatibility efficiency and saving labor costs.
Smart Images

Figure CN118567706A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servers, and in particular to a server BMC compatibility method and device. Background Art
[0002] As the server market continues to expand, there are more and more requirements for server baseboard management controller (BMC) management tools.
[0003] Since the servers that customers need to manage are of different models and manufacturers, higher compatibility requirements are placed on server BMC management tools, making compatibility an important indicator for each customer to select server BMC management tools.
[0004] In current technology, the compatibility of server BMC management tools with new models mostly depends on BMC interface documents. The advantage of developing based on BMC interface documents is that official documents are generally more comprehensive, and more compatible functions can be developed. However, this method has a slow development process, and it is not convenient to obtain BMC interface documents for servers from other manufacturers, resulting in poor compatibility of server BMC management tools. Summary of the invention
[0005] In view of the problems existing in the prior art, an embodiment of the present invention provides a server BMC compatibility method and device.
[0006] The present invention provides a server BMC compatibility method, comprising: Obtaining a server BMC compatible request carrying request data, and parsing the request data to obtain request information; Generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; Matching the initial data object with the properties of the target data object corresponding to the target function to obtain the target property associated with the initial data object; Generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; In the case where the regression test of the updated function implementation strategy is successful, the compatibility of the server BMC corresponding to the server BMC compatibility request is completed.
[0007] According to a server BMC compatibility method provided by the present invention, the request information includes a request URL, request parameters and return parameters; the initial data object includes a first data object and a second data object; The generating of the initial data object according to the request information, and matching the request information with each initial function in the server BMC function library to obtain the target function associated with the request information includes: Generate, according to the request information, a first data object corresponding to the request parameter and a second data object corresponding to the return parameter; For each initial function in the server BMC function library, determining a first similarity between the request URL and a keyword of the initial function; An initial function corresponding to a first target similarity is determined as a target function corresponding to the request information, wherein the first target similarity is a first similarity greater than a similarity threshold.
[0008] According to a server BMC compatibility method provided by the present invention, the determining of a first similarity between the request URL and a keyword of the initial function includes: Segment the request URL according to a regular expression to obtain a request word corresponding to the request URL; Determining the number of matching characters between the request word and the keyword of the initial function; Determine whether the number of matching characters is greater than a first set value; If not, determining that the first similarity between the request URL and the keyword of the initial function is a second set value; If so, the first similarity between the request URL and the keyword of the initial function is calculated based on the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of string conversions, where the number of string conversions represents half of the number of times the characters are matched by replacing the order.
[0009] According to a server BMC compatibility method provided by the present invention, the determining the number of matching characters between the request word and the keyword of the initial function includes: Determine a larger target character length between a first character length of the request word and a second character length of the keyword; Calculating a first ratio of the target character length to a first value; Determine a first difference between the first ratio and the second value as a matching window width; For each character that is the same in the request word and the keyword, determining a first position of the character in the request word and a second position of the character in the keyword; calculating a distance between the first position and the second position; Determining whether the distance is greater than the matching window width; If yes, determining that the character is a target character that matches between the request word and the keyword; If not, determining that the character is a non-target character that does not match the request word and the keyword; The number of the target characters is counted, and the number of the target characters is determined as the number of matching characters between the request word and the keyword of the initial function.
[0010] According to a server BMC compatibility method provided by the present invention, the first similarity between the request URL and the keyword of the initial function is calculated according to the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of character string conversions, including: Calculating a second ratio of the number of matching characters to the first character length of the request word, and a third ratio of the number of matching characters to the second character length of the keyword; Calculating a second difference between the number of matching characters and the number of character string conversions, and calculating a fourth ratio of the second difference to the number of matching characters; Adding the second ratio, the third ratio and the fourth ratio to obtain a ratio sum, and calculating a first product of a third value and the ratio sum; Determine whether the request word and the keyword have the same prefix; If it does not exist, the first product is determined as the first similarity between the request URL and the keyword of the initial function; if it exists, the second product of the adjustment constant and the number of characters of the same prefix is calculated, and the third difference between the fourth value and the first product is calculated; the third difference is multiplied by the second product to obtain a third product; the sum of the third product and the first product is determined as the first similarity between the request URL and the keyword of the initial function.
[0011] According to a server BMC compatibility method provided by the present invention, before determining the number of matching characters between the request word and the keyword of the initial function, the method further includes: Each character in the request word and each character in the keyword are converted according to a specified format, where the specified format is any format.
[0012] According to a server BMC compatibility method provided by the present invention, when the regression test of the updated function implementation strategy is successful, before completing the compatibility of the server BMC corresponding to the server BMC compatibility request, it also includes: Generate a test script according to the updated function implementation strategy; Based on the test script, regression test is performed on the function implementation strategy; In the case where the function implementation strategy is of the acquisition type, if there is no abnormality in the calling process of the function implementation strategy and there is data in the returned data object, it is determined that the regression test of the updated function implementation strategy is successful; In the case where the function implementation strategy is of a setting type, if there is no abnormality in the calling process of the function implementation strategy and the returned status code is normal, it is determined that the regression test of the updated function implementation strategy is successful.
[0013] According to a server BMC compatibility method provided by the present invention, before generating a function implementation strategy according to the target function and the target attribute, the method further includes: The request information and its associated target function, as well as the initial data object and its associated target attribute are displayed in the form of key-value pairs, and the request information that is not associated with the target function and the unassociated attributes in the target data object are displayed to allow the user to proofread.
[0014] The present invention also provides a server BMC compatible device, comprising: A parsing unit is configured to obtain a server BMC compatible request carrying request data, and parse the request data to obtain request information; A matching unit is configured to generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; match the initial data object with an attribute of a target data object corresponding to the target function to obtain a target attribute associated with the initial data object; A generating unit is configured to generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; The compatibility unit is configured to complete the compatibility of the server BMC corresponding to the server BMC compatibility request when the regression test of the updated function implementation strategy is successful.
[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned server BMC compatibility methods is implemented.
[0016] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the server BMC compatibility method as described above is implemented.
[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the server BMC compatibility method described above is implemented.
[0018] The server BMC compatibility method and device provided by the present invention can quickly and accurately achieve server BMC compatibility by acquiring and parsing the web request of the server BMC, and can also perform regression testing on the compatible script at the same time. It does not rely on the BMC interface document and the BMC redfish interface, but relies on requests that can already run correctly for compatibility development, which can ensure that all compatibilities are accurate and available; it is developed based on the original BMC web request, and its compatible functions are more comprehensive; it can be generated through code, and there is little manual intervention, which can greatly improve the compatibility efficiency of the server BMC and save labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 It is a flow chart of the server BMC compatibility method provided by the present invention.
[0021] Figure 2 It is a structural diagram of the server BMC management tool provided by the present invention.
[0022] Figure 3 It is a structural schematic diagram of a server BMC compatible device provided by the present invention.
[0023] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] First, the related technologies involved in the present invention are briefly described.
[0026] Related technology, the server BMC management tool can obtain the relevant interface documents of each server model, then parse the interface documents, generate a complete service data set based on the parsed interface data, and then match it with the existing data set; determine whether it can be directly reused based on the comparison results, if it cannot be directly reused, generate a recommended service data set and notify personnel to make it compatible.
[0027] However, the above method needs to be highly dependent on relevant interface documents. Compatibility with the vendor's server can be easily achieved. However, it is not easy to obtain relevant interface documents for different models of servers from other vendors. In addition, the interface document may contain spelling errors, inconsistent capitalization, etc., so the service data set generated by the interface document may be inaccurate. In addition, the interface document generally does not have test data, so after the service data set is generated, the subsequent test data set needs to be manually written.
[0028] In addition, the server BMC management tool can also be developed based on the server BMC redfish interface. The redfish interface has a set of common interface definition standards, and some common configurations can be developed through the redfish interface. The advantage is that it is compatible and fast to develop, because the common interface standard should be applicable to all servers; the disadvantage is that some manufacturers may not support the redfish interface; and the server BMC management functions covered by the redfish common interface are not comprehensive. Each manufacturer has customized development for the redfish interface, and this part of the code is different for each manufacturer. If you want to develop for these interfaces, you also need to refer to relevant documents.
[0029] Combine the following Figure 1-Figure 4 The server BMC compatibility method and device of the present invention are described.
[0030] Figure 1 It is one of the flow charts of the server BMC compatibility method provided by the present invention, such as Figure 1 As shown, the method includes steps 101 to 105.
[0031] Step 101: Obtain a server BMC compatible request carrying request data, and parse the request data to obtain request information.
[0032] It should be noted that the execution subject of the present invention may be a server BMC management tool.
[0033] See also Figure 2 , Figure 2The present invention provides a schematic diagram of the structure of the server BMC management tool. The server BMC management tool includes a web (world wide web, global wide area network) request processing module, a request parsing module, a storage module, a server BMC function template, a server BMC management data set, a code generation module, a data set integration module, a parameter conversion module, and a test module.
[0034] In actual applications, the server BMC management tool may be started first to enable the web request processing module of the server BMC management tool to capture web requests, that is, server BMC compatible requests.
[0035] The functions of the web request processing module include capturing and saving web requests. When a new model needs to be compatible, the machine of that model needs to be found. Generally, the server BMC can manage the BMC on the web page through the BMC IP address, and the functions of managing the BMC through the BMC web are all developed by the original manufacturer, so the functions included are the most comprehensive and accurate. Therefore, if the request of the BMC web can be captured, the interface information obtained is the most accurate. The web request processing module is responsible for capturing web request information and response information, and storing the captured web request information in the storage module.
[0036] Specifically, the user logs in to the BMC web page of the machine to be compatible on the web, clicks on the web page according to the function to be compatible, enters the corresponding parameters in the content to be set, and then saves, until all the functions to be compatible have been accessed, and exits the BMC web, that is, a web request is generated. Correspondingly, the web request processing module captures the BMC web request, and then saves the request data carried by the web request to the storage module. The request data is the input parameters.
[0037] Furthermore, the request parsing module of the server BMC management tool obtains the request data from the storage module, parses the request data, obtains the request information, and saves it to the storage module. The request information may include a request URL (Uniform Resource Locator), a request header, a request type, request parameters, and a return parameter.
[0038] Among them, the request parsing module is responsible for parsing web request information and response information, parsing the request data into request URL, request header, request type, request parameters and return parameters, and saving them to the storage module.
[0039] Step 102: Generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain the target function associated with the request information.
[0040] Specifically, see Figure 2 The code generation module in the server BMC management tool generates an initial data object based on the parsed data, that is, the request information. The initial data object includes the data object R (first data object) of the request parameter and the data object P (second data object) of the return parameter, as well as the request method. If the generated request method is a method of the acquisition class, the return parameter of the request method is the data object P of the return parameter; if the generated request method is a method of the setting class, the generated request method needs to have an input parameter, the parameter is the data object R of the request parameter, and the return information is the status code of the request, so that it is convenient to judge whether the request is successful based on the status code later.
[0041] The code generation module is used to generate a data object R of request parameters and a data object P of return parameters in a web request, and to generate a request calling method (request method) according to the data object R, data object P, request URL, request header and request type.
[0042] Furthermore, the data set integration module matches each initial function in the server BMC function template with the parsed request information stored in the storage module to obtain the correspondence between the initial function in the server BMC function template and the BMC web request, that is, the target function associated with the request information.
[0043] Specifically, the server BMC function template is used to define the functions that the server BMC management tool needs to be compatible with, as well as the data object class corresponding to each function. The data object class is stored in the server BMC management data set. For example, the function of obtaining CPU (Central Processing Unit) information defines its function name as getCPU, defines keywords such as CPU, processors, proc, etc., and defines the function type as an acquisition class or a setting class for function matching in subsequent operations; the corresponding data object class is CPUBean, which is used for field matching with the information obtained in subsequent requests.
[0044] Step 103: Match the initial data object with the properties of the target data object corresponding to the target function to obtain the target property associated with the initial data object.
[0045] In actual applications, after determining the target function, the data set integration module can compare the data objects again. That is, the data set integration module matches the attributes of the target data object corresponding to the target function in the server BMC management data set with the initial data object, thereby obtaining the association relationship between the data object in the server BMC management data set and the data object R of the request parameter and the data object P of the request parameter, and the association relationship between the attributes, that is, the target attribute associated with the initial data object.
[0046] Among them, the server BMC management data set is a set of pre-defined data storage objects. Although the URLs and parameters of server BMCs may be different for different manufacturers, the functions they implement are similar. Therefore, in order to achieve unified management of servers of different manufacturers and models, a set of common data object classes needs to be defined. For example, the CPU information data object contains fields such as CPU number, model, CPU current speed, maximum speed, number of cores, number of threads, first-level cache, second-level cache, and third-level cache. The CPU information obtained by the manufacturer's server will contain these fields. Because the CPU can be written in many ways, the common prefix keywords of the CPU information data object are defined, such as cpu, processors, and proc; and keywords are defined for each field, such as CPU number, keywords are id, index, etc.; model keywords are name and model; CPU current speed keywords are current_speed and speed; maximum speed keywords are max_speed and max_speed_mhz. And so on, define the keywords of all fields. If it is a memory information data object, define mem and memmory as prefix keywords. If it is a user information data object, it will contain fields such as user name, user password, user authority, whether to enable, etc. This data object can be used to process when obtaining user information and configuring user information. This ensures uniformity when managing BMC.
[0047] Step 104: Generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy.
[0048] In practical applications, see Figure 2 The code generation module in the server BMC management tool generates the corresponding function implementation method according to the association relationship, that is, according to the target function associated with the request information and the target attribute associated with the initial data object. At this point, the function implementation method is successfully generated, that is, the function implementation strategy is generated.
[0049] Specifically, the code generation module generates a corresponding function implementation method according to the above association relationship, and the function name in the server BMC function template is used as the method name. If it is an acquisition class method, the corresponding request method is called in the function implementation method, and after obtaining the return value (the data object P of the return parameter), it is converted according to the return data object and the data object corresponding to the corresponding function of the server BMC function template, and finally returns the data object defined in the server BMC management data set; if it is a setting class method, the data object R of the request parameter is used as the input parameter of the method, and the data object corresponding to the corresponding function of the server BMC function template and the request data object are converted in the implementation method, and then the corresponding request method is called to obtain the return result, and then the returned status code is judged, and the execution success or failure is returned according to the status code.
[0050] In order to verify whether the generated function implementation method is effective, a regression test is required to call the parameter conversion module in the server BMC management tool to convert the data in the request parameter into the parameters of the data object corresponding to the corresponding function of the server BMC function template according to the corresponding relationship between the data object corresponding to the corresponding function of the server BMC function template and the data object R of the request parameter. That is, the parameters of the initial data object in the function implementation strategy are replaced with the parameters of the target data object through the parameter conversion module to obtain the updated function implementation strategy.
[0051] The parameter conversion module is used to convert the data in the request parameter into the parameter of the data object corresponding to the corresponding function of the server BMC function template according to the corresponding relationship between the data object corresponding to the corresponding function of the server BMC function template and the request data.
[0052] Step 105: When the regression test of the updated function implementation strategy is successful, the compatibility of the server BMC corresponding to the server BMC compatibility request is completed.
[0053] In practical applications, see Figure 2 The test module is responsible for generating unit test scripts based on the generated function methods and the corresponding function parameter data objects, that is, the updated function implementation strategy, and performing regression tests on the generated functions. If the regression test passes, all function implementation methods are encapsulated into a large implementation class, and the compatibility of the new model (server BMC) is completed.
[0054] The server BMC compatibility method provided by the present invention can quickly and accurately achieve server BMC compatibility by acquiring and parsing the web request of the server BMC, and can also perform regression testing on the compatible script at the same time. It does not rely on the BMC interface document and the BMC redfish interface, but relies on requests that can already run correctly for compatibility development, which can ensure that all compatibilities are accurate and available; it is developed based on the original BMC web request, and its compatible functions are more comprehensive; it can be generated through code, and there is little manual intervention, which can greatly improve the compatibility efficiency of the server BMC and save labor costs.
[0055] Optionally, the request information includes a request URL, request parameters and return parameters; the initial data object includes a first data object and a second data object; The generating of the initial data object according to the request information, and matching the request information with each initial function in the server BMC function library to obtain the target function associated with the request information includes: Generate, according to the request information, a first data object corresponding to the request parameter and a second data object corresponding to the return parameter; For each initial function in the server BMC function library, determining a first similarity between the request URL and a keyword of the initial function; An initial function corresponding to a first target similarity is determined as a target function corresponding to the request information, wherein the first target similarity is a first similarity greater than a similarity threshold.
[0056] Specifically, the server BMC function library is the server BMC function template.
[0057] In actual applications, the code generation module generates a data object R of the request parameter and a data object P of the return parameter, that is, a first data object and a second data object, according to the request information.
[0058] Furthermore, the data set integration module may perform matching according to each initial function in the server BMC function template and the request URL stored in the storage module to obtain a first similarity between the request URL and a keyword of each initial function.
[0059] Specifically, the data set integration module determines whether the keywords of the request URL and the initial function can match, that is, when the first similarity is greater than the similarity threshold, it is considered that the two have the same meaning, that is, they can match. The similarity threshold can be adjusted according to the actual comparison situation, such as 0.9, 0.92, 0.95, etc. Further, the initial function corresponding to the matched keyword is used as the target function. In this way, the efficiency and accuracy of determining the target function can be improved.
[0060] Optionally, the request information further includes a request type; the matching of the initial data object with the attribute of the target data object corresponding to the target function to obtain the target attribute associated with the initial data object includes: In a case where the request type is an acquisition type, determining the second data object as a designated data object; In a case where the request type is a setting type, determining the first data object as a designated data object; For each attribute of the target data object corresponding to the target function, calculating a second similarity between the designated data object and the attribute; An attribute corresponding to a second target similarity is determined as a target attribute associated with the initial data object, wherein the second target similarity is a second similarity greater than a similarity threshold.
[0061] In actual applications, the data set integration module first divides requests into acquisition and setting types according to the request type. The request type of GET is the acquisition type (acquisition type), and the request types of PSOT, PUT, PATCH, and DELETE are the setting type (setting type). After determining the request type, when the request type is the acquisition type, the second data object is determined as the specified data object; when the request type is the setting type, the first data object is determined as the specified data object. Then, the specified data object is respectively calculated for each attribute of the target data object corresponding to the target function, and the second similarity between the specified data object and each attribute is obtained. Similarly, the attribute whose second similarity is greater than the similarity threshold is determined as the target attribute associated with the initial data object. In this way, the efficiency and accuracy of determining the target attribute can be improved.
[0062] Optionally, determining a first similarity between the request URL and a keyword of the initial function includes: Segment the request URL according to a regular expression to obtain a request word corresponding to the request URL; Determining the number of matching characters between the request word and the keyword of the initial function; Determine whether the number of matching characters is greater than a first set value; If not, determining that the first similarity between the request URL and the keyword of the initial function is a second set value; If so, the first similarity between the request URL and the keyword of the initial function is calculated based on the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of string conversions, where the number of string conversions represents half of the number of times the characters are matched by replacing the order.
[0063] In actual applications, the dataset integration module divides the request URL into a group of words, namely request words, according to regular expressions. The request words are compared with the initial functions of the corresponding function types in the server BMC function template functions. The text similarity is calculated to compare the segmented request words with the keywords in the server BMC function template functions. After the comparison is successful, the data objects are compared. When obtaining a class, the data object corresponding to the corresponding function of the server BMC function template is compared with the request data object. Each attribute in the object is compared cyclically by calculating the text similarity, and the attributes with the same attributes are associated, and finally all associated attributes are found.
[0064] Specifically, the number m of matching characters between the request word s1 and the keyword s2 of the initial function is obtained, and the first set value and the second set value may be 0. Then, the first similarity d is calculated according to the following formula.
[0065]
[0066] Among them, |s1| represents the length of the request word (the length of the first character), |s2| represents the length of the keyword (the length of the first character), and s i represents the i-th string, i is 1 or 2, m represents the number of matching characters, and t is the number of string conversions, that is, the number of string conversions. In this way, the accuracy of the first similarity can be improved.
[0067] Optionally, determining the number of matching characters between the request word and the keyword of the initial function includes: Determine a larger target character length between a first character length of the request word and a second character length of the keyword; Calculating a first ratio of the target character length to a first value; Determine a first difference between the first ratio and the second value as a matching window width; For each character that is the same in the request word and the keyword, determining a first position of the character in the request word and a second position of the character in the keyword; calculating a distance between the first position and the second position; Determining whether the distance is greater than the matching window width; If yes, determining that the character is a target character that matches between the request word and the keyword; If not, determining that the character is a non-target character that does not match the request word and the keyword; The number of the target characters is counted, and the number of the target characters is determined as the number of matching characters between the request word and the keyword of the initial function.
[0068] In practical applications, if the matching distance of two identical characters from s1 and s2 does not exceed the matching window width m, w When the characters are matched, the two characters are considered to be matched. The matching characters determine the number of transpositions, that is, the number of string transformations t. The total number of transpositions that need to be replaced to match divided by two is the size of transpositions t. Specifically, the first value can be 2, and the second value can be 1. Correspondingly, the matching window width m w The calculation formula is as follows.
[0069]
[0070] For example, if s1 = 'speed', s2 = 'maxspeed', that is, the string length of s1 (first character length) is 5, and the string length of s2 (second character length) is 8, then
[0071] Taking s1 and s2 as examples, both strings contain speed, but s1 does not contain max. First, the three characters of max do not match. index_i(str) represents the position index of the character in string i (the first position or the second position).
[0072] index_1(s)=0, index_2(s)=3, the distance between them is 3-0=3, which does not exceed the matching window 3, so the character s is matched.
[0073] index_1(p)=1, index_2(p)=4, the distance between them is 3-0=3, which does not exceed the matching window 3, so the character s is matched.
[0074] index_1(e)=2, index_2(e)=5, the distance between them is 3-0=3, which does not exceed the matching window 3, so the character s is matched.
[0075] index_1(e)=3, index_2(e)=6, the distance between them is 3-0=3, which does not exceed the matching window 3, so the character s is matched.
[0076] index_1(d)=4, index_2(d)=7, the distance between them is 3-0=3, which does not exceed the matching window 3, so the character s is matched.
[0077] The matching string is 'speed', 'speed', so no replacement is needed, so t=0.
[0078] Optionally, calculating the first similarity between the request URL and the keyword of the initial function according to the first character length of the request word, the second character length of the keyword, the number of matching characters, and the number of character string conversions includes: Calculating a second ratio of the number of matching characters to the first character length of the request word, and a third ratio of the number of matching characters to the second character length of the keyword; Calculating a second difference between the number of matching characters and the number of character string conversions, and calculating a fourth ratio of the second difference to the number of matching characters; Adding the second ratio, the third ratio and the fourth ratio to obtain a ratio sum, and calculating a first product of a third value and the ratio sum; Determine whether the request word and the keyword have the same prefix; If it does not exist, the first product is determined as the first similarity between the request URL and the keyword of the initial function; if it exists, the second product of the adjustment constant and the number of characters of the same prefix is calculated, and the third difference between the fourth value and the first product is calculated; the third difference is multiplied by the second product to obtain a third product; the sum of the third product and the first product is determined as the first similarity between the request URL and the keyword of the initial function.
[0079] In practical applications, the third value may be 1 / 3. The calculation formula of the first product Q is as follows.
[0080]
[0081] In order to further improve the accuracy of calculating similarity, it is necessary to determine whether the keywords and request words, that is, the respective character strings, have a common prefix, that is, the same prefix.
[0082] If there is no identical prefix, then
[0083] If there is the same prefix, then d = f(|s1|, |s2| ,m,t )=Q+(Lp(1-Q)), where L is the length of the same prefix of the two character strings, that is, the number of characters in the same prefix, but the longest value does not exceed 4; p is an adjustment constant, but its value cannot be greater than 0.25 to prevent the situation where d is greater than 1.
[0084] For example, s1 = 'num', s2 = 'number', the string length of s1 is 3, and the string length of s2 is 6, then
[0085] Further calculation of d=0.833+(3*0.25(1-0.833))=0.95825 shows that num and number are very similar and can be considered as strings with the same meaning.
[0086] Optionally, before determining the number of matching characters of the request word and the keyword of the initial function, the method further includes: converting each character in the request word and each character in the keyword according to a specified format, where the specified format is any format.
[0087] In actual applications, the formats of keywords and request words may be different, such as CPU, processors, and proc. To prevent uppercase and lowercase letters from affecting the comparison accuracy, keywords and request words can be converted to a specified format of all lowercase letters or a specified format of all uppercase letters.
[0088] It should be noted that the calculation process of the second similarity is similar to the calculation process of the first similarity. Exemplarily, when the keyword comparison is successful, continue to compare the attributes in the data object. First, all the attribute fields are lowercase, and then remove the fields with possible separator characters, such as _, -, etc.; then, determine whether the attribute field to be compared contains the common prefix keyword based on the common prefix defined in the data object. If it does, remove the prefix keyword first to prevent affecting the accuracy of the field pair. A keyword group is defined for each attribute, and the above formula is used to cyclically calculate the similarity between the attribute field to be compared and each keyword in the keyword group. The value with the highest similarity is taken as the similarity of the attribute field, d=max(d1, d2, ...d i ). As above, when the similarity is greater than 0.9, the keywords are considered to be the same and the two fields can be associated together.
[0089] Optionally, when the regression test on the updated function implementation strategy is successful, before completing the compatibility of the server BMC corresponding to the server BMC compatibility request, the method further includes: Generate a test script according to the updated function implementation strategy; Based on the test script, regression test is performed on the function implementation strategy; In the case where the function implementation strategy is of the acquisition type, if there is no abnormality in the calling process of the function implementation strategy and there is data in the returned data object, it is determined that the regression test of the updated function implementation strategy is successful; In the case where the function implementation strategy is of a setting type, if there is no abnormality in the calling process of the function implementation strategy and the returned status code is normal, it is determined that the regression test of the updated function implementation strategy is successful.
[0090] In actual applications, the test module generates a unit test script based on the generated function implementation strategy and the parameterized data object of the corresponding function, that is, the updated function implementation strategy. Then call the unit test script to test the function method. When the function method being tested is of the acquisition type, it is only necessary to determine whether there is an exception in the calling process and whether there is data in the returned data object. If there is data, it means that the generated function method is normal. When the function being tested is a setting class, it is necessary to pass in the parameterized data object generated in the previous step for testing. When there is no exception in the execution process and the returned status code is normal, the generated function method is considered normal.
[0091] Optionally, before generating the function implementation strategy based on the target function and the target attribute, it also includes: displaying the request information and its associated target function, as well as the initial data object and its associated target attribute in the form of key-value pairs, and displaying the request information that is not associated with the target function and the unassociated attributes in the target data object, so that the user can proofread.
[0092] In actual applications, in order to improve the accuracy of server BMC compatibility, a manual marking function can also be added. After determining the target function and target attribute, all corresponding relationships can be manually displayed in the form of key-value pairs. At the same time, there will be no corresponding request and attribute fields displayed. Manually check whether there are any missing functions. If so, the missing functions can be manually associated on the display page.
[0093] Exemplarily, the server BMC management tool is started to open the web request processing module and capture the web request. Log in to the BMC web page of the machine to be compatible on the web, click the web page according to the function to be compatible, enter the corresponding parameters for the content to be set, and then save until all the functions to be compatible have been accessed and exit the BMC web. The web request processing module captures all BMC web requests and then saves all request data to the storage module. The request parsing module obtains the request data from the storage module, parses the request data into the request url, request header, request type, request parameters and return parameters, and saves them to the storage module. The code generation module generates the data object R of the request parameter and the data object P of the return parameter and the request method according to the parsed data. Then the data set integration module matches the parsed web request information stored in the server BMC function template and the storage module. Finally, the corresponding relationship between the function and the BMC web request in the server BMC function template, the association relationship between the data object and the data object R of the request parameter and the data object P of the request parameter in the server BMC management data set, and the association relationship between the attributes are obtained. The code generation module generates the corresponding function implementation method according to the above association relationship. The parameter conversion module is called to convert the data in the request parameter into the parameter of the data object corresponding to the corresponding function of the server BMC function template according to the corresponding relationship between the data object corresponding to the corresponding function of the server BMC function template and the data object R of the request parameter. The test module generates a unit test script based on the generated function method and the parameter data object of the corresponding function. Then the unit test script is called to test the function method. When the function method being tested is an acquisition class, it is only necessary to determine whether there is an exception in the calling process and whether there is data in the returned data object. If there is data, it means that the generated function method is normal. When the function being tested is a setting class, it is necessary to pass in the parameter data object generated in the previous step for testing. When there is no exception in the execution process and the returned status code is normal, the generated function method is considered to be normal. Encapsulate all function methods into a large implementation class to complete the compatibility of the new model.
[0094] The server BMC compatibility method provided by the present invention can quickly and accurately achieve the compatibility of a server BMC by acquiring and parsing the web request of the server BMC, and can also perform regression testing on the compatible script at the same time. Relying on requests that can already run correctly for compatibility development can ensure that all compatibilities are accurate and available; it is developed based on the original BMC web request, and its compatible functions are more comprehensive; it can be generated through code, and there is little manual intervention, which can greatly improve the compatibility efficiency of the server BMC and save labor costs.
[0095] The server BMC compatible device provided by the present invention is described below. The server BMC compatible device described below and the server BMC compatible method described above can be referred to each other.
[0096] Figure 3 Schematic diagram of the structure of the server BMC compatible device provided by the present invention, such as Figure 3 As shown, the server BMC compatible device includes a parsing unit 301 , a matching unit 302 , a generating unit 303 and a compatible unit 304 .
[0097] The parsing unit 301 is configured to obtain a server BMC compatible request carrying request data, and parse the request data to obtain request information; The matching unit 302 is configured to generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; match the initial data object with a property of a target data object corresponding to the target function to obtain a target property associated with the initial data object; The generating unit 303 is configured to generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; The compatibility unit 304 is configured to complete the compatibility of the server BMC corresponding to the server BMC compatibility request when the regression test of the updated function implementation strategy is successful.
[0098] The server BMC compatibility device provided by the present invention can quickly and accurately achieve server BMC compatibility by acquiring and parsing the web request of the server BMC, and can also perform regression testing on the compatible script at the same time. It does not rely on the BMC interface document and the BMC redfish interface, but relies on the requests that can already run correctly for compatibility development, which can ensure that all compatibilities are accurate and available; it is developed based on the original BMC web request, and its compatible functions are more comprehensive; it can be generated through code, and there is little manual intervention, which can greatly improve the compatibility efficiency of the server BMC and save labor costs.
[0099] Optionally, the request information includes a request URL, request parameters and return parameters; the initial data object includes a first data object and a second data object; the matching unit 302 is further configured to: Generate, according to the request information, a first data object corresponding to the request parameter and a second data object corresponding to the return parameter; For each initial function in the server BMC function library, determining a first similarity between the request URL and a keyword of the initial function; An initial function corresponding to a first target similarity is determined as a target function corresponding to the request information, wherein the first target similarity is a first similarity greater than a similarity threshold.
[0100] Optionally, the matching unit 302 is further configured to: Segment the request URL according to a regular expression to obtain a request word corresponding to the request URL; Determining the number of matching characters between the request word and the keyword of the initial function; Determine whether the number of matching characters is greater than a first set value; If not, determining that the first similarity between the request URL and the keyword of the initial function is a second set value; If so, the first similarity between the request URL and the keyword of the initial function is calculated based on the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of string conversions, where the number of string conversions represents half of the number of times the characters are matched by replacing the order.
[0101] Optionally, the matching unit 302 is further configured to: Determine a larger target character length between a first character length of the request word and a second character length of the keyword; Calculating a first ratio of the target character length to a first value; Determine a first difference between the first ratio and the second value as a matching window width; For each character that is the same in the request word and the keyword, determining a first position of the character in the request word and a second position of the character in the keyword; calculating a distance between the first position and the second position; Determining whether the distance is greater than the matching window width; If yes, determining that the character is a target character that matches between the request word and the keyword; If not, determining that the character is a non-target character that does not match the request word and the keyword; The number of the target characters is counted, and the number of the target characters is determined as the number of matching characters between the request word and the keyword of the initial function.
[0102] Optionally, the matching unit 302 is further configured to: Calculating a second ratio of the number of matching characters to the first character length of the request word, and a third ratio of the number of matching characters to the second character length of the keyword; Calculating a second difference between the number of matching characters and the number of character string conversions, and calculating a fourth ratio of the second difference to the number of matching characters; Adding the second ratio, the third ratio and the fourth ratio to obtain a ratio sum, and calculating a first product of a third value and the ratio sum; Determine whether the request word and the keyword have the same prefix; If it does not exist, the first product is determined as the first similarity between the request URL and the keyword of the initial function; if it exists, the second product of the adjustment constant and the number of characters of the same prefix is calculated, and the third difference between the fourth value and the first product is calculated; the third difference is multiplied by the second product to obtain a third product; the sum of the third product and the first product is determined as the first similarity between the request URL and the keyword of the initial function.
[0103] Optionally, the matching unit 302 is further configured to: Each character in the request word and each character in the keyword are converted according to a specified format, where the specified format is any format.
[0104] Optionally, the device further comprises a testing unit configured to: Generate a test script according to the updated function implementation strategy; Based on the test script, regression test is performed on the function implementation strategy; In the case where the function implementation strategy is of the acquisition type, if there is no abnormality in the calling process of the function implementation strategy and there is data in the returned data object, it is determined that the regression test of the updated function implementation strategy is successful; In the case where the function implementation strategy is of a setting type, if there is no abnormality in the calling process of the function implementation strategy and the returned status code is normal, it is determined that the regression test of the updated function implementation strategy is successful.
[0105] Optionally, the device further comprises a display unit configured to: The request information and its associated target function, as well as the initial data object and its associated target attribute are displayed in the form of key-value pairs, and the request information that is not associated with the target function and the unassociated attributes in the target data object are displayed to allow the user to proofread.
[0106] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor (processor) 410, a communication interface (Communications Interface) 420, a memory (memory) 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call the logic instructions in the memory 430 to execute the server BMC compatibility method, which includes: obtaining a server BMC compatibility request carrying request data, and parsing the request data to obtain request information; generating an initial data object according to the request information, and matching the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; matching the initial data object with the attribute of the target data object corresponding to the target function to obtain a target attribute associated with the initial data object; generating a function implementation strategy according to the target function and the target attribute; replacing the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; and completing the compatibility of the server BMC corresponding to the server BMC compatibility request when the regression test of the updated function implementation strategy is successful.
[0107] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0108] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the server BMC compatibility method provided by the above methods, which includes: obtaining a server BMC compatibility request carrying request data, and parsing the request data to obtain request information; generating an initial data object according to the request information, and matching the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; matching the initial data object with the attributes of the target data object corresponding to the target function to obtain the target attribute associated with the initial data object; generating a function implementation strategy according to the target function and the target attribute; replacing the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; and when the regression test of the updated function implementation strategy is successful, completing the compatibility of the server BMC corresponding to the server BMC compatibility request.
[0109] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the server BMC compatibility method provided by the above-mentioned methods, the method comprising: obtaining a server BMC compatibility request carrying request data, and parsing the request data to obtain request information; generating an initial data object based on the request information, and matching the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; matching the initial data object with the attribute of the target data object corresponding to the target function to obtain a target attribute associated with the initial data object; generating a function implementation strategy based on the target function and the target attribute; replacing the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; and completing the compatibility of the server BMC corresponding to the server BMC compatibility request when the regression test of the updated function implementation strategy is successful.
[0110] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A server BMC compatibility method, It is characterized in that include: Obtaining a server BMC compatible request carrying request data, and parsing the request data to obtain request information; Generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; Matching the initial data object with the properties of the target data object corresponding to the target function to obtain the target property associated with the initial data object; Generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; In the case where the regression test of the updated function implementation strategy is successful, the compatibility of the server BMC corresponding to the server BMC compatibility request is completed.
2. The server BMC compatibility method according to claim 1, It is characterized in that The request information includes a request URL, request parameters and return parameters; the initial data object includes a first data object and a second data object; The generating of the initial data object according to the request information, and matching the request information with each initial function in the server BMC function library to obtain the target function associated with the request information includes: Generate, according to the request information, a first data object corresponding to the request parameter and a second data object corresponding to the return parameter; For each initial function in the server BMC function library, determining a first similarity between the request URL and a keyword of the initial function; An initial function corresponding to a first target similarity is determined as a target function corresponding to the request information, wherein the first target similarity is a first similarity greater than a similarity threshold.
3. The server BMC compatibility method according to claim 2, It is characterized in that The determining of a first similarity between the request URL and the keyword of the initial function includes: Segment the request URL according to a regular expression to obtain a request word corresponding to the request URL; Determining the number of matching characters between the request word and the keyword of the initial function; Determine whether the number of matching characters is greater than a first set value; If not, determining that the first similarity between the request URL and the keyword of the initial function is a second set value; If so, the first similarity between the request URL and the keyword of the initial function is calculated based on the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of string conversions, where the number of string conversions represents half of the number of times the characters are matched by replacing the order.
4. The server BMC compatibility method according to claim 3, It is characterized in that The determining the number of matching characters between the request word and the keyword of the initial function includes: Determine a larger target character length between a first character length of the request word and a second character length of the keyword; Calculating a first ratio of the target character length to a first value; Determine a first difference between the first ratio and the second value as a matching window width; For each character that is the same in the request word and the keyword, determining a first position of the character in the request word and a second position of the character in the keyword; calculating a distance between the first position and the second position; Determining whether the distance is greater than the matching window width; If yes, determining that the character is a target character that matches between the request word and the keyword; If not, determining that the character is a non-target character that does not match the request word and the keyword; The number of the target characters is counted, and the number of the target characters is determined as the number of matching characters between the request word and the keyword of the initial function.
5. The server BMC compatibility method according to claim 3 or 4, It is characterized in that The calculating, according to the first character length of the request word, the second character length of the keyword, the number of matching characters and the number of character string conversions, a first similarity between the request URL and the keyword of the initial function comprises: Calculating a second ratio of the number of matching characters to the first character length of the request word, and a third ratio of the number of matching characters to the second character length of the keyword; Calculating a second difference between the number of matching characters and the number of character string conversions, and calculating a fourth ratio of the second difference to the number of matching characters; Adding the second ratio, the third ratio and the fourth ratio to obtain a ratio sum, and calculating a first product of a third value and the ratio sum; Determine whether the request word and the keyword have the same prefix; If it does not exist, the first product is determined as the first similarity between the request URL and the keyword of the initial function; if it exists, the second product of the adjustment constant and the number of characters of the same prefix is calculated, and the third difference between the fourth value and the first product is calculated; the third difference is multiplied by the second product to obtain a third product; the sum of the third product and the first product is determined as the first similarity between the request URL and the keyword of the initial function.
6. The server BMC compatibility method according to claim 3 or 4, It is characterized in that Before determining the number of matching characters between the request word and the keyword of the initial function, the method further includes: Each character in the request word and each character in the keyword are converted according to a specified format, where the specified format is any format.
7. The server BMC compatibility method according to claim 1, It is characterized in that In the case where the regression test of the updated function implementation strategy is successful, before completing the compatibility of the server BMC corresponding to the server BMC compatibility request, it also includes: Generate a test script according to the updated function implementation strategy; Based on the test script, regression test is performed on the function implementation strategy; In the case where the function implementation strategy is of the acquisition type, if there is no abnormality in the calling process of the function implementation strategy and there is data in the returned data object, it is determined that the regression test of the updated function implementation strategy is successful; In the case where the function implementation strategy is of a setting type, if there is no abnormality in the calling process of the function implementation strategy and the returned status code is normal, it is determined that the regression test of the updated function implementation strategy is successful.
8. The server BMC compatibility method according to claim 1, It is characterized in that Before generating a function implementation strategy according to the target function and the target attribute, the method further includes: The request information and its associated target function, as well as the initial data object and its associated target attribute are displayed in the form of key-value pairs, and the request information that is not associated with the target function and the unassociated attributes in the target data object are displayed to allow the user to proofread.
9. A server BMC compatible device, It is characterized in that include: A parsing unit is configured to obtain a server BMC compatible request carrying request data, and parse the request data to obtain request information; A matching unit is configured to generate an initial data object according to the request information, and match the request information with each initial function in the server BMC function library to obtain a target function associated with the request information; match the initial data object with an attribute of a target data object corresponding to the target function to obtain a target attribute associated with the initial data object; A generating unit is configured to generate a function implementation strategy according to the target function and the target attribute; replace the parameters of the initial data object in the function implementation strategy with the parameters of the target data object to obtain an updated function implementation strategy; The compatibility unit is configured to complete the compatibility of the server BMC corresponding to the server BMC compatibility request when the regression test of the updated function implementation strategy is successful.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the server BMC compatibility method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the server BMC compatibility method according to any one of claims 1 to 8 is implemented.
