Browse Source

Добавлена поддержа конфига для создания хостов

master
Mikhail Grebenkin 7 years ago
parent
commit
809163c012
4 changed files with 271 additions and 61 deletions
  1. +1
    -0
      .gitignore
  2. +238
    -34
      .idea/workspace.xml
  3. +11
    -0
      config-sample.json
  4. +21
    -27
      kea_hosts_generane.py

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
config.json

+ 238
- 34
.idea/workspace.xml View File

@ -2,9 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="860870ba-65f3-49c8-9afa-136b118d341a" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/.gitignore" />
<change beforePath="" afterPath="$PROJECT_DIR$/config-sample.json" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/hosts.tpl" afterPath="$PROJECT_DIR$/hosts.tpl" />
<change beforePath="$PROJECT_DIR$/main.tpl" afterPath="$PROJECT_DIR$/main.tpl" />
<change beforePath="$PROJECT_DIR$/kea_hosts_generane.py" afterPath="$PROJECT_DIR$/kea_hosts_generane.py" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -18,8 +19,33 @@
<file leaf-file-name="kea_hosts_generane.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="72" column="27" lean-forward="false" selection-start-line="72" selection-start-column="27" selection-end-line="72" selection-end-column="27" />
<state relative-caret-position="432">
<caret line="24" column="9" lean-forward="true" selection-start-line="24" selection-start-column="9" selection-end-line="24" selection-end-column="9" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="12" lean-forward="false" selection-start-line="5" selection-start-column="12" selection-end-line="5" selection-end-column="12" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config-sample.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/config-sample.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="12" lean-forward="true" selection-start-line="1" selection-start-column="12" selection-end-line="1" selection-end-column="12" />
<folding />
</state>
</provider>
@ -38,8 +64,8 @@
<file leaf-file-name="hosts.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="361">
<caret line="26" column="34" lean-forward="false" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<state relative-caret-position="324">
<caret line="18" column="12" lean-forward="true" selection-start-line="18" selection-start-column="12" selection-end-line="18" selection-end-column="12" />
<folding />
</state>
</provider>
@ -49,7 +75,7 @@
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="16" lean-forward="true" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<caret line="8" column="16" lean-forward="false" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<folding />
</state>
</provider>
@ -60,6 +86,7 @@
<component name="FindInProjectRecents">
<findStrings>
<find>print</find>
<find>read_t</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -68,17 +95,20 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
<option value="$PROJECT_DIR$/web-leases.py" />
<option value="$PROJECT_DIR$/main.tpl" />
<option value="$PROJECT_DIR$/hosts.tpl" />
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
<option value="$PROJECT_DIR$/config-sample.json" />
<option value="$PROJECT_DIR$/config.json" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="62" />
<option name="width" value="1699" />
<option name="height" value="1080" />
<option name="x" value="1729" />
<option name="y" value="-4" />
<option name="width" value="1366" />
<option name="height" value="772" />
</component>
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
@ -98,6 +128,8 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -113,8 +145,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@ -181,8 +211,8 @@
</list>
<recent_temporary>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="Python.web-leases" />
<item index="1" class="java.lang.String" itemvalue="Python.kea_hosts_generane" />
<item index="0" class="java.lang.String" itemvalue="Python.kea_hosts_generane" />
<item index="1" class="java.lang.String" itemvalue="Python.web-leases" />
</list>
</recent_temporary>
</component>
@ -221,19 +251,25 @@
<option name="project" value="LOCAL" />
<updated>1513189694157</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Довел до ума отчет.">
<created>1513190487783</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1513190487783</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="62" y="0" width="1368" height="780" extended-state="6" />
<editor active="true" />
<frame x="1366" y="-4" width="1920" height="1084" extended-state="6" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2489019" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17708333" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32882884" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21771772" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21676892" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
@ -255,7 +291,8 @@
<MESSAGE value="Поправил пару косяков. Ничего важного." />
<MESSAGE value="добавлен отчет, поменял команду перезагрузки на корректную." />
<MESSAGE value="мелкие косметические изменения" />
<option name="LAST_COMMIT_MESSAGE" value="мелкие косметические изменения" />
<MESSAGE value="Довел до ума отчет." />
<option name="LAST_COMMIT_MESSAGE" value="Довел до ума отчет." />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -264,11 +301,127 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1728">
<caret line="97" column="17" lean-forward="false" selection-start-line="97" selection-start-column="17" selection-end-line="97" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="16" lean-forward="false" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="26" column="34" lean-forward="false" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1728">
<caret line="97" column="17" lean-forward="false" selection-start-line="97" selection-start-column="17" selection-end-line="97" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="16" lean-forward="false" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="26" column="34" lean-forward="false" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1728">
<caret line="97" column="17" lean-forward="false" selection-start-line="97" selection-start-column="17" selection-end-line="97" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="16" lean-forward="true" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="26" column="34" lean-forward="false" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="18" column="7" lean-forward="false" selection-start-line="18" selection-start-column="7" selection-end-line="18" selection-end-column="7" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -292,7 +445,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -308,7 +466,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="14" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="1" selection-end-column="14" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -332,7 +495,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="14" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="1" selection-end-column="14" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -356,7 +524,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -372,7 +545,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -380,7 +558,12 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
@ -394,15 +577,15 @@
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="16" lean-forward="true" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<caret line="8" column="16" lean-forward="false" selection-start-line="8" selection-start-column="16" selection-end-line="8" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="361">
<caret line="26" column="34" lean-forward="false" selection-start-line="26" selection-start-column="34" selection-end-line="26" selection-end-column="34" />
<state relative-caret-position="324">
<caret line="18" column="12" lean-forward="true" selection-start-line="18" selection-start-column="12" selection-end-line="18" selection-end-column="12" />
<folding />
</state>
</provider>
@ -415,13 +598,34 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<entry file="file://$PROJECT_DIR$/config-sample.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="12" lean-forward="true" selection-start-line="1" selection-start-column="12" selection-end-line="1" selection-end-column="12" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="72" column="27" lean-forward="false" selection-start-line="72" selection-start-column="27" selection-end-line="72" selection-end-column="27" />
<state relative-caret-position="90">
<caret line="5" column="12" lean-forward="false" selection-start-line="5" selection-start-column="12" selection-end-line="5" selection-end-column="12" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="432">
<caret line="24" column="9" lean-forward="true" selection-start-line="24" selection-start-column="9" selection-end-line="24" selection-end-column="9" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#1531#3579#0" expanded="false" />
<element signature="e#3639#4090#0" expanded="false" />
<element signature="e#4820#5606#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

