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


Python netutils.get_my_ipv4方法代码示例

本文整理汇总了Python中oslo_utils.netutils.get_my_ipv4方法的典型用法代码示例。如果您正苦于以下问题:Python netutils.get_my_ipv4方法的具体用法?Python netutils.get_my_ipv4怎么用?Python netutils.get_my_ipv4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_utils.netutils的用法示例。


在下文中一共展示了netutils.get_my_ipv4方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_my_ip

# 需要导入模块: from oslo_utils import netutils [as 别名]
# 或者: from oslo_utils.netutils import get_my_ipv4 [as 别名]
def test_get_my_ip(self):
        sock_attrs = {
            'return_value.getsockname.return_value': ['1.2.3.4', '']}
        with mock.patch('socket.socket', **sock_attrs):
            addr = netutils.get_my_ipv4()
        self.assertEqual(addr, '1.2.3.4') 
开发者ID:openstack,项目名称:oslo.utils,代码行数:8,代码来源:test_netutils.py

示例2: test_get_my_ip_socket_error

# 需要导入模块: from oslo_utils import netutils [as 别名]
# 或者: from oslo_utils.netutils import get_my_ipv4 [as 别名]
def test_get_my_ip_socket_error(self, ip, mock_socket):
        mock_socket.side_effect = socket.error
        ip.return_value = '1.2.3.4'
        addr = netutils.get_my_ipv4()
        self.assertEqual(addr, '1.2.3.4') 
开发者ID:openstack,项目名称:oslo.utils,代码行数:7,代码来源:test_netutils.py

示例3: __init__

# 需要导入模块: from oslo_utils import netutils [as 别名]
# 或者: from oslo_utils.netutils import get_my_ipv4 [as 别名]
def __init__(self, reactor, hpepluginconfig):
        """
        :param IReactorTime reactor: Reactor time interface implementation.
        :param Ihpepluginconfig : hpedefaultconfig configuration
        """
        LOG.info(_LI('Initialize Volume Plugin'))

        self._reactor = reactor
        self._hpepluginconfig = hpepluginconfig
        hpeplugin_driver = hpepluginconfig.hpedockerplugin_driver

        self.hpeplugin_driver = \
            importutils.import_object(hpeplugin_driver, self._hpepluginconfig)

        if self.hpeplugin_driver is None:
            msg = (_('hpeplugin_driver import driver failed'))
            LOG.error(msg)
            raise exception.HPEPluginNotInitializedException(reason=msg)

        try:
            self.hpeplugin_driver.do_setup()
            self.hpeplugin_driver.check_for_setup_error()
        except Exception as ex:
            msg = (_('hpeplugin_driver do_setup failed, error is: %s'),
                   six.text_type(ex))
            LOG.error(msg)
            raise exception.HPEPluginNotInitializedException(reason=msg)

        self._voltracker = {}
        self._path_info = []
        self._my_ip = netutils.get_my_ipv4()

        self._etcd = util.EtcdUtil(
            self._hpepluginconfig.host_etcd_ip_address,
            self._hpepluginconfig.host_etcd_port_number,
            self._hpepluginconfig.host_etcd_client_cert,
            self._hpepluginconfig.host_etcd_client_key)

        # TODO: make device_scan_attempts configurable
        # see nova/virt/libvirt/volume/iscsi.py
        root_helper = 'sudo'
        self.use_multipath = self._hpepluginconfig.use_multipath
        self.enforce_multipath = self._hpepluginconfig.enforce_multipath
        self.connector = connector.InitiatorConnector.factory(
            'ISCSI', root_helper, use_multipath=self.use_multipath,
            device_scan_attempts=5, transport='default') 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:48,代码来源:hpe_storage_api.py


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