当前位置: 首页>>代码示例>>Python>>正文


Python rhnSQL.rollback函数代码示例

本文整理汇总了Python中spacewalk.server.rhnSQL.rollback函数的典型用法代码示例。如果您正苦于以下问题:Python rollback函数的具体用法?Python rollback怎么用?Python rollback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rollback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: moveChannelDownloads

 def moveChannelDownloads(self, channel_id, old_channel_family_id,
                            new_channel_family_id, username, password):
     log_debug(3)
     self._auth(username, password)
     
     if old_channel_family_id is None or \
            old_channel_family_id == new_channel_family_id:
         # Nothing to be done here, same channel family
         return 0
     log_debug(3, "  Migrating downloads")
     
     try:
         rhnSQL.execute("""
         update rhnDownloads
            set channel_family_id = :new_channel_family_id
          where channel_family_id = :old_channel_family_id
            and id in (
                select downloads_id
                  from rhnChannelDownloads
                 where channel_id = :channel_id)
             """,
             channel_id=channel_id,
             old_channel_family_id=old_channel_family_id,
             new_channel_family_id=new_channel_family_id,
             )
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:28,代码来源:channel.py

示例2: updateDist

    def updateDist(self, kwargs, username, password):
        log_debug(3)
        self._auth(username, password)
        
        if not kwargs.get('release'):
            raise rhnFault(23, "Insufficient data, release missing to update dist", explain=0)
                     
        if not kwargs.get('os'):
            kwargs['os'] = 'Red Hat Linux'

        if kwargs.get('channel_id') is None:
            # Missing stuff
            raise rhnFault(23, "Insufficient data, channel_id missing to update dist", explain=0)

        if kwargs.get('channel_arch_id') is None:
            # Missing stuff
            raise rhnFault(23, "Insufficient data, channel arch id missing to update dist", explain=0)
            
        try:
            rhnSQL.execute("""
            insert into rhnDistChannelMap 
                (channel_id, channel_arch_id, os, release)
            values
                (:channel_id, :channel_arch_id, :os, :release)
            """, kwargs)
        except rhnSQL.SQLError, e:
            rhnSQL.rollback()
            raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:28,代码来源:channel.py

示例3: delete_guests

def delete_guests(server_id):
    """
    Callback used after a successful kickstart to remove any guest virtual
    instances, as well as their associated servers.
    """
    # First delete all the guest server objects:
    h = rhnSQL.prepare(_query_lookup_guests_for_host)
    h.execute(server_id=server_id)
    delete_server = rhnSQL.Procedure("delete_server")
    log_debug(4, "Deleting guests")
    while 1:
        row = h.fetchone_dict()
        if not row:
            break
        guest_id = row['virtual_system_id']
        log_debug(4, 'Deleting guest server: %s' % guest_id)
        try:
            if guest_id is not None:
                delete_server(guest_id)
        except rhnSQL.SQLError:
            log_error("Error deleting server: %s" % guest_id)

    # Finally delete all the virtual instances:
    log_debug(4, "Deleting all virtual instances for host")
    h = rhnSQL.prepare(_query_delete_virtual_instances)
    h.execute(server_id=server_id)

    # Commit all changes:
    try:
        rhnSQL.commit()
    except rhnSQL.SQLError:
        e = sys.exc_info()[1]
        log_error("Error committing transaction: %s" % e)
        rhnSQL.rollback()
开发者ID:m47ik,项目名称:uyuni,代码行数:34,代码来源:server_kickstart.py

示例4: main

    def main(self):
        parser = OptionParser(option_list=options_table)

        (self.options, _args) = parser.parse_args()

        rhnSQL.initDB()

        self._channels_hash = self._get_channels()

        package_ids = self._get_packages()
        if package_ids is None:
            return 1

        if self.options.backup_file:
            self._backup_packages(package_ids, self.options.backup_file)

        try:
            self._add_package_header_values(package_ids)
        except:
            rhnSQL.rollback()
            raise

        if self.options.commit:
            print "Commiting work"
            rhnSQL.commit()
        else:
            print "Rolling back"
            rhnSQL.rollback()
开发者ID:TJM,项目名称:spacewalk,代码行数:28,代码来源:satComputePkgHeaders.py

