Browse Source

- сделан класс SetupMiners

- добавлены файлы с командами
- добавлен метод настройки хостов через телнет
master
Mikhail Grebenkin 7 years ago
parent
commit
58041e8979
8 changed files with 385 additions and 151 deletions
  1. +230
    -102
      .idea/workspace.xml
  2. +127
    -0
      SetupMinersClass.py
  3. +4
    -0
      config-sample.json
  4. +16
    -47
      kea_hosts_generane.py
  5. +3
    -0
      sshs.json
  6. +3
    -0
      telnets.json
  7. +1
    -1
      venv/pip-selfcheck.json
  8. +1
    -1
      venv1/pip-selfcheck.json

+ 230
- 102
.idea/workspace.xml View File

@ -2,15 +2,14 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="860870ba-65f3-49c8-9afa-136b118d341a" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/tpl/import_hosts.tpl" />
<change beforePath="" afterPath="$PROJECT_DIR$/tpl/remove_hosts.tpl" />
<change beforePath="" afterPath="$PROJECT_DIR$/SetupMinersClass.py" />
<change beforePath="" afterPath="$PROJECT_DIR$/sshs.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/telnets.json" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/config-sample.json" afterPath="$PROJECT_DIR$/config-sample.json" />
<change beforePath="$PROJECT_DIR$/hosts.tpl" afterPath="$PROJECT_DIR$/tpl/hosts.tpl" />
<change beforePath="$PROJECT_DIR$/kea_host_wacher.py" afterPath="$PROJECT_DIR$/kea_host_wacher.py" />
<change beforePath="$PROJECT_DIR$/kea_hosts_generane.py" afterPath="$PROJECT_DIR$/kea_hosts_generane.py" />
<change beforePath="$PROJECT_DIR$/main.tpl" afterPath="$PROJECT_DIR$/tpl/main.tpl" />
<change beforePath="$PROJECT_DIR$/web-leases.py" afterPath="$PROJECT_DIR$/web-leases.py" />
<change beforePath="$PROJECT_DIR$/venv/pip-selfcheck.json" afterPath="$PROJECT_DIR$/venv/pip-selfcheck.json" />
<change beforePath="$PROJECT_DIR$/venv1/pip-selfcheck.json" afterPath="$PROJECT_DIR$/venv1/pip-selfcheck.json" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -24,22 +23,56 @@
<file leaf-file-name="kea_hosts_generane.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="144" column="19" lean-forward="true" selection-start-line="144" selection-start-column="19" selection-end-line="144" selection-end-column="19" />
<state relative-caret-position="666">
<caret line="143" column="13" lean-forward="false" selection-start-line="143" selection-start-column="13" selection-end-line="143" selection-end-column="13" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="kea_host_wacher.py" pinned="false" current-in-tab="true">
<file leaf-file-name="sshs.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/sshs.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="2" column="1" lean-forward="true" selection-start-line="2" selection-start-column="1" selection-end-line="2" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="telnets.json" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/telnets.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="1" lean-forward="true" selection-start-line="0" selection-start-column="1" selection-end-line="0" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="SetupMinersClass.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/SetupMinersClass.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="774">
<caret line="112" column="0" lean-forward="false" selection-start-line="112" selection-start-column="0" selection-end-line="117" selection-end-column="50" />
<folding>
<element signature="e#36#52#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<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="-450">
<caret line="15" column="23" lean-forward="true" selection-start-line="15" selection-start-column="23" selection-end-line="15" selection-end-column="23" />
<state relative-caret-position="1170">
<caret line="98" column="0" lean-forward="false" selection-start-line="98" selection-start-column="0" selection-end-line="98" selection-end-column="0" />
<folding>
<element signature="e#36#50#0" expanded="true" />
</folding>
@ -50,8 +83,8 @@
<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="180">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="15" />
<state relative-caret-position="288">
<caret line="16" column="0" lean-forward="true" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
<folding />
</state>
</provider>
@ -60,8 +93,8 @@
<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="216">
<caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<state relative-caret-position="144">
<caret line="8" column="13" lean-forward="false" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
</state>
</provider>
@ -70,7 +103,7 @@
<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="450">
<state relative-caret-position="684">
<caret line="172" column="24" lean-forward="false" selection-start-line="172" selection-start-column="24" selection-end-line="172" selection-end-column="24" />
<folding>
<element signature="e#35#102#0" expanded="true" />
@ -80,26 +113,6 @@
</provider>
</entry>
</file>
<file leaf-file-name="import_hosts.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tpl/import_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" column="7" lean-forward="true" selection-start-line="25" selection-start-column="7" selection-end-line="25" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="remove_hosts.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tpl/remove_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108">
<caret line="6" column="17" lean-forward="false" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="hosts.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tpl/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
@ -113,8 +126,8 @@
<file leaf-file-name="main.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tpl/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="10" column="44" lean-forward="true" selection-start-line="10" selection-start-column="8" selection-end-line="10" selection-end-column="44" />
<state relative-caret-position="252">
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
<folding />
</state>
</provider>
@ -143,23 +156,27 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/kea_host_wacher.py" />
<option value="$PROJECT_DIR$/config.json" />
<option value="$PROJECT_DIR$/config-sample.json" />
<option value="$PROJECT_DIR$/hosts.tpl" />
<option value="$PROJECT_DIR$/tpl/import_hosts.tpl" />
<option value="$PROJECT_DIR$/main.tpl" />
<option value="$PROJECT_DIR$/tpl/hosts.tpl" />
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
<option value="$PROJECT_DIR$/tpl/remove_hosts.tpl" />
<option value="$PROJECT_DIR$/web-leases.py" />
<option value="$PROJECT_DIR$/config.json" />
<option value="$PROJECT_DIR$/config-sample.json" />
<option value="$PROJECT_DIR$/send_telnet.py" />
<option value="$PROJECT_DIR$/SetupMinersClass.py" />
<option value="$PROJECT_DIR$/sshs.json" />
<option value="$PROJECT_DIR$/telnets.json" />
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="2321" />
<option name="y" value="206" />
<option name="x" value="1775" />
<option name="y" value="-4" />
<option name="width" value="1364" />
<option name="height" value="764" />
<option name="height" value="792" />
</component>
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
@ -179,6 +196,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -195,7 +213,6 @@
<select />
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
@ -224,7 +241,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.kea_host_wacher">
<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" />
@ -261,6 +278,24 @@
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="send_telnet" 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$/SetupMinersClass.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="web-leases" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -279,16 +314,18 @@
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<list size="3">
<list size="4">
<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" />
<item index="3" class="java.lang.String" itemvalue="Python.send_telnet" />
</list>
<recent_temporary>
<list size="3">
<item index="0" class="java.lang.String" itemvalue="Python.kea_host_wacher" />
<item index="1" class="java.lang.String" itemvalue="Python.kea_hosts_generane" />
<item index="2" class="java.lang.String" itemvalue="Python.web-leases" />
<list size="4">
<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.send_telnet" />
<item index="3" class="java.lang.String" itemvalue="Python.kea_host_wacher" />
</list>
</recent_temporary>
</component>
@ -355,18 +392,26 @@
<option name="project" value="LOCAL" />
<updated>1514411099952</updated>
</task>
<option name="localTasksCounter" value="8" />
<task id="LOCAL-00008" summary="- Добавлена поддержка конфига в web_leases&#10;- Добавлен функционал всяческий">
<created>1514494342613</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1514494342613</updated>
</task>
<option name="localTasksCounter" value="9" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="1366" y="-4" width="1920" height="1084" extended-state="6" />
<editor active="true" />
<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.10104167" 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.13958333" 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="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21063395" 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.21063395" 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" />
@ -392,7 +437,8 @@
<MESSAGE value="Добавлена поддержа конфига для создания хостов" />
<MESSAGE value="Переработаны скрипты с поддержкой конфига, кроме веб-морды" />
<MESSAGE value="Поправил wotcher так, чтобы не цеплял лизинг с нулевым третьим октетом" />
<option name="LAST_COMMIT_MESSAGE" value="Поправил wotcher так, чтобы не цеплял лизинг с нулевым третьим октетом" />
<MESSAGE value="- Добавлена поддержка конфига в web_leases&#10;- Добавлен функционал всяческий" />
<option name="LAST_COMMIT_MESSAGE" value="- Добавлена поддержка конфига в web_leases&#10;- Добавлен функционал всяческий" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -401,14 +447,48 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/tpl/import_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" column="7" lean-forward="true" selection-start-line="25" selection-start-column="7" selection-end-line="25" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tpl/remove_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108">
<caret line="6" column="17" lean-forward="false" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tpl/hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="10" column="44" lean-forward="false" selection-start-line="10" selection-start-column="44" selection-end-line="10" selection-end-column="44" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tpl/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="3" column="7" lean-forward="true" selection-start-line="3" selection-start-column="7" selection-end-line="3" selection-end-column="7" />
<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="612">
<caret line="57" column="30" lean-forward="false" 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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -464,8 +544,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -503,8 +585,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -542,8 +626,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -581,8 +667,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -612,8 +700,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -635,8 +725,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -666,8 +758,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -697,8 +791,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -720,8 +816,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -732,8 +830,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#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
@ -752,18 +852,18 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.json">
<entry file="file://$PROJECT_DIR$/tpl/import_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="15" />
<state relative-caret-position="450">
<caret line="25" column="7" lean-forward="false" selection-start-line="25" selection-start-column="7" selection-end-line="25" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config-sample.json">
<entry file="file://$PROJECT_DIR$/tpl/remove_hosts.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<state relative-caret-position="108">
<caret line="6" column="17" lean-forward="false" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
<folding />
</state>
</provider>
@ -778,31 +878,41 @@
</entry>
<entry file="file://$PROJECT_DIR$/tpl/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="10" column="44" lean-forward="true" selection-start-line="10" selection-start-column="8" selection-end-line="10" selection-end-column="44" />
<state relative-caret-position="252">
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tpl/import_hosts.tpl">
<entry file="file://$PROJECT_DIR$/config-sample.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" column="7" lean-forward="true" selection-start-line="25" selection-start-column="7" selection-end-line="25" selection-end-column="7" />
<state relative-caret-position="144">
<caret line="8" column="13" lean-forward="false" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tpl/remove_hosts.tpl">
<entry file="file://$PROJECT_DIR$/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108">
<caret line="6" column="17" lean-forward="false" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
<state relative-caret-position="288">
<caret line="16" column="0" lean-forward="true" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_host_wacher.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1170">
<caret line="98" column="0" lean-forward="false" selection-start-line="98" selection-start-column="0" selection-end-line="98" selection-end-column="0" />
<folding>
<element signature="e#36#50#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<state relative-caret-position="684">
<caret line="172" column="24" lean-forward="false" selection-start-line="172" selection-start-column="24" selection-end-line="172" selection-end-column="24" />
<folding>
<element signature="e#35#102#0" expanded="true" />
@ -813,25 +923,43 @@
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="144" column="19" lean-forward="true" selection-start-line="144" selection-start-column="19" selection-end-line="144" selection-end-column="19" />
<state relative-caret-position="666">
<caret line="143" column="13" lean-forward="false" selection-start-line="143" selection-start-column="13" selection-end-line="143" selection-end-column="13" />
<folding>
<element signature="e#37#48#0" expanded="true" />
<element signature="e#492#586#0" expanded="false" />
<element signature="e#604#1405#0" expanded="false" />
<element signature="e#140#280#0" expanded="false" />
<element signature="e#293#518#0" expanded="false" />
<element signature="e#532#626#0" expanded="false" />
<element signature="e#644#1445#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_host_wacher.py">
<entry file="file://$PROJECT_DIR$/SetupMinersClass.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-450">
<caret line="15" column="23" lean-forward="true" selection-start-line="15" selection-start-column="23" selection-end-line="15" selection-end-column="23" />
<state relative-caret-position="774">
<caret line="112" column="0" lean-forward="false" selection-start-line="112" selection-start-column="0" selection-end-line="117" selection-end-column="50" />
<folding>
<element signature="e#36#50#0" expanded="true" />
<element signature="e#36#52#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sshs.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="2" column="1" lean-forward="true" selection-start-line="2" selection-start-column="1" selection-end-line="2" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/telnets.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="1" lean-forward="true" selection-start-line="0" selection-start-column="1" selection-end-line="0" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

