Method and device for generating initialization configuration of network equipment in batch

文档序号:1963514 发布日期:2021-12-14 浏览:15次 中文

阅读说明:本技术 批量生成网络设备初始化配置的方法及装置 (Method and device for generating initialization configuration of network equipment in batch ) 是由 汤荣波 于 2021-09-18 设计创作,主要内容包括:本发明涉及一种批量生成网络设备初始化配置的方法及装置,所述方法包括配置变量表以及通过Jinja2模块配置模板;通过Python脚本关联所述变量报表和模板,生成命令;通过Netmiko模块将所述命令上传至网络设备并执行。本发明提供的技术方案能够解决交换机批量交付场景,手动配置耗时费力、容易出错的问题,通过本申请提供的方法可以提高数据中心网络运维的工作效率。(The invention relates to a method and a device for generating initialization configuration of network equipment in batches, wherein the method comprises the steps of configuring a variable table and configuring a template through a Jinja2 module; associating the variable report form with the template through a Python script to generate a command; and uploading the command to a network device through a Netmiko module and executing the command. The technical scheme provided by the invention can solve the problems that the switch batch delivery scene is time-consuming and labor-consuming in manual configuration and easy to make mistakes, and the method provided by the invention can improve the working efficiency of the operation and maintenance of the data center network.)

1. A method for generating initialization configurations of network devices in batches, comprising:

configuring a variable table and a template through a Jinja2 module;

associating the variable report form with the template through a Python script to generate a command;

and uploading the command to a network device through a Netmiko module and executing the command.

2. The method of claim 1, wherein configuring the variable table comprises:

acquiring IP information of equipment needing to be operated;

and configuring the IP information into a variable table.

3. The method according to claim 2, wherein the associating the variable table and the template through a Python script generates a command comprising:

and performing ID judgment on the IP information in the variable table and generating a command according to the application of the Jinja2 module in the Python script.

4. The method of claim 1, wherein the network device comprises:

computers, hubs, switches, bridges, routers, gateways, and printers.

5. An apparatus for generating network device initialization configurations in batches, comprising:

the configuration module is used for configuring the variable table and the template through the Jinja2 module;

the generating module is used for associating the variable report form with the template through a Python script to generate a command;

and the execution module is used for uploading the command to the network equipment through the Netmiko module and executing the command.

Technical Field

The invention belongs to the technical field of networks, and particularly relates to a method and a device for generating initialization configuration of network equipment in batches.

Background

Network devices and components are physical entities connected into a network. The variety of network devices is great and increasing. The basic network devices are: computers (whether personal computers or servers), hubs, switches, bridges, routers, gateways, Network Interface Cards (NICs), Wireless Access Points (WAPs), printers and modems, fiber optic transceivers, fiber optic cables, and the like.

The current computer network is rapidly developed, the number of used bottom network devices is increasingly huge, and with the appearance of various remote connection technologies and the continuous expansion of network scale, the network is more and more dispersed geographically, and even if the network is a small network, the network devices can be far away from each other.

When a network project is opened, whether ZTP or manual command knocking is adopted, the equipment configuration files of all Role in the whole network are required to be prepared. The existing technical scheme is that scripts are manually created manually based on baseline configuration, but characters in a configuration template are manually replaced one by one, so that the workload is too large, and errors are easy to occur.

Disclosure of Invention

In view of the above, the present invention provides a method and an apparatus for generating initialization configuration of network devices in batch, so as to solve the problem in the prior art that characters in a configuration template are replaced one by one manually, which results in too large workload and is prone to error.

In order to achieve the purpose, the invention adopts the following technical scheme: a method of generating network device initialization configurations in batches, comprising:

configuring a variable table and a template through a Jinja2 module;

associating the variable report form with the template through a Python script to generate a command;

and uploading the command to a network device through a Netmiko module and executing the command.

Further, the configuration variable table includes:

acquiring IP information of equipment needing to be operated;

and configuring the IP information into a variable table.

Further, the associating the variable table and the template through the Python script generates a command, including:

and performing ID judgment on the IP information in the variable table and generating a command according to the application of the Jinja2 module in the Python script.

Further, the network device includes:

computers, hubs, switches, bridges, routers, gateways, and printers.

The embodiment of the present application provides an apparatus for generating initialization configuration of network devices in batch, including:

the configuration module is used for configuring the variable table and the template through the Jinja2 module;

