A compatibility switch database loading method and apparatus
By obtaining and determining the database field types in the switch system and adopting loading rules for the configuration database and the default database, the problem of inconsistent configuration semantics caused by changes in switch image versions was solved, thus achieving orderly loading of configuration data and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 武汉迈威通信股份有限公司
- Filing Date
- 2026-02-04
- Publication Date
- 2026-06-02
AI Technical Summary
The existing switch database loading system cannot correctly parse configuration semantics after the image version changes, resulting in device startup failures or loss of user configurations.
By obtaining the target database fields, determining their types, and searching for or loading the corresponding functional configurations in the configuration database and default database according to different loading rules, a method for creating database field names is constructed to distinguish version identifiers, thereby achieving orderly loading and compatibility processing of configuration data.
To prevent configuration loading failures when the image version changes, ensure the stability of the switch system and the continuity of configuration, and reduce the risk of configuration loading failures.
Smart Images

Figure CN122132093A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and in particular to a method and apparatus for loading a compatible switch database. Background Technology
[0002] With the continuous development of switch network management technology, the addition or deletion of function configurations or the adjustment of configuration methods are inevitable during the evolution of switches. This leads to the addition or deletion of default database fields in the switch image, or changes in the content definition, format, allowed length or value range of database fields with the same name.
[0003] After the switch image upgrade is completed, if the switch directly loads all the user configurations saved before the upgrade when the system restarts, the existing switch database loading system lacks a mechanism to distinguish and handle changes in the semantics of database fields. It still performs simple matching based on field names and forcibly loads the configuration data. Therefore, it is very likely that the configuration semantics of configuration items that have changed with the image function cannot be correctly parsed and loaded, which may lead to device startup failure or the loss of the original user configuration after the device starts up.
[0004] Therefore, there is an urgent need for a compatible method and device for loading databases on switches. Summary of the Invention
[0005] This application provides a compatible switch database loading method and apparatus, which solves the problem that existing switch database loading systems may cause device startup failure or loss of original user configurations after device startup.
[0006] The first aspect of this application provides a method for loading a compatible switch database. The method includes: responding to a system restart operation after the switch has been upgraded, obtaining a target database field; determining the database field type corresponding to the target database field according to a first loading rule; if the target database field is a first-type database field, checking whether the first-type database field can be found in the configuration database; if the first-type database field is found, loading normally; if the first-type database field cannot be found, searching for a third-type database field according to a second loading rule, and selecting the function configuration to load the third-type database field based on the search result; if the target database field is a second-type database field, checking whether the second-type database field can be found in the configuration database; if the second-type database field is found, loading normally; if the second-type database field cannot be found, loading the default value of the second-type database field in the default database as the function configuration corresponding to the second-type database field.
[0007] Optionally, before retrieving the target database field in response to the system restart operation after the switch upgrade is completed, the method further includes constructing a field name creation method corresponding to the database field: obtaining the configuration semantic description information corresponding to the database field; obtaining the switch database of the current image version of the switch, and determining whether the configuration semantic description information belongs to the existing configuration semantics in the switch database; if the configuration semantic description information does not belong to the existing configuration semantics in the switch database, then confirming that the configuration semantic description information is newly added configuration semantic description information; and creating a field name for the database field without carrying a version identifier.
[0008] Optionally, if the configuration semantic description belongs to the existing configuration semantics in the switch database, then it is further determined whether the configuration semantic description information has undergone configuration semantic changes. Configuration semantic changes include at least one of the following: changes in content definition, changes in parameter structure, changes in value range, or changes in format. If the configuration semantic description information has undergone configuration semantic changes, then a field name carrying a version identifier is created for the database field according to the preset version increment rule.
[0009] Optionally, constructing a switch database specifically includes: constructing configuration data for multiple functions, each function corresponding to one or more configuration semantics; constructing a correspondence between multiple configuration semantics and multiple database fields; the configuration semantics include management function semantics, forwarding function semantics, and alarm function semantics; one configuration semantic corresponds to one database field; and saving the configuration data and correspondence to the switch database to construct the switch database.
[0010] Optionally, if a first-class database field is found, it will be loaded normally. Specifically, if a first-class database field is found, the corresponding function configuration will be loaded normally.
[0011] Optionally, the third type of database field is searched according to the second loading rule, specifically including: based on the field name creation method, searching in the configuration database for a third type of database field that has the same field name as the first type of database field but a different version identifier; searching in the configuration database in descending order of version identifier using a recursive search method; if a third type of database field is found, the function configuration of the third type of database field is loaded normally as the function configuration corresponding to the first type of database field.
[0012] Optionally, if no third-category database field is found, the first-category database field corresponding to the target database field is used; in the default database, the default value corresponding to the first-category database field is loaded as the function configuration corresponding to the first-category database field.
[0013] A second aspect of this application provides a compatibility switch database loading device, the device including an acquisition module and a processing module, wherein, The acquisition module is used to retrieve target database fields in response to the system restart operation after the switch has been upgraded.
[0014] The processing module is used to determine the database field type corresponding to the target database field according to the first loading rule. If the target database field is a first-type database field, it checks whether the first-type database field can be found in the configuration database. If the first-type database field is found, it is loaded normally. If the first-type database field cannot be found, it searches for a third-type database field according to the second loading rule and selects the function configuration to load the third-type database field based on the search result. If the target database field is a second-type database field, it checks whether the second-type database field can be found in the configuration database. If the second-type database field is found, it is loaded normally. If the second-type database field cannot be found, it loads the default value of the second-type database field in the default database as the function configuration corresponding to the second-type database field.
[0015] A third aspect of this application provides an electronic device including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described above.
[0016] A fourth aspect of this application provides a non-transitory computer-readable storage medium storing a computer program, the computer program being executed by a processor using any of the methods described above.
[0017] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. Obtain the target database field and determine the database field type corresponding to the target database field according to the first loading rule. If the target database field is a first-type database field, check whether the first-type database field can be found in the configuration database. If not found, search for the third-type database field according to the second loading rule and load the function configuration of the third-type database field. If the target database field is a second-type database field, check whether the second-type database field can be found in the configuration database. If not found, load the default value of the second-type database field in the default database as the function configuration corresponding to the second-type database field. This ensures orderly loading and compatibility processing of configuration data when the switch image version changes, avoiding configuration loading failure or system startup abnormalities caused by inconsistent database fields.
[0018] 2. Construct a method for creating field names corresponding to database fields. By obtaining the configuration semantic description information corresponding to the database field and combining it with the switch database of the current image version of the switch, determine whether the configuration semantic description information belongs to the existing configuration semantics in the switch database. When the configuration semantic description information does not belong to the existing configuration semantics, it is confirmed as newly added configuration semantic description information, and a field name without version identifier is created for the corresponding database field. When the configuration semantic description information belongs to the existing configuration semantics, it is further determined whether a configuration semantic change has occurred. If any configuration semantic change is confirmed to have occurred, such as a change in content definition, parameter structure, value range, or format, a field name with version identifier is created for the database field according to a preset version increment rule. This achieves clear identification of different version configuration semantics through the distinction at the field name level, avoids semantic conflicts between database fields with the same name during cross-version loading, and improves the controllability of the configuration loading process and the stability of the switch system operation.
[0019] 3. Based on the field name creation method, search the configuration database for a third type of database field that has the same field name as the first type of database field but a different version identifier. Search the configuration database for the third type of database field in descending order of version identifier using a recursive search method. If the third type of database field is found, load the functional configuration of the third type of database field as the functional configuration corresponding to the first type of database field. This ensures backward compatibility with historical configuration data even when the current version of the database field is missing, guaranteeing the continuity of switch configuration and reducing the risk of configuration loading failure due to field version changes. Attached Figure Description
[0020] Figure 1 This is a flowchart illustrating a compatibility switch database loading method provided in an embodiment of this application; Figure 2 This is a schematic diagram of a compatible switch database loading device provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0021] Explanation of reference numerals in the attached drawings: 21. Acquisition module; 22. Processing module; 301. Processor; 302. Communication bus; 303. User interface; 304. Network interface; 305. Memory. Detailed Implementation
[0022] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0023] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0024] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0025] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0026] Please refer to Figure 1 The flowchart illustrates a method for loading a compatibility switch database according to an embodiment of this application. The flowchart mainly includes the following steps: S101 to S108.
[0027] Step S101: Respond to the system restart operation of the switch after the upgrade is completed and obtain the target database fields.
[0028] Specifically, a switch device typically contains two types of databases: one is used to store user-saved configuration data, called the configuration database, or DB_CONFIG, which is compressed and packaged into the switch's startup configuration file and remains unchanged before and after the image upgrade, and is automatically loaded when the system starts; the other is used to store the default configurations of various functions in different version images, called the default database, or DB_DEFAULT, which is compressed and packaged into the image file, and is decompressed onto the switch device after the upgrade, directly overwriting the DB_DEFAULT in the old image.
[0029] With the continuous development of switch management technology, switches inevitably experience additions / deletions of function configurations or modifications to configuration methods. This leads to the addition / deletion of default database fields in the switch image, or changes in the definition / format / allowed length / value range of database fields with the same name.
[0030] If, after the upgrade is completed, the switch forcibly loads all previous user configurations during system restart, it may cause the configuration semantics of the mirroring function to fail to load correctly, which may result in the device failing to start or losing the original user configurations after the device starts.
[0031] Therefore, to solve the above-mentioned technical problems, this application designs a compatible switch database loading method. In this method, during the system restart process triggered after the switch is upgraded, all user configurations in the configuration database are no longer loaded indiscriminately. Instead, database fields are used as the basic processing unit. During the system startup phase, the target database field to be loaded is obtained, and an ordered loading judgment relationship is established between the configuration database and the default database around the target database field. By distinguishing different types of database fields and combining them with preset loading rules, the actual loading source of configuration data is controlled. Thus, when the image version changes, problems such as configuration loading failure, functional abnormality, or system startup failure caused by inconsistent database field definitions are avoided.
[0032] In one possible implementation, step S101 further includes: constructing configuration data for multiple functions, each function corresponding to one or more configuration semantics; constructing a correspondence between multiple configuration semantics and multiple database fields; the configuration semantics include management function semantics, forwarding function semantics, and alarm function semantics; one configuration semantic corresponds to one database field; and saving the configuration data and correspondence to the switch database to construct the switch database.
[0033] Specifically, the switch database centrally stores the configuration data corresponding to all functions of the switch. Each function can be broken down into multiple configuration items and their semantics. Each configuration item and its semantics corresponds to an independent database field, which uses the format "". <key> = <value>The configuration is expressed in a structure of "" and "", where field names uniquely identify the configuration semantics, and field content records the parameter values corresponding to those semantics. Depending on the characteristics of different configuration semantics, field content can be represented as numeric, a string containing delimiters, or an empty string to adapt to the expression requirements of different types of functional configurations. After establishing the correspondence between configuration semantics and database fields, the configuration data and their corresponding relationships are uniformly saved to the switch database, forming a complete switch database structure. This provides a consistent data foundation for subsequent acquisition of target database fields, field type determination, and rule loading execution. The management function semantics are used to characterize the switch... The configuration semantics of the switch in terms of device management, system control, and operation and maintenance configuration include, but are not limited to, user permission configuration, management interface parameter configuration, system time and log policy configuration, etc.; the forwarding function semantics are used to characterize the configuration semantics of the switch in terms of data forwarding and service processing, including but not limited to port forwarding policies, forwarding table entry parameters, service traffic control, and forwarding feature enabling configuration, etc.; the alarm function semantics are used to characterize the configuration semantics of the switch in terms of operation status monitoring and anomaly notification, including but not limited to alarm triggering conditions, alarm type definitions, alarm level configuration, and alarm reporting policies, etc., so that different types of configuration semantics have clear semantic boundaries and a unified field expression form in the switch database.
[0034] In one possible implementation, step S101 further includes: obtaining configuration semantic description information corresponding to the database field; obtaining the switch database of the current image version of the switch, and determining whether the configuration semantic description information belongs to the existing configuration semantics in the switch database; if the configuration semantic description information does not belong to the existing configuration semantics in the switch database, then confirming that the configuration semantic description information is newly added configuration semantic description information; and creating a field name for the database field that does not carry a version identifier.
[0035] Specifically, for database fields with completely new functionality, a completely new key name must be used, which cannot be the same as the key name of a previous database field. No version number is required after the key name. When it is determined that the configuration semantic description information does not belong to the existing configuration semantics in the switch database, the configuration semantic description information is confirmed as new configuration semantic description information, and a completely new field name is used to identify it during the database field naming stage. For database fields corresponding to this type of new configuration semantic, the created field name does not carry a version identifier, and the field name is different from any field name in the historical image version of the switch database. This ensures that the new function configuration has an independent and unique identifier at the database level, thereby avoiding conflicts or ambiguities with existing database fields during subsequent configuration loading, and providing a foundation for the correct loading and stable operation of the new function configuration in the switch system.
[0036] In one possible implementation, step S101 further includes: if the configuration semantic description belongs to the existing configuration semantic in the switch database, then further determine whether the configuration semantic description information has undergone configuration semantic change, the configuration semantic change includes at least one of the following: content definition change, parameter structure change, value range change or format change; if the configuration semantic description information has undergone configuration semantic change, then create a field name carrying a version identifier for the database field according to the preset version increment rule.
[0037] Specifically, for database fields that change only in content definition, format, string length, or value range, a version-based naming method is used to distinguish them during the field name creation phase. Assuming a database field named "a" already exists in a historical image version, when the configuration semantics corresponding to this database field need to be adjusted in a new image version, a field name carrying a version identifier, "a#1," is created for this database field in the new image version. In subsequent image versions, if the configuration semantics continue to be adjusted, the version identifier is incremented sequentially based on the previous version's field name, forming field names such as "a#2," "a#3," etc. The letter part of the field name is used to identify the corresponding configuration semantics, and the version identifier is used to represent the revision order of the configuration semantics in different image versions.
[0038] After introducing version identifiers into database fields, to ensure that the switch can be compatible with user configurations from previous versions when loading the configuration database, compatibility handling logic for the previous version's database fields is configured in the corresponding functional modules during each database field version update. When a database field with the current version's field name is not detected in the configuration database, the database field with the same field name but a lower version identifier is processed to achieve a mapping of the current version's configuration semantics. For some configuration semantic parameters that do not exist in the lower version's database fields, the default values corresponding to the current version's database fields are used to supplement them, thereby maintaining the continuity of functional configuration while avoiding configuration loading failures caused by changes in field semantics.
[0039] Step S102: Determine the database field type corresponding to the target database field according to the first loading rule.
[0040] Specifically, the first loading rule is to confirm whether the field name of the target database field carries a version number, that is, whether it contains a version identifier used to indicate the field's revision status. This step determines whether the target database field is a database field that carries a version identifier by parsing the field name structure of the target database field and judging whether the field name carries a version identifier used to indicate the field's revision status.
[0041] Step S103, if the target database field is a first - type database field, confirm whether the first - type database field can be found in the configuration database.
[0042] Specifically, when it is determined that the target database field is a first - type database field, perform a field search process for the first - type database field in the configuration database. By matching the field name of the first - type database field with the database fields already stored in the configuration database, confirm whether there is a record corresponding to the first - type database field in the configuration database.
[0043] Step S104, if the first - type database field is found, load it normally.
[0044] Specifically, if the first - type database field is successfully found in the configuration database, directly load the configuration content corresponding to the configuration semantics recorded in the first - type database field, and use it as the effective function configuration of the target database field to complete the preferential loading of the database field carrying the version identifier.
[0045] Step S105, if the first - type database field cannot be found, search for a third - type database field according to the second loading rule, and select and load the function configuration of the third - type database field according to the search result.
[0046] In a possible implementation manner, step S105 further includes: based on the field - name creation method, search for a third - type database field in the configuration database that has the same field name as the first - type database field but a different version identifier; in the configuration database, use a recursive search method in order from the highest to the lowest version identifier to search for the third - type database field; if the third - type database field is found, load the function configuration of the third - type database field normally as the function configuration corresponding to the first - type database field; if the third - type database field is not found, based on the first - type database field corresponding to the target database field; in the default database, load the default value corresponding to the first - type database field as the function configuration corresponding to the first - type database field.
[0047] Specifically, when the first - type database field is not found in the configuration database, based on the field - name creation method, search for a third - type database field in the configuration database that has the same key name as the first - type database field but a different version identifier, and perform a recursive search process on the third - type database field in order from the highest to the lowest version identifier. In this process, taking the field name of the target database field as "a#n" as an example, first search for the database field with the field name "a#n - 1" in the configuration database. If not found, continue to search downward for the field name "a#n - 2" until the database field with the field name "a#m" (m < n) is found, or the database field "a" without a version identifier is found.
[0048] When the database field "a#m" (m < n) or "a" is found in the configuration database, the database field is determined as the third type of database field, and the compatibility processing functions corresponding to the database fields "a#n-1", "a#n-2",..., "a#m" or "a" are recursively executed in sequence, so that the configuration semantics in the low-version database fields are gradually mapped to the configuration semantics corresponding to the target database field "a#n", thereby finally implementing the function configuration loading of the first type of database field through the third type of database field.
[0049] When no low-version database field with the same key name as the first type of database field is found in the configuration database, or only the database field "a#m" (m > n) with a version identifier greater than the target version identifier is found, to avoid abnormal configuration loading due to database field semantic mismatch, the field compatibility loading based on the configuration database is abandoned, and the first type of database field corresponding to the target version identifier "n" is determined based on the search results from high to low version identifiers. In this case, the default value of the database field "a#n" is loaded from the default database DB_DEFAULT, and the default value is used as the function configuration corresponding to the first type of database field, so as to complete the safe loading of the target database field on the premise of ensuring the stable startup of the switch system.
[0050] Step S106, if the target database field is the second type of database field, confirm whether the second type of database field can be found in the configuration database.
[0051] Specifically, when it is determined that the target database field is the second type of database field, a field search process for database fields without version identifiers is performed in the configuration database. By matching the field name of the second type of database field with the database fields already stored in the configuration database DB_CONFIG, it is confirmed whether there is a corresponding database field.
[0052] Step S107, if the second type of database field is found, load it normally.
[0053] Specifically, when the database field with the field name "b" is found in the configuration database, the function configuration recorded in the database field is directly loaded and used as the function configuration corresponding to the second type of database field.
[0054] Step S108, if the second type of database field cannot be found, load the default value of the second type of database field from the default database as the function configuration corresponding to the second type of database field.
[0055] Specifically, when the second type of database field is not found in the configuration database, the backward compatibility lookup process is no longer performed. Instead, the default value corresponding to the second type of database field is directly loaded from the default database DB_DEFAULT, and the default value is used as the function configuration corresponding to the second type of database field to complete the default loading of the database field that does not carry a version identifier.
[0056] To facilitate understanding and implementation of compatibility handling logic for database fields with the same name in cross-version scenarios, this application illustrates the implementation of backward compatibility handling functions for database fields with the same name through several typical scenarios. The following embodiments are only used to illustrate the compatibility handling approach and do not constitute a limitation on the scope of protection of this application: In Example 1, for cases where a new version database field adds configuration parameters compared to a lower version database field, the corresponding compatibility handling function performs a coverage check on different values of existing configuration parameters in the lower version database field with the same name, and assigns values to the newly added configuration parameters in the new version database field based on the check results. For example, in webpage function configuration, the new version database field "a#n= <https> : <http>"This corresponds to the enabled states of HTTPS and HTTP respectively, while the field "a#n-1=" in older database versions..." <web>"If the web enable state is used to uniformly indicate whether a webpage function is on or off, then in the compatibility handling function, when..." <web>When ==1, the corresponding setting is... <https>=1 and <http>=1; when <web>When == 0, the corresponding setting is... <https>=0 and <http>= 0, thus realizing the mapping of the configuration semantics from the low-version fields to the high-version fields.
[0057] In Embodiment 2, for the case where the same-name database fields "a#n-1" and "a#n" only differ in the parameter value range, it is judged in the compatibility processing function whether the configuration value of the low-version database field falls within the value range allowed by the new-version database field. When the low-version configuration value belongs to the allowed value range of the new-version database field, the configuration value of the low-version database field is directly loaded; when the low-version configuration value does not belong to the allowed value range of the new-version database field, the default value corresponding to the new-version database field is loaded. For example, when bcast_threshold = 2500 and the default value of bcast_threshold#1 is 25000, if the allowed value range of bcast_threshold#1 is [25000, 65535], then 2500 does not belong to this range, and the final value of bcast_threshold in the compatibility processing function is 25000; if the allowed value range of bcast_threshold#1 is [2500, 65535], then 2500 belongs to this range, and the final value of bcast_threshold in the compatibility processing function is 2500. Another example, when alarm_type#3 = "power_down" and the default value of alarm_type#4 is "port_link_down", if the allowed alarm types of alarm_type#4 include "power_down", then the final value of alarm_type in the compatibility processing function is "power_down", otherwise "port_link_down" is loaded as the final value. To improve the processing efficiency, in this type of scenario, the step-by-step iteration of the intermediate-version fields can be skipped, and the value range relationship between the database field "a#n" required by the new image and the user-configured database field "a#m" (m < n) or "a" can be directly compared to determine the final loaded value.
[0058] In Embodiment 3, for the case where the same-name database fields "a#n-1" and "a#n" only differ in the allowed length of the content string or the character set, in the compatibility processing function, it is judged whether the length and character composition of the configuration string in the lower-version database field meet the permission conditions of the new-version database field. When the permission conditions are met, the configuration string in the lower-version database field is loaded; when the permission conditions are not met, the default content string corresponding to the new-version database field is loaded. For example, when device_loc = "", and the default value of device_loc#1 is "WuHan", if the allowed string length of device_loc#1 includes the case of length 0, then the final value of device_loc in the compatibility processing function is ""; otherwise, "WuHan" is loaded. Another example is when name#3 = "abc_123", and name#4 does not allow the character "_", then the final value of name in the compatibility processing function is the default value of name#4. Similarly, in this type of scenario, it is also possible to directly compare the string length and character permission range of the database field "a#n" required by the new image with the user-configured database field "a#m" (m < n) or "a", skipping the step-by-step judgment of the intermediate version to improve the execution efficiency of the compatibility processing function.
[0059] Please refer to Figure 2 , which shows a module schematic diagram of a compatibility switch database loading device provided by an embodiment of the present application. The device includes an acquisition module 21 and a processing module 22, where, The acquisition module 21 is configured to obtain a target database field in response to a system restart operation after the switch is upgraded.
[0060] The processing module 22 is configured to judge the database field type corresponding to the target database field according to the first loading rule; if the target database field is a first-type database field, it is confirmed whether the first-type database field can be found in the configuration database; if the first-type database field is found, it is loaded normally; if the first-type database field cannot be found, the third-type database field is searched according to the second loading rule, and the function configuration of the third-type database field is selected according to the search result; if the target database field is a second-type database field, it is confirmed whether the second-type database field can be found in the configuration database; if the second-type database field is found, it is loaded normally; if the second-type database field cannot be found, the default value of the second-type database field is loaded in the default database as the function configuration corresponding to the second-type database field.
[0061] In one possible implementation, before the acquisition module 21 acquires the target database field in response to the system restart operation after the switch upgrade is completed, the method further includes: constructing a field name creation method corresponding to the database field: acquiring the configuration semantic description information corresponding to the database field; acquiring the switch database of the current image version of the switch, and determining whether the configuration semantic description information belongs to the existing configuration semantics in the switch database; if the configuration semantic description information does not belong to the existing configuration semantics in the switch database, then confirming that the configuration semantic description information is newly added configuration semantic description information; and creating a field name for the database field without carrying a version identifier.
[0062] In one possible implementation, the acquisition module 21 is used to further determine whether the configuration semantic description information has undergone configuration semantic changes if the configuration semantic description belongs to the existing configuration semantics in the switch database. The configuration semantic changes include at least one of the following: changes in content definition, changes in parameter structure, changes in value range, or changes in format. If the configuration semantic description information has undergone configuration semantic changes, a field name carrying a version identifier is created for the database field according to a preset version increment rule.
[0063] In one possible implementation, the acquisition module 21 is used to construct a switch database, specifically including: constructing configuration data for multiple functions, each function corresponding to one or more configuration semantics; constructing a correspondence between multiple configuration semantics and multiple database fields; the configuration semantics include management function semantics, forwarding function semantics, and alarm function semantics; one configuration semantic corresponds to one database field; and saving the configuration data and correspondence to the switch database to construct the switch database.
[0064] In one possible implementation, the processing module 22 is used to load normally if a first type of database field is found, specifically including: if a first type of database field is found, loading the function configuration corresponding to the first type of database field normally.
[0065] In one possible implementation, the processing module 22 is used to search for a third type of database field according to the second loading rule, specifically including: based on the field name creation method, searching for a third type of database field in the configuration database that has the same field name as the first type of database field but a different version identifier; searching for the third type of database field in the configuration database in descending order of version identifier using a recursive search method; if the third type of database field is found, then loading the function configuration of the third type of database field normally as the function configuration corresponding to the first type of database field.
[0066] In one possible implementation, the processing module 22 is used to, if no third type of database field is found, load the default value corresponding to the first type of database field in the default database as the function configuration corresponding to the first type of database field.
[0067] It should be noted that the above embodiments of the apparatus are only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0068] This application also provides an electronic device. (See reference...) Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: at least one processor 301, at least one communication bus 302, a user interface 303, at least one network interface 304, and a memory 305.
[0069] The communication bus 302 is used to enable communication between these components.
[0070] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0071] The network interface 304 may include standard wired interfaces and wireless interfaces (such as Wi-Fi interfaces).
[0072] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 305, and by calling data stored in memory 305. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.
[0073] The memory 305 may include random access memory (RAM) or read-only memory. Optionally, the memory 305 may include a non-transitory computer-readable storage medium. The memory 305 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 305 may also be at least one storage device located remotely from the aforementioned processor 301. (Refer to...) Figure 3 The memory 305, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a compatibility switch database loading application.
[0074] exist Figure 3 In the illustrated electronic device, the user interface 303 is primarily used to provide an input interface for the user and acquire user input data; while the processor 301 can be used to call the storage compatibility switch database in the memory 305 to load the application program. When executed by one or more processors 301, the electronic device performs one or more of the methods described in the above embodiments. It should be noted that, for the foregoing method embodiments, for the sake of simplicity, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0075] This application also provides a non-transitory computer-readable storage medium storing instructions. When executed by one or more processors, these instructions cause an electronic device to perform one or more of the methods described in the above embodiments.
[0076] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0077] In the various embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between apparatuses or units may be electrical or other forms.
[0078] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0079] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0080] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0081] The above description is merely an exemplary embodiment disclosed in this application and should not be construed as limiting the scope of this application. Any equivalent changes and modifications made in accordance with the teachings of this application shall still fall within the scope of this application.
[0082] This application is intended to cover any variations, uses, or adaptations disclosed herein that follow the general principles disclosed herein and include common knowledge or customary technical means in the art that are not described in this application.< / http> < / https> < / web> < / http> < / https> < / web> < / web> < / http> < / https> < / value> < / key>
Claims
1. A method for loading a compatible switch database, characterized in that, The method includes: Respond to the system reboot operation of the switch after the upgrade is completed and obtain the target database fields; The database field type corresponding to the target database field is determined according to the first loading rule; If the target database field is a first type of database field, then check in the configuration database whether the first type of database field can be found; If the first type of database field is found, it will be loaded normally; If the first type of database field cannot be found, then the third type of database field is searched according to the second loading rule, and the function configuration for loading the third type of database field is selected based on the search results; If the target database field is a second type of database field, then confirm in the configuration database whether the second type of database field can be found; If the second type of database field is found, it will load normally; If the second type of database field cannot be found, the default value of the second type of database field will be loaded into the default database as the corresponding function configuration.
2. The method according to claim 1, characterized in that, Before the system restart operation of the response switch after the upgrade is completed and the target database field is obtained, the method further includes constructing a field name creation method corresponding to the database field: Obtain the configuration semantic description information corresponding to the database field; Obtain the switch database of the current image version of the switch, and determine whether the configuration semantic description information belongs to the existing configuration semantics in the switch database; If the configuration semantic description information does not belong to the existing configuration semantics in the switch database, then the configuration semantic description information is confirmed as newly added configuration semantic description information; Create field names for the database fields that do not carry version identifiers.
3. The method according to claim 2, characterized in that, The method further includes: If the configuration semantic description belongs to the existing configuration semantics in the switch database, then it is further determined whether the configuration semantic description information has undergone configuration semantic changes. The configuration semantic changes include at least one of the following: changes in content definition, changes in parameter structure, changes in value range, or changes in format. If the configuration semantic description information undergoes a configuration semantic change, then a field name carrying the version identifier is created for the database field according to a preset version increment rule.
4. The method according to claim 2, characterized in that, Constructing the switch database specifically includes: Construct configuration data for multiple functions, with each function corresponding to one or more of the aforementioned configuration semantics; A correspondence is established between multiple configuration semantics and multiple database fields; the configuration semantics include management function semantics, forwarding function semantics, and alarm function semantics; one configuration semantic corresponds to one database field; The configuration data and the corresponding relationship are saved to the switch database to construct the switch database.
5. The method according to claim 1, characterized in that, If the first type of database field is found, the database will load normally, specifically including: If the first type of database field is found, the corresponding function configuration will be loaded normally.
6. The method according to claim 2, characterized in that, If the first type of database field is not found, the third type of database field will be searched according to the second loading rule, which specifically includes: Based on the field name creation method, a third type of database field with the same field name as the first type of database field but a different version identifier is searched in the configuration database; The third type of database field is searched in the configuration database in descending order of version identifier. If the third type of database field is found, the function configuration of the third type of database field is loaded normally as the function configuration corresponding to the first type of database field.
7. The method according to claim 6, characterized in that, The method further includes: If the third type of database field is not found, then in the default database, the default value corresponding to the first type of database field is loaded as the function configuration corresponding to the first type of database field.
8. A compatible switch database loading device, characterized in that, The device includes an acquisition module and a processing module, wherein, The acquisition module is used to acquire target database fields in response to the system restart operation of the switch after the upgrade is completed; The processing module is used to determine the database field type corresponding to the target database field according to the first loading rule; if the target database field is a first type of database field, it checks whether the first type of database field can be found in the configuration database; if the first type of database field is found, it is loaded normally; if the first type of database field cannot be found, it searches for a third type of database field according to the second loading rule, and selects to load the function configuration of the third type of database field according to the search result; if the target database field is a second type of database field, it checks whether the second type of database field can be found in the configuration database; if the second type of database field cannot be found, it loads the default value of the second type of database field in the default database as the function configuration corresponding to the second type of database field.
9. An electronic device, characterized in that, The device includes a processor, a communication bus, a user interface, a network interface, and a memory. The memory is used to store instructions. The user interface and the network interface are used to communicate with other devices. The processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1 to 7.