"""Show a list of all physical hosts. Filter by zone.
args: [zone]
"""
- print("%-25s\t%-15s" % (_('host'),
- _('zone')))
+ print(_("%(host)-25s\t%(zone)-15s") % {'host': 'host', 'zone': 'zone'})
ctxt = context.get_admin_context()
services = db.service_get_all(ctxt)
if zone:
hosts.append(srv)
for h in hosts:
- print("%-25s\t%-15s" % (h['host'], h['availability_zone']))
+ print(_("%(host)-25s\t%(availability_zone)-15s")
+ % {'host': h['host'],
+ 'availability_zone': h['availability_zone']})
class DbCommands(object):
host = volume['host']
if not host:
- print("Volume not yet assigned to host.")
- print("Deleting volume from database and skipping rpc.")
+ print(_("Volume not yet assigned to host."))
+ print(_("Deleting volume from database and skipping rpc."))
db.volume_destroy(ctxt, param2id(volume_id))
return
if volume['status'] == 'in-use':
- print("Volume is in-use.")
- print("Detach volume from instance and then try again.")
+ print(_("Volume is in-use."))
+ print(_("Detach volume from instance and then try again."))
return
rpc.cast(ctxt,
ctxt = context.get_admin_context()
volume = db.volume_get(ctxt, param2id(volume_id))
if not volume['instance_id']:
- print("volume is not attached to an instance")
+ print(_("volume is not attached to an instance"))
return
instance = db.instance_get(ctxt, volume['instance_id'])
host = instance['host']
if print_name == 0:
print(log_file + ":-")
print_name = 1
- print("Line %d : %s" % (len(lines) - index, line))
+ print(_("Line %(dis)d : %(line)s") %
+ {'dis': len(lines) - index, 'line': line})
if error_found == 0:
- print("No errors in logfiles!")
+ print(_("No errors in logfiles!"))
@args('num_entries', nargs='?', type=int, default=10,
help='Number of entries to list (default: %(default)d)')
elif os.path.exists('/var/log/messages'):
log_file = '/var/log/messages'
else:
- print("Unable to find system log file!")
+ print(_("Unable to find system log file!"))
sys.exit(1)
lines = [line.strip() for line in open(log_file, "r")]
lines.reverse()
- print("Last %s cinder syslog entries:-" % (entries))
+ print(_("Last %s cinder syslog entries:-") % (entries))
for line in lines:
if line.find("cinder") > 0:
count += 1
- print("%s" % (line))
+ print(_("%s") % (line))
if count == entries:
break
if count == 0:
- print("No cinder entries in syslog!")
+ print(_("No cinder entries in syslog!"))
class BackupCommands(object):
print(script_name + " category action [<args>]")
print(_("Available categories:"))
for category in CATEGORIES:
- print("\t%s" % category)
+ print(_("\t%s") % category)
sys.exit(2)
try:
def _exit_error(execname, message, errorcode, log=True):
- print("%s: %s" % (execname, message))
+ print(_("%(execname)s: %(message)s") %
+ {'execname': execname, 'message': message})
if log:
logging.error(message)
sys.exit(errorcode)
rawconfig.read(configfile)
config = wrapper.RootwrapConfig(rawconfig)
except ValueError as exc:
- msg = "Incorrect value in %s: %s" % (configfile, exc.message)
+ msg = (_("Incorrect value in %(configfile)s: %(message)s")
+ % {'configfile': configfile, 'message': exc.message})
_exit_error(execname, msg, RC_BADCONFIG, log=False)
except ConfigParser.Error:
_exit_error(execname, "Incorrect configuration file: %s" % configfile,
sys.exit(obj.returncode)
except wrapper.FilterMatchNotExecutable as exc:
- msg = ("Executable not found: %s (filter match = %s)"
- % (exc.match.exec_path, exc.match.name))
+ msg = (_("Executable not found: %(exec_path)s "
+ "(filter match = %(name)s)")
+ % {'exec_path': exc.match.exec_path, 'name': exc.match.name})
_exit_error(execname, msg, RC_NOEXECFOUND, log=config.use_syslog)
except wrapper.NoFilterMatched:
- msg = ("Unauthorized command: %s (no filter matched)"
+ msg = (_("Unauthorized command: %s (no filter matched)")
% ' '.join(userargs))
_exit_error(execname, msg, RC_UNAUTHORIZED, log=config.use_syslog)