+ 11
- 0
config-sample.json View File

@ -0,0 +1,11 @@
{
"ip_oct1":"10",
"ip_oct2":"100",
"sshuser":"root",
"sshpass":"admin",
"dbhost":"127.0.0.1",
"dbuser":"kea",
"dbpass":"kea1234",
"dbbase":"dhcp4",
"ippool":["10","210"]
}

+ 21
- 27
kea_hosts_generane.py View File

@ -1,25 +1,13 @@
#! /usr/bin/python3
# coding=utf-8
# import os
# import subprocess
# import sys
import time
import paramiko
import MySQLdb
import json
ip_oct1 = '10'
ip_oct2 = '5'
sshuser = 'root'
sshpass = 'admin'
dbhost = '10.5.1.248'
dbuser = 'kea'
dbpass = 'kea1234'
dbbase = 'dhcp4'
ippool = [10, 210]
q1c = "SELECT REPLACE(hw_addr, ':','') as hw_addr, " \
"serial, " \
"net_num " \
@ -102,7 +90,7 @@ def send_data(user, password, name, host):
return errorcode # Вертаем все, что наковыряли
def read_table(sql):
def read_table(sql, dbhost, dbuser, dbpass, dbbase):
try:
conn = MySQLdb.connect(host=dbhost, user=dbuser,
passwd=dbpass, db=dbbase)
@ -119,11 +107,8 @@ def read_table(sql):
return data
def first_free_ip(ips, ip_pool, net_num):
def first_free_ip(ips, ip_pool, octet1, octet2, octet3):
locked_ip = []
octet1 = ip_oct1
octet2 = ip_oct2
octet3 = net_num
octet4 = ''
set_octets = False
for ip in ips:
@ -132,10 +117,10 @@ def first_free_ip(ips, ip_pool, net_num):
octet1 = octets[0]
octet2 = octets[1]
set_octets = True
if octets[2] == str(net_num):
if octets[2] == str(octet3):
locked_ip.append(octets[3])
i = ip_pool[0]
while i < ip_pool[1]:
i = int(ip_pool[0])
while i < int(ip_pool[1]):
if not str(i) in locked_ip:
octet4 = str(i)
break
@ -146,7 +131,7 @@ def first_free_ip(ips, ip_pool, net_num):
return "%s.%s.%s.%s" % (octet1, octet2, octet3, octet4)
def make_hosts(sql, ip, hostname, hw_addr):
def make_hosts(sql, ip, hostname, hw_addr, dbhost, dbuser, dbpass, dbbase):
try:
conn = MySQLdb.connect(host=dbhost, user=dbuser,
passwd=dbpass, db=dbbase)
@ -173,19 +158,28 @@ def make_hosts(sql, ip, hostname, hw_addr):
return data
def read_conf():
conf = json.load(open('config.json'))
return conf
def main():
data_1c = read_table(q1c)
data_leases = read_table(qleases4)
conf = read_conf()
data_1c = read_table(q1c, conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase'])
data_leases = read_table(qleases4, conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase'])
for line in data_1c:
set_ip = first_free_ip(read_table(qhosts_ip), ippool, line['net_num'])
set_ip = first_free_ip(read_table(qhosts_ip, conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase']),
conf['ippool'], conf['ip_oct1'], conf['ip_oct2'], line['net_num'])
set_hw_addr = line['hw_addr']
set_host = line['serial']
make_hosts(qinsert_hosts, set_ip, set_host, set_hw_addr)
make_hosts(qinsert_hosts, set_ip, set_host, set_hw_addr,
conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase'])
print('host built name %s, mac %s, ip %s' % (set_host, set_hw_addr, set_ip))
for line in data_1c:
for lease in data_leases:
if line['hw_addr'] == lease['hw_addr']:
send_data(sshuser, sshpass, line['serial'], lease['ip4'])
send_data(conf['sshuser'], conf['sshpass'], line['serial'], lease['ip4'])
if __name__ == '__main__':


Loading…
Cancel
Save

Powered by TurnKey Linux.