CN113703781A - Storage system interface generation method and device, electronic equipment and readable storage medium - Google Patents

Storage system interface generation method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN113703781A
CN113703781A CN202110808080.3A CN202110808080A CN113703781A CN 113703781 A CN113703781 A CN 113703781A CN 202110808080 A CN202110808080 A CN 202110808080A CN 113703781 A CN113703781 A CN 113703781A
Authority
CN
China
Prior art keywords
data type
definition file
resource object
file
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110808080.3A
Other languages
Chinese (zh)
Other versions
CN113703781B (en
Inventor
张贵勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110808080.3A priority Critical patent/CN113703781B/en
Publication of CN113703781A publication Critical patent/CN113703781A/en
Application granted granted Critical
Publication of CN113703781B publication Critical patent/CN113703781B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a storage system interface generation method and device, electronic equipment and a readable storage medium. The method comprises the steps of decoupling a basic code, a request processing code and a request execution code which are strongly related to a target interface specification in advance; automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information; automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class; and importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object. The method and the device can efficiently, conveniently and accurately generate the interface of the storage system, and are favorable for rapidly upgrading the interface version.

Description

Storage system interface generation method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for generating a storage system interface, an electronic device, and a readable storage medium.
Background
A storage system generally provides a REST (Representational State Transfer) interface to the outside for managing and monitoring the storage system, and accordingly, a storage user needs to monitor and manage a storage device of the storage system through a monitoring platform based on the REST interface. At present, each storage manufacturer customizes an REST interface according to the characteristics of the storage product, so that URLs (Uniform Resource locators) and data formats of the REST interfaces of the storage manufacturers are different, which is not only beneficial to Uniform management, but also brings about a large amount of development adaptation workload when a storage user develops a monitoring platform based on the REST interface.
The Swordfish is a Storage-oriented REST interface specification which is issued by SNIA (Storage Networking Industry Association) and can be used for monitoring, managing and storing, and provides standard URL (uniform resource locator), data format and Storage management method. If each storage manufacturer realizes the Swordfish interface on the storage system, the storage manufacturer is beneficial to the storage user to dock various storage devices on the monitoring platform based on the Swordfish interface, so that the unified management is convenient, and the development workload can be greatly reduced. Swordfish provides a large number of data format files for describing storage resource objects, and the data format files clearly define the attributes, the data types of attribute values, the operation methods, the parameters of the operation methods, the data types of the operation methods and the like of each storage resource object. The manual coding realizes the Swordfish interface, the workload is large, the error is easy to occur, the debugging is not easy, and the code is not easy to be synchronously upgraded when the Swordfish standard version is upgraded.
In view of this, how to solve the technical disadvantages in the related art that the generation efficiency of the Swordfish interface is not high, an error is easy to occur, and the version of the Swordfish interface is difficult to upgrade is a technical problem to be solved by technical personnel in the field.
Disclosure of Invention
The application provides a storage system interface generation method and device, electronic equipment and a readable storage medium, which can efficiently, conveniently and accurately generate a storage system interface and are beneficial to quickly upgrading the interface version.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
an embodiment of the present invention provides a method for generating an interface of a storage system, including:
decoupling a basic code, a request processing code and a request execution code which are strongly related to a target interface specification in advance;
automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information;
automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class;
and importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object.
Optionally, the automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information includes:
and analyzing the resource object definition file provided by the target interface specification to obtain the data types of the stored resource object name, the attribute and the attribute value, the method parameter and the method parameter value, which contain the version number, and automatically generating a corresponding class file according to an object-oriented programming mode.
Optionally, the automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information includes:
the name and the version number of the storage resource object are used as the name of the resource object type definition file, the resource object type definition file is declared, and if the storage resource object of the current version inherits the resource object definition of the lower version, the inheritance relationship is marked while the storage resource object of the current version is declared;
defining the attribute in the resource object class definition file and the definition file of each data type, and adding an acquisition and setting method of an attribute value corresponding to the attribute;
defining the method and the parameters thereof in the resource object class definition file and the definition file of each data type;
if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file;
and importing the preset data types defined in the predefined class file into the resource object class definition file and the definition file of each data type.
Optionally, if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file, including:
if the data type of the attribute value is a composite type, redefining a first type file for the data type of the attribute value, wherein the definition in the first type file comprises a sub-attribute and a method for acquiring and setting the sub-attribute value;
if the data type of the attribute value is an enumeration type, defining the data type of the attribute value in a predefined enumeration type class definition file;
if the data type of the attribute value is a character string or a numerical value, a verification method is defined for the attribute in the current resource object class definition file so as to verify whether the attribute value is valid.
Optionally, if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file, including:
if the data type of the method parameter value is a composite type, redefining a second type file for the data type of the method parameter value, wherein the definition in the second type file comprises a sub-attribute and a method for acquiring and setting the sub-attribute value;
if the data type of the method parameter value is an enumeration type, defining the data type of the method parameter value in a predefined enumeration type class definition file;
if the data type of the method parameter value is a character string or a numerical value, a verification method is defined in the current resource object class definition file to verify whether the method parameter value is valid.
Optionally, the automatically generating a request processing class definition file according to a correspondence between a pre-constructed URL analytic expression and a request processing class includes:
pre-constructing a URL regular matching library comprising a plurality of regular expressions, wherein each regular expression is used for matching the URL in the request and acquiring variable parameter values in the corresponding URL;
and automatically generating the request processing class definition file by utilizing the URL regular matching library.
Another aspect of the embodiments of the present invention provides a storage system interface generating apparatus, including:
the decoupling module is used for decoupling a basic code, a request processing code and a request execution code which are strongly related to a target interface specification in advance;
the basic file generation module is used for automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information;
the request file generation module is used for automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class;
and the file association module is used for importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object.
Optionally, the system further includes a database construction module, configured to pre-construct a URL regular matching library including a plurality of regular expressions, where each regular expression is used to match a URL in the request and obtain a variable parameter value in the corresponding URL.
An embodiment of the present invention further provides an electronic device, which includes a processor, and the processor is configured to implement the steps of the storage system interface generation method according to any one of the foregoing when executing the computer program stored in the memory.
Finally, an embodiment of the present invention provides a readable storage medium, where a computer program is stored on the readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the storage system interface generation method according to any of the foregoing.
The technical scheme provided by the application has the advantages that when the target interface is realized, the resource object type definition file, the definition file of each data type and the request processing type definition file are automatically generated, the stored resource object is associated with the request, so that the basic frame codes of the target interface are automatically generated, the basic frame codes are realized without manual coding of developers, the development workload can be greatly reduced, the error probability of interface generation caused by manual error is reduced, the interface of the storage system can be efficiently, conveniently and accurately generated, and meanwhile, the version is easy to upgrade to support the target interface specification of the latest version.
In addition, the embodiment of the invention also provides a corresponding implementation device, electronic equipment and a readable storage medium for the storage system interface generation method, so that the method has higher practicability, and the device, the electronic equipment and the readable storage medium have corresponding advantages.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the related art, the drawings required to be used in the description of the embodiments or the related art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a storage system interface generation method according to an embodiment of the present invention;
fig. 2 is a structural diagram of a storage system interface generating apparatus according to an embodiment of the present invention;
fig. 3 is a block diagram of an embodiment of an electronic device according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may include other steps or elements not expressly listed.
Having described the technical solutions of the embodiments of the present invention, various non-limiting embodiments of the present application are described in detail below.
Referring to fig. 1, fig. 1 is a schematic flow chart of a storage system interface generation method according to an embodiment of the present invention, where the embodiment of the present invention may include the following:
s101: and decoupling basic codes and request processing codes which are strongly related to the target interface specification from the request execution codes in advance.
The target interface may be any storage system interface, especially an interface with a large amount of basic code, and the target interface may be a swirdfish interface, for example. The present embodiment divides all codes involved in the target interface generation process into a base code, a request proxy code, and a request execution code. The base code includes class definition code and data type definition code corresponding to the resource object defined by the target interface. The request processing code is used for receiving a request of a client and analyzing a basic format of a verification request parameter, wherein the analysis mainly includes which parameters the request includes, and the verification is used for verifying whether data types corresponding to the parameters are legal or not, for example, whether enumerated data are in a standard range or not, and the like. The request execution code is used for receiving the parameters transmitted by the request processing code and executing a specific command to acquire corresponding storage information or configure storage resources according to the parameter condition. The basic code and the request processing code of this embodiment may be automatically generated based on the subsequent steps S102 and S103, and the request execution code is adapted and completed based on the user, i.e., the developer, invoking the system command or the command library which is constructed in advance according to the actual request execution condition, that is, the request execution code completes the information acquisition of the Swordfish interface or the method execution through the command provided by the system or other interfaces. Correspondingly, responding to the information acquisition command, matching a corresponding data reading command in a pre-constructed instruction library, and acquiring required storage information or the like through a target interface by using the data reading command; and responding to the resource configuration command, matching a corresponding configuration command in a pre-constructed instruction library, and configuring the storage resource through the target interface by using the configuration command.
S102: and automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information.
In this step, the information of the storage resource object includes, but is not limited to, the data type for storing the name, attribute value, method parameter, and method parameter value of the resource object, and correspondingly, the step may be to parse the data type for storing the name, attribute value, method parameter, and method parameter value of the resource object provided by the target interface specification to obtain the data type for storing the resource object name, attribute value, method parameter, and method parameter value, and automatically generate a corresponding class file according to an object-oriented programming manner.
S103: and automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class.
The URL parsing formula is used to match URLs by parsing parameters of URLs (Uniform Resource locators) in the request, and one request processing class is responsible for processing one URL, so that a corresponding request processing class definition file can be automatically generated for the currently received request based on a corresponding relationship between the URL parsing formula and the request processing class. As an optional implementation manner, the corresponding relationship between the URL analytic expression and the request processing class may be constructed by using a regular expression, and a URL regular matching library may be pre-constructed, where the library includes a plurality of regular expressions, and each regular expression is used to match a URL in a request and obtain a variable parameter value in a corresponding URL, that is, the corresponding relationship between the URL analytic expression and the request processing class may be a series of URL regular expressions and class names of corresponding request processing class files. The request processing class definition file can be automatically generated by utilizing the URL regular matching library.
S104: and importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object.
It will be appreciated that a URL parse may be used to match a URL in a request and retrieve variable parameter values in the URL. The request processing class is a class file for receiving requests, and each request processing class file only processes a certain URL request. The request processing class analyzes the parameters in the URL through a URL analytic expression, checks the parameter values, converts the parameters of the composite type and the values thereof into object instances of the corresponding class, and transmits the parameter values to a method for providing the request processing code. The associated storage resource object class is used for being imported into the automatically generated request processing class file, so that the storage resource object class is convenient to use in the class file.
In the technical scheme provided by the embodiment of the invention, when the target interface is realized, the resource object class definition file, the definition file of each data type and the request processing class definition file are automatically generated, and the stored resource object is associated with the request, so that the basic frame codes of the target interface are automatically generated, the basic frame codes are realized without manual coding of developers, the development workload can be greatly reduced, the error probability of interface generation caused by manual error is reduced, the interface of the storage system can be efficiently, conveniently and accurately generated, and meanwhile, the version is easy to upgrade to support the target interface specification of the latest version.
It should be noted that, in the present application, there is no strict sequential execution order among the steps, and as long as the logical order is met, the steps may be executed simultaneously or according to a certain preset order, and fig. 1 is only an exemplary manner, and does not represent that only the execution order is the order.
In the above embodiment, how to execute step S102 is not limited, and a generation manner of the resource object class definition file and the definition file of each data type in this embodiment may include the following steps:
a1: and if the storage resource object of the current version inherits the resource object definition of a lower version, marking an inheritance relationship at the same time of the declaration.
In the step, the analyzed resource object name and the version number thereof are used as the name of the automatically generated class file, and the class is declared in the class file; if the resource object of the current version inherits from the resource object definition of the lower version, the inheritance relationship needs to be labeled according to the object-oriented programming mode when the class is declared,
a2: defining attributes in the definition file of the resource object class and the definition file of each data type, and adding an acquisition and setting method of attribute values corresponding to the attributes.
In the step, the analyzed attributes are defined in a class file according to an object-oriented programming mode, and an acquisition and setting method of attribute values is added; for the data type of the attribute, the processing can be performed according to the method shown in A4.
A3: the method and its parameters are defined in the definition file of the resource object class and the definition file of each data type.
In this step, the parsed method and its parameters are defined in a class file according to an object-oriented programming mode, and the method name in the class definition is the same as the method name in the resource definition file. The data type of the method parameter may be automatically generated according to the method shown in a 4.
A4: and if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file.
The preset data type may be, for example, a composite type or an enumerated type, and a person skilled in the art may select the preset data type according to the actual situation, and the predefined class file is a class file for defining the preset data type.
A5: and importing the preset data types defined in the predefined class file into the resource object class definition file and the definition file of each data type.
The foregoing embodiment does not limit the data type processing method, and the present application also provides an implementation manner by taking the data type of the attribute value and the data type of the method parameter value as examples, and may include:
a410: and if the data type of the attribute value is a composite type, redefining the data type of the attribute value into a first type file, wherein the definition in the first type file comprises the sub-attribute and a method for acquiring and setting the sub-attribute value.
The composite type is that a plurality of sub-attribute combinations represent a data type, if the data type of the attribute value is the composite type, a class file is redefined for the data type, and the definition in the class file comprises the sub-attribute and the acquisition and setting method of the sub-attribute value. The first class file is only for distinguishing the predefined class file from the second class file, and is essentially the predefined class file in the above embodiment for defining the data type of the attribute value.
A420: and if the data type of the attribute value is an enumeration type, defining the data type of the attribute value in a predefined enumeration type class definition file.
The enumeration type contains a plurality of fixed values, of which 1 attribute value is taken. An enumeration type class definition file is dedicated to defining each enumeration type. If the data type of the attribute value is an enumerated type, the data type can be defined in an enumerated type class definition file according to an object-oriented programming mode.
A430: if the data type of the attribute value is a character string or a numerical value, a verification method is defined for the attribute in the current resource object class definition file so as to verify whether the attribute value is valid.
If the data type of the attribute value is a basic type or an enumeration type such as a character string, a numerical value and the like, a verification method is defined for the attribute in the current resource object class definition file to verify whether the attribute value is valid. The validation method uses the character string regular expression, the numerical value range and the enumeration value range defined in the resource definition file to carry out validity validation.
A411: and if the data type of the method parameter value is a composite type, redefining a second type file according to the data type of the method parameter value, wherein the definition in the second type file comprises the acquisition and setting methods of the sub-attribute and the sub-attribute value.
The second class file is only used to distinguish the predefined class file from the first class file, and is essentially the predefined class file in the above embodiments for defining the data type of the parameter value of the method.
A421: and if the data type of the method parameter value is an enumeration type, defining the data type of the method parameter value in a predefined enumeration type class definition file.
A431: if the data type of the method parameter value is a character string or a numerical value, a verification method is defined in the current resource object class definition file to verify whether the method parameter value is valid.
For the data types of the composite type in a410 and a411, it can be understood that, because the composite type includes a plurality of sub-attributes, if the data type corresponding to the sub-attribute value is the composite type, the corresponding sub-attribute value is processed according to a410 and a 411.
In order to make the technical solutions of the present application more clearly understood by those skilled in the art, the present application also uses the target interface as a Swordfish interface as an example, and describes an automatic generation method of the Swordfish interface, which may include the following contents:
the implementation framework of the Swordfish interface is firstly divided into three parts, namely basic code, request processing code and request execution code. The base code includes class definition code and data type definition code corresponding to the resource object defined by the Swordfish. The request processing code is used for receiving a request of the client and analyzing a basic format of the verification request parameter, mainly the data type of the verification request parameter. The request execution code is used for receiving the parameters transmitted by the request processing code and executing a specific command to acquire corresponding storage information or configure storage resources according to the parameter condition.
In this embodiment, a Swordfish resource object definition analysis module, a Swordfish resource object class definition generation module, a URL regular matching library, a request processing class relationship module, and a request processing class definition generation module are pre-constructed. The Swordfish resource object definition analysis module is used for analyzing a Swordfish resource object definition file to obtain the attribute, the method and the method parameter of each resource object and the data type related to the attribute value and the method parameter value; the Swordfish resource object class definition generating module: automatically generating a class definition code file of the resource object by analyzing the resource object definition file provided by the Swordfish specification; analyzing the data type definition in each resource object definition file to generate a corresponding data type definition code file; the URL regular matching library and the request processing class relation module comprise a series of URL regular expressions and class names of corresponding request processing class files. And the request processing class definition generating module is used for automatically generating a request processing class definition file according to the URL regular matching library and the request processing class relation. The developer only needs to pay attention to the adaptation of the code required to be executed, namely how to complete the information acquisition or method execution of the Swordfish interface through the command or other interfaces provided by the system.
Wherein the request processing class definition generating module is further operable to: and defining the corresponding relation among a URL regular matching library, a request processing class and an associated Swordfish resource object class. The URL regular matching library is a series of regular expressions used for matching the URL in the request and obtaining the variable parameter values in the URL. The request processing class is a class file for receiving requests, and each request processing class file only processes a certain URL request. The request processing class analyzes the parameters in the URL through the URL regular expression, checks the parameter values, converts the parameters of the composite type and the values thereof into the object instances of the corresponding class, and transmits the parameter values to the method for providing the request processing code. The associated Swordfish resource object class is used for being imported into an automatically generated request processing class file, so that the application in the class file is facilitated.
By way of example, in JSON, the computer program corresponding to the basic framework code required to implement the Swordfish interface may be:
Figure BDA0003167154910000121
therefore, the embodiment of the invention realizes the automatic generation of the basic framework code required by realizing the Swordfish interface, reduces the development workload, and is easy to upgrade the version to support the Swordfish specification of the latest version.
The embodiment of the invention also provides a corresponding device for the storage system interface generation method, so that the method has higher practicability. Wherein the means can be described separately from the functional module point of view and the hardware point of view. In the following, the storage system interface generation apparatus provided by the embodiment of the present invention is introduced, and the storage system interface generation apparatus described below and the storage system interface generation method described above may be referred to correspondingly.
Based on the angle of the functional module, referring to fig. 2, fig. 2 is a structural diagram of a storage system interface generating apparatus according to an embodiment of the present invention, in a specific implementation manner, where the apparatus may include:
a decoupling module 201, configured to decouple a basic code, a request processing code, and a request execution code, which are strongly related to a target interface specification, in advance;
a basic file generation module 202, configured to automatically generate a resource object class definition file and a definition file of each data type according to information of each storage resource object obtained by parsing a resource object definition file of a target interface and a data type corresponding to each information;
the request file generation module 203 is configured to automatically generate a request processing class definition file according to a pre-constructed correspondence between the URL parsing formula and the request processing class;
the file association module 204 is configured to import the resource object class definition file and the definition file of each data type into the request processing class definition file based on a pre-constructed URL parsing formula, a correspondence between the request processing class and the storage resource object.
Optionally, in some embodiments of this embodiment, the basic file generating module 202 may be configured to: and analyzing the resource object definition file provided by the target interface specification to obtain the data types of the stored resource object name, the attribute and the attribute value, the method parameter and the method parameter value, which contain the version number, and automatically generating a corresponding class file according to an object-oriented programming mode.
As an optional implementation manner of the foregoing embodiment, the basic file generating module 202 may be further configured to: the name and the version number of the storage resource object are used as the name of the resource object type definition file, the resource object type definition file is declared, and if the storage resource object of the current version inherits the resource object definition of the lower version, the inheritance relationship is marked while the storage resource object of the current version is declared; defining attributes in the resource object class definition file and the definition file of each data type, and adding an acquisition and setting method of attribute values corresponding to the attributes; defining methods and parameters thereof in a resource object class definition file and definition files of various data types; if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file; and importing the preset data types defined in the predefined class file into the resource object class definition file and the definition file of each data type.
As another optional implementation manner of the foregoing embodiment, the basic file generating module 202 may include an attribute value data type processing unit and a parameter value data type processing unit;
the attribute value data type processing unit is used for redefining the data type which is the attribute value into a first type file if the data type of the attribute value is a composite type, wherein the definition in the first type file comprises the sub-attribute and the acquisition and setting method of the sub-attribute value; if the data type of the attribute value is an enumeration type, defining the data type of the attribute value in a predefined enumeration type definition file; if the data type of the attribute value is a character string or a numerical value, a verification method is defined for the attribute in the current resource object class definition file so as to verify whether the attribute value is valid.
If the data type of the method parameter value is a composite type, the parameter value data type processing unit redefines a second type file of the data type of the method parameter value, wherein the definition in the second type file comprises a sub-attribute and a method for acquiring and setting the sub-attribute value; if the data type of the method parameter value is an enumeration type, defining the data type of the method parameter value in a predefined enumeration type definition file; if the data type of the method parameter value is a character string or a numerical value, a verification method is defined in the current resource object class definition file to verify whether the method parameter value is valid.
Optionally, in another implementation manner of this embodiment, the apparatus may further include a database construction module, for example, configured to pre-construct a URL regular matching library including a plurality of regular expressions, where each regular expression is used to match a URL in the request and obtain a variable parameter value in the corresponding URL.
Correspondingly, as an optional implementation manner of this embodiment, the request file generating module 203 may be further configured to: and automatically generating a request processing class definition file by using a URL regular matching library.
The functions of each functional module of the storage system interface generating device according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
Therefore, the embodiment of the invention not only can efficiently, conveniently and accurately generate the interface of the storage system, but also is beneficial to quickly upgrading the interface version.
The storage system interface generating apparatus mentioned above is described from the perspective of functional modules, and further, the present application also provides an electronic device described from the perspective of hardware. Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 3, the electronic device comprises a memory 30 for storing a computer program; a processor 31, configured to implement the steps of the storage system interface generation method according to any one of the above embodiments when executing the computer program.
The processor 31 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the processor 31 may also be a controller, a microcontroller, a microprocessor or other data processing chip, and the like. The processor 31 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 31 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 31 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed by the display screen. In some embodiments, the processor 31 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
Memory 30 may include one or more computer-readable storage media, which may be non-transitory. Memory 30 may also include high speed random access memory as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. The memory 30 may in some embodiments be an internal storage unit of the electronic device, for example a hard disk of a server. The memory 30 may also be an external storage device of the electronic device in other embodiments, such as a plug-in hard disk provided on a server, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 30 may also include both an internal storage unit and an external storage device of the electronic device. The memory 30 can be used for storing various data and application software installed in the electronic device, such as: the code of the program that executes the vulnerability handling method, etc. may also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 30 is at least used for storing the following computer program 301, wherein after being loaded and executed by the processor 31, the computer program can implement the relevant steps of the storage system interface generation method disclosed in any of the foregoing embodiments. In addition, the resources stored by the memory 30 may also include an operating system 302, data 303, and the like, and the storage may be transient storage or permanent storage. Operating system 302 may include Windows, Unix, Linux, etc. Data 303 may include, but is not limited to, data corresponding to results generated by a storage system interface, and the like.
In some embodiments, the electronic device may further include a display 32, an input/output interface 33, a communication interface 34 or network interface, a power source 35, and a communication bus 36. The display 32 and the input/output interface 33, such as a Keyboard (Keyboard), belong to a user interface, and the optional user interface may also include a standard wired interface, a wireless interface, and the like. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, as appropriate, is used for displaying information processed in the electronic device and for displaying a visualized user interface. The communication interface 34 may optionally include a wired interface and/or a wireless interface, such as a WI-FI interface, a bluetooth interface, etc., typically used to establish a communication connection between an electronic device and other electronic devices. The communication bus 36 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.
Those skilled in the art will appreciate that the configuration shown in fig. 3 is not intended to be limiting of the electronic device and may include more or fewer components than those shown, such as a sensor 37 to perform various functions.
The functions of the functional modules of the electronic device according to the embodiments of the present invention may be specifically implemented according to the method in the above method embodiments, and the specific implementation process may refer to the description related to the above method embodiments, which is not described herein again.
Therefore, the embodiment of the invention not only can efficiently, conveniently and accurately generate the interface of the storage system, but also is beneficial to quickly upgrading the interface version.
It is to be understood that, if the storage system interface generating method in the above embodiments is implemented in the form of a software functional unit and sold or used as a stand-alone product, it may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application may be substantially or partially implemented in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the methods of the embodiments of the present application, or all or part of the technical solutions. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), an electrically erasable programmable ROM, a register, a hard disk, a multimedia card, a card type Memory (e.g., SD or DX Memory, etc.), a magnetic Memory, a removable magnetic disk, a CD-ROM, a magnetic or optical disk, and other various media capable of storing program codes.
Based on this, the embodiment of the present invention further provides a readable storage medium, which stores a computer program, and the computer program is executed by a processor, and the steps of the storage system interface generation method according to any one of the above embodiments are provided.
The functions of the functional modules of the readable storage medium according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the description related to the foregoing method embodiment, which is not described herein again.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. For hardware including devices and electronic equipment disclosed by the embodiment, the description is relatively simple because the hardware includes the devices and the electronic equipment correspond to the method disclosed by the embodiment, and the relevant points can be obtained by referring to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The above detailed description is provided for a storage system interface generation method, apparatus, electronic device and readable storage medium provided by the present application. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present application.

