-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from noahzaozao/8.0-add-connector-dns
[ADD] connector_dns
- Loading branch information
Showing
44 changed files
with
4,098 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============= | ||
Connector DNS | ||
============= | ||
|
||
This module aims to create a framework for DNS management through the | ||
odoo-connector in order to be able to manage your DNS records in Odoo and be | ||
able to connect to external service providers via API and the odoo-connector | ||
job-queue. | ||
|
||
This module only introduces the main data model and can be used as is to | ||
manually store DNS records. It provides the objects or basic mapping to | ||
create API connection but does not provide any connector per se. | ||
|
||
Additional modules for specific connectors need to be added to manage the | ||
service provider connection. | ||
|
||
With specific DNS provider module, the DNS connector supports: | ||
|
||
* Import the domains and records from your DNS provider into Odoo | ||
* DNS domain creation / deletion (TBD) / update and synchronization to your | ||
DNS provider | ||
* Records creation / deletion (TBD) / update and synchronization to your | ||
DNS provider | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to install the odoo-connector module. | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Install a specific module such as connector_dns_dnspod | ||
#. Create and set up the authentication for the DNS service provider in | ||
Connectors/DNS/backends | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Create your domains, select the DNS provider and confirm them in | ||
Connectors/DNS/Domains | ||
#. Once the domains are created, you can create the records accordingly | ||
in Connectors/DNS/records | ||
#. Every time you create, delete or update a new record, a job will be | ||
created in Connectors/Queue/Jobs | ||
#. if a job fails, you can check the error and retry the job if necessary. | ||
|
||
You might want to check the official documentation of the | ||
`Odoo Connector <http://odoo-connector.com/index.html>`_ to build your own | ||
DNS provider connector. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/224/8.0 | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* Add validations for record types: ``SPF``, ``NAPTR`` | ||
* Add a delete synchronizer | ||
* Add tests for each of the ``dns.record.type`` validation regexes | ||
* Add missing tests for ``export_synchronizer`` & ``import_synchronizer`` | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/infrastructure-dns/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Dave Lasley <dave@laslabs.com> | ||
* Eric Caudal <eric.caudal@elico-corp.com> | ||
* Noah Wang <noah.wang@elico-corp.com> | ||
* Liu Lixia <contact@elico-corp.com> | ||
* Augustin Cisterne-Kaas <contact@elico-corp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import backend | ||
from . import connector | ||
from . import models | ||
from . import unit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# Copyright 2016 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'DNS connector', | ||
'version': '8.0.1.0.0', | ||
'category': 'Connector', | ||
'depends': ['connector'], | ||
'author': 'Elico Corp, ' | ||
'LasLabs, ' | ||
'Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'website': 'https://www.elico-corp.com', | ||
'data': [ | ||
'views/dns_backend.xml', | ||
'views/dns_record.xml', | ||
'views/dns_zone.xml', | ||
'views/dns_menu.xml', | ||
'views/connector_config_settings.xml', | ||
'data/dns_record_type.xml', | ||
'security/dns.xml', | ||
'security/ir.model.access.csv', | ||
], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import openerp.addons.connector.backend as backend | ||
|
||
dns = backend.Backend('dns') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# Copyright 2016 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields, api | ||
from openerp.addons.connector.connector import Environment | ||
from openerp.addons.connector.checkpoint import checkpoint | ||
|
||
|
||
def get_environment(session, model_name, backend_id): | ||
""" Create an environment to work with. """ | ||
backend_record = session.env['dns.backend'].browse(backend_id) | ||
env = Environment(backend_record, session, model_name) | ||
return env | ||
|
||
|
||
class DNSBinding(models.AbstractModel): | ||
""" Abstract Model for the Bindigs. | ||
All the models used as bindings between External System and Odoo | ||
(``aws.dns.record``, ``aws.dns.zone``, ...) should ``_inherit`` it. | ||
""" | ||
_name = 'dns.binding' | ||
_inherit = 'external.binding' | ||
_description = 'DNS Binding (abstract)' | ||
|
||
dns_backend_id = fields.Many2one( | ||
comodel_name='dns.backend', | ||
string='DNS Backend', | ||
store=True, | ||
required=True, | ||
ondelete='restrict', | ||
default=lambda s: s._default_dns_backend_id() | ||
) | ||
dns_id_external = fields.Char( | ||
string='External ID', | ||
help='ID of the record in external system.', | ||
) | ||
fail_date = fields.Datetime() | ||
|
||
_sql_constraints = [ | ||
('backend_uniq', 'unique(dns_backend_id, dns_id_external)', | ||
'A binding already exists with the same DNS External ID.'), | ||
] | ||
|
||
@api.model | ||
def _default_dns_backend_id(self): | ||
return self.env['dns.backend'].search([ | ||
('is_default', '=', True), | ||
('active', '=', True), | ||
], | ||
limit=1, | ||
) | ||
|
||
|
||
def add_checkpoint(session, model_name, record_id, backend_id): | ||
""" Add a row in the model ``connector.checkpoint`` for a record, | ||
meaning it has to be reviewed by a user. | ||
:param session: current session | ||
:type session: :class:`openerp.addons.connector.session.ConnectorSession` | ||
:param model_name: name of the model of the record to be reviewed | ||
:type model_name: str | ||
:param record_id: ID of the record to be reviewed | ||
:type record_id: int | ||
:param backend_id: ID of the dnspod Backend | ||
:type backend_id: int | ||
""" | ||
return checkpoint.add_checkpoint(session, model_name, record_id, | ||
'dns.backend', backend_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from .unit.export_synchronizer import export_record | ||
|
||
|
||
import logging | ||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def delay_export(session, model_name, record_id, vals): | ||
""" Delay a job which export a binding record. | ||
(A binding record being a ``dns.record.bind``, | ||
``dns.zone.bind``, ...) | ||
""" | ||
if session.context.get('connector_no_export'): | ||
return | ||
fields = vals.keys() | ||
export_record.delay(session, model_name, record_id, fields=fields) | ||
|
||
|
||
def delay_export_all_bindings(session, model_name, record_id, vals): | ||
""" Delay a job which export all the bindings of a record. | ||
In this case, it is called on records of normal models and will delay | ||
the export for all the bindings. | ||
""" | ||
if session.context.get('connector_no_export'): | ||
return | ||
record = session.env[model_name].browse(record_id) | ||
fields = vals.keys() | ||
for binding in record.dns_bind_ids: | ||
export_record.delay(session, binding._model._name, binding.id, | ||
fields=fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="1"> | ||
|
||
<record id="type_a" model="dns.record.type"> | ||
<field name="name">IPv4 Address</field> | ||
<field name="code">A</field> | ||
<field name="help">IPv4 address. Enter multiple addresses | ||
on separate lines. | ||
Example: | ||
192.0.2.235 | ||
198.51.100.234 | ||
</field> | ||
<field name="validate_regex">^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\n?)+$</field> | ||
</record> | ||
|
||
<record id="type_aaaa" model="dns.record.type"> | ||
<field name="name">IPv6 Address</field> | ||
<field name="code">AAAA</field> | ||
<field name="help">IPv6 address. Enter multiple addresses | ||
on separate lines. | ||
Example: | ||
2001:0db8:85a3:0:0:8a2e:0370:7334 | ||
fe80:0:0:0:202:b3ff:fe1e:8329 | ||
</field> | ||
<field name="validate_regex">^((?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}\n?)+$</field> | ||
</record> | ||
|
||
<record id="type_cname" model="dns.record.type"> | ||
<field name="name">Canonical Name</field> | ||
<field name="code">CNAME</field> | ||
<field name="help">The domain name that you want to | ||
resolve to instead of the value in the | ||
Name field. | ||
Example: | ||
www.example.com | ||
</field> | ||
<field name="validate_regex">^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$</field> | ||
</record> | ||
|
||
<record id="type_mx" model="dns.record.type"> | ||
<field name="name">Mail Exchange</field> | ||
<field name="code">MX</field> | ||
<field name="help">A priority and a domain name that | ||
specifies a mail server. Enter multiple | ||
values on separate lines. | ||
Format: | ||
[priority] [mail server host name] | ||
Example: | ||
10 mailserver.example.com. | ||
20 mailserver2.example.com. | ||
</field> | ||
<field name="validate_regex">^([12]?\d ([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\n)+$</field> | ||
</record> | ||
|
||
<record id="type_txt" model="dns.record.type"> | ||
<field name="name">Text</field> | ||
<field name="code">TXT</field> | ||
<field name="help">A text record. | ||
Enter multiple values on separate lines. | ||
Enclose text in quotation marks. | ||
Example: | ||
"Sample Text Entries" | ||
"Enclose entries in quotation marks" | ||
</field> | ||
<field name="validate_regex">^(".*"\n)+$</field> | ||
</record> | ||
|
||
<record id="type_ptr" model="dns.record.type"> | ||
<field name="name">Pointer</field> | ||
<field name="code">PTR</field> | ||
<field name="help">The domain name that you want to return. | ||
Example: | ||
www.example.com | ||
</field> | ||
<field name="validate_regex">^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$</field> | ||
</record> | ||
|
||
<record id="type_srv" model="dns.record.type"> | ||
<field name="name">Service Locator</field> | ||
<field name="code">SRV</field> | ||
<field name="help">A SRV record. For information about SRV | ||
record format, refer to the applicable | ||
documentation. Enter multiple values | ||
on separate lines. | ||
Format: | ||
[priority] [weight] [port] [server host name] | ||
Example: | ||
1 10 5269 xmpp-server.example.com. | ||
2 12 5060 sip-server.example.com. | ||
</field> | ||
<field name="validate_regex">^(\d+ \d+ \d+ ([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\n)+$</field> | ||
</record> | ||
|
||
<record id="type_spf" model="dns.record.type"> | ||
<field name="name">Sender Policy Framework</field> | ||
<field name="code">SPF</field> | ||
<field name="help">An SPF record. For information about SPF | ||
record format, refer to the applicable | ||
documentation. Enter multiple values | ||
on separate lines. Enclose values in | ||
quotation marks. | ||
Example: | ||
"v=spf1 ip4:192.168.0.1/16-all" | ||
</field> | ||
<field name="validate_regex">.*</field> | ||
</record> | ||
|
||
<record id="type_naptr" model="dns.record.type"> | ||
<field name="name">Name Authority Pointer</field> | ||
<field name="code">NAPTR</field> | ||
<field name="help">An NAPTR record. For information about NAPTR | ||
record format, refer to the applicable | ||
documentation. Enter multiple values | ||
on separate lines. | ||
Format: | ||
[order] [preference] [flags] [services] [regexp] [replacement] | ||
Example: | ||
100 100 "U" "" "!^.*$!sip:info@bar.example.com!" . | ||
10 100 "S" "SIP+D2U" "" foo.example.com. | ||
</field> | ||
<field name="validate_regex">.*</field> | ||
</record> | ||
|
||
<record id="type_ns" model="dns.record.type"> | ||
<field name="name">Name Server</field> | ||
<field name="code">A</field> | ||
<field name="help">The domain name of a name server. | ||
Enter multiple name servers on | ||
separate lines. | ||
Example: | ||
ns1.amazon.com | ||
ns2.amazon.org | ||
ns3.amazon.net | ||
ns4.amazon.co.uk | ||
</field> | ||
<field name="validate_regex">^(([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\n)+$</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
Oops, something went wrong.