コード例 #1
0
    def consume_in_thread(self):
        """Runs the ZmqProxy service"""
        ipc_dir = CONF.rpc_zmq_ipc_dir
        consume_in = "tcp://%s:%s" % \
            (CONF.rpc_zmq_bind_address,
             CONF.rpc_zmq_port)
        consumption_proxy = InternalContext(None)

        if not os.path.isdir(ipc_dir):
            try:
                utils.execute('mkdir', '-p', ipc_dir, run_as_root=True)
                utils.execute('chown',
                              "%s:%s" % (os.getuid(), os.getgid()),
                              ipc_dir,
                              run_as_root=True)
                utils.execute('chmod', '750', ipc_dir, run_as_root=True)
            except utils.ProcessExecutionError:
                with excutils.save_and_reraise_exception():
                    LOG.error(
                        _("Could not create IPC directory %s") % (ipc_dir, ))

        try:
            self.register(consumption_proxy,
                          consume_in,
                          zmq.PULL,
                          out_bind=True)
        except zmq.ZMQError:
            with excutils.save_and_reraise_exception():
                LOG.error(
                    _("Could not create ZeroMQ receiver daemon. "
                      "Socket may already be in use."))

        super(ZmqProxy, self).consume_in_thread()
コード例 #2
0
ファイル: impl_zmq.py プロジェクト: bluzader/designate
    def consume_in_thread(self):
        """Runs the ZmqProxy service"""
        ipc_dir = CONF.rpc_zmq_ipc_dir
        consume_in = "tcp://%s:%s" % \
            (CONF.rpc_zmq_bind_address,
             CONF.rpc_zmq_port)
        consumption_proxy = InternalContext(None)

        if not os.path.isdir(ipc_dir):
            try:
                utils.execute('mkdir', '-p', ipc_dir, run_as_root=True)
                utils.execute('chown', "%s:%s" % (os.getuid(), os.getgid()),
                              ipc_dir, run_as_root=True)
                utils.execute('chmod', '750', ipc_dir, run_as_root=True)
            except utils.ProcessExecutionError:
                with excutils.save_and_reraise_exception():
                    LOG.error(_("Could not create IPC directory %s") %
                              (ipc_dir, ))

        try:
            self.register(consumption_proxy,
                          consume_in,
                          zmq.PULL,
                          out_bind=True)
        except zmq.ZMQError:
            with excutils.save_and_reraise_exception():
                LOG.error(_("Could not create ZeroMQ receiver daemon. "
                            "Socket may already be in use."))

        super(ZmqProxy, self).consume_in_thread()
コード例 #3
0
ファイル: impl_zmq.py プロジェクト: arjunpola/designate
    def consume_in_thread(self):
        """Runs the ZmqProxy service."""
        ipc_dir = CONF.rpc_zmq_ipc_dir
        consume_in = "tcp://%s:%s" % \
            (CONF.rpc_zmq_bind_address,
             CONF.rpc_zmq_port)
        consumption_proxy = InternalContext(None)

        try:
            os.makedirs(ipc_dir)
        except os.error:
            if not os.path.isdir(ipc_dir):
                with excutils.save_and_reraise_exception():
                    LOG.error(
                        _("Required IPC directory does not exist at"
                          " %s") % (ipc_dir, ))
        try:
            self.register(consumption_proxy, consume_in, zmq.PULL)
        except zmq.ZMQError:
            if os.access(ipc_dir, os.X_OK):
                with excutils.save_and_reraise_exception():
                    LOG.error(
                        _("Permission denied to IPC directory at"
                          " %s") % (ipc_dir, ))
            with excutils.save_and_reraise_exception():
                LOG.error(
                    _("Could not create ZeroMQ receiver daemon. "
                      "Socket may already be in use."))

        super(ZmqProxy, self).consume_in_thread()
