Browse Source

Переработаны скрипты с поддержкой конфига, кроме веб-морды

master
Mikhail Grebenkin 7 years ago
parent
commit
c597b23aff
3 changed files with 282 additions and 97 deletions
  1. +174
    -92
      .idea/workspace.xml
  2. +102
    -0
      kea_host_wacher.py
  3. +6
    -5
      kea_hosts_generane.py

+ 174
- 92
.idea/workspace.xml View File

@ -2,8 +2,7 @@
<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="" afterPath="$PROJECT_DIR$/kea_host_wacher.py" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/kea_hosts_generane.py" afterPath="$PROJECT_DIR$/kea_hosts_generane.py" />
</list>
@ -19,33 +18,36 @@
<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="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" />
<state relative-caret-position="180">
<caret line="57" column="30" lean-forward="true" selection-start-line="57" selection-start-column="30" selection-end-line="57" selection-end-column="30" />
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#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">
<file leaf-file-name="kea_host_wacher.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/kea_host_wacher.py">
<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 relative-caret-position="414">
<caret line="91" column="72" lean-forward="true" selection-start-line="91" selection-start-column="72" selection-end-line="91" selection-end-column="72" />
<folding>
<element signature="e#36#47#0" expanded="true" />
</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">
<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="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" />
<state relative-caret-position="198">
<caret line="11" column="0" lean-forward="true" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
@ -54,9 +56,11 @@
<file leaf-file-name="web-leases.py" pinned="false" current-in-tab="false">
<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 relative-caret-position="1746">
<caret line="97" column="39" lean-forward="false" selection-start-line="97" selection-start-column="39" selection-end-line="97" selection-end-column="39" />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -83,6 +87,13 @@
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>print</find>
@ -98,15 +109,15 @@
<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" />
<option value="$PROJECT_DIR$/kea_host_wacher.py" />
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1729" />
<option name="y" value="-4" />
<option name="y" value="610" />
<option name="width" value="1366" />
<option name="height" value="772" />
</component>
@ -137,10 +148,6 @@
<item name="kea_for_miners" type="b2602c69:ProjectViewProjectNode" />
<item name="kea_for_miners" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="kea_for_miners" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
</path>
</expand>
<select />
</subPane>
@ -168,7 +175,25 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.web-leases">
<component name="RunManager" selected="Python.kea_hosts_generane">
<configuration name="kea_host_wacher" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="kea_for_miners" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/kea_host_wacher.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="kea_hosts_generane" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -205,14 +230,16 @@
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<list size="2">
<list size="3">
<item index="0" class="java.lang.String" itemvalue="Python.kea_hosts_generane" />
<item index="1" class="java.lang.String" itemvalue="Python.web-leases" />
<item index="2" class="java.lang.String" itemvalue="Python.kea_host_wacher" />
</list>
<recent_temporary>
<list size="2">
<list size="3">
<item index="0" class="java.lang.String" itemvalue="Python.kea_hosts_generane" />
<item index="1" class="java.lang.String" itemvalue="Python.web-leases" />
<item index="1" class="java.lang.String" itemvalue="Python.kea_host_wacher" />
<item index="2" class="java.lang.String" itemvalue="Python.web-leases" />
</list>
</recent_temporary>
</component>
@ -258,18 +285,26 @@
<option name="project" value="LOCAL" />
<updated>1513190487783</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="Добавлена поддержа конфига для создания хостов">
<created>1513799532745</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1513799532745</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="1366" y="-4" width="1920" height="1084" extended-state="6" />
<frame x="0" y="610" width="1366" height="772" extended-state="6" />
<layout>
<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="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1420205" 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="Find" 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="1" side_tool="false" 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.21676892" 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.3093093" 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" />
@ -279,7 +314,6 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" 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="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" 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="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
@ -292,11 +326,12 @@
<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>
<option name="time" value="1" />
<option name="time" value="2" />
</breakpoint-manager>
<watches-manager />
</component>
@ -307,9 +342,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -318,7 +354,9 @@
<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 />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -344,9 +382,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -355,7 +394,9 @@
<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 />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -381,9 +422,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -392,7 +434,9 @@
<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 />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -418,9 +462,10 @@
<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>
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -429,7 +474,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="504">
<caret line="28" column="8" lean-forward="false" selection-start-line="28" selection-start-column="8" selection-end-line="28" selection-end-column="8" />
<folding />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -447,9 +494,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -458,7 +506,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="486">
<caret line="28" column="8" lean-forward="true" selection-start-line="28" selection-start-column="8" selection-end-line="28" selection-end-column="8" />
<folding />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -468,9 +518,10 @@
<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>
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -487,7 +538,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="true" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -497,9 +550,10 @@
<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>
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -516,7 +570,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="756">
<caret line="43" column="34" lean-forward="false" selection-start-line="43" selection-start-column="34" selection-end-line="43" selection-end-column="34" />
<folding />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -526,9 +582,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -537,7 +594,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="756">
<caret line="43" column="33" lean-forward="false" selection-start-line="43" selection-start-column="33" selection-end-line="43" selection-end-column="33" />
<folding />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -547,9 +606,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -560,9 +620,10 @@
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>
@ -574,14 +635,32 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.tpl">
<entry file="file://$PROJECT_DIR$/config-sample.json">
<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" />
<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$/.gitignore">
<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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1746">
<caret line="97" column="39" lean-forward="false" selection-start-line="97" selection-start-column="39" selection-end-line="97" selection-end-column="39" />
<folding>
<element signature="e#35#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="324">
@ -590,39 +669,42 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<entry file="file://$PROJECT_DIR$/main.tpl">
<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" />
<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$/config-sample.json">
<entry file="file://$PROJECT_DIR$/kea_host_wacher.py">
<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 relative-caret-position="414">
<caret line="91" column="72" lean-forward="true" selection-start-line="91" selection-start-column="72" selection-end-line="91" selection-end-column="72" />
<folding>
<element signature="e#36#47#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<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" />
<state relative-caret-position="198">
<caret line="11" column="0" lean-forward="true" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<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" />
<state relative-caret-position="180">
<caret line="57" column="30" lean-forward="true" selection-start-line="57" selection-start-column="30" selection-end-line="57" selection-end-column="30" />
<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" />
<element signature="e#100#246#0" expanded="false" />
<element signature="e#498#592#0" expanded="false" />
<element signature="e#610#1411#0" expanded="false" />
<element signature="e#4821#5607#0" expanded="false" />
</folding>
</state>
</provider>


