本文整理汇总了Python中charmhelpers.contrib.openstack.context.AMQPContext方法的典型用法代码示例。如果您正苦于以下问题:Python context.AMQPContext方法的具体用法?Python context.AMQPContext怎么用?Python context.AMQPContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.openstack.context
的用法示例。
在下文中一共展示了context.AMQPContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_amqp_context_with_data_altname
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_data_altname(self):
'''Test amqp context with alternative relation name'''
relation = FakeRelation(relation_data=AMQP_RELATION)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_NOVA_CONFIG
amqp = context.AMQPContext(
rel_name='amqp-nova',
relation_prefix='nova')
result = amqp()
expected = {
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbitmq_virtual_host': 'foo',
'transport_url': 'rabbit://adam:[email protected]:5672/foo'
}
self.assertEquals(result, expected)
示例2: test_amqp_context_with_data_ssl
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_data_ssl(self, _open):
'''Test amqp context with all required data and ssl'''
relation = FakeRelation(relation_data=AMQP_RELATION_WITH_SSL)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_CONFIG
ssl_dir = '/etc/sslamqp'
amqp = context.AMQPContext(ssl_dir=ssl_dir)
result = amqp()
expected = {
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbit_ssl_port': 5671,
'rabbitmq_virtual_host': 'foo',
'rabbit_ssl_ca': ssl_dir + '/rabbit-client-ca.pem',
'rabbitmq_ha_queues': True,
'transport_url': 'rabbit://adam:[email protected]:5671/foo'
}
_open.assert_called_once_with(ssl_dir + '/rabbit-client-ca.pem', 'wb')
self.assertEquals(result, expected)
self.assertEquals([call(AMQP_RELATION_WITH_SSL['ssl_ca'])],
self.b64decode.call_args_list)
示例3: test_amqp_context_with_data_ssl_noca
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_data_ssl_noca(self):
'''Test amqp context with all required data with ssl but missing ca'''
relation = FakeRelation(relation_data=AMQP_RELATION_WITH_SSL)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_CONFIG
amqp = context.AMQPContext()
result = amqp()
expected = {
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbit_ssl_port': 5671,
'rabbitmq_virtual_host': 'foo',
'rabbit_ssl_ca': 'cert',
'rabbitmq_ha_queues': True,
'transport_url': 'rabbit://adam:[email protected]:5671/foo'
}
self.assertEquals(result, expected)
示例4: test_amqp_context_with_data_clustered
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_data_clustered(self):
'''Test amqp context with all required data with clustered rabbit'''
relation_data = copy(AMQP_RELATION)
relation_data['clustered'] = 'yes'
relation = FakeRelation(relation_data=relation_data)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_CONFIG
amqp = context.AMQPContext()
result = amqp()
expected = {
'clustered': True,
'rabbitmq_host': relation_data['vip'],
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbitmq_virtual_host': 'foo',
'transport_url': 'rabbit://adam:[email protected]:5672/foo'
}
self.assertEquals(result, expected)
示例5: test_amqp_context_with_ipv6
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_ipv6(self, format_ipv6_addr):
'''Test amqp context with ipv6'''
relation_data = copy(AMQP_AA_RELATION)
relation = FakeRelation(relation_data=relation_data)
self.relation_get.side_effect = relation.get
self.relation_ids.side_effect = relation.relation_ids
self.related_units.side_effect = relation.relation_units
format_ipv6_addr.return_value = '[2001:db8:1::1]'
self.config.return_value = AMQP_CONFIG
amqp = context.AMQPContext()
result = amqp()
expected = {
'rabbitmq_host': '[2001:db8:1::1]',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbitmq_virtual_host': 'foo',
'rabbitmq_hosts': '[2001:db8:1::1],[2001:db8:1::1]',
'transport_url': ('rabbit://adam:[email protected][2001:db8:1::1]:5672'
',adam:[email protected][2001:db8:1::1]:5672/foo')
}
self.assertEquals(result, expected)
示例6: test_amqp_context_with_oslo_messaging
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_oslo_messaging(self):
"""Test amqp context with oslo-messaging-flags option"""
relation = FakeRelation(relation_data=AMQP_RELATION)
self.relation_get.side_effect = relation.get
AMQP_OSLO_CONFIG.update(AMQP_CONFIG)
self.config.return_value = AMQP_OSLO_CONFIG
amqp = context.AMQPContext()
result = amqp()
expected = {
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbitmq_virtual_host': 'foo',
'oslo_messaging_flags': {
'rabbit_max_retries': '1',
'rabbit_retry_backoff': '1',
'rabbit_retry_interval': '1'
},
'transport_url': 'rabbit://adam:[email protected]:5672/foo'
}
self.assertEquals(result, expected)
示例7: is_cellv2_init_ready
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def is_cellv2_init_ready():
"""Determine if we're ready to initialize the cell v2 databases
Cells v2 init requires transport_url and database connections to be set
in nova.conf.
"""
amqp = context.AMQPContext()
shared_db = nova_cc_context.NovaCellV2SharedDBContext()
if (CompareOpenStackReleases(os_release('nova-common')) >= 'ocata' and
amqp() and shared_db()):
return True
log("OpenStack release, database, or rabbitmq not ready for Cells V2",
level=DEBUG)
return False
示例8: test_amqp_context_with_data
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_data(self):
'''Test amqp context with all required data'''
relation = FakeRelation(relation_data=AMQP_RELATION)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_CONFIG
amqp = context.AMQPContext()
result = amqp()
expected = {
'rabbitmq_host': 'rabbithost',
'rabbitmq_password': 'foobar',
'rabbitmq_user': 'adam',
'rabbitmq_virtual_host': 'foo',
'transport_url': 'rabbit://adam:[email protected]:5672/foo'
}
self.assertEquals(result, expected)
示例9: test_amqp_context_with_missing_relation
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_missing_relation(self):
'''Test amqp context missing relation data'''
incomplete_relation = copy(AMQP_RELATION)
incomplete_relation['password'] = ''
relation = FakeRelation(relation_data=incomplete_relation)
self.relation_get.side_effect = relation.get
self.config.return_value = AMQP_CONFIG
amqp = context.AMQPContext()
result = amqp()
self.assertEquals({}, result)
示例10: test_amqp_context_with_missing_config
# 需要导入模块: from charmhelpers.contrib.openstack import context [as 别名]
# 或者: from charmhelpers.contrib.openstack.context import AMQPContext [as 别名]
def test_amqp_context_with_missing_config(self):
'''Test amqp context missing relation data'''
incomplete_config = copy(AMQP_CONFIG)
del incomplete_config['rabbit-user']
relation = FakeRelation(relation_data=AMQP_RELATION)
self.relation_get.side_effect = relation.get
self.config.return_value = incomplete_config
amqp = context.AMQPContext()
self.assertRaises(context.OSContextError, amqp)