コード例 #4
0
ファイル: impl_zmq.py プロジェクト: arjunpola/designate
    def consume_in_thread(self):
        """Runs the ZmqProxy service."""
        ipc_dir = CONF.rpc_zmq_ipc_dir
        consume_in = "tcp://%s:%s" % \
            (CONF.rpc_zmq_bind_address,
             CONF.rpc_zmq_port)
        consumption_proxy = InternalContext(None)

        try:
            os.makedirs(ipc_dir)
        except os.error:
            if not os.path.isdir(ipc_dir):
                with excutils.save_and_reraise_exception():
                    LOG.error(_("Required IPC directory does not exist at"
                                " %s") % (ipc_dir, ))
        try:
            self.register(consumption_proxy,
                          consume_in,
                          zmq.PULL)
        except zmq.ZMQError:
            if os.access(ipc_dir, os.X_OK):
                with excutils.save_and_reraise_exception():
                    LOG.error(_("Permission denied to IPC directory at"
                                " %s") % (ipc_dir, ))
            with excutils.save_and_reraise_exception():
                LOG.error(_("Could not create ZeroMQ receiver daemon. "
                            "Socket may already be in use."))

        super(ZmqProxy, self).consume_in_thread()
コード例 #5
0
 def create_domain(self, context, domain):
     self.master.create_domain(context, domain)
     try:
         self.slave.create_domain(context, domain)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.master.delete_domain(context, domain)
コード例 #6
0
 def delete_tsigkey(self, context, tsigkey):
     self.slave.delete_tsigkey(context, tsigkey)
     try:
         self.master.delete_tsigkey(context, tsigkey)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.slave.create_tsigkey(context, tsigkey)
コード例 #7
0
 def delete_server(self, context, server):
     self.slave.delete_server(context, server)
     try:
         self.master.delete_server(context, server)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.slave.create_server(context, server)
コード例 #8
0
ファイル: impl_multi.py プロジェクト: rvadim/designate
 def create_tsigkey(self, context, tsigkey):
     self.master.create_tsigkey(context, tsigkey)
     try:
         self.slave.create_tsigkey(context, tsigkey)
     except Exception:
         with excutils.save_and_reraise_exception():
             self.master.delete_tsigkey(context, tsigkey)
コード例 #9
0
ファイル: impl_multi.py プロジェクト: rvadim/designate
 def create_server(self, context, server):
     self.master.create_server(context, server)
     try:
         self.slave.create_server(context, server)
     except Exception:
         with excutils.save_and_reraise_exception():
             self.master.delete_server(context, server)
コード例 #10
0
ファイル: __init__.py プロジェクト: mudrykaa/designate
    def create_domain(self, context, domain):
        try:
            self.session.begin()
            servers = self.central_service.find_servers(self.admin_context)

            domain_values = {
                'designate_id': domain['id'],
                'name': domain['name'].rstrip('.'),
                'master': servers[0]['name'].rstrip('.'),
                'type': CONF['backend:powerdns'].domain_type,
                'account': context.tenant
            }

            domain_ref = self._create(tables.domains, domain_values)

            # Install all TSIG Keys on this domain
            query = select([tables.tsigkeys.c.name])
            resultproxy = self.session.execute(query)
            values = [i for i in resultproxy.fetchall()]

            self._update_domainmetadata(domain_ref['id'], 'TSIG-ALLOW-AXFR',
                                        values)

            # Install all Also Notify's on this domain
            self._update_domainmetadata(domain_ref['id'], 'ALSO-NOTIFY',
                                        CONF['backend:powerdns'].also_notify)
        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #11