+ 127
- 0
SetupMinersClass.py View File

@ -0,0 +1,127 @@
#! /usr/bin/python3
# coding=utf-8
import telnetlib
import json
import paramiko
import time
class SSHSetup:
def __init__(self, host, port, user, passwd, comlist=[]):
self.host = host
self.user = user
self.passwd = passwd
self.port = port
try:
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(hostname=self.host, port=self.port, username=self.user, password=self.passwd,
look_for_keys=False, allow_agent=False)
self.ssh = self.client.invoke_shell()
time.sleep(1)
self.ssh.recv(10000)
except Exception as exc:
raise Exception('ssh error: {}'.format(exc))
if len(comlist) > 0:
if 'exit' not in comlist:
comlist.append('exit')
self.sendall(comlist)
self.close()
def send(self, command):
self.ssh.send(command + '\n')
time.sleep(1)
print(self.ssh.recv(10000).decode())
def sendall(self, commlist=[]):
for command in commlist:
self.send(command)
def close(self):
self.ssh.close()
class TelnetSetup:
def __init__(self, host, port, user, passwd, comlist=[]):
self.host = host
self.port = port
self.user = user
self.passwd = passwd
try:
self.tn = telnetlib.Telnet(host, port)
except Exception as exc:
raise Exception('telnet error: {}'.format(exc))
if len(comlist) > 0:
if 'exit' not in comlist:
comlist.append('exit')
self.login()
self.sendall(comlist)
self.close()
def login(self):
print(self.tn.read_until(b'login:'))
self.tn.write(self.user.encode('utf8') + b'\n')
print(self.tn.read_until(b'Password:'))
self.tn.write(self.passwd.encode('utf8') + b'\n')
self.tn.read_until(self.user.encode('utf8'))
def send(self, command):
self.tn.write(command.encode('utf8') + b'\n')
print(self.tn.read_until(self.user.encode('utf8')).decode('utf8'))
def sendall(self, comlist=[]):
for command in comlist:
self.send(command)
def close(self):
self.tn.close()
class SetupMiner:
def __init__(self, host, conf={}, telnets=[], sshs=[]):
self.host = host
self.conf = conf
if len(telnets) == 0:
self.telnets = ["uname -a", "ps -A", "exit"]
else:
self.telnets = telnets
if len(sshs) == 0:
self.sshs = ["uname -a", "ps -A", "exit"]
else:
self.sshs = sshs
try:
TelnetSetup(self.host, self.conf['telnetport'], self.conf['telnetuser'], self.conf['telnetpass'],
self.telnets)
except Exception as exc:
print(exc)
try:
SSHSetup(self.host, self.conf['sshport'], self.conf['sshuser'], conf['sshpass'], self.sshs)
except Exception as exc:
raise exc
def read_conf():
with open('config.json') as f:
conf = json.load(f)
return conf
def main():
conf = read_conf()
minerconf = {"sshuser": conf["sshuser"],
"sshpass": conf["sshpass"],
"sshport": conf["sshport"],
"telnetuser": conf["telnetuser"],
"telnetpass": conf["telnetpass"],
"telnetport": conf["telnetport"]}
comlist = ["uname -a", "ps -A", "exit"]
try:
SetupMiner('10.100.0.48', minerconf)
except Exception as exc:
print(exc)
if __name__ == '__main__':
main()