Claims (10)

1. A storage system interface generation method is characterized by comprising the following steps:
decoupling a basic code, a request processing code and a request execution code which are strongly related to a target interface specification in advance;
automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information;
automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class;
and importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object.
2. The method for generating an interface of a storage system according to claim 1, wherein the automatically generating a definition file of a resource object class and a definition file of each data type according to information of each storage resource object obtained by parsing a definition file of a resource object of the target interface and a data type corresponding to each information comprises:
and analyzing the resource object definition file provided by the target interface specification to obtain the data types of the stored resource object name, the attribute and the attribute value, the method parameter and the method parameter value, which contain the version number, and automatically generating a corresponding class file according to an object-oriented programming mode.
3. The method for generating an interface of a storage system according to claim 2, wherein the automatically generating a definition file of a resource object class and a definition file of each data type according to information of each storage resource object obtained by parsing a definition file of a resource object of the target interface and a data type corresponding to each information comprises:
the name and the version number of the storage resource object are used as the name of the resource object type definition file, the resource object type definition file is declared, and if the storage resource object of the current version inherits the resource object definition of the lower version, the inheritance relationship is marked while the storage resource object of the current version is declared;
defining the attribute in the resource object class definition file and the definition file of each data type, and adding an acquisition and setting method of an attribute value corresponding to the attribute;
defining the method and the parameters thereof in the resource object class definition file and the definition file of each data type;
if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file;
and importing the preset data types defined in the predefined class file into the resource object class definition file and the definition file of each data type.
4. The storage system interface generation method according to claim 3, wherein if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file includes:
if the data type of the attribute value is a composite type, redefining a first type file for the data type of the attribute value, wherein the definition in the first type file comprises a sub-attribute and a method for acquiring and setting the sub-attribute value;
if the data type of the attribute value is an enumeration type, defining the data type of the attribute value in a predefined enumeration type class definition file;
if the data type of the attribute value is a character string or a numerical value, a verification method is defined for the attribute in the current resource object class definition file so as to verify whether the attribute value is valid.
5. The storage system interface generation method according to claim 3, wherein if the data type of the attribute value and the data type of the method parameter value are preset data types, defining the data type of the attribute value and the data type of the method parameter value in a predefined class file includes:
if the data type of the method parameter value is a composite type, redefining a second type file for the data type of the method parameter value, wherein the definition in the second type file comprises a sub-attribute and a method for acquiring and setting the sub-attribute value;
if the data type of the method parameter value is an enumeration type, defining the data type of the method parameter value in a predefined enumeration type class definition file;
if the data type of the method parameter value is a character string or a numerical value, a verification method is defined in the current resource object class definition file to verify whether the method parameter value is valid.
6. The storage system interface generation method according to any one of claims 1 to 5, wherein automatically generating a request processing class definition file according to a correspondence between a pre-constructed URL analytic expression and a request processing class includes:
pre-constructing a URL regular matching library comprising a plurality of regular expressions, wherein each regular expression is used for matching the URL in the request and acquiring variable parameter values in the corresponding URL;
and automatically generating the request processing class definition file by utilizing the URL regular matching library.
7. A storage system interface generation apparatus, comprising:
the decoupling module is used for decoupling a basic code, a request processing code and a request execution code which are strongly related to a target interface specification in advance;
the basic file generation module is used for automatically generating a resource object class definition file and a definition file of each data type according to the information of each storage resource object obtained by analyzing the resource object definition file of the target interface and the data type corresponding to each information;
the request file generation module is used for automatically generating a request processing class definition file according to the corresponding relation between the pre-constructed URL analytic expression and the request processing class;
and the file association module is used for importing the resource object class definition file and the definition file of each data type into the request processing class definition file based on the corresponding relation between the pre-constructed URL analytic expression and the request processing class and the storage resource object.
8. The storage system interface generation apparatus according to claim 7, further comprising a database construction module configured to pre-construct a URL regular matching library including a plurality of regular expressions, each regular expression being configured to match a URL in a request and obtain a variable parameter value in the corresponding URL.
9. An electronic device comprising a processor and a memory, the processor being configured to implement the steps of the storage system interface generation method according to any one of claims 1 to 6 when executing a computer program stored in the memory.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the storage system interface generation method according to any one of claims 1 to 6.
CN202110808080.3A 2021-07-16 2021-07-16 Storage system interface generation method and device, electronic equipment and readable storage medium Active CN113703781B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110808080.3A CN113703781B (en) 2021-07-16 2021-07-16 Storage system interface generation method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110808080.3A CN113703781B (en) 2021-07-16 2021-07-16 Storage system interface generation method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN113703781A true CN113703781A (en) 2021-11-26
CN113703781B CN113703781B (en) 2023-07-21

