コード例 #1
0
    def test_NeutronAPIContext(self):
        self.relation_ids.return_value = ['neutron-api:12']
        self.related_units.return_value = ['neutron-api/0']
        settings = {'neutron-plugin': 'ovs',
                    'enable-sriov': 'False',
                    'enable-hardware-offload': 'False',
                    'neutron-security-groups': 'yes',
                    'neutron-url': 'http://neutron:9696'}

        def fake_rel_get(attribute=None, unit=None, rid=None):
            if attribute:
                return settings.get(attribute)

            return settings

        self.relation_get.side_effect = fake_rel_get
        ctxt = context.NeutronAPIContext()()
        expected = {'network_manager': 'neutron',
                    'neutron_plugin': 'ovs',
                    'neutron_security_groups': 'yes',
                    'neutron_url': 'http://neutron:9696'}
        self.assertEqual(ctxt, expected)

        settings['enable-sriov'] = 'True'
        expected['additional_neutron_filters'] = 'PciPassthroughFilter'
        ctxt = context.NeutronAPIContext()()
        self.assertEqual(ctxt, expected)

        settings['enable-sriov'] = 'False'
        settings['enable-hardware-offload'] = 'True'
        expected['additional_neutron_filters'] = 'PciPassthroughFilter'
        ctxt = context.NeutronAPIContext()()
        self.assertEqual(ctxt, expected)
コード例 #2
0
def neutron_settings():
    neutron_settings = {}
    if hookenv.is_relation_made('neutron-api', 'neutron-plugin'):
        neutron_api_info = nova_cc_context.NeutronAPIContext()()
        neutron_settings.update({
            # XXX: Rename these relations settings?
            'quantum_plugin': neutron_api_info['neutron_plugin'],
            'region': hookenv.config('region'),
            'quantum_security_groups':
            neutron_api_info['neutron_security_groups'],
            'quantum_url': neutron_api_info['neutron_url'],
        })
        neutron_url = urlparse(neutron_settings['quantum_url'])
        neutron_settings['quantum_host'] = neutron_url.hostname
        neutron_settings['quantum_port'] = neutron_url.port
    return neutron_settings