update
This commit is contained in:
parent
bfe906a1cf
commit
6a11181075
7 changed files with 26 additions and 12 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
settings.ini
|
settings.ini
|
||||||
.idea/
|
.idea/
|
||||||
|
.venv/
|
||||||
# Created by .ignore support plugin (hsz.mobi)
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
### Python template
|
### Python template
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.venv
|
.venv
|
||||||
.git
|
.git
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
*.egg-info/
|
||||||
venv
|
venv
|
|
@ -7,15 +7,19 @@ from SWSCloudCore.controllers.tasks import ControllerTasks
|
||||||
from SWSCloudCore import models
|
from SWSCloudCore import models
|
||||||
from SWSCloudAdministrator.Administrator.common import requires_login
|
from SWSCloudAdministrator.Administrator.common import requires_login
|
||||||
|
|
||||||
view_administrator_compute_vms = Blueprint('administrator_compute_vms', __name__, url_prefix='/administrator/compute/vms')
|
view_administrator_compute_vms = Blueprint(
|
||||||
|
'administrator_compute_vms',
|
||||||
|
__name__,
|
||||||
|
url_prefix='/administrator/compute/vms')
|
||||||
|
|
||||||
|
|
||||||
@view_administrator_compute_vms.route('/', methods=['GET'])
|
@view_administrator_compute_vms.route('/', methods=['GET'])
|
||||||
@requires_login
|
@requires_login
|
||||||
def index():
|
def index():
|
||||||
# формируем список правил
|
"""Virtual Machines list"""
|
||||||
return render_template(
|
template = 'administrator/compute/vms/index.html'
|
||||||
'administrator/compute/vms/index.html', vms=models.Vms.get_items())
|
items = models.Vms.get_items()
|
||||||
|
return render_template(template, vms=items)
|
||||||
|
|
||||||
|
|
||||||
@view_administrator_compute_vms.route('/<uuid:vm_id>', methods=['GET'])
|
@view_administrator_compute_vms.route('/<uuid:vm_id>', methods=['GET'])
|
||||||
|
|
|
@ -51,7 +51,11 @@ app.register_blueprint(view_administrator_compute_containers)
|
||||||
def before_request():
|
def before_request():
|
||||||
g.settings = dict()
|
g.settings = dict()
|
||||||
# извлекаем настройки и определяем их в глобальную переменную
|
# извлекаем настройки и определяем их в глобальную переменную
|
||||||
for setting in models.Settings.select(models.Settings.key, models.Settings.val).execute():
|
settings = models.Settings.select(
|
||||||
|
models.Settings.key,
|
||||||
|
models.Settings.val
|
||||||
|
).execute()
|
||||||
|
for setting in settings:
|
||||||
g.settings[setting.key] = setting.val
|
g.settings[setting.key] = setting.val
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# coding: utf-8
|
"""Stack Web Services LLC."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from flask import Blueprint, jsonify, request, g
|
from flask import Blueprint, jsonify, request, g
|
||||||
|
|
|
@ -2,8 +2,13 @@ import requests
|
||||||
|
|
||||||
|
|
||||||
class SWSStatisticsClient(object):
|
class SWSStatisticsClient(object):
|
||||||
def get_vm(self, vm_id, limit=96):
|
def get_vm(self, vm_id: str, limit: int = 96):
|
||||||
r = requests.get('http://server-stats.gocloud.ru/stats/v1/compute/vms/%s' % vm_id, params={'limit': limit})
|
r = requests.get(
|
||||||
|
f"http://server-stats.gocloud.ru/stats/v1/compute/vms/{vm_id}",
|
||||||
|
params={
|
||||||
|
'limit': limit
|
||||||
|
}
|
||||||
|
)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
return r.json()
|
return r.json()
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[Database]
|
[Database]
|
||||||
host = localhost
|
host = localhost
|
||||||
user = postgres
|
user = cherry
|
||||||
password = postgres
|
password = P@ss5476
|
||||||
port = 5432
|
port = 5432
|
||||||
name = gocloud
|
name = testdb
|
||||||
|
|
||||||
[Application]
|
[Application]
|
||||||
DEBUG = true
|
DEBUG = true
|
||||||
|
|
Loading…
Add table
Reference in a new issue