Merge "azureservice: added redundance for wireserver"
This commit is contained in:
commit
d6e28339eb
@ -36,6 +36,7 @@ LOG = oslo_logging.getLogger(__name__)
|
||||
|
||||
WIRESERVER_DHCP_OPTION = 245
|
||||
WIRE_SERVER_VERSION = '2015-04-05'
|
||||
WIRE_SERVER_FALLBACK_IP = '168.63.129.16'
|
||||
|
||||
GOAL_STATE_STARTED = "Started"
|
||||
|
||||
@ -66,8 +67,8 @@ class AzureService(base.BaseHTTPMetadataService):
|
||||
self._osutils = osutils_factory.get_os_utils()
|
||||
|
||||
def _get_wire_server_endpoint_address(self):
|
||||
total_time = 300
|
||||
poll_time = 5
|
||||
total_time = 150
|
||||
poll_time = 2
|
||||
retries = total_time / poll_time
|
||||
|
||||
while True:
|
||||
@ -78,7 +79,8 @@ class AzureService(base.BaseHTTPMetadataService):
|
||||
raise exception.MetadataNotFoundException(
|
||||
"Cannot find Azure WireServer endpoint address")
|
||||
return socket.inet_ntoa(endpoint)
|
||||
except Exception:
|
||||
except Exception as ex:
|
||||
LOG.debug(ex)
|
||||
if not retries:
|
||||
raise
|
||||
time.sleep(poll_time)
|
||||
@ -452,10 +454,13 @@ class AzureService(base.BaseHTTPMetadataService):
|
||||
def load(self):
|
||||
try:
|
||||
wire_server_endpoint = self._get_wire_server_endpoint_address()
|
||||
self._base_url = "http://%s" % wire_server_endpoint
|
||||
except Exception:
|
||||
LOG.debug("Azure WireServer endpoint not found")
|
||||
return False
|
||||
LOG.debug(
|
||||
"Azure WireServer endpoint not found. "
|
||||
"Using default endpoint %s.", WIRE_SERVER_FALLBACK_IP)
|
||||
wire_server_endpoint = WIRE_SERVER_FALLBACK_IP
|
||||
|
||||
self._base_url = "http://%s" % wire_server_endpoint
|
||||
|
||||
try:
|
||||
super(AzureService, self).load()
|
||||
|
@ -594,16 +594,19 @@ class AzureServiceTest(unittest.TestCase):
|
||||
endpoint_side_effect=None, load_side_effect=None):
|
||||
if endpoint_side_effect:
|
||||
mock_get_endpoint_address.side_effect = endpoint_side_effect
|
||||
expected_logging = ["Azure WireServer endpoint not found"]
|
||||
mock_endpoint = "168.63.129.16"
|
||||
expected_logging = [
|
||||
"Azure WireServer endpoint not found. "
|
||||
"Using default endpoint 168.63.129.16."]
|
||||
with self._logsnatcher:
|
||||
res = self._azureservice.load()
|
||||
self.assertFalse(res)
|
||||
self.assertTrue(res)
|
||||
self.assertEqual(self._logsnatcher.output, expected_logging)
|
||||
mock_get_endpoint_address.assert_called_once_with()
|
||||
return
|
||||
else:
|
||||
mock_endpoint = mock.sentinel.endpoint
|
||||
mock_get_endpoint_address.return_value = mock_endpoint
|
||||
|
||||
mock_endpoint = mock.sentinel.endpoint
|
||||
mock_get_endpoint_address.return_value = mock_endpoint
|
||||
if load_side_effect:
|
||||
mock_check_version_header.side_effect = load_side_effect
|
||||
res = self._azureservice.load()
|
||||
@ -613,9 +616,8 @@ class AzureServiceTest(unittest.TestCase):
|
||||
res = self._azureservice.load()
|
||||
self.assertTrue(res)
|
||||
self.assertIn(str(mock_endpoint), self._azureservice._base_url)
|
||||
mock_check_version_header.assert_called_once_with()
|
||||
mock_get_ovf_env.assert_called_once_with()
|
||||
return
|
||||
mock_check_version_header.assert_called_with()
|
||||
mock_get_ovf_env.assert_called_with()
|
||||
|
||||
def test_load_no_endpoint(self):
|
||||
self._test_load(endpoint_side_effect=Exception)
|
||||
|
Loading…
x
Reference in New Issue
Block a user