本文整理汇总了Python中charmhelpers.core.hookenv.unit_private_ip方法的典型用法代码示例。如果您正苦于以下问题:Python hookenv.unit_private_ip方法的具体用法?Python hookenv.unit_private_ip怎么用?Python hookenv.unit_private_ip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.core.hookenv
的用法示例。
在下文中一共展示了hookenv.unit_private_ip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_database_setup
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def get_database_setup(self):
"""Provide the default database credentials as a list of 3-tuples
returns a structure of:
[
{'database': <database>,
'username': <username>,
'hostname': <hostname of this unit>
'prefix': <the optional prefix for the database>, },
]
:returns [{'database': ...}, ...]: credentials for multiple databases
"""
return [
dict(
database=self.config['database'],
username=self.config['database-user'],
hostname=hookenv.unit_private_ip(), )
]
示例2: server_removed
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def server_removed():
"""
Remove a server from the cluster
"""
private_address = unit_private_ip()
log("Removing server: {}".format(private_address), INFO)
示例3: configure_openvswitch
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def configure_openvswitch(self, odl_ovsdb):
hookenv.log("Configuring OpenvSwitch with ODL OVSDB controller: %s" %
odl_ovsdb.connection_string())
local_ip = ch_ip.get_address_in_network(
self.config.get('os-data-network'),
hookenv.unit_private_ip())
ovs.set_config('local_ip', local_ip)
ovs.set_config('controller-ips', odl_ovsdb.private_address(),
table='external_ids')
ovs.set_config('host-id', socket.gethostname(),
table='external_ids')
ovs.set_manager(odl_ovsdb.connection_string())
hookenv.status_set('active', 'Unit is ready')
示例4: odl_node_registration
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def odl_node_registration(self, controller):
""" Register node with ODL if not registered already """
odl_conn = odl.ODLConfig(**controller.connection())
device_name = socket.gethostname()
if odl_conn.is_device_registered(device_name):
hookenv.log('{} is already registered in odl'.format(device_name))
else:
local_ip = ch_ip.get_address_in_network(
self.config('os-data-network'),
hookenv.unit_private_ip())
hookenv.log('Registering {} ({}) in odl'.format(
device_name, local_ip))
odl_conn.odl_register_node(device_name, local_ip)
示例5: get_database_setup
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def get_database_setup(self):
return [{
'database': 'mistral',
'username': 'mistral',
'hostname': hookenv.unit_private_ip() },]
示例6: set_sync_info
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def set_sync_info(self, sync_time, sync_file):
"""Update leader DB with sync information
:param sync_time: str Time sync was created in epoch seconds
:param sync_file: str Local file containing zone information
:returns: None
"""
sync_info = {
LEADERDB_SYNC_SRC_KEY: 'http://{}:80/zone-syncs/{}'.format(
hookenv.unit_private_ip(), sync_file),
LEADERDB_SYNC_TIME_KEY: sync_time,
}
hookenv.leader_set(sync_info)
示例7: prepare_tls_certificates
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def prepare_tls_certificates(tls):
status_set('maintenance', 'Requesting tls certificates.')
common_name = hookenv.unit_public_ip()
sans = []
sans.append(hookenv.unit_public_ip())
sans.append(hookenv.unit_private_ip())
sans.append(socket.gethostname())
certificate_name = hookenv.local_unit().replace('/', '_')
tls.request_server_cert(common_name, sans, certificate_name)
示例8: test_gets_unit_private_ip
# 需要导入模块: from charmhelpers.core import hookenv [as 别名]
# 或者: from charmhelpers.core.hookenv import unit_private_ip [as 别名]
def test_gets_unit_private_ip(self, _unitget):
_unitget.return_value = sentinel.private_ip
self.assertEqual(sentinel.private_ip, hookenv.unit_private_ip())
_unitget.assert_called_once_with('private-address')