Пример #1
0
 def get_host_ip_addr(self):
     ips = compute_utils.get_machine_ips()
     if CONF.my_ip not in ips:
         LOG.warn(_LW('my_ip address (%(my_ip)s) was not found on '
                      'any of the interfaces: %(ifaces)s'),
                  {'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)})
     return CONF.my_ip
Пример #2
0
 def get_host_ip_addr(self):
     ips = compute_utils.get_machine_ips()
     if CONF.my_ip not in ips:
         LOG.warn(_LW('my_ip address (%(my_ip)s) was not found on '
                      'any of the interfaces: %(ifaces)s'),
                  {'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)})
     return CONF.my_ip
Пример #3
0
 def get_host_ip_addr(self):
     ips = compute_utils.get_machine_ips()
     if CONF.my_ip not in ips:
         LOG.warn(
             _LW("my_ip address (%(my_ip)s) was not found on " "any of the interfaces: %(ifaces)s"),
             {"my_ip": CONF.my_ip, "ifaces": ", ".join(ips)},
         )
     return CONF.my_ip
Пример #4
0
 def test_get_machine_ips_value_error(self, mock_interfaces):
     # Tests that the utility method does not explode if netifaces raises
     # a ValueError.
     iface = mock.sentinel
     mock_interfaces.return_value = [iface]
     with mock.patch("netifaces.ifaddresses", side_effect=ValueError) as mock_ifaddresses:
         addresses = compute_utils.get_machine_ips()
         self.assertEqual([], addresses)
     mock_ifaddresses.assert_called_once_with(iface)
Пример #5
0
 def test_get_machine_ips_value_error(self, mock_interfaces):
     # Tests that the utility method does not explode if netifaces raises
     # a ValueError.
     iface = mock.sentinel
     mock_interfaces.return_value = [iface]
     with mock.patch('netifaces.ifaddresses',
                     side_effect=ValueError) as mock_ifaddresses:
         addresses = compute_utils.get_machine_ips()
         self.assertEqual([], addresses)
     mock_ifaddresses.assert_called_once_with(iface)