Dynamic adapting method for network equipment interface
Technical Field
The present invention relates to the field of network device interface adaptation technologies, and in particular, to a network device and an interface dynamic adaptation method thereof.
Background
The network equipment is configured with one or more network cards, and the equipment network card communication schematic illustration is usually displayed in real time in the equipment preassembly system and is used for displaying information such as network IP, gateway information, interface name flow and the like, but a plurality of products can relate to hardware configuration of one system for adapting to different models and a plurality of specifications, so that the problem that the product system cannot adapt to different types of hardware and is mainly reflected in a network port display area can occur, and the phenomenon of network port disorder can be caused when the system switches one product type.
However, in the prior art, an independent static dom template is allocated for each model, a complete element sequence is defined in a javascript controller file, the marked sequence is bound to the dom structure, and the service requirement of display is adjusted according to the difference of acquired data, so that each customized static template is required to be different, and series of problems such as disordered distribution occur.
Disclosure of Invention
1. Technical problem to be solved
The invention aims to solve the problems that each customized static template is required to be different and the distribution is disordered in the prior art, and provides network equipment and an interface dynamic adaptation method thereof.
2. Technical proposal
In order to achieve the above purpose, the present invention adopts the following technical scheme:
a network device and its interface dynamic adapting method, including the following steps:
step 1: firstly, loading an element set document;
step 2: generating a main entry file in a root directory, and then creating a template according to the function requirement, wherein the template is provided with an independent controller;
step 3: finding out all element sets in the controller, and obtaining current state data of all network cards through communication with the middleware;
step 4: extracting the data of the network cards according to the state data of all the network cards, wherein the data is independent of the total sequence, defining the data types of different hardware models, and injecting the returned data of the different hardware models into the defined types;
step 5: judging which type of data application corresponds to according to the returned model;
step 6: then judging which model the expansion card slot is according to the type and the number of the network ports;
step 7: finally, the size of the wide and high pixels of the product panel is adjusted according to the number of the net openings, so that the product panel is suitable for the panel area of the homepage.
Preferably, in the step 1, a jquery operation element object is adopted, and a compiling environment script configuration is defined.
Preferably, the main portal file in said step 2 will be created by html.
Preferably, in the step 3, jquery is used to find all element sets.
Preferably, in the step 5, the management port and the extension port are respectively defined as agl0 and ext under the mgmtinfo object attribute without depending on the master module to operate separately.
Preferably, the mgmtinfo object attributes are respectively: parameter eth represents the network port name, parameter IP network port binding IP address, parameter IP6 represents the network port binding IPV6 address, parameter mac represents the network port mac address, parameter mask represents the network port binding sub-net mask and parameter state represents the network port state.
Preferably, in the step 6, all the network ports in the whole expansion card slot are traversed, and corresponding network card icons are respectively applied.
3. Advantageous effects
Compared with the prior art, the invention has the advantages that:
(1) In the invention, an html static module is firstly established to independently store a DOM set, an element set template and a controller are separated, the independent editing operation is realized, an element set sequence is established in a root directory, different network ports are bound on corresponding sequences, requirements are defined in a controller file, the same grouping elements are extracted from the DOM set, different classes are defined, then the data classification of the product model is obtained through ajax, different classes are applied to each product, and the compiling operation is realized.
(2) In the invention, the realization logic is clearer, the readability is strong, the team development division is clear, the control is easy, and the code can be reused; the common module is abstracted, the maintainability is strong, and the hardware model of different types can be compatible.
Drawings
Fig. 1 is a schematic diagram of a multi-port module adapting execution step in a network device and an interface dynamic adapting method thereof according to the present invention;
fig. 2 is a diagram of a network port adaptation model of a network device and an interface dynamic adaptation method thereof according to the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments.
Example 1:
referring to fig. 1-2, a network device and an interface dynamic adaptation method thereof, comprising the steps of:
step 1: firstly, loading an element set document, and adopting jquery operation element objects to define compiling environment script configuration;
step 2: generating a main entry file in a root directory, wherein the file is created by html, and then creating a template according to the function requirement, wherein the template is provided with an independent controller;
step 3: finding out all element sets by using jquery in a controller, and obtaining current state data of all network cards through communication with middleware;
step 4: extracting the classification according to the state data, defining data categories of different hardware models independent of the existence of the total sequence, and injecting returned data of the different hardware models into the defined categories;
step 5: according to the returned model, judging which class corresponds to the data application, and independently running without depending on a main module, wherein a management port and an expansion port are respectively defined as agl0 and ext under the mgmtinfo object attribute, and the attributes of the management port and the expansion port are respectively as follows:
1. parameter eth: representing the name of the network port;
2. parameter IP: binding an IP address by the network port;
3. parameter IP6: the internet access binds the IPV6 address;
4. parameter mac: a portal mac address;
5. parameter mask: the network port binds the subnet mask;
6. parameter state: a network port state;
in the invention, under the expansion port object attribute slotinfo, the pluggable expansion network card set of the current equipment is respectively represented, the expansion board is respectively represented, and multiple types of network port integration can exist in the expansion board: a. four electric ports, b. four electric ports + four optical ports, c. eight electric ports etc., we take one of the net ports as an example, and have the following properties respectively:
1. parameter content: is of an array type, and comprises an IP address, a mac address and a gateway of the network port;
2. parameter num: the expansion board card comprises a plurality of network ports;
3. parameter online: indicating whether the current network port is online or not;
4. parameter slot: the arrangement sequence of the network ports in the current card inserting and dialing mode;
step 6: judging which type of the expansion card slot is according to the type and the number of the network ports, traversing all network ports in the whole expansion card slot, and respectively applying corresponding network card icons;
step 7: and then the size of the wide and high pixels of the product panel is adjusted according to the number of the net openings, so that the product panel is suitable for the panel area of the homepage.
In the invention, an html static module is firstly established to independently store a DOM set, an element set template and a controller are separated, the independent editing operation is realized, an element set sequence is established in a root directory, different network ports are bound on corresponding sequences, requirements are defined in a controller file, the same grouping elements are extracted from the DOM set, different classes are defined, then the data classification of the product model is obtained through ajax, different classes are applied to each product, and the compiling operation is realized.
In the invention, the realization logic is clearer, the readability is strong, the team development division is clear, the control is easy, and the code can be reused; the common module is abstracted, the maintainability is strong, and the hardware model of different types can be compatible.
The foregoing is only a preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art, who is within the scope of the present invention, should make equivalent substitutions or modifications according to the technical scheme of the present invention and the inventive concept thereof, and should be covered by the scope of the present invention.