当前位置: 首页>>代码示例>>Python>>正文


Python hookenv.unit_private_ip方法代码示例

本文整理汇总了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(), )
        ] 
开发者ID:openstack,项目名称:charm-murano,代码行数:21,代码来源:murano.py

示例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) 
开发者ID:openstack,项目名称:charm-glusterfs,代码行数:8,代码来源:server_removed.py

示例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') 
开发者ID:openstack,项目名称:charm-openvswitch-odl,代码行数:15,代码来源:openvswitch_odl.py

示例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) 
开发者ID:openstack,项目名称:charm-openvswitch-odl,代码行数:15,代码来源:openvswitch_odl.py

示例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() },] 
开发者ID:openstack,项目名称:charm-mistral,代码行数:7,代码来源:mistral.py

示例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) 
开发者ID:openstack,项目名称:charm-designate-bind,代码行数:15,代码来源:designate_bind.py

示例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) 
开发者ID:juju-solutions,项目名称:layer-etcd,代码行数:11,代码来源:etcd.py

示例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') 
开发者ID:juju,项目名称:charm-helpers,代码行数:6,代码来源:test_hookenv.py


注:本文中的charmhelpers.core.hookenv.unit_private_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。