def test_ctxt_consistent_auths(self):
        self.socket.gethostname.return_value = 'testhost'
        mon_ctxt = context.MonContext()
        addresses = ['10.5.4.1', '10.5.4.2', '10.5.4.3']
        auths = ['cephx', 'cephx', 'cephx']

        def _relation_get(attr, unit, rid):
            if attr == 'ceph-public-address':
                return addresses.pop()
            elif attr == 'auth':
                return auths.pop()
        self.relation_get.side_effect = _relation_get
        self.relation_ids.return_value = ['mon:6']
        self.related_units.return_value = ['ceph/0', 'ceph/1', 'ceph/2']
        self.determine_api_port.return_value = 70
        expect = {
            'auth_supported': 'cephx',
            'hostname': 'testhost',
            'mon_hosts': '10.5.4.1 10.5.4.2 10.5.4.3',
            'old_auth': False,
            'unit_public_ip': '10.255.255.255',
            'use_syslog': 'false',
            'loglevel': 1,
            'port': 70,
            'client_radosgw_gateway': {'rgw init timeout': 60},
            'ipv6': False
        }
        self.assertEqual(expect, mon_ctxt())
 def test_ctxt_missing_data(self):
     self.socket.gethostname.return_value = 'testhost'
     mon_ctxt = context.MonContext()
     self.relation_get.return_value = None
     self.relation_ids.return_value = ['mon:6']
     self.related_units.return_value = ['ceph/0', 'ceph/1', 'ceph/2']
     self.assertEqual({}, mon_ctxt())
    def test_list_of_addresses_from_ceph_proxy(self, mock_ensure_rsv_v6):
        self.socket.gethostname.return_value = 'testhost'
        mon_ctxt = context.MonContext()
        addresses = ['10.5.4.1 10.5.4.2 10.5.4.3']
        self.cmp_pkgrevno.return_value = 1

        def _relation_get(attr, unit, rid):
            if attr == 'ceph-public-address':
                return addresses.pop()
            elif attr == 'auth':
                return 'cephx'
            elif attr == 'rgw.testhost_key':
                return 'testkey'
            elif attr == 'fsid':
                return 'testfsid'

        self.relation_get.side_effect = _relation_get
        self.relation_ids.return_value = ['mon:6']
        self.related_units.return_value = ['ceph-proxy/0']
        self.determine_api_port.return_value = 70
        expect = {
            'auth_supported': 'cephx',
            'hostname': 'testhost',
            'mon_hosts': '10.5.4.1 10.5.4.2 10.5.4.3',
            'old_auth': False,
            'systemd_rgw': True,
            'unit_public_ip': '10.255.255.255',
            'use_syslog': 'false',
            'loglevel': 1,
            'port': 70,
            'client_radosgw_gateway': {
                'rgw init timeout': 60
            },
            'ipv6': False,
            'rgw_zone': None,
            'fsid': 'testfsid',
        }
        self.assertEqual(expect, mon_ctxt())
        self.assertFalse(mock_ensure_rsv_v6.called)

        self.test_config.set('prefer-ipv6', True)
        addresses = ['10.5.4.1 10.5.4.2 10.5.4.3']
        expect['ipv6'] = True
        expect['port'] = "[::]:%s" % (70)
        self.assertEqual(expect, mon_ctxt())
        self.assertTrue(mock_ensure_rsv_v6.called)
    def test_ctxt(self, mock_ensure_rsv_v6):
        self.socket.gethostname.return_value = 'testhost'
        mon_ctxt = context.MonContext()
        addresses = ['10.5.4.1', '10.5.4.2', '10.5.4.3']

        def _relation_get(attr, unit, rid):
            if attr == 'ceph-public-address':
                return addresses.pop()
            elif attr == 'auth':
                return 'cephx'

        self.relation_get.side_effect = _relation_get
        self.relation_ids.return_value = ['mon:6']
        self.related_units.return_value = ['ceph/0', 'ceph/1', 'ceph/2']
        expect = {
            'auth_supported': 'cephx',
            'hostname': 'testhost',
            'mon_hosts': '10.5.4.1 10.5.4.2 10.5.4.3',
            'old_auth': False,
            'use_syslog': 'false',
            'loglevel': 1,
            'port': 70,
            'client_radosgw_gateway': {
                'rgw init timeout': 60
            },
            'ipv6': False
        }
        self.assertEqual(expect, mon_ctxt())
        self.assertFalse(mock_ensure_rsv_v6.called)

        self.test_config.set('prefer-ipv6', True)
        addresses = ['10.5.4.1', '10.5.4.2', '10.5.4.3']
        expect['ipv6'] = True
        expect['port'] = "[::]:%s" % (70)
        self.assertEqual(expect, mon_ctxt())
        self.assertTrue(mock_ensure_rsv_v6.called)
예제 #5
0
UNUSED_APACHE_SITE_FILES = ["/etc/apache2/sites-available/000-default.conf"]
APACHE_PORTS_FILE = "/etc/apache2/ports.conf"
APACHE_SITE_CONF = '/etc/apache2/sites-available/openstack_https_frontend'
APACHE_SITE_24_CONF = '/etc/apache2/sites-available/' \
    'openstack_https_frontend.conf'

BASE_RESOURCE_MAP = OrderedDict([
    (HAPROXY_CONF, {
        'contexts': [
            context.HAProxyContext(singlenode_mode=True),
            ceph_radosgw_context.HAProxyContext()
        ],
        'services': ['haproxy'],
    }),
    (CEPH_CONF, {
        'contexts': [ceph_radosgw_context.MonContext()],
        'services': [],
    }),
    (APACHE_SITE_CONF, {
        'contexts': [ceph_radosgw_context.ApacheSSLContext()],
        'services': ['apache2'],
    }),
    (APACHE_SITE_24_CONF, {
        'contexts': [ceph_radosgw_context.ApacheSSLContext()],
        'services': ['apache2'],
    }),
])


def listen_port():
    """Determine port to listen to.