示例5: guest_registered

    def guest_registered(self, host_sid, guest_sid):
        host_system_slots = server_lib.check_entitlement(host_sid)
        host_system_slots = list(host_system_slots.keys())

        try:
            host_system_slots.remove("virtualization_host")
        except ValueError:
            pass

        guest_system_slots = server_lib.check_entitlement(guest_sid)
        guest_system_slots = list(guest_system_slots.keys())

        for entitlement in host_system_slots:
            if entitlement not in guest_system_slots:
                try:
                    rhnSQL.transaction(entitlement)
                    procedure.rhn_entitlements.entitle_server(guest_sid,
                                                              entitlement)
                except rhnSQL.SQLError:
                    e = sys.exc_info()[1]
                    rhnSQL.rollback(entitlement)
                    log_error("Error adding entitlement %s to host ID-%s: %s"
                              % (entitlement, guest_sid, str(e)))
                    # rhnSQL.rollback()
                    return
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:25,代码来源:rhnVirtualization.py

示例6: test_1

def test_1():
    try:
        _test_1()
    except:
        rhnSQL.rollback()
        raise

    rhnSQL.commit()
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:test-add-download-2.py

示例7: _channelPermission

 def _channelPermission(self, label, role, commit, username, password, query):
     log_debug(3)
     self._auth(username, password)
     try:
         rhnSQL.execute(query, username = username, label = label, role_label = role)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:channel.py

示例8: test_statement_prepare_error

    def test_statement_prepare_error(self):
        rhnSQL.transaction("test_statement_prepare_error")

        query = "aaa bbb ccc"
        cursor = rhnSQL.prepare(query)
        self.assertRaises(rhnSQL.SQLError,
                          cursor.execute)

        rhnSQL.rollback("test_statement_prepare_error")
开发者ID:m47ik,项目名称:uyuni,代码行数:9,代码来源:dbtests.py

示例9: sync

    def sync(self):
        """Trigger a reposync"""
        start_time = datetime.now()
        for (repo_id, url, repo_label, channel_family_id) in self.urls:
            print("")
            self.print_msg("Repo URL: %s" % url)
            plugin = None

            # If the repository uses a uln:// URL, switch to the ULN plugin, overriding the command-line
            if url.startswith("uln://"):
                self.repo_plugin = self.load_plugin("uln")

            # pylint: disable=W0703
            try:
                plugin = self.repo_plugin(url, self.channel_label)
                if repo_id is not None:
                    keys = rhnSQL.fetchone_dict("""
                        select k1.key as ca_cert, k2.key as client_cert, k3.key as client_key
                        from rhncontentssl
                                join rhncryptokey k1
                                on rhncontentssl.ssl_ca_cert_id = k1.id
                                left outer join rhncryptokey k2
                                on rhncontentssl.ssl_client_cert_id = k2.id
                                left outer join rhncryptokey k3
                                on rhncontentssl.ssl_client_key_id = k3.id
                        where rhncontentssl.content_source_id = :repo_id
                        or rhncontentssl.channel_family_id = :channel_family_id
                        """, repo_id=int(repo_id), channel_family_id=int(channel_family_id))
                    if keys and ('ca_cert' in keys):
                        plugin.set_ssl_options(keys['ca_cert'], keys['client_cert'], keys['client_key'])
                self.import_packages(plugin, repo_id, url)
                self.import_groups(plugin, url)

                if not self.no_errata:
                    self.import_updates(plugin, url)

                # only for repos obtained from the DB
                if self.sync_kickstart and repo_label:
                    try:
                        self.import_kickstart(plugin, url, repo_label)
                    except:
                        rhnSQL.rollback()
                        raise
            except Exception:
                e = sys.exc_info()[1]
                self.error_msg("ERROR: %s" % e)
            if plugin is not None:
                plugin.clear_ssl_cache()
        if self.regen:
            taskomatic.add_to_repodata_queue_for_channel_package_subscription(
                [self.channel_label], [], "server.app.yumreposync")
            taskomatic.add_to_erratacache_queue(self.channel_label)
        self.update_date()
        rhnSQL.commit()
        total_time = datetime.now() - start_time
        self.print_msg("Sync completed.")
        self.print_msg("Total time: %s" % str(total_time).split('.')[0])
开发者ID:jiridostal,项目名称:spacewalk,代码行数:57,代码来源:reposync.py

示例10: save

    def save(self):
        if self._token is None:
            self.generate_token()

        try:
            return self._save()
        except:
            rhnSQL.rollback()
            raise
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:9,代码来源:rhnActivationKey.py