0
ファイル: __init__.py プロジェクト: rvadim/designate
    def _update_domains_on_server_delete(self, server):
        """
        For performance, manually prepare a bulk update query to
        update all NS records for all existing domains that need
        updating of their corresponding NS record in Record table
        """

        # find a replacement server
        replacement_server_name = None
        servers = self.central_service.find_servers(self.admin_context)

        for replacement in servers:
            if replacement["id"] != server["id"]:
                replacement_server_name = replacement["name"]
                break

        LOG.debug(
            "This existing server name will be used to update existing"
            " SOA records upon server delete: %s " % replacement_server_name
        )

        # NOTE: because replacement_server_name came from central storage
        # it has the trailing period

        # Execute the manually prepared query
        # A TX is required for, at the least, SQLite.
        try:
            self.session.begin()
            # first delete affected NS records
            self.session.query(models.Record).filter_by(type="NS", designate_id=server["id"]).delete()

            # then update all SOA records as necessary
            # Do the SOA last, ensuring we don't trigger a
            # NOTIFY before the NS records are in place.
            #
            # Update the content field of every SOA record that
            # has the deleted server name as part of its
            # 'content' field to reflect the name of another
            # server that exists
            # both server['name'] and replacement_server_name
            # have trailing period so we are fine just doing the
            # substitution without striping trailing period
            self.session.execute(
                models.Record.__table__.update()
                .where(
                    and_(
                        models.Record.__table__.c.type == "SOA",
                        models.Record.__table__.c.content.like("%s%%" % server["name"]),
                    )
                )
                .values(
                    content=func.replace(models.Record.__table__.c.content, server["name"], replacement_server_name)
                )
            )

        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #12
0
ファイル: impl_multi.py プロジェクト: akshatknsl/designate
 def delete_tsigkey(self, context, tsigkey):
     self.slave.delete_tsigkey(context, tsigkey)
     try:
         self.master.delete_tsigkey(context, tsigkey)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.slave.create_tsigkey(context, tsigkey)
コード例 #13
0
ファイル: impl_multi.py プロジェクト: akshatknsl/designate
 def delete_server(self, context, server):
     self.slave.delete_server(context, server)
     try:
         self.master.delete_server(context, server)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.slave.create_server(context, server)
コード例 #14
0
ファイル: impl_multi.py プロジェクト: akshatknsl/designate
 def create_domain(self, context, domain):
     self.master.create_domain(context, domain)
     try:
         self.slave.create_domain(context, domain)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.master.delete_domain(context, domain)
コード例 #15
0
    def _update_domains_on_server_create(self, server):
        """
        For performance, manually prepare a bulk insert query to
        build NS records for all existing domains for insertion
        into Record table
        """
        ns_rec_content = self._sanitize_content("NS", server['name'])

        LOG.debug("Content field of newly created NS records for "
                  "existing domains upon server create is: %s" %
                  ns_rec_content)

        query_select = select([
            null(), models.Domain.__table__.c.id,
            models.Domain.__table__.c.name, "'NS'",
            "'%s'" % ns_rec_content,
            null(),
            null(),
            null(),
            null(), 1,
            "'%s'" % self._sanitize_uuid_str(server['id']), 1
        ])
        query = InsertFromSelect(models.Record.__table__, query_select)

        # Execute the manually prepared query
        # A TX is required for, at the least, SQLite.
        try:
            self.session.begin()
            self.session.execute(query)
        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #16
0
    def _update_domains_on_server_delete(self, server):
        """
        For performance, manually prepare a bulk update query to
        update all NS records for all existing domains that need
        updating of their corresponding NS record in Record table
        """

        # find a replacement server
        replacement_server_name = None
        servers = self.central_service.find_servers(self.admin_context)

        for replacement in servers:
            if replacement['id'] != server['id']:
                replacement_server_name = replacement['name']
                break

        LOG.debug("This existing server name will be used to update existing"
                  " SOA records upon server delete: %s "
                  % replacement_server_name)

        # NOTE: because replacement_server_name came from central storage
        # it has the trailing period

        # Execute the manually prepared query
        # A TX is required for, at the least, SQLite.
        try:
            self.session.begin()
            # first delete affected NS records
            self.session.query(models.Record)\
                .filter_by(type='NS', designate_id=server['id'])\
                .delete()

            # then update all SOA records as necessary
            # Do the SOA last, ensuring we don't trigger a
            # NOTIFY before the NS records are in place.
            #
            # Update the content field of every SOA record that
            # has the deleted server name as part of its
            # 'content' field to reflect the name of another
            # server that exists
            # both server['name'] and replacement_server_name
            # have trailing period so we are fine just doing the
            # substitution without striping trailing period
            self.session.execute(models.Record.__table__
                .update()
                .where(and_(models.Record.__table__.c.type == "SOA",
                       models.Record.__table__.c.content.like
                           ("%s%%" % server['name'])))
                .values(content=func.replace(
                        models.Record.__table__.c.content,
                        server['name'],
                        replacement_server_name)))

        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #17
