本文整理汇总了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')
示例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')
示例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')