Browse Source

добавлен отчет, поменял команду перезагрузки на корректную.

master
Mikhail Grebenkin 7 years ago
parent
commit
ed7f1b1c69
5 changed files with 238 additions and 75 deletions
  1. +148
    -70
      .idea/workspace.xml
  2. +37
    -0
      hosts.tpl
  3. +1
    -1
      kea_hosts_generane.py
  4. +6
    -3
      main.tpl
  5. +46
    -1
      web-leases.py

+ 148
- 70
.idea/workspace.xml View File

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="860870ba-65f3-49c8-9afa-136b118d341a" name="Default" comment="" />
<list default="true" id="860870ba-65f3-49c8-9afa-136b118d341a" name="Default" comment="Поправил пару косяков. Ничего важного.">
<change beforePath="" afterPath="$PROJECT_DIR$/hosts.tpl" />
<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" />
<change beforePath="$PROJECT_DIR$/main.tpl" afterPath="$PROJECT_DIR$/main.tpl" />
<change beforePath="$PROJECT_DIR$/web-leases.py" afterPath="$PROJECT_DIR$/web-leases.py" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -11,29 +17,32 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="kea_hosts_generane.py" pinned="false" current-in-tab="false">
<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="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>
<element signature="e#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<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" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="web-leases.py" pinned="false" current-in-tab="true">
<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="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>
<element signature="e#0#52#0" expanded="true" />
</folding>
<state relative-caret-position="397">
<caret line="88" column="24" lean-forward="true" selection-start-line="88" selection-start-column="24" selection-end-line="88" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<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="199">
<caret line="22" column="29" lean-forward="false" selection-start-line="22" selection-start-column="29" selection-end-line="22" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
@ -41,8 +50,8 @@
<file leaf-file-name="main.tpl" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="8" column="0" lean-forward="false" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<state relative-caret-position="108">
<caret line="6" column="34" lean-forward="true" selection-start-line="6" selection-start-column="34" selection-end-line="6" selection-end-column="34" />
<folding />
</state>
</provider>
@ -55,12 +64,16 @@
<find>print</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
<option value="$PROJECT_DIR$/main.tpl" />
<option value="$PROJECT_DIR$/web-leases.py" />
<option value="$PROJECT_DIR$/hosts.tpl" />
<option value="$PROJECT_DIR$/kea_hosts_generane.py" />
</list>
</option>
</component>
@ -69,6 +82,9 @@
<option name="width" value="1699" />
<option name="height" value="1080" />
</component>
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
@ -91,18 +107,27 @@
<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>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
@ -177,6 +202,14 @@
<option name="presentableId" value="Default" />
<updated>1512923489622</updated>
</task>
<task id="LOCAL-00001" summary="Поправил пару косяков. Ничего важного.">
<created>1513092720380</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1513092720380</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="ToolWindowManager">
@ -185,10 +218,10 @@
<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="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.33" 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="false" weight="0.33" sideWeight="0.5" order="7" 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="false" show_stripe_button="true" weight="0.21856287" 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.21771772" 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" />
@ -206,6 +239,10 @@
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Поправил пару косяков. Ничего важного." />
<option name="LAST_COMMIT_MESSAGE" value="Поправил пару косяков. Ничего важного." />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="1" />
@ -213,16 +250,75 @@
<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="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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.tpl">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="12" lean-forward="false" 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$/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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<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 />
</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="0" lean-forward="false" selection-start-line="8" selection-start-column="0" selection-end-line="8" 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="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 />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<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>
<element signature="e#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -238,9 +334,7 @@
<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>
<element signature="e#0#52#0" expanded="true" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -248,12 +342,7 @@
<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#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -261,9 +350,7 @@
<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>
<element signature="e#0#52#0" expanded="true" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -271,12 +358,7 @@
<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#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -284,12 +366,7 @@
<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#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<folding />
</state>
</provider>
</entry>
@ -302,32 +379,33 @@
</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="0" lean-forward="false" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<state relative-caret-position="108">
<caret line="6" column="34" lean-forward="true" selection-start-line="6" selection-start-column="34" selection-end-line="6" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/kea_hosts_generane.py">
<entry file="file://$PROJECT_DIR$/web-leases.py">
<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>
<element signature="e#81#92#0" expanded="true" />
<element signature="e#259#405#0" expanded="false" />
<element signature="e#418#642#0" expanded="false" />
<element signature="e#656#750#0" expanded="false" />
</folding>
<state relative-caret-position="397">
<caret line="88" column="24" lean-forward="true" selection-start-line="88" selection-start-column="24" selection-end-line="88" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/web-leases.py">
<entry file="file://$PROJECT_DIR$/hosts.tpl">
<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>
<element signature="e#0#52#0" expanded="true" />
</folding>
<state relative-caret-position="199">
<caret line="22" column="29" lean-forward="false" selection-start-line="22" selection-start-column="29" selection-end-line="22" selection-end-column="29" />
<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="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" />
<folding />
</state>
</provider>
</entry>