0
ファイル: impl_zmq.py プロジェクト: arjunpola/designate
def _serialize(data):
    """Serialization wrapper.

    We prefer using JSON, but it cannot encode all types.
    Error if a developer passes us bad data.
    """
    try:
        return jsonutils.dumps(data, ensure_ascii=True)
    except TypeError:
        with excutils.save_and_reraise_exception():
            LOG.error(_("JSON serialization failed."))
コード例 #18
0
def _serialize(data):
    """
    Serialization wrapper
    We prefer using JSON, but it cannot encode all types.
    Error if a developer passes us bad data.
    """
    try:
        return jsonutils.dumps(data, ensure_ascii=True)
    except TypeError:
        with excutils.save_and_reraise_exception():
            LOG.error(_("JSON serialization failed."))
コード例 #19
0
ファイル: __init__.py プロジェクト: mudrykaa/designate
    def create_recordset(self, context, domain, recordset):
        try:
            self.session.begin(subtransactions=True)

            # Create all the records..
            for record in recordset.records:
                self.create_record(context, domain, recordset, record)
        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #20
0
ファイル: api.py プロジェクト: bluzader/designate
    def create_tsigkey(self, context, values):
        """
        Create a TSIG Key.

        :param context: RPC Context.
        """
        tsigkey = self.storage.create_tsigkey(context, values)

        try:
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_tsigkey(context, tsigkey['id'])
コード例 #21
0
    def create_tsigkey(self, context, values):
        """
        Create a TSIG Key.

        :param context: RPC Context.
        """
        tsigkey = self.storage.create_tsigkey(context, values)

        try:
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_tsigkey(context, tsigkey['id'])
コード例 #22
0
ファイル: fileutils.py プロジェクト: zacdev/designate
def remove_path_on_error(path, remove=delete_if_exists):
    """Protect code that wants to operate on PATH atomically.
    Any exception will cause PATH to be removed.

    :param path: File to work with
    :param remove: Optional function to remove passed path
    """

    try:
        yield
    except Exception:
        with excutils.save_and_reraise_exception():
            remove(path)
コード例 #23
0
    def create_quota(self, context, values):
        """
        Create a Quota.

        :param context: RPC Context.
        :param values: Values to create the new Quota from.
        """
        quota = self.storage.create_quota(context, values)

        try:
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_quota(context, quota['id'])
コード例 #24
0
    def create_domain(self, context, values):
        """
        Create a new Domain.

        :param context: RPC Context.
        :param values: Values to create the new Domain from.
        """
        domain = self.storage.create_domain(context, values)

        try:
            yield domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_domain(context, domain['id'])
コード例 #25
0
    def create_server(self, context, values):
        """
        Create a Server.

        :param context: RPC Context.
        :param values: Values to create the new Domain from.
        """
        server = self.storage.create_server(context, values)

        try:
            yield server
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_server(context, server['id'])
コード例 #26
0
ファイル: __init__.py プロジェクト: mudrykaa/designate
    def update_recordset(self, context, domain, recordset):
        # TODO(kiall): This is a total kludge. Intended as the simplest
        #              possible fix for the issue. This needs to be
        #              re-implemented correctly.
        try:
            self.session.begin(subtransactions=True)

            self.delete_recordset(context, domain, recordset)
            self.create_recordset(context, domain, recordset)
        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #27
0
 def delete_domain(self, context, domain):
     # Get the "full" domain (including id) from Central first, as we may
     # have to recreate it on slave if delete on master fails
     full_domain = self.central.find_domain(
         context, criterion={'name': domain['name']})
     self.slave.delete_domain(context, domain)
     try:
         self.master.delete_domain(context, domain)
     except (exceptions.Base, exceptions.Backend):
         with excutils.save_and_reraise_exception():
             self.slave.create_domain(context, domain)
             [self.slave.create_record(context, domain, record)
              for record in self.central.find_records(context,
                                                      full_domain['id'])]