示例11: _push_file

    def _push_file(self, config_channel_id, file):
        if not file:
            # Nothing to do
            return {}

        # Check for full path on the file
        path = file.get('path')
        if not (path[0] == os.sep):
	        raise ConfigFilePathIncomplete(file)

        if not file.has_key('config_file_type_id'):
           log_debug(4, "Client does not support config directories, so set file_type_id to 1")
           file['config_file_type_id'] = '1'
        # Check if delimiters are present
        if self._is_file(file) and \
                    not (file.get('delim_start') and file.get('delim_end')):
            # Need delimiters
            raise ConfigFileMissingDelimError(file)

        if not (file.get('user') and file.get('group') and 
                file.get('mode')) and not self._is_link(file) :
            raise ConfigFileMissingInfoError(file)

        # Oracle doesn't like certain binding variables
        file['username'] = file.get('user','')
        file['groupname'] = file.get('group','')
        file['file_mode'] = file.get('mode','')
        file['selinux_ctx'] = file.get('selinux_ctx','')
        result = {}
        
        try:

            if self._is_file(file):
                self._push_contents(file)
            elif self._is_link(file):
                file['symlink'] = file.get('symlink') or ''
        except ConfigFileTooLargeError:
            result['file_too_large'] = 1

        t = rhnSQL.Table('rhnConfigFileState', 'label')
        state_id_alive = t['alive']['id']

        file['state_id'] = state_id_alive
        file['config_channel_id'] = config_channel_id

        try:
            self._push_config_file(file)
            self._push_revision(file)
        except rhnSQL.SQLSchemaError, e:
            log_debug(4, "schema error", e)
            rhnSQL.rollback() # blow away the contents that got inserted
            if e.errno == 20267:
                # ORA-20267: (not_enough_quota) - Insufficient available quota
                # for the specified action
                raise ConfigFileExceedsQuota(file)
            raise
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:56,代码来源:configFilesHandler.py

示例12: addKSTree

    def addKSTree(self, username, password, channel_label, ks_label, path,
                  install_type, tree_type, clear, files, pkgs, ignore_lint_errors, commit):

        log_debug(3)
        self._auth(username, password)

        # channel = rhnChannel.channel_info(channel_label)

        # if channel is '':
            # raise rhnFault(40, 'Could not lookup channel ' + channel_label)
# 
        # channel_id = channel['id']            
       
        kstree = rhnKickstart.lookup_tree(ks_label, pkgs)

        if kstree != None and clear:
            kstree.delete_tree()
            kstree = None

        if kstree == None:
            boot_image = ks_label
            kstree = rhnKickstart.create_tree(ks_label, channel_label, path, boot_image,
                                              tree_type, install_type, pkgs)

        # Firstly, we should lint the tree, and if we're not set to ignore linting errors
        # we error.
        lint_results =  kstree.lint_tree()

        if lint_results != None and not ignore_lint_errors:
            rhnSQL.rollback()
            raise rhnFault (2102, """
            The following packages in the kickstart tree were not found in the
            channel:
            %s
            """ % lint_results, explain=0)
        
        kstree.clear_files()

        for file in files:
            if kstree.has_file(file):
                continue
            else:

                log_debug(3, 'trying to insert ' + file['last_modified'] + ' as last_modified')

                kstree.add_file(file)

        if commit:
            rhnSQL.commit()
            message = 'Success. Committing transaction.'
        else:
            rhnSQL.rollback()
            message = 'Success. Rolling back transaction.  --commit not specified'

        return message
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:55,代码来源:channel.py

示例13: deleteDist

 def deleteDist(self, channel_id, username, password):
     log_debug(3)
     self._auth(username, password)
     
     try:
         rhnSQL.execute("""
         delete from rhnDistChannelMap where channel_id = :channel_id
         """, channel_id=channel_id)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:11,代码来源:channel.py

示例14: deleteChannel

 def deleteChannel(self, channel_id, commit, username, password):
     log_debug(3)
     authobj = self._auth(username, password)
     authobj.isChannelAdmin()
     
     try:
         p = rhnSQL.Procedure("delete_channel")
         p(channel_id)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:11,代码来源:channel.py

示例15: check_token_limits

def check_token_limits(server_id, tokens_obj):
    assert(isinstance(tokens_obj, ActivationTokens))
    rhnSQL.transaction("check_token_limits")
    for token in tokens_obj.tokens:
        try:
            _check_token_limits(server_id, token)
        except:
            log_debug(4, "Rolling back transaction")
            rhnSQL.rollback("check_token_limits")
            raise
    return 0
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:11,代码来源:server_token.py


注:本文中的spacewalk.server.rhnSQL.rollback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。