Merge "Instance details view shows hostname (if it has it) or IP"
This commit is contained in:
commit
339a811687
@ -46,7 +46,6 @@ cinder_url = http://localhost:8776/v1
|
||||
swift_url = http://localhost:8080/v1/AUTH_
|
||||
|
||||
# Config option for showing the IP address that nova doles out
|
||||
add_addresses = True
|
||||
network_label_regex = ^private$
|
||||
#ip_regex = ^(15.|123.)
|
||||
|
||||
|
@ -70,7 +70,6 @@ nova_service_type = compute
|
||||
nova_service_name = Compute Service
|
||||
|
||||
# Config option for showing the IP address that nova doles out
|
||||
add_addresses = True
|
||||
network_label_regex = ^private$
|
||||
ip_regex = ^(15.|123.)
|
||||
|
||||
|
@ -41,9 +41,6 @@ common_opts = [
|
||||
cfg.StrOpt('api_paste_config',
|
||||
default="api-paste.ini",
|
||||
help='File name for the paste.deploy config for trove-api'),
|
||||
cfg.BoolOpt('add_addresses',
|
||||
default=False,
|
||||
help='Whether to add IP addresses to the list operations'),
|
||||
cfg.BoolOpt('trove_volume_support',
|
||||
default=True,
|
||||
help='Whether to provision a cinder volume for datadir'),
|
||||
|
@ -95,11 +95,9 @@ class InstanceDetailView(InstanceView):
|
||||
result['instance']['datastore']['version'] = (self.instance.
|
||||
datastore_version.name)
|
||||
|
||||
dns_support = CONF.trove_dns_support
|
||||
if dns_support:
|
||||
if self.instance.hostname:
|
||||
result['instance']['hostname'] = self.instance.hostname
|
||||
|
||||
if CONF.add_addresses:
|
||||
else:
|
||||
ip = get_ip_address(self.instance.addresses)
|
||||
if ip is not None and len(ip) > 0:
|
||||
result['instance']['ip'] = ip
|
||||
|
@ -13,10 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
from mock import Mock
|
||||
from testtools import TestCase
|
||||
from trove.common import cfg
|
||||
from trove.instance.views import get_ip_address
|
||||
from trove.instance.views import filter_ips
|
||||
from trove.instance.views import InstanceView
|
||||
from trove.instance.views import InstanceDetailView
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
@ -68,3 +71,50 @@ class InstanceViewsTest(TestCase):
|
||||
self.assertTrue(len(ip) == 2)
|
||||
self.assertTrue('123.123.123.123' in ip)
|
||||
self.assertTrue('15.123.123.123' in ip)
|
||||
|
||||
|
||||
class InstanceDetailViewTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(InstanceDetailViewTest, self).setUp()
|
||||
self.build_links_method = InstanceView._build_links
|
||||
self.build_flavor_links_method = InstanceView._build_flavor_links
|
||||
InstanceView._build_links = Mock()
|
||||
InstanceView._build_flavor_links = Mock()
|
||||
self.instance = Mock()
|
||||
self.instance.created = 'Yesterday'
|
||||
self.instance.updated = 'Now'
|
||||
self.instance.datastore_version = Mock()
|
||||
self.instance.datastore_version.name = 'mysql_test_version'
|
||||
self.instance.hostname = 'test.trove.com'
|
||||
self.ip = "1.2.3.4"
|
||||
self.instance.addresses = {"private": [{"addr": self.ip}]}
|
||||
self.instance.volume_used = '3'
|
||||
self.instance.root_password = 'iloveyou'
|
||||
|
||||
def tearDown(self):
|
||||
super(InstanceDetailViewTest, self).tearDown()
|
||||
InstanceView._build_links = self.build_links_method
|
||||
InstanceView._build_flavor_links = self.build_flavor_links_method
|
||||
|
||||
def test_data_hostname(self):
|
||||
view = InstanceDetailView(self.instance, Mock())
|
||||
result = view.data()
|
||||
self.assertEqual(self.instance.created, result['instance']['created'])
|
||||
self.assertEqual(self.instance.updated, result['instance']['updated'])
|
||||
self.assertEqual(self.instance.datastore_version.name,
|
||||
result['instance']['datastore']['version'])
|
||||
self.assertEqual(self.instance.hostname,
|
||||
result['instance']['hostname'])
|
||||
self.assertNotIn('ip', result['instance'])
|
||||
|
||||
def test_data_ip(self):
|
||||
self.instance.hostname = None
|
||||
view = InstanceDetailView(self.instance, Mock())
|
||||
result = view.data()
|
||||
self.assertEqual(self.instance.created, result['instance']['created'])
|
||||
self.assertEqual(self.instance.updated, result['instance']['updated'])
|
||||
self.assertEqual(self.instance.datastore_version.name,
|
||||
result['instance']['datastore']['version'])
|
||||
self.assertNotIn('hostname', result['instance'])
|
||||
self.assertEqual([self.ip], result['instance']['ip'])
|
||||
|
Loading…
Reference in New Issue
Block a user