Merge "Remove locals() from messages in virt/disk/api.py"

This commit is contained in:
Jenkins 2013-05-17 19:38:19 +00:00 committed by Gerrit Code Review
commit 505af894f3

View File

@ -131,7 +131,8 @@ def can_resize_fs(image, size, use_cow=False):
"""Check whether we can resize contained file system.""" """Check whether we can resize contained file system."""
LOG.debug(_('Checking if we can resize image %(image)s. ' LOG.debug(_('Checking if we can resize image %(image)s. '
'size=%(size)s, CoW=%(use_cow)s'), locals()) 'size=%(size)s, CoW=%(use_cow)s'),
{'image': image, 'size': size, 'use_cow': use_cow})
# Check that we're increasing the size # Check that we're increasing the size
virt_size = get_disk_size(image) virt_size = get_disk_size(image)
@ -281,9 +282,10 @@ def inject_data(image, key=None, net=None, metadata=None, admin_password=None,
Raises an exception if a mandatory item can't be injected. Raises an exception if a mandatory item can't be injected.
""" """
LOG.debug(_("Inject data image=%(image)s key=%(key)s net=%(net)s " LOG.debug(_("Inject data image=%(image)s key=%(key)s net=%(net)s "
"metadata=%(metadata)s admin_password=ha-ha-not-telling-you " "metadata=%(metadata)s admin_password=<SANITIZED> "
"files=%(files)s partition=%(partition)s use_cow=%(use_cow)s") "files=%(files)s partition=%(partition)s use_cow=%(use_cow)s"),
% locals()) {'image': image, 'key': key, 'net': net, 'metadata': metadata,
'files': files, 'partition': partition, 'use_cow': use_cow})
fmt = "raw" fmt = "raw"
if use_cow: if use_cow:
fmt = "qcow2" fmt = "qcow2"
@ -298,7 +300,7 @@ def inject_data(image, key=None, net=None, metadata=None, admin_password=None,
if inject_val: if inject_val:
raise raise
LOG.warn(_('Ignoring error injecting data into image ' LOG.warn(_('Ignoring error injecting data into image '
'(%(e)s)') % locals()) '(%(e)s)'), {'e': e})
return False return False
try: try:
@ -317,7 +319,7 @@ def setup_container(image, container_dir, use_cow=False):
img = _DiskImage(image=image, use_cow=use_cow, mount_dir=container_dir) img = _DiskImage(image=image, use_cow=use_cow, mount_dir=container_dir)
if not img.mount(): if not img.mount():
LOG.error(_("Failed to mount container filesystem '%(image)s' " LOG.error(_("Failed to mount container filesystem '%(image)s' "
"on '%(target)s': %(errors)s") % "on '%(target)s': %(errors)s"),
{"image": img, "target": container_dir, {"image": img, "target": container_dir,
"errors": img.errors}) "errors": img.errors})
raise exception.NovaException(img.errors) raise exception.NovaException(img.errors)
@ -372,7 +374,7 @@ def inject_data_into_fs(fs, key, net, metadata, admin_password, files,
if inject in mandatory: if inject in mandatory:
raise raise
LOG.warn(_('Ignoring error injecting %(inject)s into image ' LOG.warn(_('Ignoring error injecting %(inject)s into image '
'(%(e)s)') % locals()) '(%(e)s)'), {'e': e})
status = False status = False
return status return status
@ -383,8 +385,8 @@ def _inject_files_into_fs(files, fs):
def _inject_file_into_fs(fs, path, contents, append=False): def _inject_file_into_fs(fs, path, contents, append=False):
LOG.debug(_("Inject file fs=%(fs)s path=%(path)s append=%(append)s") % LOG.debug(_("Inject file fs=%(fs)s path=%(path)s append=%(append)s"),
locals()) {'fs': fs, 'path': path, 'append': append})
if append: if append:
fs.append_file(path, contents) fs.append_file(path, contents)
else: else:
@ -392,8 +394,8 @@ def _inject_file_into_fs(fs, path, contents, append=False):
def _inject_metadata_into_fs(metadata, fs): def _inject_metadata_into_fs(metadata, fs):
LOG.debug(_("Inject metadata fs=%(fs)s metadata=%(metadata)s") % LOG.debug(_("Inject metadata fs=%(fs)s metadata=%(metadata)s"),
locals()) {'fs': fs, 'metadata': metadata})
metadata = dict([(m['key'], m['value']) for m in metadata]) metadata = dict([(m['key'], m['value']) for m in metadata])
_inject_file_into_fs(fs, 'meta.js', jsonutils.dumps(metadata)) _inject_file_into_fs(fs, 'meta.js', jsonutils.dumps(metadata))
@ -433,8 +435,7 @@ def _inject_key_into_fs(key, fs):
fs is the path to the base of the filesystem into which to inject the key. fs is the path to the base of the filesystem into which to inject the key.
""" """
LOG.debug(_("Inject key fs=%(fs)s key=%(key)s") % LOG.debug(_("Inject key fs=%(fs)s key=%(key)s"), {'fs': fs, 'key': key})
locals())
sshdir = os.path.join('root', '.ssh') sshdir = os.path.join('root', '.ssh')
fs.make_path(sshdir) fs.make_path(sshdir)
fs.set_ownership(sshdir, "root", "root") fs.set_ownership(sshdir, "root", "root")
@ -462,8 +463,7 @@ def _inject_net_into_fs(net, fs):
net is the contents of /etc/network/interfaces. net is the contents of /etc/network/interfaces.
""" """
LOG.debug(_("Inject key fs=%(fs)s net=%(net)s") % LOG.debug(_("Inject key fs=%(fs)s net=%(net)s"), {'fs': fs, 'net': net})
locals())
netdir = os.path.join('etc', 'network') netdir = os.path.join('etc', 'network')
fs.make_path(netdir) fs.make_path(netdir)
fs.set_ownership(netdir, "root", "root") fs.set_ownership(netdir, "root", "root")
@ -489,8 +489,7 @@ def _inject_admin_password_into_fs(admin_passwd, fs):
# necessary changes, and then copy them back. # necessary changes, and then copy them back.
LOG.debug(_("Inject admin password fs=%(fs)s " LOG.debug(_("Inject admin password fs=%(fs)s "
"admin_passwd=ha-ha-not-telling-you") % "admin_passwd=<SANITIZED>"), {'fs': fs})
locals())
admin_user = 'root' admin_user = 'root'
fd, tmp_passwd = tempfile.mkstemp() fd, tmp_passwd = tempfile.mkstemp()