Family

ID=78648756

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110808080.3A Active CN113703781B (en) 2021-07-16 2021-07-16 Storage system interface generation method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN113703781B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114116730A (en) * 2022-01-21 2022-03-01 深圳微迅信息科技有限公司 Interface management method, device, equipment and storage medium
CN114297541A (en) * 2021-12-27 2022-04-08 中国民航信息网络股份有限公司 Data processing method and device based on NDC standard
CN115174394A (en) * 2022-06-30 2022-10-11 济南浪潮数据技术有限公司 Storage data acquisition method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061464A (en) * 2019-11-24 2020-04-24 济南浪潮数据技术有限公司 Analysis code generation method, device, equipment and storage medium
CN111258563A (en) * 2020-01-16 2020-06-09 江苏满运软件科技有限公司 Interface document generation method and device, storage medium and electronic equipment
CN111694613A (en) * 2020-05-29 2020-09-22 平安科技(深圳)有限公司 Decoupling method between application program modules, electronic device and storage medium
CN112306549A (en) * 2020-10-30 2021-02-02 康键信息技术(深圳)有限公司 Interface document configuration method, device, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061464A (en) * 2019-11-24 2020-04-24 济南浪潮数据技术有限公司 Analysis code generation method, device, equipment and storage medium
CN111258563A (en) * 2020-01-16 2020-06-09 江苏满运软件科技有限公司 Interface document generation method and device, storage medium and electronic equipment
CN111694613A (en) * 2020-05-29 2020-09-22 平安科技(深圳)有限公司 Decoupling method between application program modules, electronic device and storage medium
CN112306549A (en) * 2020-10-30 2021-02-02 康键信息技术(深圳)有限公司 Interface document configuration method, device, equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114297541A (en) * 2021-12-27 2022-04-08 中国民航信息网络股份有限公司 Data processing method and device based on NDC standard
CN114116730A (en) * 2022-01-21 2022-03-01 深圳微迅信息科技有限公司 Interface management method, device, equipment and storage medium
CN115174394A (en) * 2022-06-30 2022-10-11 济南浪潮数据技术有限公司 Storage data acquisition method, device, equipment and medium
CN115174394B (en) * 2022-06-30 2023-09-22 济南浪潮数据技术有限公司 Storage data acquisition method, device, equipment and medium

