Merge "Use my_ip as default URL instead of localhost"

This commit is contained in:
Jenkins 2015-04-03 11:43:56 +00:00 committed by Gerrit Code Review
commit d20820a690
2 changed files with 13 additions and 6 deletions

View File

@ -16,13 +16,14 @@ from __future__ import print_function
import argparse
import json
from oslo_utils import netutils
import requests
import six
from ironic_discoverd.common.i18n import _
_DEFAULT_URL = 'http://127.0.0.1:5050/v1'
_DEFAULT_URL = 'http://' + netutils.get_my_ipv4() + ':5050/v1'
_ERROR_ENCODING = 'utf-8'
@ -54,7 +55,7 @@ def introspect(uuid, base_url=None, auth_token=None,
:param uuid: node uuid
:param base_url: *ironic-discoverd* URL in form: http://host:port[/ver],
defaults to ``http://127.0.0.1:5050/v1``.
defaults to ``http://<current host>:5050/v1``.
:param auth_token: Keystone authentication token.
:param new_ipmi_password: if set, *ironic-discoverd* will update IPMI
password to this value.
@ -81,7 +82,7 @@ def get_status(uuid, base_url=None, auth_token=None):
New in ironic-discoverd version 1.0.0.
:param uuid: node uuid.
:param base_url: *ironic-discoverd* URL in form: http://host:port[/ver],
defaults to ``http://127.0.0.1:5050/v1``.
defaults to ``http://<current host>:5050/v1``.
:param auth_token: Keystone authentication token.
:raises: *requests* library HTTP errors.
"""

View File

@ -14,6 +14,7 @@
import unittest
import mock
from oslo_utils import netutils
from oslo_utils import uuidutils
from ironic_discoverd import client
@ -25,6 +26,7 @@ class TestIntrospect(unittest.TestCase):
def setUp(self):
super(TestIntrospect, self).setUp()
self.uuid = uuidutils.generate_uuid()
self.my_ip = 'http://' + netutils.get_my_ipv4() + ':5050/v1'
def test(self, mock_post):
client.introspect(self.uuid, base_url="http://host:port",
@ -52,7 +54,8 @@ class TestIntrospect(unittest.TestCase):
def test_default_url(self, mock_post):
client.introspect(self.uuid, auth_token="token")
mock_post.assert_called_once_with(
"http://127.0.0.1:5050/v1/introspection/%s" % self.uuid,
"%(my_ip)s/introspection/%(uuid)s" %
{'my_ip': self.my_ip, 'uuid': self.uuid},
headers={'X-Auth-Token': 'token'},
params={'new_ipmi_username': None, 'new_ipmi_password': None}
)
@ -70,7 +73,8 @@ class TestIntrospect(unittest.TestCase):
def test_none_ok(self, mock_post):
client.introspect(self.uuid)
mock_post.assert_called_once_with(
"http://127.0.0.1:5050/v1/introspection/%s" % self.uuid,
"%(my_ip)s/introspection/%(uuid)s" %
{'my_ip': self.my_ip, 'uuid': self.uuid},
headers={},
params={'new_ipmi_username': None, 'new_ipmi_password': None}
)
@ -118,6 +122,7 @@ class TestGetStatus(unittest.TestCase):
def setUp(self):
super(TestGetStatus, self).setUp()
self.uuid = uuidutils.generate_uuid()
self.my_ip = 'http://' + netutils.get_my_ipv4() + ':5050/v1'
def test(self, mock_get):
mock_get.return_value.json.return_value = 'json'
@ -125,7 +130,8 @@ class TestGetStatus(unittest.TestCase):
client.get_status(self.uuid, auth_token='token')
mock_get.assert_called_once_with(
"http://127.0.0.1:5050/v1/introspection/%s" % self.uuid,
"%(my_ip)s/introspection/%(uuid)s" %
{'my_ip': self.my_ip, 'uuid': self.uuid},
headers={'X-Auth-Token': 'token'}
)