本文整理汇总了Python中spacewalk.server.rhnSQL.commit函数的典型用法代码示例。如果您正苦于以下问题:Python commit函数的具体用法?Python commit怎么用?Python commit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了commit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: store_rhnCryptoKey
def store_rhnCryptoKey(description, cert, org_id, verbosity=0):
""" stores cert in rhnCryptoKey
uses:
_checkCertMatch_rhnCryptoKey
_delete_rhnCryptoKey - not currently used
_insertPrep_rhnCryptoKey
_lobUpdate_rhnCryptoKey
"""
try:
# look for a cert match in the database
rhn_cryptokey_id = _checkCertMatch_rhnCryptoKey(cert, description,
org_id, deleteRowYN=1,
verbosity=verbosity)
if rhn_cryptokey_id is None:
# nothing to do - cert matches
return
# insert into the database
if rhn_cryptokey_id == -1:
rhn_cryptokey_id = _insertPrep_rhnCryptoKey(rhn_cryptokey_id,
description, org_id)
# write/update
_lobUpdate_rhnCryptoKey(rhn_cryptokey_id, cert)
rhnSQL.commit()
except rhnSQL.sql_base.SQLError:
raise_with_tb(CaCertInsertionError(
"...the traceback: %s" % fetchTraceback()), sys.exc_info()[2])
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:26,代码来源:satCerts.py
示例2: _delete_rpm_group
def _delete_rpm_group(packageIds):
references = [
'rhnChannelPackage',
'rhnErrataPackage',
'rhnErrataPackageTMP',
'rhnPackageChangelogRec',
'rhnPackageConflicts',
'rhnPackageFile',
'rhnPackageObsoletes',
'rhnPackageProvides',
'rhnPackageRequires',
'rhnPackageRecommends',
'rhnPackageSuggests',
'rhnPackageSupplements',
'rhnPackageEnhances',
'rhnPackageBreaks',
'rhnPackagePredepends',
'rhnServerNeededCache',
]
deleteStatement = "delete from %s where package_id = :package_id"
for table in references:
h = rhnSQL.prepare(deleteStatement % table)
count = h.executemany(package_id=packageIds)
log_debug(3, "Deleted from %s: %d rows" % (table, count))
deleteStatement = "delete from rhnPackage where id = :package_id"
h = rhnSQL.prepare(deleteStatement)
count = h.executemany(package_id=packageIds)
if count:
log_debug(2, "DELETED package id %s" % str(packageIds))
else:
log_error("No such package id %s" % str(packageIds))
rhnSQL.commit()
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:33,代码来源:contentRemove.py
示例3: _register_dispatcher
def _register_dispatcher(self, jabber_id, hostname, port):
h = rhnSQL.prepare(self._query_update_register_dispatcher)
rowcount = h.execute(jabber_id_in=jabber_id, hostname_in=hostname, port_in=port, password_in=self._password)
if not rowcount:
h = rhnSQL.prepare(self._query_insert_register_dispatcher)
h.execute(jabber_id_in=jabber_id, hostname_in=hostname, port_in=port, password_in=self._password)
rhnSQL.commit()
开发者ID:mantel,项目名称:spacewalk,代码行数:7,代码来源:osa_dispatcher.py
示例4: save_packages
def save_packages(self, schedule=1):
""" wrapper for the Packages.save_packages_byid() which requires the sysid """
ret = self.save_packages_byid(self.server["id"], schedule=schedule)
# this function is primarily called from outside
# so we have to commit here
rhnSQL.commit()
return ret
开发者ID:flavio,项目名称:spacewalk,代码行数:7,代码来源:server_wrapper.py
示例5: client_set_namespaces
def client_set_namespaces(self, systemid, namespaces):
self.auth_system(systemid)
server_id = self.server.getid()
org_id = self.server.server['org_id']
h = rhnSQL.prepare("""
delete from rhnServerConfigChannel where server_id = :server_id
""")
h.execute(server_id=server_id)
h = rhnSQL.prepare("""
insert into rhnServerConfigChannel (server_id, config_channel_id, position)
select :server_id, id, :position
from rhnConfigChannel
where name = :config_channel
and org_id = :org_id
""")
position = 0
for config_channel in namespaces:
rowcount = h.execute(server_id=server_id, position=position,
config_channel=config_channel, org_id=org_id)
if not rowcount:
raise rhnFault(4009, "Unable to find config channel %s" %
config_channel, explain=0)
position = position + 1
rhnSQL.commit()
return 0
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:30,代码来源:rhn_config_management.py
示例6: _update_package_data
def _update_package_data(self, crash_id, pkg_data):
log_debug(1, "_update_package_data: %s, %s" % (crash_id, pkg_data))
# Older versions of abrt used to store the package info in a single 'package' file
if pkg_data and 'package' in pkg_data:
(n, e, v, r) = parseRPMName(pkg_data['package'])
if not all((n, e, v, r)):
return 0
h = rhnSQL.prepare(_query_update_pkg_data1)
r = h.execute(
crash_id=crash_id,
pkg_name=n,
pkg_epoch=e,
pkg_version=v,
pkg_release=r)
rhnSQL.commit()
return r
for item in ['pkg_name', 'pkg_epoch', 'pkg_version', 'pkg_release', 'pkg_arch']:
if not (item in pkg_data and pkg_data[item]):
return 0
h = rhnSQL.prepare(_query_update_pkg_data2)
r = h.execute(
crash_id=crash_id,
pkg_name=pkg_data['pkg_name'],
pkg_epoch=pkg_data['pkg_epoch'],
pkg_version=pkg_data['pkg_version'],
pkg_release=pkg_data['pkg_release'],
pkg_arch=pkg_data['pkg_arch'])
rhnSQL.commit()
return r
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:34,代码来源:abrt.py
示例7: update_client_message_received
def update_client_message_received(self, jid):
jid = str(jid)
state_id = self._get_push_state_id('online')
h = rhnSQL.prepare(self._query_update_client_message_received)
ret = h.execute(jid=jid, state_id=state_id)
if ret:
rhnSQL.commit()
开发者ID:colloquium,项目名称:spacewalk,代码行数:7,代码来源:dispatcher_client.py
示例8: test_new_server_1
def test_new_server_1(self):
"Test normal server registration, with username/password"
u, password = self._create_new_user()
username = u.contact['login']
org_id = u.contact['org_id']
entitlements = self._entitlements
os_release = "2.1as"
t = misc_functions.create_activation_key(
org_id=u.contact['org_id'],
entitlement_level=entitlements,
user_id=u.getid(),
release=os_release
)
params = build_new_system_params_with_username(username=username,
password=password, os_release=os_release)
system_id = register_new_system(params)
rhnSQL.commit()
s = rhnServer.get(system_id)
self.assertNotEqual(s, None)
server_id = s.getid()
channels = rhnChannel.channels_for_server(server_id)
self.assertEqual(len(channels), 1)
self.assertEqual(channels[0]['label'], self._channel)
开发者ID:aronparsons,项目名称:spacewalk,代码行数:28,代码来源:test_server_registration.py
示例9: test_new_server_token_1
def test_new_server_token_1(self):
"test registration with token"
u, _ = self._create_new_user()
org_id = u.contact['org_id']
entitlements = self._entitlements
os_release = "2.1as"
t = misc_functions.create_activation_key(
org_id=u.contact['org_id'],
entitlement_level=entitlements,
user_id=u.getid(),
release=os_release
)
token = t.get_token()
params = build_new_system_params_with_token(
token=token,
os_release=os_release
)
system_id = register_new_system(params)
rhnSQL.commit()
s = rhnServer.get(system_id)
self.assertNotEqual(s, None)
开发者ID:aronparsons,项目名称:spacewalk,代码行数:26,代码来源:test_server_registration.py
示例10: test_execute_rowcount
def test_execute_rowcount(self):
"""Tests row counts"""
table_name = "misatest"
try:
tables = self._list_tables()
if not table_name in tables:
rhnSQL.execute("create table %s (id int, value int)" % table_name)
else:
rhnSQL.execute("delete from %s" % table_name)
insert_statement = rhnSQL.Statement(
"insert into %s values (:item_id, :value)" % table_name
)
h = rhnSQL.prepare(insert_statement)
ret = h.execute(item_id=1, value=2)
self.assertEqual(ret, 1)
ret = h.execute(item_id=2, value=2)
self.assertEqual(ret, 1)
delete_statement = rhnSQL.Statement("delete from %s" % table_name)
h = rhnSQL.prepare(delete_statement)
ret = h.execute()
self.assertEqual(ret, 2)
rhnSQL.commit()
finally:
rhnSQL.execute("drop table %s" % table_name)
开发者ID:flavio,项目名称:spacewalk,代码行数:26,代码来源:test_1.py
示例11: test_new_server_token_2
def test_new_server_token_2(self):
"Test registration with token that specifies a base channel"
# FIXME: the test fails because there's no channel associated with the
# freshly created Server: rhnServerChannel is not populated by the
# registration code.
u, _ = self._create_new_user()
org_id = u.contact['org_id']
base_channel = 'rhel-i386-as-3'
entitlements = self._entitlements
os_release = "2.1as"
t = misc_functions.create_activation_key(org_id=u.contact['org_id'],
entitlement_level=entitlements, user_id=u.getid(),
channels=[base_channel], release=os_release)
token = t.get_token()
params = build_new_system_params_with_token(
token=token,
os_release=os_release
)
system_id = register_new_system(params)
rhnSQL.commit()
s = rhnServer.get(system_id)
self.assertNotEqual(s, None)
server_id = s.getid()
channels = rhnChannel.channels_for_server(server_id)
self.assertEqual(len(channels), 1)
self.assertEqual(channels[0]['label'], base_channel)
开发者ID:aronparsons,项目名称:spacewalk,代码行数:34,代码来源:test_server_registration.py
示例12: store_rhnCryptoKey
def store_rhnCryptoKey(description, caCert, verbosity=0):
""" stores CA cert in rhnCryptoKey
uses:
_checkCertMatch_rhnCryptoKey
_delete_rhnCryptoKey - not currently used
_insertPrep_rhnCryptoKey
_lobUpdate_rhnCryptoKey
"""
org_ids = get_all_orgs()
for org_id in org_ids:
org_id = org_id['id']
try:
## look for a cert match in the database
rhn_cryptokey_id = _checkCertMatch_rhnCryptoKey(caCert, description,
org_id, deleteRowYN=1,
verbosity=verbosity)
if rhn_cryptokey_id is None:
# nothing to do - cert matches
continue
## insert into the database
if rhn_cryptokey_id == -1:
rhn_cryptokey_id = _insertPrep_rhnCryptoKey(rhn_cryptokey_id,
description, org_id)
## write/update
_lobUpdate_rhnCryptoKey(rhn_cryptokey_id, caCert)
rhnSQL.commit()
except rhnSQL.sql_base.SQLError:
raise CaCertInsertionError(
"...the traceback: %s" % fetchTraceback()), None, sys.exc_info()[2]
开发者ID:T-D-Oe,项目名称:spacewalk,代码行数:30,代码来源:satCerts.py
示例13: 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
示例14: install_missing_product_packages
def install_missing_product_packages(self):
'''
Find missing products and schedule an action to install them
'''
h = rhnSQL.prepare(self._query_product_packages)
package_names = {}
h.execute(server_id=self.server['id'])
while True:
row = h.fetchone_dict()
if not row:
break
pn_id = row['name_id']
pa_id = row['arch_id']
package_names[(pn_id, pa_id)] = row['name']
if not package_names:
return None
package_arch_ids = package_names.keys()
action_id = rhnAction.schedule_server_packages_update_by_arch(self.server['id'],
package_arch_ids,
org_id=self.server['org_id'],
action_name="Product Package Auto-Install")
for p in package_names.values():
log_debug(1, "Scheduled for install: '%s'" % p)
rhnSQL.commit()
return action_id
开发者ID:m47ik,项目名称:uyuni,代码行数:30,代码来源:server_packages.py
示例15: find_or_create_channel_arch
def find_or_create_channel_arch(name, label):
lookup = """
SELECT id from rhnChannelArch
WHERE label='%s' AND name = '%s'
""" % (label, name)
h = rhnSQL.prepare(lookup)
h.execute()
row = h.fetchone_dict()
if row:
return row['id']
query_create = """
INSERT INTO rhnChannelArch
(id, arch_type_id, label, name)
VALUES (sequence_nextval('rhn_channel_arch_id_seq'), :arch_type_id, :label, :name)
"""
arch_type_id = find_or_create_arch_type(name = name, label = label)
h = rhnSQL.prepare(query_create)
try:
h.execute(
arch_type_id = arch_type_id,
label = label,
name = name
)
rhnSQL.commit()
except rhnSQL.SQLError, e:
# if we're here that means we're voilating something
raise
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:29,代码来源:misc_functions.py
示例16: management_remove_channel
def management_remove_channel(self, dict):
log_debug(1)
self._get_and_validate_session(dict)
config_channel = dict.get('config_channel')
# XXX Validate the namespace
row = rhnSQL.fetchone_dict(self._query_config_channel_by_label,
org_id=self.org_id, label=config_channel)
if not row:
raise rhnFault(4009, "Channel not found")
delete_call = rhnSQL.Procedure('rhn_config.delete_channel')
try:
delete_call(row['id'])
except rhnSQL.SQLError:
e = sys.exc_info()[1]
errno = e.args[0]
if errno == 2292:
raise_with_tb(rhnFault(4005, "Cannot remove non-empty channel %s" %
config_channel, explain=0), sys.exc_info()[2])
raise
log_debug(5, "Removed:", config_channel)
rhnSQL.commit()
return ""
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:28,代码来源:rhn_config_management.py
示例17: populate_rhn_dist_channel_map
def populate_rhn_dist_channel_map(channel_id, channel_arch_id, org_id, release):
if not release:
release = 'unit test'
lookup = """
SELECT 1 FROM rhnDistChannelMap
WHERE release = :release AND
channel_arch_id = :channel_arch_id AND
org_id = :org_id
"""
h = rhnSQL.prepare(lookup)
h.execute(
release = release,
channel_arch_id = channel_arch_id,
org_id = org_id
)
if h.fetchone_dict():
return
query_create = """
INSERT INTO rhnDistChannelMap
(os, release, channel_arch_id, channel_id, org_id)
VALUES (:os, :release, :channel_arch_id, :channel_id, :org_id)
"""
h = rhnSQL.prepare(query_create)
h.execute(
os = "TestOS",
release = release,
channel_arch_id = channel_arch_id,
channel_id = channel_id,
org_id = org_id
)
rhnSQL.commit()
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:35,代码来源:misc_functions.py
示例18: management_create_channel
def management_create_channel(self, dict):
log_debug(1)
self._get_and_validate_session(dict)
config_channel = dict.get('config_channel')
# XXX Validate the namespace
config_channel_name = dict.get('config_channel_name') or config_channel
config_channel_description = dict.get('description') or config_channel
row = rhnSQL.fetchone_dict(self._query_lookup_config_channel,
org_id=self.org_id, config_channel=config_channel)
if row:
raise rhnFault(4010, "Configuration channel %s already exists" %
config_channel, explain=0)
insert_call = rhnSQL.Function('rhn_config.insert_channel',
rhnSQL.types.NUMBER())
config_channel_id = insert_call(self.org_id,
'normal',
config_channel_name,
config_channel,
config_channel_description)
rhnSQL.commit()
return {}
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:26,代码来源:rhn_config_management.py
示例19: update_crash_count
def update_crash_count(self, system_id, crash, crash_count):
self.auth_system(system_id)
log_debug(1, self.server_id, "Updating crash count for %s to %s" % (crash, crash_count))
server_org_id = self.server.server['org_id']
server_crash_dir = get_crash_path(str(server_org_id), str(self.server_id), crash)
if not server_crash_dir:
log_debug(1, self.server_id, "Error composing crash directory path")
raise rhnFault(5002)
h = rhnSQL.prepare(_query_update_crash_count)
r = h.execute(
crash_count=crash_count,
server_id=self.server_id,
crash=crash)
rhnSQL.commit()
if r == 0:
log_debug(1, self.server_id, "No record for crash: %s" % crash)
raise rhnFault(5005, "Invalid crash name: %s" % crash)
absolute_dir = os.path.join(CFG.MOUNT_POINT, server_crash_dir)
absolute_file = os.path.join(absolute_dir, 'count')
log_debug(1, self.server_id, "Updating crash count file: %s" % absolute_file)
f = open(absolute_file, 'w+')
f.write(crash_count)
f.close()
return 1
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:31,代码来源:abrt.py
示例20: main
def main():
rhnSQL.initDB()
blob_values1 = [
# Regular update
[1, 1, 'value 11', 'value 12', 1],
[2, 1, 'value 21', 'value 22', 2],
# Update with one of the primary keys being None
[3, None, 'value 31', 'value 32', 3],
[4, None, 'value 41', 'value 42', 4],
# Test for writing an empty string into the blob
[5, 5, '', 'value 52', 5],
# Test for writing a shorter string into the blob
[6, 6, 'value 61', 'value 62', 6],
]
newval1_1 = 'new value 11'
newval1_2 = 'new value 12'
newval3_1 = 'new value 31 ' * 1024
newval3_2 = 'new value 32' * 2048
newval5_1 = 'new value 51'
newval5_2 = ''
newval6_1 = 'v61'
newval6_2 = 'v61'
blob_values2 = blob_values1[:]
for r in [0, 2, 4, 5]:
# Copy the old values
blob_values2[r] = blob_values1[r][:]
blob_values2[0][2:5] = [newval1_1, newval1_2, 11]
blob_values2[2][2:5] = [newval3_1, newval3_2, 2]
blob_values2[4][2:5] = [newval5_1, newval5_2, 33]
blob_values2[5][2:5] = [newval6_1, newval6_2, 4]
test_blob_update = Table("test_blob_update",
fields={
'id1': DBint(),
'id2': DBint(),
'val1': DBblob(),
'val2': DBblob(),
'nval': DBint(),
},
# Setting the nullable column to be the first one, to force a specific codepath
pk=['id2', 'id1'],
nullable=['id2'],
)
fields = ['id1', 'id2', 'val1', 'val2', 'nval']
setup(test_blob_update, blob_values1, fields)
print("Insert test")
verify(blob_values1)
t = TableUpdate(test_blob_update, rhnSQL)
rows = [0, 2, 4, 5]
values = _build_update_hash(fields, blob_values2, rows)
t.query(values)
rhnSQL.commit()
print("Updates test")
verify(blob_values2)
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:60,代码来源:test_blob_update.py
注:本文中的spacewalk.server.rhnSQL.commit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论