+ 37
- 0
hosts.tpl View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<head>
<title>DHCP web-viewer</title>
</head>
<html>
<body>
<a href="/hosts/">отчет по занятым хостам</a>
<h1>Leases report</h1>
<br /><br />
<table border="1">
<caption>Таблица аренды адресов</caption>
<tr>
<th>IP адрес</th>
<th>Имя хоста</th>
<th>Mac адрес</th>
<th>адрес арендован</th>
</tr>
%for a in A:
<tr>
%for i in a:
<td>
%if i == '-':
<font size="5" color="red" face="Arial">-</font>
%end
%if i == '+':
<font size="5" color="green" face="Arial">+</font>
%end
%if not i == '+' and not i == '-':
{{i}}
%end
</td>
%end
</tr>
%end
</table>
</body>
</html>

+ 1
- 1
kea_hosts_generane.py View File

@ -70,7 +70,7 @@ def send_data(user, password, name, host):
# commands.append("echo 'hostname=%s' > /config/network.conf" % name)
# commands.append("echo 'dhcp=true' >> /config/network.conf")
# commands.append("sync")
commands.append("reboot \n")
commands.append("/sbin/reboot \n")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # если нет хоста - добавляем
try:


+ 6
- 3
main.tpl View File

@ -1,10 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Bottle Home</title>
<title>DHCP web-viewer</title>
</head>
<html>
<body>
<h1>Initial page</h1>
<a href="/hosts/">отчет по занятым хостам</a>
<h1>Leases report</h1>
<br /><br />
<table border="1">
<caption>Таблица аренды адресов</caption>
@ -20,5 +21,7 @@
<td>{{i}}</td>
%end
%end
</tr>
</table>
</body>
</html>

+ 46
- 1
web-leases.py View File

@ -50,4 +50,49 @@ def server_homepage():
return template('main.tpl', A=data_list)
run(host='10.5.1.248', port=8080, debug=True)
@route('/hosts/')
def server_hosts_repo():
dbhost = '10.5.1.248'
dbuser = 'kea'
dbpass = 'kea1234'
dbbase = 'dhcp4'
sql = "SELECT " \
"INET_NTOA(hosts.ipv4_address) AS ip4," \
" hosts.hostname," \
" HEX(dhcp_identifier)as hw_addr, " \
" if(hex(inet_ntoa(lease4.address)), '+','-') as leased " \
"FROM " \
" hosts " \
"LEFT JOIN" \
" lease4" \
" on" \
" dhcp_identifier = hwaddr " \
"ORDER BY ip4;" \
# "where " \
# " INET_NTOA(hosts.ipv4_address) LIKE '10.5.1%';"
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)
cur.execute(sql)
data = cur.fetchall()
except MySQLdb.Error as err:
print("Query error: {}".format(err))
conn.close()
data_list = []
for row in data:
temp = []
temp.append(row['ip4'])
temp.append(row['hostname'])
temp.append(row['hw_addr'])
temp.append(row['leased'])
data_list.append(temp)
print(data_list)
return template('hosts.tpl', A=data_list)
run(host='127.0.0.1', port=8080, debug=True)

Loading…
Cancel
Save

Powered by TurnKey Linux.