+ 4
- 0
config-sample.json View File

@ -3,6 +3,10 @@
"ip_oct2":"100",
"sshuser":"root",
"sshpass":"admin",
"sshport":"22",
"telnetuser":"telnetd",
"telnetpass":"admin",
"telnetport":"23",
"dbhost":"127.0.0.1",
"dbuser":"kea",
"dbpass":"kea1234",


+ 16
- 47
kea_hosts_generane.py View File

@ -6,6 +6,7 @@ import time
import paramiko
import MySQLdb
import json
from SetupMinersClass import SetupMiner
q1c = "SELECT REPLACE(hw_addr, ':','') as hw_addr, " \
@ -47,49 +48,6 @@ qinsert_hosts = "START TRANSACTION; " \
qupdate_1c = "update 1c_import set imported = 1 where serial = '%s';"
def send_data(user, password, name, host):
errorcode = ''
# work = True
commands = []
# commands.append("hostname %s" % name)
# commands.append("echo '%s' > /etc/hostname" % name)
# commands.append("echo 'hostname=%s' > /etc/network.conf.factory" % name)
# commands.append("echo 'dhcp=true' >> /etc/network.conf.factory")
# commands.append("echo 'hostname=%s' > /config/network.conf" % name)
# commands.append("echo 'dhcp=true' >> /config/network.conf")
# commands.append("sync")
commands.append("/sbin/reboot \n")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # если нет хоста - добавляем
try:
client.connect(hostname=host, username=user, password=password, look_for_keys=False,
allow_agent=False) # пытаемся подключиться, look_for_keys=False, allow_agent=False - зачем-то
# нужны циске.
except Exception as exept: # в случае исключения -
print(exept) # возвращаем код и описание исключения
else: # усли все в порядке
conn = client.invoke_shell() # врубаем интерактивный шелл - с цисками только так.
time.sleep(1) # задержка
conn.recv(1000) # хаваем все, что выплюнула, дабы не отсвечивало (ограничиваю 1000 строк)
# conn.send("head -n 1 /config/network.conf\n")
# time.sleep(1)
# h = conn.recv(100)
# if "hostname=" + name in h:
# work = False
work = True # ЗАГЛУШКА!!! В данном случае условия не проверяются.
if work:
print(name, host, "will reboot")
for command in commands: # Читаем и исполняем команды
conn.send(command + '\n') # засылаем команду
time.sleep(0.1) # ждем указанный таймаут
print(conn.recv(99999999999)) # хаваем его в никуда
else:
print("nothing to do")
finally: # по окончании всех процедур
client.close() # закрываем коннектий
return errorcode # Вертаем все, что наковыряли
def read_table(sql, dbhost, dbuser, dbpass, dbbase):
try:
conn = MySQLdb.connect(host=dbhost, user=dbuser,
@ -158,14 +116,25 @@ def make_hosts(sql, ip, hostname, hw_addr, dbhost, dbuser, dbpass, dbbase):
return data
def read_conf():
with open('config.json') as f:
def read_conf(file):
with open(file) as f:
conf = json.load(f)
return conf
def main():
conf = read_conf()
conf = read_conf('config.json')
sshs = read_conf('sshs.json')
telnets = read_conf('telnets.json')
print(sshs)
print(telnets)
telnets = read_conf('telnets.json')
minerconf = {"sshuser": conf["sshuser"],
"sshpass": conf["sshpass"],
"sshport": conf["sshport"],
"telnetuser": conf["telnetuser"],
"telnetpass": conf["telnetpass"],
"telnetport": conf["telnetport"]}
dbconf = [conf['dbhost'], conf['dbuser'], conf['dbpass'], conf['dbbase']]
data_1c = read_table(q1c, *dbconf)
data_leases = read_table(qleases4.format(conf['ip_oct2']), *dbconf)
@ -182,7 +151,7 @@ def main():
for lease in data_leases:
if line['hw_addr'] == lease['hw_addr']:
print('rebooting %s' % lease['ip4'])
send_data(conf['sshuser'], conf['sshpass'], line['serial'], lease['ip4'])
SetupMiner(lease['ip4'], minerconf, telnets=telnets, sshs=sshs)
if __name__ == '__main__':


+ 3
- 0
sshs.json View File

@ -0,0 +1,3 @@
[
"/sbin/reboot"
]

+ 3
- 0
telnets.json View File

@ -0,0 +1,3 @@
[
"/sbin/reboot"
]

+ 1
- 1
venv/pip-selfcheck.json View File

@ -1 +1 @@
{"last_check":"2017-12-10T20:23:26Z","pypi_version":"9.0.1"}
{"last_check":"2017-12-30T20:22:40Z","pypi_version":"9.0.1"}

+ 1
- 1
venv1/pip-selfcheck.json View File

@ -1 +1 @@
{"last_check":"2017-12-10T20:32:13Z","pypi_version":"9.0.1"}
{"last_check":"2017-12-30T20:23:42Z","pypi_version":"9.0.1"}

Loading…
Cancel
Save

Powered by TurnKey Linux.