+ 102
- 0
kea_host_wacher.py View File

@ -0,0 +1,102 @@
#! /usr/bin/python3
# coding=utf-8
import time
import MySQLdb
import json
import datetime
from kea_hosts_generane import read_table, read_conf
qinsert_last_seen = "insert into was_last_seen (id_1c_import, datetime) " \
"values (%s, now());"
qupdate_last_seen = "update was_last_seen set datetime = now() where id_1c_import = '%s';"
qdelete_last_seen = "delete from was_last_seen where id_1c_import = '%s';"
qdelete_host = "DELETE " \
"FROM" \
" hosts " \
"WHERE" \
" dhcp_identifier " \
"IN " \
" (SELECT " \
" unhex(replace(hw_addr, ':', '')) AS hw_addr" \
" FROM 1c_import" \
" WHERE id like '%s');"
qonline = "select " \
" 1c_import.id as 1c_id " \
"from 1c_import" \
" right join lease4 " \
" on (unhex(replace(1c_import.hw_addr, ':', '')) = lease4.hwaddr);"
qselect_last_seen = "select * from was_last_seen;"
def update_seen(sql, id, dbhost, dbuser, dbpass, dbbase):
try:
conn = MySQLdb.connect(host=dbhost, user=dbuser,
passwd=dbpass, db=dbbase)
except MySQLdb.Error as err:
print("Connection error: {}".format(err))
conn.close()
try:
cur = conn.cursor(MySQLdb.cursors.DictCursor)
print(sql % id)
cur.execute(sql % id)
data = cur.fetchall()
except MySQLdb.Error as err:
print("Query error: {}".format(err))
conn.commit()
conn.close()
return data
def update_hosts(sql, id, dbhost, dbuser, dbpass, dbbase):
try:
conn = MySQLdb.connect(host=dbhost, user=dbuser,
passwd=dbpass, db=dbbase)
except MySQLdb.Error as err:
print("Connection error: {}".format(err))
conn.close()
try:
cur = conn.cursor(MySQLdb.cursors.DictCursor)
print(sql % id)
cur.execute(sql % id)
data = cur.fetchall()
except MySQLdb.Error as err:
print("Query error: {}".format(err))
conn.commit()
conn.close()
return data
def main():
conf = read_conf()
dbconf = [conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase']]
online_hosts = read_table(qonline, *dbconf)
print(online_hosts)
seen = read_table(qselect_last_seen, *dbconf)
print(seen)
seen_list = []
for seen_h in seen:
seen_list.append(seen_h['id_1c_import'])
print(seen_list)
for online_host in online_hosts:
if online_host['1c_id'] in seen_list:
print('need to update host 1c_id = %s' % online_host['1c_id'])
update_seen(qupdate_last_seen, online_host['1c_id'], *dbconf)
elif online_host not in seen:
print('need to add host 1c_id = %s' % online_host['1c_id'])
update_seen(qinsert_last_seen, online_host['1c_id'], *dbconf)
seen = read_table(qselect_last_seen, *dbconf)
for seen_host in seen:
if seen_host['datetime'] < (datetime.datetime.now() - datetime.timedelta(minutes=1)):
print('need to remove host 1c_id = %s' % seen_host['id_1c_import'])
update_hosts(qdelete_host, seen_host['id_1c_import'], *dbconf)
update_seen(qdelete_last_seen, seen_host['id_1c_import'], *dbconf)
if __name__ == '__main__':
main()

+ 6
- 5
kea_hosts_generane.py View File

@ -19,7 +19,7 @@ qleases4 = "SELECT INET_NTOA(address) as ip4, " \
"expire, " \
"valid_lifetime " \
"FROM lease4 " \
"where INET_NTOA(address) like '10.5.0%';"
"where INET_NTOA(address) like '10.%s.0%';"
qhosts_ip = "SELECT " \
"INET_NTOA(ipv4_address) AS ipv4_address " \
@ -165,16 +165,17 @@ def read_conf():
def main():
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'])
dbconf = [conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase']]
data_1c = read_table(q1c, *dbconf)
data_leases = read_table(qleases4 % conf['ip_oct2'], *dbconf)
for line in data_1c:
set_ip = first_free_ip(read_table(qhosts_ip, conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase']),
set_ip = first_free_ip(read_table(qhosts_ip, *dbconf),
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,
conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase'])
*dbconf)
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:


Loading…
Cancel
Save

Powered by TurnKey Linux.