コード例 #28
0
ファイル: api.py プロジェクト: bluzader/designate
    def create_domain(self, context, values):
        """
        Create a new Domain.

        :param context: RPC Context.
        :param values: Values to create the new Domain from.
        """
        domain = self.storage.create_domain(context, values)

        try:
            yield domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_domain(context, domain['id'])
コード例 #29
0
ファイル: api.py プロジェクト: bluzader/designate
    def create_quota(self, context, values):
        """
        Create a Quota.

        :param context: RPC Context.
        :param values: Values to create the new Quota from.
        """
        quota = self.storage.create_quota(context, values)

        try:
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_quota(context, quota['id'])
コード例 #30
0
ファイル: api.py プロジェクト: bluzader/designate
    def create_server(self, context, values):
        """
        Create a Server.

        :param context: RPC Context.
        :param values: Values to create the new Domain from.
        """
        server = self.storage.create_server(context, values)

        try:
            yield server
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_server(context, server['id'])
コード例 #31
0
    def create_record(self, context, domain_id, values):
        """
        Create a record on a given Domain ID

        :param context: RPC Context.
        :param domain_id: Domain ID to create the record in.
        :param values: Values to create the new Record from.
        """
        record = self.storage.create_record(context, domain_id, values)

        try:
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_record(context, record['id'])
コード例 #32
0
ファイル: api.py プロジェクト: bluzader/designate
    def create_record(self, context, domain_id, values):
        """
        Create a record on a given Domain ID

        :param context: RPC Context.
        :param domain_id: Domain ID to create the record in.
        :param values: Values to create the new Record from.
        """
        record = self.storage.create_record(context, domain_id, values)

        try:
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.delete_record(context, record['id'])
コード例 #33
0
    def create_tsigkey(self, context, values):
        """
        Create a TSIG Key.

        :param context: RPC Context.
        """
        self.storage.begin()

        try:
            tsigkey = self.storage.create_tsigkey(context, values)
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #34
0
ファイル: api.py プロジェクト: muraliselva10/designate
    def create_tsigkey(self, context, values):
        """
        Create a TSIG Key.

        :param context: RPC Context.
        """
        self.storage.begin()

        try:
            tsigkey = self.storage.create_tsigkey(context, values)
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #35
0
    def update_record(self, context, record_id, values):
        """
        Update a record via ID

        :param context: RPC Context
        :param record_id: Record ID to update
        """
        backup = self.storage.get_record(context, record_id)
        record = self.storage.update_record(context, record_id, values)

        try:
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                restore = self._extract_dict_subset(backup, values.keys())
                self.storage.update_record(context, record_id, restore)
コード例 #36
0
ファイル: api.py プロジェクト: bluzader/designate
    def update_record(self, context, record_id, values):
        """
        Update a record via ID

        :param context: RPC Context
        :param record_id: Record ID to update
        """
        backup = self.storage.get_record(context, record_id)
        record = self.storage.update_record(context, record_id, values)

        try:
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                restore = self._extract_dict_subset(backup, values.keys())
                self.storage.update_record(context, record_id, restore)
コード例 #37
0
ファイル: __init__.py プロジェクト: rvadim/designate
    def _update_domains_on_server_create(self, server):
        """
        For performance, manually prepare a bulk insert query to
        build NS records for all existing domains for insertion
        into Record table
        """
        ns_rec_content = self._sanitize_content("NS", server["name"])

        LOG.debug(
            "Content field of newly created NS records for "
            "existing domains upon server create is: %s" % ns_rec_content
        )

        query_select = select(
            [
                models.Domain.__table__.c.id,
                "'%s'" % self._sanitize_uuid_str(server["id"]),
                models.Domain.__table__.c.name,
                "'NS'",
                "'%s'" % ns_rec_content,
                1,
                1,
            ]
        )

        columns = [
            models.Record.__table__.c.domain_id,
            models.Record.__table__.c.designate_id,
            models.Record.__table__.c.name,
            models.Record.__table__.c.type,
            models.Record.__table__.c.content,
            models.Record.__table__.c.auth,
            models.Record.__table__.c.inherit_ttl,
        ]

        query = InsertFromSelect(models.Record.__table__, query_select, columns)

        # Execute the manually prepared query
        # A TX is required for, at the least, SQLite.
        try:
            self.session.begin()
            self.session.execute(query)
        except Exception:
            with excutils.save_and_reraise_exception():
                self.session.rollback()
        else:
            self.session.commit()