the generating module is used for associating the variable report form with the template through a Python script to generate a command;

and the execution module is used for uploading the command to the network equipment through the Netmiko module and executing the command.

By adopting the technical scheme, the invention can achieve the following beneficial effects:

the invention provides a method and a device for generating initialization configuration of network equipment in batches, wherein the method comprises the steps of configuring a variable table and configuring a template through a Jinja2 module; associating the variable report form with the template through a Python script to generate a command; and uploading the command to a network device through a Netmiko module and executing the command. The technical scheme provided by the invention can solve the problems that the switch batch delivery scene is time-consuming and labor-consuming in manual configuration and easy to make mistakes, and the method provided by the invention can improve the working efficiency of the operation and maintenance of the data center network.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, 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 the drawings without creative efforts.

FIG. 1 is a schematic diagram illustrating steps of a method for batch generation of network device initialization configuration according to the present invention;

fig. 2 is a schematic structural diagram of an apparatus for batch-generating network device initialization configuration according to the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. 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 examples given herein without any inventive step, are within the scope of the present invention.

A specific method for generating initialization configuration of network devices in batch according to the embodiment of the present application is described below with reference to the accompanying drawings.

As shown in fig. 1, the method for batch-generating network device initialization configuration provided in this embodiment of the present application includes:

s101, configuring a variable table and a template through a Jinja2 module;

s102, associating the variable report form and the template through a Python script to generate a command;

and S103, uploading the command to the network equipment through the Netmiko module and executing the command.

The working principle of the method for generating the initialization configuration of the network equipment in batches is as follows: configuring a variable table and a template through a Jinja2 module; associating the variable report form with the template through a Python script to generate a command; and uploading the command to a network device through a Netmiko module and executing the command.

In some embodiments, the configuration variable table comprises:

acquiring IP information of equipment needing to be operated;

and configuring the IP information into a variable table.

Preferably, the associating the variable table and the template by the Python script to generate the command includes:

and performing ID judgment on the IP information in the variable table and generating a command according to the application of the Jinja2 module in the Python script.

Preferably, the network device includes:

computers, hubs, switches, bridges, routers, gateways, and printers.

As shown in fig. 2, the present application provides an apparatus for generating initialization configurations of network devices in batch, including:

the configuration module 201 is used for configuring the variable table and configuring the template through the Jinja2 module;

the generating module 202 is configured to associate the variable report with the template through a Python script, and generate a command;

and the execution module 203 is used for uploading the command to the network equipment through the Netmiko module and executing the command.

The working principle of the device for generating the initialization configuration of the network equipment in batches provided by the application is that the configuration module 201 configures a variable table and a template through a Jinja2 module; the generating module 202 associates the variable report form and the template through a Python script to generate a command; the execution module 203 uploads the command to the network device through the Netmiko module and executes it.

Preferably, the configuration variable table includes:

acquiring IP information of equipment needing to be operated;

and configuring the IP information into a variable table.

Preferably, the associating the variable table and the template by the Python script to generate the command includes:

and performing ID judgment on the IP information in the variable table and generating a command according to the application of the Jinja2 module in the Python script.

Preferably, the network device includes:

computers, hubs, switches, bridges, routers, gateways, and printers.

The embodiment of the application provides computer equipment, which comprises a processor and a memory connected with the processor;

the memory is used for storing computer program, and the computer program is used for executing

Configuring a variable table and a template through a Jinja2 module;

associating the variable report form with the template through a Python script to generate a command;

uploading the command to a network device through a Netmiko module and executing the command;

the processor is used to call and execute the computer program in the memory.

In summary, the present invention provides a method and an apparatus for generating initialization configuration of network devices in batch, where the method includes configuring a variable table and configuring a template through Jinja2 module; associating the variable report form with the template through a Python script to generate a command; and uploading the command to a network device through a Netmiko module and executing the command. The technical scheme provided by the invention can solve the problems that the switch batch delivery scene is time-consuming and labor-consuming in manual configuration and easy to make mistakes, and the method provided by the invention can improve the working efficiency of the operation and maintenance of the data center network.

It is to be understood that the embodiments of the method provided above correspond to the embodiments of the apparatus described above, and the corresponding specific contents may be referred to each other, which is not described herein again.

As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.

The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:页面加载方法、业务处理方法、装置、存储介质与设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!