# 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() 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 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