コード例 #38
0
ファイル: api.py プロジェクト: raychorn/designate
    def create_tsigkey(self, context, tsigkey):
        """
        Create a TSIG Key.

        :param context: RPC Context.
        :param tsigkey: TsigKey object with the values to be created.
        """
        self.storage.begin()

        try:
            created_tsigkey = self.storage.create_tsigkey(context, tsigkey)
            yield created_tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #39
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_tsigkey(self, context, tsigkey_id):
        """
        Delete a TSIG Key via ID.

        :param context: RPC Context.
        :param tsigkey_id: Delete a TSIG Key via ID
        """
        self.storage.begin()

        try:
            tsigkey = self.storage.delete_tsigkey(context, tsigkey_id)
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #40
0
ファイル: api.py プロジェクト: raychorn/designate
    def create_quota(self, context, values):
        """
        Create a Quota.

        :param context: RPC Context.
        :param values: Values to create the new Quota from.
        """
        self.storage.begin()

        try:
            quota = self.storage.create_quota(context, values)
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #41
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_domain(self, context, domain_id):
        """
        Delete a Domain

        :param context: RPC Context.
        :param domain_id: Domain ID to delete.
        """
        self.storage.begin()

        try:
            domain = self.storage.delete_domain(context, domain_id)
            yield domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #42
0
ファイル: api.py プロジェクト: dhellmann/designate
    def update_record(self, context, record_id, values):
        """
        Update a record via ID

        :param context: RPC Context
        :param record_id: Record ID to update
        """
        self.storage.begin()

        try:
            record = self.storage.update_record(context, record_id, values)
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #43
0
ファイル: api.py プロジェクト: dhellmann/designate
    def create_domain(self, context, domain):
        """
        Create a new Domain.

        :param context: RPC Context.
        :param domain: Domain object with the values to be created.
        """
        self.storage.begin()

        try:
            created_domain = self.storage.create_domain(context, domain)
            yield created_domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #44
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_quota(self, context, quota_id):
        """
        Delete a Quota via ID.

        :param context: RPC Context.
        :param quota_id: Delete a Quota via ID
        """
        self.storage.begin()

        try:
            quota = self.storage.delete_quota(context, quota_id)
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #45
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_blacklist(self, context, blacklist_id):
        """
        Delete a Blacklisted Domain

        :param context: RPC Context.
        :param blacklist_id: Blacklist ID to delete.
        """
        self.storage.begin()

        try:
            blacklist = self.storage.delete_blacklist(context, blacklist_id)
            yield blacklist
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #46
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_record(self, context, record_id):
        """
        Delete a record

        :param context: RPC Context
        :param record_id: Record ID to delete
        """
        self.storage.begin()

        try:
            record = self.storage.delete_record(context, record_id)
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #47
0
ファイル: api.py プロジェクト: raychorn/designate
    def update_record(self, context, record_id, values):
        """
        Update a record via ID

        :param context: RPC Context
        :param record_id: Record ID to update
        """
        self.storage.begin()

        try:
            record = self.storage.update_record(context, record_id, values)
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #48
0
ファイル: api.py プロジェクト: dhellmann/designate
    def create_quota(self, context, values):
        """
        Create a Quota.

        :param context: RPC Context.
        :param values: Values to create the new Quota from.
        """
        self.storage.begin()

        try:
            quota = self.storage.create_quota(context, values)
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #49
0
ファイル: api.py プロジェクト: dhellmann/designate
    def delete_blacklist(self, context, blacklist_id):
        """
        Delete a Blacklisted Domain

        :param context: RPC Context.
        :param blacklist_id: Blacklist ID to delete.
        """
        self.storage.begin()

        try:
            blacklist = self.storage.delete_blacklist(context, blacklist_id)
            yield blacklist
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #50
0
ファイル: api.py プロジェクト: dhellmann/designate
    def delete_tsigkey(self, context, tsigkey_id):
        """
        Delete a TSIG Key via ID.

        :param context: RPC Context.
        :param tsigkey_id: Delete a TSIG Key via ID
        """
        self.storage.begin()

        try:
            tsigkey = self.storage.delete_tsigkey(context, tsigkey_id)
            yield tsigkey
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #51
0
ファイル: api.py プロジェクト: raychorn/designate
    def create_domain(self, context, domain):
        """
        Create a new Domain.

        :param context: RPC Context.
        :param domain: Domain object with the values to be created.
        """
        self.storage.begin()

        try:
            created_domain = self.storage.create_domain(context, domain)
            yield created_domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #52
