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
|
||||
.idea/
|
||||
|
||||
.venv/
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Python template
|
||||
# Byte-compiled / optimized / DLL files
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
.venv
|
||||
.git
|
||||
__pycache__/
|
||||
*.egg-info/
|
||||
venv
|
|
@ -7,15 +7,19 @@ from SWSCloudCore.controllers.tasks import ControllerTasks
|
|||
from SWSCloudCore import models
|
||||
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'])
|
||||
@requires_login
|
||||
def index():
|
||||
# формируем список правил
|
||||
return render_template(
|
||||
'administrator/compute/vms/index.html', vms=models.Vms.get_items())
|
||||
"""Virtual Machines list"""
|
||||
template = 'administrator/compute/vms/index.html'
|
||||
items = models.Vms.get_items()
|
||||
return render_template(template, vms=items)
|
||||
|
||||
|
||||
@view_administrator_compute_vms.route('/<uuid:vm_id>', methods=['GET'])
|
||||
|
|
|
@ -51,7 +51,11 @@ app.register_blueprint(view_administrator_compute_containers)
|
|||
def before_request():
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# coding: utf-8
|
||||
"""Stack Web Services LLC."""
|
||||
|
||||
import json
|
||||
from flask import Blueprint, jsonify, request, g
|
||||
|
|
|
@ -2,8 +2,13 @@ import requests
|
|||
|
||||
|
||||
class SWSStatisticsClient(object):
|
||||
def get_vm(self, vm_id, limit=96):
|
||||
r = requests.get('http://server-stats.gocloud.ru/stats/v1/compute/vms/%s' % vm_id, params={'limit': limit})
|
||||
def get_vm(self, vm_id: str, limit: int = 96):
|
||||
r = requests.get(
|
||||
f"http://server-stats.gocloud.ru/stats/v1/compute/vms/{vm_id}",
|
||||
params={
|
||||
'limit': limit
|
||||
}
|
||||
)
|
||||
if r.status_code == 200:
|
||||
return r.json()
|
||||
return None
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[Database]
|
||||
host = localhost
|
||||
user = postgres
|
||||
password = postgres
|
||||
user = cherry
|
||||
password = P@ss5476
|
||||
port = 5432
|
||||
name = gocloud
|
||||
name = testdb
|
||||
|
||||
[Application]
|
||||
DEBUG = true
|
||||
|
|
Loading…
Add table
Reference in a new issue