I18N support for log message and attributes schema

The log message and attributes schema should support i18n.

Change-Id: Iea8a73ba8aabd3c12efe43cdda9188f9216f50de
This commit is contained in:
huangtianhua 2014-01-25 16:00:12 +08:00
parent 0936135169
commit 6e5dfcfa1d
6 changed files with 33 additions and 21 deletions

View File

@ -281,5 +281,5 @@ def available_resource_mapping():
if DOCKER_INSTALLED:
return resource_mapping()
else:
logger.warn("Docker plug-in loaded, but docker lib not installed.")
logger.warn(_("Docker plug-in loaded, but docker lib not installed."))
return {}

View File

@ -354,8 +354,8 @@ class CloudLoadBalancer(resource.Resource):
}
attributes_schema = {
'PublicIp': ('Public IP address of the specified '
'instance.')}
'PublicIp': _('Public IP address of the specified '
'instance.')}
update_allowed_keys = ('Properties',)
@ -606,7 +606,8 @@ class CloudLoadBalancer(resource.Resource):
raise exception.InvalidTemplateAttribute(resource=self.name,
key=key)
function = attribute_function[key]
logger.info('%s.GetAtt(%s) == %s' % (self.name, key, function))
logger.info(_('%(name)s.GetAtt(%(key)s) == %(function)s'),
{'name': self.name, 'key': key, 'function': function})
return unicode(function)

View File

@ -193,9 +193,10 @@ class ElasticIpAssociation(resource.Resource):
server = self.nova().servers.get(self.properties[self.INSTANCE_ID])
server.add_floating_ip(self.properties[self.EIP])
self.resource_id_set(self.properties[self.EIP])
logger.debug('ElasticIpAssociation %s.add_floating_ip(%s)' %
(self.properties[self.INSTANCE_ID],
self.properties[self.EIP]))
logger.debug(_('ElasticIpAssociation '
'%(instance)s.add_floating_ip(%(eip)s)'),
{'instance': self.properties[self.INSTANCE_ID],
'eip': self.properties[self.EIP]})
elif self.properties[self.ALLOCATION_ID]:
assert clients.neutronclient, "Neutron required for VPC operations"
port_id = None

View File

@ -334,7 +334,10 @@ class Instance(resource.Resource):
'PrivateDnsName']:
res = self._ipaddress()
logger.info('%s._resolve_attribute(%s) == %s' % (self.name, name, res))
logger.info(_('%(name)s._resolve_attribute(%(attname)s) == %(res)s'),
{'name': self.name,
'attname': name,
'res': res})
return unicode(res) if res else None
def _build_nics(self, network_interfaces,
@ -649,8 +652,10 @@ class Instance(resource.Resource):
return True
server.get()
logger.debug("%s check_suspend_complete status = %s" %
(self.name, server.status))
logger.debug(_("%(name)s check_suspend_complete "
"status = %(status)s"),
{'name': self.name,
'status': server.status})
if server.status in list(nova_utils.deferred_server_statuses +
['ACTIVE']):
return server.status == 'SUSPENDED'

View File

@ -344,16 +344,18 @@ class LoadBalancer(stack_resource.StackResource):
}
attributes_schema = {
"CanonicalHostedZoneName": ("The name of the hosted zone that is "
"associated with the LoadBalancer."),
"CanonicalHostedZoneNameID": ("The ID of the hosted zone name that is "
"associated with the LoadBalancer."),
"DNSName": "The DNS name for the LoadBalancer.",
"SourceSecurityGroup.GroupName": ("The security group that you can use"
" as part of your inbound rules for "
"your LoadBalancer's back-end "
"instances."),
"SourceSecurityGroup.OwnerAlias": "Owner of the source security group."
"CanonicalHostedZoneName": _("The name of the hosted zone that is "
"associated with the LoadBalancer."),
"CanonicalHostedZoneNameID": _("The ID of the hosted zone name "
"that is associated with the "
"LoadBalancer."),
"DNSName": _("The DNS name for the LoadBalancer."),
"SourceSecurityGroup.GroupName": _("The security group that you can "
"use as part of your inbound "
"rules for your LoadBalancer's "
"back-end instances."),
"SourceSecurityGroup.OwnerAlias": _("Owner of the source "
"security group.")
}
update_allowed_keys = ('Properties',)

View File

@ -284,7 +284,10 @@ class WaitCondition(resource.Resource):
raise exception.InvalidTemplateAttribute(resource=self.name,
key=key)
logger.debug('%s.GetAtt(%s) == %s' % (self.name, key, res))
logger.debug(_('%(name)s.GetAtt(%(key)s) == %(res)s') %
{'name': self.name,
'key': key,
'res': res})
return unicode(json.dumps(res))