278
CEPH_REL_WITH_PUBLIC_ADDR_PORT = {
281
'ceph-public-address': '192.168.1.10:1234',
282
'private-address': 'ceph_node1',
287
'ceph-public-address': '192.168.1.11:4321',
288
'private-address': 'ceph_node2',
295
CEPH_REL_WITH_PUBLIC_IPv6_ADDR = {
298
'ceph-public-address': '2001:5c0:9168::1',
299
'private-address': 'ceph_node1',
304
'ceph-public-address': '2001:5c0:9168::2',
305
'private-address': 'ceph_node2',
312
CEPH_REL_WITH_PUBLIC_IPv6_ADDR_PORT = {
315
'ceph-public-address': '[2001:5c0:9168::1]:1234',
316
'private-address': 'ceph_node1',
321
'ceph-public-address': '[2001:5c0:9168::2]:4321',
322
'private-address': 'ceph_node2',
329
CEPH_REL_WITH_MULTI_PUBLIC_ADDR = {
332
'ceph-public-address': '192.168.1.10 192.168.1.20',
333
'private-address': 'ceph_node1',
338
'ceph-public-address': '192.168.1.11 192.168.1.21',
339
'private-address': 'ceph_node2',
278
346
IDENTITY_RELATION_NO_CERT = {
279
347
'identity-service:0': {
1072
1140
amqp = context.AMQPContext()
1073
1141
self.assertRaises(context.OSContextError, amqp)
1075
def test_amqp_context_with_ipv6(self):
1143
@patch('charmhelpers.contrib.openstack.context.format_ipv6_addr')
1144
def test_amqp_context_with_ipv6(self, format_ipv6_addr):
1076
1145
'''Test amqp context with ipv6'''
1077
1146
relation_data = copy(AMQP_AA_RELATION)
1078
1147
relation = FakeRelation(relation_data=relation_data)
1079
1148
self.relation_get.side_effect = relation.get
1080
1149
self.relation_ids.side_effect = relation.relation_ids
1081
1150
self.related_units.side_effect = relation.relation_units
1082
self.format_ipv6_addr.return_value = '[2001:db8:1::1]'
1151
format_ipv6_addr.return_value = '[2001:db8:1::1]'
1083
1152
self.config.return_value = AMQP_CONFIG
1084
1153
amqp = context.AMQPContext()
1085
1154
result = amqp()
1251
1320
@patch('os.path.isdir')
1252
1321
@patch('os.mkdir')
1253
1322
@patch.object(context, 'ensure_packages')
1323
def test_ceph_context_with_public_addr_and_port(
1324
self, ensure_packages, mkdir, isdir, mock_config):
1325
'''Test ceph context in host with multiple networks with all
1327
isdir.return_value = False
1328
config_dict = {'use-syslog': True}
1330
def fake_config(key):
1331
return config_dict.get(key)
1333
mock_config.side_effect = fake_config
1334
relation = FakeRelation(relation_data=CEPH_REL_WITH_PUBLIC_ADDR_PORT)
1335
self.relation_get.side_effect = relation.get
1336
self.relation_ids.side_effect = relation.relation_ids
1337
self.related_units.side_effect = relation.relation_units
1338
ceph = context.CephContext()
1341
'mon_hosts': '192.168.1.10:1234 192.168.1.11:4321',
1344
'use_syslog': 'true',
1346
self.assertEquals(result, expected)
1347
ensure_packages.assert_called_with(['ceph-common'])
1348
mkdir.assert_called_with('/etc/ceph')
1350
@patch.object(context, 'config')
1351
@patch('os.path.isdir')
1353
@patch.object(context, 'ensure_packages')
1354
def test_ceph_context_with_public_ipv6_addr(self, ensure_packages, mkdir,
1355
isdir, mock_config):
1356
'''Test ceph context in host with multiple networks with all
1358
isdir.return_value = False
1359
config_dict = {'use-syslog': True}
1361
def fake_config(key):
1362
return config_dict.get(key)
1364
mock_config.side_effect = fake_config
1365
relation = FakeRelation(relation_data=CEPH_REL_WITH_PUBLIC_IPv6_ADDR)
1366
self.relation_get.side_effect = relation.get
1367
self.relation_ids.side_effect = relation.relation_ids
1368
self.related_units.side_effect = relation.relation_units
1369
ceph = context.CephContext()
1372
'mon_hosts': '[2001:5c0:9168::1] [2001:5c0:9168::2]',
1375
'use_syslog': 'true',
1377
self.assertEquals(result, expected)
1378
ensure_packages.assert_called_with(['ceph-common'])
1379
mkdir.assert_called_with('/etc/ceph')
1381
@patch.object(context, 'config')
1382
@patch('os.path.isdir')
1384
@patch.object(context, 'ensure_packages')
1385
def test_ceph_context_with_public_ipv6_addr_port(
1386
self, ensure_packages, mkdir, isdir, mock_config):
1387
'''Test ceph context in host with multiple networks with all
1389
isdir.return_value = False
1390
config_dict = {'use-syslog': True}
1392
def fake_config(key):
1393
return config_dict.get(key)
1395
mock_config.side_effect = fake_config
1396
relation = FakeRelation(
1397
relation_data=CEPH_REL_WITH_PUBLIC_IPv6_ADDR_PORT)
1398
self.relation_get.side_effect = relation.get
1399
self.relation_ids.side_effect = relation.relation_ids
1400
self.related_units.side_effect = relation.relation_units
1401
ceph = context.CephContext()
1404
'mon_hosts': '[2001:5c0:9168::1]:1234 [2001:5c0:9168::2]:4321',
1407
'use_syslog': 'true',
1409
self.assertEquals(result, expected)
1410
ensure_packages.assert_called_with(['ceph-common'])
1411
mkdir.assert_called_with('/etc/ceph')
1413
@patch.object(context, 'config')
1414
@patch('os.path.isdir')
1416
@patch.object(context, 'ensure_packages')
1417
def test_ceph_context_with_multi_public_addr(
1418
self, ensure_packages, mkdir, isdir, mock_config):
1419
'''Test ceph context in host with multiple networks with all
1421
isdir.return_value = False
1422
config_dict = {'use-syslog': True}
1424
def fake_config(key):
1425
return config_dict.get(key)
1427
mock_config.side_effect = fake_config
1428
relation = FakeRelation(relation_data=CEPH_REL_WITH_MULTI_PUBLIC_ADDR)
1429
self.relation_get.side_effect = relation.get
1430
self.relation_ids.side_effect = relation.relation_ids
1431
self.related_units.side_effect = relation.relation_units
1432
ceph = context.CephContext()
1435
'mon_hosts': '192.168.1.10 192.168.1.11 192.168.1.20 192.168.1.21',
1438
'use_syslog': 'true',
1440
self.assertEquals(result, expected)
1441
ensure_packages.assert_called_with(['ceph-common'])
1442
mkdir.assert_called_with('/etc/ceph')
1444
@patch.object(context, 'config')
1445
@patch('os.path.isdir')
1447
@patch.object(context, 'ensure_packages')
1254
1448
def test_ceph_context_with_rbd_cache(self, ensure_packages, mkdir, isdir,
1256
1450
isdir.return_value = False