44 Списание редств со счёта пользователя
This commit is contained in:
parent
43514e4652
commit
a86243b475
2 changed files with 40 additions and 17 deletions
|
@ -17,8 +17,12 @@
|
||||||
<li><a href="{{ url_for('account.logout') }}">Выход</a></li>
|
<li><a href="{{ url_for('account.logout') }}">Выход</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="left">
|
<ul class="left">
|
||||||
|
{% if g.settings.get('SERVICE_CONTAINERS_ENABLE', "0") == "1" %}
|
||||||
<li><a href="{{ url_for('containers.index') }}">Контейнеры</a></li>
|
<li><a href="{{ url_for('containers.index') }}">Контейнеры</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if g.settings.get('SERVICE_VMS_ENABLE', '0') == '1' %}
|
||||||
<li><a href="{{ url_for('vms.index') }}">Виртуальные машины</a></li>
|
<li><a href="{{ url_for('vms.index') }}">Виртуальные машины</a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
<ul class="right">
|
<ul class="right">
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
from SWSCloudCore import models
|
from SWSCloudCore import models
|
||||||
|
|
||||||
|
|
||||||
print 'total vms:', models.Vms.select().count()
|
if int(models.Settings.select().where(models.Settings.key == 'SERVICE_VMS_ENABLE').get().val) == 1:
|
||||||
for vm in models.Vms.select():
|
print 'total vms:', models.Vms.select().count()
|
||||||
|
for vm in models.Vms.select():
|
||||||
# Высчитываем, сколько стоит виртуальная машина 15 минут
|
# Высчитываем, сколько стоит виртуальная машина 15 минут
|
||||||
price_quarter = vm.plan.price / 30 / 24 / 4
|
price_quarter = vm.plan.price / 30 / 24 / 4
|
||||||
|
|
||||||
|
@ -19,9 +20,27 @@ for vm in models.Vms.select():
|
||||||
)
|
)
|
||||||
x.execute()
|
x.execute()
|
||||||
|
|
||||||
print 'total containers:', models.Containers.select().count()
|
if int(models.Settings.select().where(models.Settings.key == 'SERVICE_CONTAINERS_ENABLE').get().val) == 1:
|
||||||
|
print 'total containers:', models.Containers.select().count()
|
||||||
|
for container in models.Containers.select():
|
||||||
|
container_state = models.ContainersStatisticsState.select().where(
|
||||||
|
models.ContainersStatisticsState.container == container.id
|
||||||
|
).get()
|
||||||
|
# min_price = 100 + (container_state.size * )
|
||||||
|
|
||||||
# Post operations
|
# # Высчитываем, сколько стоит виртуальная машина 15 минут
|
||||||
# Check user balance
|
# price_quarter = vm.plan.price / 30 / 24 / 4
|
||||||
# If user balance less that allowable limit
|
#
|
||||||
# then power off all virtual machines and containers
|
# print dict(id=vm.id, user=vm.user.id, plan=vm.plan.id, cost_mo=vm.plan.price, cost_quarter=price_quarter)
|
||||||
|
#
|
||||||
|
# # Списание средств
|
||||||
|
# x = models.UsersBalance.update(
|
||||||
|
# balance=models.UsersBalance.balance - price_quarter
|
||||||
|
# ).where(
|
||||||
|
# models.UsersBalance.user == vm.user.id
|
||||||
|
# )
|
||||||
|
# x.execute()
|
||||||
|
# Post operations
|
||||||
|
# Check user balance
|
||||||
|
# If user balance less that allowable limit
|
||||||
|
# then power off all virtual machines and containers
|
||||||
|
|
Loading…
Add table
Reference in a new issue