diff --git a/app/cloud/controllers/ips/manage.py b/app/cloud/controllers/ips/manage.py
index 089ed36..90655fd 100644
--- a/app/cloud/controllers/ips/manage.py
+++ b/app/cloud/controllers/ips/manage.py
@@ -1 +1,9 @@
-__author__ = 'vanzhiganov'
+from app import models
+
+
+class ControllerManageIPs:
+ def items_get(self):
+ return {
+ 'total': models.Ips.select().count(),
+ 'items': models.Ips.select()
+ }
diff --git a/app/cloud/controllers/server_api/server.py b/app/cloud/controllers/server_api/server.py
new file mode 100644
index 0000000..a31648c
--- /dev/null
+++ b/app/cloud/controllers/server_api/server.py
@@ -0,0 +1,6 @@
+from app import models
+
+
+class ControllerServerServerAPI:
+ def report_set(self):
+ pass
diff --git a/app/cloud/views/administrator/__init__.py b/app/cloud/views/administrator/__init__.py
index 40985d6..eb9655f 100644
--- a/app/cloud/views/administrator/__init__.py
+++ b/app/cloud/views/administrator/__init__.py
@@ -19,6 +19,7 @@ from app.cloud.controllers.datacenters.manage import ControllerManageDatacenters
from app.cloud.controllers.servers.manage import ControllerManageServer
from app.cloud.controllers.billing import ControllerBilling
from app.cloud.controllers.containers.manage import ControllerManageContainers
+from app.cloud.controllers.ips.manage import ControllerManageIPs
viewAdministrator = Blueprint('administrator', __name__, url_prefix='/administrator')
@@ -128,7 +129,10 @@ def containers():
return redirect(url_for("administrator.logout"))
# формируем список правил
rules_items = ControllerManageContainers().get_all_items()
- return render_template('administrator/containers/index.html', rules=rules_items)
+ return render_template(
+ 'administrator/containers/index.html',
+ containers=rules_items
+ )
@viewAdministrator.route('/payments')
@@ -220,10 +224,26 @@ def servers_index():
# auth user
if not ControllerAdministrators().auth(session['admin_email'], session['admin_password']):
return redirect(url_for("administrator.logout"))
+ #
+ return render_template(
+ 'administrator/servers/index.html',
+ servers=ControllerManageServer().items_get()
+ )
- servers_items = ControllerManageServer().items_get()
- return render_template('administrator/servers/index.html', servers=servers_items)
+@viewAdministrator.route('/ips/')
+def ips_index():
+ # check session
+ if not ControllerAdministrators().check_session():
+ return redirect(url_for("administrator.logout"))
+ # auth user
+ if not ControllerAdministrators().auth(session['admin_email'], session['admin_password']):
+ return redirect(url_for("administrator.logout"))
+ #
+ return render_template(
+ 'administrator/ips/index.html',
+ ips=ControllerManageIPs().items_get()
+ )
@viewAdministrator.route('/servers/create', methods=['GET', 'POST'])
diff --git a/app/cloud/views/server_api/__init__.py b/app/cloud/views/server_api/__init__.py
index 96e6811..61b90b2 100644
--- a/app/cloud/views/server_api/__init__.py
+++ b/app/cloud/views/server_api/__init__.py
@@ -1,14 +1,12 @@
# coding: utf-8
import json
-import uuid
-
-from flask import Response
+# import uuid
+# from flask import Response
from flask import request
from flask import Blueprint
from flask import jsonify
-
-from app import models
+# from app import models
from app.cloud.controllers.tasks.server import ControllerTasksServer
# from .controllers import ControllerRulesStatistics
@@ -61,3 +59,28 @@ def task_status_update():
server_api.update(task_id, status)
return jsonify({'status': 0})
+
+
+@viewServerAPI.route('/report/container_status', methods=['POST'])
+def report_container_status():
+ node_id = request.args.get('node_id')
+ node_secret = request.args.get('node_secret')
+ server_api = ControllerTasksServer(node_id, node_secret)
+ # auth request
+ if not server_api.auth():
+ # status: 403 - access denied
+ return jsonify({'status': 403})
+
+ """
+ {
+ "cpu_use": 644394623336,
+ "memory_use": 614473728,
+ "link": "vethB2RLMU"
+ "tx_bytes": 48337383,
+ "rx_bytes": 1049439046,
+ "total_bytes": 1097776429
+ }
+ """
+ status = json.loads(request.form['status'])
+
+ return jsonify({})
diff --git a/app/models.py b/app/models.py
index e178645..bab1785 100644
--- a/app/models.py
+++ b/app/models.py
@@ -77,6 +77,8 @@ class UsersSecrets(PgSQLModel):
user = ForeignKeyField(Users, related_name='userssecrets')
secret = CharField(unique=True, null=False)
acl = TextField()
+ # 0 - inactive
+ # 1 - active
status = IntegerField()
diff --git a/app/templates/administrator/_layout.auth.html b/app/templates/administrator/_layout.auth.html
index 9657ffb..d2c5e5a 100644
--- a/app/templates/administrator/_layout.auth.html
+++ b/app/templates/administrator/_layout.auth.html
@@ -117,7 +117,7 @@
Settings
diff --git a/app/templates/administrator/containers/index.html b/app/templates/administrator/containers/index.html
index 0757aa6..800d74b 100644
--- a/app/templates/administrator/containers/index.html
+++ b/app/templates/administrator/containers/index.html
@@ -1,35 +1,38 @@
{% extends 'administrator/_layout.auth.html' %}
-{% block title %}Rules{% endblock %}
+{% block title %}Containers{% endblock %}
-{% block subtitle %}Rules list{% endblock %}
+{% block subtitle %}Containers list{% endblock %}
{% block content %}
- Total: {{ rules.total }}
+ Total: {{ containers.total }}
Id |
- Email |
+ Datacenter |
+ Server |
+ User |
+ IPv4 |
+ IPv6 |
Status |
- Source |
- Alias |
- Action |
- {% if rules.total == 0 %}
+ {% if containers.total == 0 %}
Нет ни одного правила |
{% else %}
- {% for rule in rules['items'] %}
+ {% for container in containers['items'] %}
- {{ rule.id }} |
- {{ rule.user.email }} |
- {{ rule.status }} |
- {{ rule.source }} |
- {{ rule.alias }} |
+ {{ container.id }} |
+ {{ container.datacenter.name }} |
+ {{ container.server.hostname }} |
+ {{ container.user.email }} |
+ {{ container.ipv4 }} |
+ {{ container.ipv6 }} |
+ {{ container.status }} |
Edit |
{% endfor %}
diff --git a/app/templates/administrator/ips/index.html b/app/templates/administrator/ips/index.html
new file mode 100644
index 0000000..0b71433
--- /dev/null
+++ b/app/templates/administrator/ips/index.html
@@ -0,0 +1,51 @@
+{% extends 'administrator/_layout.auth.html' %}
+
+{% block title %}IPs{% endblock %}
+
+{% block subtitle %}IPs list{% endblock %}
+
+{% block content %}
+ Total: {{ ips['total'] }}
+
+
+
+ Id |
+ Data center |
+ Server |
+ IPv4 |
+ IPv4 gateway |
+ IPv6 |
+ IPv6 gateway |
+ Status |
+ Action |
+
+
+
+ {% if ips['total'] == 0 %}
+
+ Нет ни одного правила |
+
+ {% else %}
+ {% for ip in ips['items'] %}
+
+ {{ ip.id }} |
+ {{ ip.datacenter.name }} |
+ {{ ip.server.hostname }} |
+ {{ ip.ipv4 }} |
+ {{ ip.ipv4_gateway }} |
+ {{ ip.ipv6 }} |
+ {{ ip.ipv6_gateway }} |
+
+ {% if ip.status == 0 %}
+ Free
+ {% else %}
+ Busy
+ {% endif %}
+ |
+ Edit |
+
+ {% endfor %}
+ {% endif %}
+
+
+{% endblock %}
diff --git a/app/templates/administrator/payments.html b/app/templates/administrator/payments.html
index 8b9991e..2451140 100644
--- a/app/templates/administrator/payments.html
+++ b/app/templates/administrator/payments.html
@@ -26,7 +26,13 @@
{{ payment.id }} |
{{ payment.user.email }} |
{{ payment.amount }} |
- {{ payment.status }} |
+
+ {% if payment.status == 'process' %}
+ {{ payment.status }}
+ {% elif payment.status == 'success' %}
+ {{ payment.status }}
+ {% endif %}
+ |
{{ payment.notified }} |
{{ payment.created }} |
edit |
diff --git a/app/templates/administrator/users/index.html b/app/templates/administrator/users/index.html
index deada31..4ac5a2a 100644
--- a/app/templates/administrator/users/index.html
+++ b/app/templates/administrator/users/index.html
@@ -22,7 +22,13 @@
{{ user.id }} |
{{ user.email }} |
- {{ user.status }} |
+
+ {% if user.status == 0 %}
+ Inactive
+ {% else %}
+ Active
+ {% endif %}
+ |
Edit
|
diff --git a/cli-dc-ls.py b/cli-dc-ls.py
index b0808b8..3222657 100644
--- a/cli-dc-ls.py
+++ b/cli-dc-ls.py
@@ -21,3 +21,6 @@ for item in items:
print 'id: %s code: %s name: %s country: %s, city: %s, status: %s' % (
item.id, item.code, item.name, item.country, item.city, item.status
)
+
+print '---'
+print 'if you want to add a new data center, use cli-dc-add.py --'
diff --git a/cli-server-add.py b/cli-server-add.py
index 6576328..2f4054e 100644
--- a/cli-server-add.py
+++ b/cli-server-add.py
@@ -2,6 +2,7 @@ import argparse
from uuid import uuid4
from hashlib import md5
from app import models
+from app.cloud.controllers.servers.manage import ControllerManageServer
__author__ = 'vanzhiganov'
@@ -17,17 +18,10 @@ args = parser.parse_args()
server_id = uuid4()
-if models.Servers.select().where(
- (models.Servers.ip == args.ip) |
- (models.Servers.hostname == args.hostname)
-).count() == 0:
- models.Servers.create(
- id=server_id,
- datacenter=args.datacenter,
- secret=args.secret,
- ip=args.ip,
- hostname=args.hostname,
- status=args.status
+if not ControllerManageServer().check_exists(args.ip, None, args.hostname):
+ ControllerManageServer().item_create(
+ args.datacenter, server_id, args.secret, args.hostname,
+ args.ip, None, args.status
)
else:
print 'fail'
diff --git a/requirements.txt b/requirements.txt
index b5899e0..3e0cf77 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,8 @@
Flask==0.10.1
+Flask-Markdown==0.3
psycopg2==2.6.1
requests==2.7.0
uWSGI==2.0.11.1
wsgiref==0.1.2
validators
-sshpubkeys
\ No newline at end of file
+sshpubkeys