Also Published As

Publication number Publication date
CN113703781B (en) 2023-07-21

Similar Documents

Publication Publication Date Title
CN113703781B (en) Storage system interface generation method and device, electronic equipment and readable storage medium
CN109976761B (en) Software development kit generation method and device and terminal equipment
EP3433732B1 (en) Converting visual diagrams into code
CN109683953B (en) Method and device for processing configuration file based on visual interface
EP2530583A1 (en) Computer-implemented method, system and computer program product for displaying a user interface component
US10855533B2 (en) System, a cloud platform, a device and a method for configuring edge devices
CN112118286B (en) Multi-thread link tracking method and device based on MDC and computer readable storage medium
CN113342590B (en) NVMe device debugging function implementation method, device, equipment and storage medium
CN111061464B (en) Analysis code generation method, device, equipment and storage medium
CN112559354A (en) Front-end code specification detection method and device, computer equipment and storage medium
CN112527459B (en) Log analysis method and device based on Kubernetes cluster
CN111290802B (en) Information analysis method and device for BMC internal device and readable storage medium
CN111475175B (en) Method, device and medium for installing and guiding operation system based on ARM server
CN112214256B (en) Machine learning operation control method and device, electronic equipment and storage medium
CN113259480B (en) Twin synchronization method based on configuration, Internet of things system and equipment and storage medium
CN111831277B (en) Virtual data generation method, system, device and computer readable storage medium
CN113849229A (en) Server starting method and device, electronic equipment and readable storage medium
CN112905931B (en) Page information display method and device, electronic equipment and storage medium
CN111258628A (en) Rule file comparison method and device, readable storage medium and terminal equipment
CN113703852B (en) Out-of-band management method and device of server, electronic equipment and readable storage medium
CN114818656B (en) Binary file analysis method, device, equipment and medium based on gray scale upgrading
CN112256237B (en) Operating system customization method, customization system, electronic device and customization resource file
CN110413644B (en) Data caching method, electronic device and computer readable storage medium
CN117931174A (en) Software package validation method and device, target electronic equipment and computer storage medium
CN118132411A (en) POJO unit test code generation method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant