def __init__(self, port_map=None, service_name=None, charm_instance=None):
"""
Note passing port_map and service_name is deprecated, but supported for
backwards compatibility. The port_map and service_name can be obtained
from the self.charm_instance weak reference.
:param port_map: Map containing service names and the ports used e.g.
port_map = {
'svc1': {
'admin': 9001,
'public': 9001,
'int': 9001,
},
'svc2': {
'admin': 9002,
'public': 9002,
'int': 9002,
},
}
:param service_name: Name of service being deployed
:param charm_instance: a charm instance that will be passed to the base
constructor
"""
super(APIConfigurationAdapter, self).__init__(
charm_instance=charm_instance)
if port_map is not None:
hookenv.log(
"DEPRECATION: should not use port_map parameter in "
"APIConfigurationAdapter.__init__()", level=hookenv.WARNING)
self.port_map = port_map
elif self.charm_instance is not None:
self.port_map = self.charm_instance.api_ports
else:
self.port_map = None
if service_name is not None:
hookenv.log(
"DEPRECATION: should not use service_name parameter in "
"APIConfigurationAdapter.__init__()", level=hookenv.WARNING)
self.service_name = service_name
elif self.charm_instance is not None:
self.service_name = self.charm_instance.name
else:
self.service_name = None
self.__network_addresses = None
评论列表
文章目录