A technical framework expansion query method based on Openstack4j
By extending the query methods of OpenStack4j and using variable-length arrays to pass parameters and array concatenation request bodies, the lack of flexibility in port list queries in existing technologies is solved, achieving more efficient multi-value filtering and operational flexibility.
Patent Information
- Application Number
- CN202010868502.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-26
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-08-26
AI Technical Summary
The existing OpenStack4j SDK cannot effectively use variable parameters for filtering when querying the Port list, resulting in inconvenient operation and insufficient flexibility.
By creating an entity class that passes values as input parameters using a variable-length array, extending the query method, constructing a request body by concatenating arrays, and calling OpenStack4j to obtain the permission client, multi-value passing and filtering are achieved.
Improved the ease of using combined filtering parameters when querying the Port list, and enhanced the flexibility and scalability of operating the OpenStack underlying layer.
Smart Images

Figure CN112035098B
Abstract
Description
Technical Field
[0001] The invention discloses an extended query method, and relates to the technical field of cloud platforms, in particular to an extended query method based on the technical framework of Openstack4j. Background Art
[0002] The current use of cloud computing is generally based on the underlying architecture of openstack, and upper-layer applications such as cloud platforms require SDKs to improve R&D efficiency and perform related component operations on openstack. Openstack4j is an open source Java development tool. Its class library can be used to easily operate and manage Openstack system components, including virtual machines, networks, storage and other resources. It is implemented through the RESTful API method.
[0003] However, when using the interface provided by openstack4j to query the Port list, it is often found that it is inconvenient to use parameters for filtering, that is, it is impossible to use variable parameters such as status and fixed_ips, nor is it possible to use array parameters for combined filtering. Summary of the invention
[0004] Aiming at the problem that the methods provided by the existing openstack4j SDK are imperfect and incomplete, the present invention provides a technical framework expansion method based on Openstack4j, expands and improves the SDK without increasing the cost of self-research, improves the convenience of using combined filtering parameters when querying the Port list, and enhances the flexibility and scalability of operating the bottom layer of openstack.
[0005] The specific scheme proposed by the present invention is:
[0006] A technical framework expansion query method based on Openstack4j:
[0007] Step 1: Create an entity class for port query, and modify the original parameter adding method to pass the value into the variable-length array.
[0008] Step 2: Build the Service implementation class, inherit the framework class BaseNetworkingServices, and extend the query method. The splicing parameter method when building the request body is array splicing.
[0009] Step 3: Call the openstack4j method to obtain the execution permission client and write the permission object in the current execution thread session.
[0010] Step 4: Execute the extended query method to filter.
[0011] In the Openstack4j-based technical framework extended query method, in step 1, a map with a key-value attribute is constructed, and the value is a List <object>, used for passing multiple values into the parameter.
[0012] In the Openstack4j-based technical framework extended query method, when the key value exists, the original corresponding value is retained and modified to a List, and the new value is passed in and added to the array.
[0013] In the Openstack4j-based technical framework extended query method, in step 2, the paramList method in the corresponding framework class is called to perform array splicing.
[0014] A technical framework extension query system based on Openstack4j, including creation module, extension module, call module and execution module.
[0015] Create a module to create an entity class for port query, and modify the original parameter adding method to pass the value into the parameter using a variable-length array.
[0016] The extension module builds the Service implementation class, inherits the framework class BaseNetworkingServices, and extends the query method. The splicing parameter method when building the request body is array splicing.
[0017] The calling module calls openstack4j to obtain the execution permission client method and writes the permission object in the current execution thread session.
[0018] The execution module executes the extended query method to perform filtering.
[0019] The described Openstack4j-based technical framework expansion query system creates a module to build a map with a key-value attribute, and the value is a List <object>, used for passing multiple values into the parameter.
[0020] In the Openstack4j-based technical framework extended query system, when the key value exists, the creation module retains the original corresponding value, modifies it into a List, and passes the new value into the array.
[0021] The calling module in the Openstack4j-based technical framework extension query system calls the paramList method in the corresponding framework class to perform array splicing.
[0022] The benefits of the present invention are:
[0023] The invention provides an extended query method based on the technical framework of Openstack4j. The invention creates an entity class for port query, modifies the original parameter adding method into a variable-length array value passing parameter, constructs a Service implementation class, inherits the framework class BaseNetworkingServices, and extends the query method. The splicing parameter mode when constructing the request body is array splicing, so that the variable parameters are multi-valued and passed, which greatly improves the code repeatability and the complexity of the native interface call. At the same time, the method of obtaining the execution permission client of openstack4j is called, the permission object is written in the current execution thread session, and the extended query method is executed, and filtering can be performed, so as to improve the convenience of using the combined filtering parameters when querying the Port list, and improve the flexibility and scalability of operating the bottom layer of openstack. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a schematic flow chart of the method of the present invention;
[0025] Figure 2 It is a diagram of the technical architecture for implementing Openstack4j. DETAILED DESCRIPTION
[0026] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0027] The present invention provides a technical framework expansion query method based on Openstack4j:
[0028] Step 1: Create an entity class for port query, and modify the original parameter adding method to pass the value into the variable-length array.
[0029] Step 2: Build the Service implementation class, inherit the framework class BaseNetworkingServices, and extend the query method. The splicing parameter method when building the request body is array splicing.
[0030] Step 3: Call the openstack4j method to obtain the execution permission client and write the permission object in the current execution thread session.
[0031] Step 4: Execute the extended query method to filter.
[0032] By utilizing the method of the present invention, the SDK can be expanded and improved without increasing the cost of self-research. Multi-value transmission can be performed through variable parameters, which greatly improves the repeatability of the code and the complexity of the native interface call. In addition, this idea can be extended to other components under this framework, and the extensibility is strong and rich.
[0033] In one embodiment of the method of the present invention, the application process is specifically described:
[0034] Step 1: Create an entity class PortListOptionsExt for port query (the name can be made up by yourself),
[0035] The constructed attribute is a map in key-value format, and the Value is a List <object>, used for multi-value transfer;
[0036] Add a public value-transfer method add(String key,Object value) to the entity class. When the key value exists, the original corresponding value is retained and modified to List. The new value is passed in and added to the array, and the current object is returned in a chain-constructed manner.
[0037] Step 2: Build the Service implementation class, inherit the framework class BaseNetworkingServices, and extend the query method, passing the object built in step 1 as a parameter;
[0038] Before calling the request, the concatenation parameter method when constructing the request body is set to array concatenation. The specific method used is located in its framework class org.openstack4j.openstack.internal.BaseOpenStackService.Invocation <r>, call the paramList method in the class;
[0039] Step 3: Call the method provided by openstack4j to obtain the execution permission client and write the permission object in the current execution thread session.
[0040] Step 4: Call the extended query method constructed in step 3 to complete the result filtering through the variable parameter values.
[0041] In the above process, the port list query interface can be / v2.0 / ports, the request method is GET, and the request parameters are in JSON format. In the code, the entity class PortListOptionsExt constructed in step 1 accepts the acquisition.
[0042] The above process extension implementation is not limited to any other query interface under Openstack4j such as Neutron, Compute, Keystone, etc.
[0043] The present invention also provides an extended query system based on the Openstack4j technical framework, including a creation module, an extension module, a call module and an execution module.
[0044] Create a module to create an entity class for port query, and modify the original parameter adding method to pass the value into the parameter using a variable-length array.
[0045] The extension module builds the Service implementation class, inherits the framework class BaseNetworkingServices, and extends the query method. The splicing parameter method when building the request body is array splicing.
[0046] The calling module calls openstack4j to obtain the execution permission client method and writes the permission object in the current execution thread session.
[0047] The execution module executes the extended query method to perform filtering.
[0048] The information interaction, execution process and other contents between the modules in the above-mentioned system are based on the same concept as the embodiment of the method of the present invention. For the specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.
[0049] It should be noted that not all steps and modules in the above-mentioned processes and system structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0050] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.< / r> < / object> < / object> < / object>
Claims
1. A technical framework expansion query method based on Openstack4j, characterized by include: Step 1: Create an entity class for port query, and modify the original parameter adding method to a variable-length array to pass the value into the parameter, where the construction attribute is a map in the form of key-value, and the value is a List <object>, used for passing multiple values into the parameter, Add a public value-transfer method add(String key, Object value) to the entity class. When the key value exists, the original corresponding value is retained and modified to List. The new value is passed in and added to the array. The currently constructed object is returned in a chain-constructed manner. Step 2: Build the Service implementation class, inherit the framework class BaseNetworkingServices, and extend the query method. Pass the object built in step 1 as a parameter. The splicing parameter method when building the request body is array splicing. Step 3: Call the openstack4j method to obtain the execution permission client and write the permission object in the current execution thread session. Step 4: Execute the extended query method to filter.
2. According to claim 1, a method for extending query based on the Openstack4j technical framework is characterized in that In step 2, call the paramList method in the corresponding framework class to perform array splicing.
3. An extended query system based on the Openstack4j technical framework, characterized by Including creating modules, extending modules, calling modules and executing modules, Create a module to create an entity class for port query, and modify the original parameter adding method to a variable-length array to pass the value into the parameter. The creation module builds a map with a key-value form, and the value is a List <object>, used for passing multiple values into the parameter, Add a public value-transfer method add(String key, Object value) to the entity class. When the key value exists, the original corresponding value is retained and modified to List. The new value is passed in and added to the array. The currently constructed object is returned in a chain-constructed manner. The extension module builds the Service implementation class, inherits the framework class BaseNetworkingServices, and extends the query method. The object built by the creation module is passed in as a parameter. The splicing parameter method when building the request body is array splicing. The calling module calls openstack4j to obtain the execution permission client method and writes the permission object in the current execution thread session. The execution module executes the extended query method to perform filtering.
4. The Openstack4j-based technical framework extended query system according to claim 3 is characterized in that The calling module calls the paramList method in the corresponding framework class to perform array splicing. < / object> < / object>
