python类unit_private_ip()的实例源码

murano.py 文件源码 项目:charm-murano 作者: openstack 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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(), )
        ]
server_removed.py 文件源码 项目:charm-glusterfs 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def server_removed():
    """
    Remove a server from the cluster
    """
    private_address = unit_private_ip()
    log("Removing server: {}".format(private_address), INFO)
openvswitch_odl.py 文件源码 项目:charm-openvswitch-odl 作者: openstack 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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')
openvswitch_odl.py 文件源码 项目:charm-openvswitch-odl 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
mistral.py 文件源码 项目:charm-mistral 作者: openstack 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_database_setup(self):
        return [{
            'database': 'mistral',
            'username': 'mistral',
            'hostname': hookenv.unit_private_ip() },]
designate_bind.py 文件源码 项目:charm-designate-bind 作者: openstack 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)
etcd.py 文件源码 项目:layer-etcd 作者: juju-solutions 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
test_hookenv.py 文件源码 项目:charm-helpers 作者: juju 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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')


问题


面经


文章

微信
公众号

扫码关注公众号