本文整理匯總了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')