當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。