1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # -*- coding: utf-8 -*-
- from openerp import http
- from openerp.addons.bus import bus
- from openerp.http import request as r
- from ..utils import docker_api as docker
- class ConfigController(http.Controller):
- @http.route('/odoo_management/get_config', auth='user', type='json')
- def get_config(self, **kw):
- settings = r.env['odoo.management.config'].get_default_settings([])
- settings.update({
- 'images': docker.get_all_containers(),
- 'containers': docker.get_all_containers(),
- 'networks': docker.get_all_networks()
- })
- return settings
- @http.route('/odoo_management/save_config', auth='user', type='json')
- def save_config(self, **kw):
- r.env['odoo.management.config'].set_default_settings(kw)
- @http.route('/odoo_management/images', auth='user', methods=['GET'], type='json')
- def get_images(self, **kw):
- images = docker.get_all_images()
- return images
- @http.route('/odoo_management/containers', auth='user', methods=['GET'], type='json')
- def get_containers(self, **kw):
- containers = docker.get_all_containers()
- return containers
- class InstancesController(bus.Controller):
- def _poll(self, dbname, channels, last, options):
- if r.session.uid:
- registry, cr, uid, context = r.registry, r.cr, r.session.uid, r.context
- new_channel = (r.db, 'odoo.instance', r.uid)
- channels.append(new_channel)
- return super(InstancesController, self)._poll(dbname, channels, last, options)
|