예제 #1
0
 def test_instance_console_context_no_https(self, mock_resolve_address,
                                            mock_os_path_exists,
                                            mock_ch_cluster):
     mock_os_path_exists.return_value = True
     mock_resolve_address.return_value = "10.20.30.40"
     mock_ch_cluster.https.return_value = False
     ctxt = context.InstanceConsoleContext()()
     self.assertEqual(ctxt, {})
 def check_instance_console_context_with_memcache(self, os_release, ip,
                                                  formated_ip):
     memcached_servers = [{'private-address': formated_ip, 'port': '11211'}]
     self.relation_ids.return_value = ['cache:0']
     self.relations_for_id.return_value = memcached_servers
     self.related_units.return_value = 'memcached/0'
     instance_console = context.InstanceConsoleContext()
     os_release.return_value = 'icehouse'
     self.maxDiff = None
     self.assertEqual({'memcached_servers': "%s:11211" % (formated_ip, )},
                      instance_console())
예제 #3
0
 def test_instance_console_context(self, mock_resolve_address,
                                   mock_os_path_exists, mock_ch_cluster):
     mock_os_path_exists.return_value = True
     mock_resolve_address.return_value = "10.20.30.40"
     mock_ch_cluster.https.return_value = True
     ctxt = context.InstanceConsoleContext()()
     self.assertEqual(
         ctxt, {
             'ssl_cert': '/etc/apache2/ssl/nova/cert_10.20.30.40',
             'ssl_key': '/etc/apache2/ssl/nova/key_10.20.30.40'
         })
     mock_resolve_address.assert_called_once_with(
         endpoint_type=context.ch_ip.PUBLIC)
 def test_instance_console_context_without_memcache(self, os_release, log_):
     self.relation_ids.return_value = 'cache:0'
     self.related_units.return_value = 'memcached/0'
     instance_console = context.InstanceConsoleContext()
     os_release.return_value = 'icehouse'
     self.assertEqual({'memcached_servers': ''}, instance_console())