0
ファイル: api.py プロジェクト: dhellmann/designate
    def delete_domain(self, context, domain_id):
        """
        Delete a Domain

        :param context: RPC Context.
        :param domain_id: Domain ID to delete.
        """
        self.storage.begin()

        try:
            domain = self.storage.delete_domain(context, domain_id)
            yield domain
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #53
0
    def update_quota(self, context, quota_id, values):
        """
        Update a Quota via ID

        :param context: RPC Context.
        :param quota_id: Quota ID to update.
        :param values: Values to update the Quota from
        """
        backup = self.storage.get_quota(context, quota_id)
        quota = self.storage.update_quota(context, quota_id, values)

        try:
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                restore = self._extract_dict_subset(backup, values.keys())
                self.storage.update_quota(context, quota_id, restore)
コード例 #54
0
ファイル: api.py プロジェクト: dhellmann/designate
    def delete_record(self, context, record_id):
        """
        Delete a record

        :param context: RPC Context
        :param record_id: Record ID to delete
        """
        self.storage.begin()

        try:
            record = self.storage.delete_record(context, record_id)
            yield record
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #55
0
ファイル: api.py プロジェクト: raychorn/designate
    def create_tld(self, context, tld):
        """
        Create a TLD.

        :param context: RPC Context.
        :param tld: Tld object with the values to be created.
        """
        self.storage.begin()

        try:
            created_tld = self.storage.create_tld(context, tld)
            yield created_tld
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #56
0
ファイル: api.py プロジェクト: dhellmann/designate
    def delete_quota(self, context, quota_id):
        """
        Delete a Quota via ID.

        :param context: RPC Context.
        :param quota_id: Delete a Quota via ID
        """
        self.storage.begin()

        try:
            quota = self.storage.delete_quota(context, quota_id)
            yield quota
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #57
0
ファイル: api.py プロジェクト: raychorn/designate
    def create_server(self, context, server):
        """
        Create a Server.

        :param context: RPC Context.
        :param server: Server object with the values to be created.
        """
        self.storage.begin()

        try:
            created_server = self.storage.create_server(context, server)
            yield created_server
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #58
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_tld(self, context, tld_id):
        """
        Delete a TLD via ID.

        :param context: RPC Context.
        :param tld_id: Delete a TLD via ID
        """
        self.storage.begin()

        try:
            tld = self.storage.delete_tld(context, tld_id)
            yield tld
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()
コード例 #59
0
ファイル: api.py プロジェクト: raychorn/designate
    def delete_server(self, context, server_id):
        """
        Delete a Server via ID.

        :param context: RPC Context.
        :param server_id: Delete a Server via ID
        """
        self.storage.begin()

        try:
            server = self.storage.delete_server(context, server_id)
            yield server
        except Exception:
            with excutils.save_and_reraise_exception():
                self.storage.rollback()
        else:
            self.storage.commit()