Exemplo n.º 1
0
 def test_HorizonHAProxyContext_no_cluster(self):
     self.relation_ids.return_value = []
     self.local_unit.return_value = 'openstack-dashboard/0'
     self.unit_get.return_value = "10.5.0.1"
     with patch_open() as (_open, _file):
         self.assertEquals(horizon_contexts.HorizonHAProxyContext()(),
                           {'units': {'openstack-dashboard-0': '10.5.0.1'},
                            'service_ports': {'dash_insecure': [80, 70],
                                              'dash_secure': [443, 433]},
                            'prefer_ipv6': False})
         _open.assert_called_with('/etc/default/haproxy', 'w')
         self.assertTrue(_file.write.called)
 def test_HorizonHAProxyContext_clustered(self):
     self.relation_ids.return_value = ['cluster:0']
     self.related_units.return_value = [
         'openstack-dashboard/1', 'openstack-dashboard/2'
     ]
     self.relation_get.side_effect = ['10.5.0.2', '10.5.0.3']
     self.local_unit.return_value = 'openstack-dashboard/0'
     self.get_relation_ip.return_value = "10.5.0.1"
     with patch_open() as (_open, _file):
         self.assertEqual(horizon_contexts.HorizonHAProxyContext()(),
                          {'units': {'openstack-dashboard-0': '10.5.0.1',
                                     'openstack-dashboard-1': '10.5.0.2',
                                     'openstack-dashboard-2': '10.5.0.3'},
                           'service_ports': {'dash_insecure': [80, 70],
                                             'dash_secure': [443, 433]},
                           'prefer_ipv6': False})
         _open.assert_called_with('/etc/default/haproxy', 'w')
         self.assertTrue(_file.write.called)
         self.get_relation_ip.assert_called_with('cluster')
    }),
    (APACHE_DEFAULT, {
        'hook_contexts': [horizon_contexts.ApacheContext()],
        'services': ['apache2', 'memcached'],
    }),
    (APACHE_24_DEFAULT, {
        'hook_contexts': [horizon_contexts.ApacheContext()],
        'services': ['apache2', 'memcached'],
    }),
    (PORTS_CONF, {
        'hook_contexts': [horizon_contexts.ApacheContext()],
        'services': ['apache2', 'memcached'],
    }),
    (HAPROXY_CONF, {
        'hook_contexts': [
            horizon_contexts.HorizonHAProxyContext(),
            context.HAProxyContext(singlenode_mode=True),
        ],
        'services': ['haproxy'],
    }),
    (ROUTER_SETTING, {
        'hook_contexts': [horizon_contexts.RouterSettingContext()],
        'services': ['apache2', 'memcached'],
    }),
    (KEYSTONEV3_POLICY, {
        'hook_contexts': [horizon_contexts.IdentityServiceContext()],
        'services': ['apache2', 'memcached'],
    }),
])