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: if DOCKER_INSTALLED:
return resource_mapping() return resource_mapping()
else: else:
logger.warn("Docker plug-in loaded, but docker lib not installed.") logger.warn(_("Docker plug-in loaded, but docker lib not installed."))
return {} return {}

View File

@ -354,7 +354,7 @@ class CloudLoadBalancer(resource.Resource):
} }
attributes_schema = { attributes_schema = {
'PublicIp': ('Public IP address of the specified ' 'PublicIp': _('Public IP address of the specified '
'instance.')} 'instance.')}
update_allowed_keys = ('Properties',) update_allowed_keys = ('Properties',)
@ -606,7 +606,8 @@ class CloudLoadBalancer(resource.Resource):
raise exception.InvalidTemplateAttribute(resource=self.name, raise exception.InvalidTemplateAttribute(resource=self.name,
key=key) key=key)
function = attribute_function[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) return unicode(function)

View File

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

View File

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

View File

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

View File

@ -284,7 +284,10 @@ class WaitCondition(resource.Resource):
raise exception.InvalidTemplateAttribute(resource=self.name, raise exception.InvalidTemplateAttribute(resource=self.name,
key=key) 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)) return unicode(json.dumps(res))