2016-05-16 09:24:27 +03:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
from SWSCloudCore.models import PlansVMs
|
|
|
|
|
|
|
|
|
|
|
|
class ControllerPlans(object):
|
|
|
|
def get(self, status=None):
|
|
|
|
"""
|
|
|
|
Тарифные планы
|
|
|
|
:param status:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
if status:
|
|
|
|
return PlansVMs.select().where(PlansVMs.status == status)
|
|
|
|
return PlansVMs.select()
|
2016-05-22 12:36:54 +03:00
|
|
|
|
2016-06-09 03:09:58 +03:00
|
|
|
def get_plans(self, status=None):
|
|
|
|
x = PlansVMs.select().where(PlansVMs.status == status) if status else PlansVMs.select()
|
|
|
|
|
|
|
|
results = list()
|
|
|
|
for i in x:
|
|
|
|
results.append(dict(id=str(i.id), name=i.name, price=i.price, cores=i.cores, storage=i.storage, swap=i.swap, memory=i.memory))
|
|
|
|
return results
|
|
|
|
|
2016-05-22 12:36:54 +03:00
|
|
|
def plan_get(self, plan_id):
|
|
|
|
return PlansVMs.select().where(PlansVMs.id == plan_id).get()
|
|
|
|
|
|
|
|
def exists(self, plan_id):
|
|
|
|
if PlansVMs.select().where(PlansVMs.id == plan_id).count() == 0:
|
|
|
|
return False
|
|
|
|
return True
|