diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 8ae9a066..63e5702e 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -197,6 +197,7 @@ class NeutronCCContext(context.NeutronContext): ctxt['dhcp_agents_per_network'] = config('dhcp-agents-per-network') ctxt['overlay_network_type'] = self.neutron_overlay_network_type ctxt['external_network'] = config('neutron-external-network') + release = os_release('neutron-server') if config('neutron-plugin') in ['vsp']: _config = config() for k, v in _config.iteritems(): @@ -206,7 +207,7 @@ class NeutronCCContext(context.NeutronContext): for unit in related_units(rid): rdata = relation_get(rid=rid, unit=unit) vsd_ip = rdata.get('vsd-ip-address') - if os_release('neutron-server') >= 'kilo': + if release >= 'kilo': cms_id_value = rdata.get('nuage-cms-id') log('relation data:cms_id required for' ' nuage plugin: {}'.format(cms_id_value)) @@ -254,6 +255,11 @@ class NeutronCCContext(context.NeutronContext): ctxt['enable_ml2_port_security'] = config('enable-ml2-port-security') ctxt['enable_sriov'] = config('enable-sriov') + if release == 'kilo' or release >= 'mitaka': + ctxt['enable_hyperv'] = True + else: + ctxt['enable_hyperv'] = False + return ctxt diff --git a/hooks/neutron_api_utils.py b/hooks/neutron_api_utils.py index 2a6c0cfb..ab8480e5 100755 --- a/hooks/neutron_api_utils.py +++ b/hooks/neutron_api_utils.py @@ -301,9 +301,14 @@ def determine_packages(source=None): 'neutron') packages.extend(pkgs) - if get_os_codename_install_source(source) >= 'kilo': + release = get_os_codename_install_source(source) + + if release >= 'kilo': packages.extend(KILO_PACKAGES) + if release == 'kilo' or release >= 'mitaka': + packages.append('python-networking-hyperv') + if config('neutron-plugin') == 'vsp': nuage_pkgs = config('nuage-packages').split() packages += nuage_pkgs @@ -315,7 +320,7 @@ def determine_packages(source=None): for p in GIT_PACKAGE_BLACKLIST: if p in packages: packages.remove(p) - if get_os_codename_install_source(source) >= 'kilo': + if release >= 'kilo': for p in GIT_PACKAGE_BLACKLIST_KILO: packages.remove(p) diff --git a/templates/kilo/ml2_conf.ini b/templates/kilo/ml2_conf.ini index 5589ffb5..5265b950 100644 --- a/templates/kilo/ml2_conf.ini +++ b/templates/kilo/ml2_conf.ini @@ -16,6 +16,8 @@ type_drivers = {{ overlay_network_type }},vlan,flat,local tenant_network_types = {{ overlay_network_type }},vlan,flat,local {% if enable_sriov %} mechanism_drivers = openvswitch,l2population,sriovnicswitch +{% elif enable_hyperv %} +mechanism_drivers = openvswitch,hyperv,l2population {% else %} mechanism_drivers = openvswitch,l2population {% endif %} diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 30cfb90d..5fcb8af3 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -586,13 +586,14 @@ class NeutronAPIBasicDeployment(OpenStackAmuletDeployment): } } - if self._get_openstack_release() >= self.trusty_kilo: - # Kilo or later + if (self._get_openstack_release() in + [self.trusty_liberty, self.wily_liberty]): + # Liberty expected['ml2'].update({ 'mechanism_drivers': 'openvswitch,l2population' }) else: - # Juno or earlier + # Earlier or later than Liberty expected['ml2'].update({ 'mechanism_drivers': 'openvswitch,hyperv,l2population' }) diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index bb32f772..77cdec02 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -339,7 +339,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_vip': 10, 'vlan_ranges': 'physnet1:1000:2000', 'vni_ranges': '1001:2000', - 'enable_ml2_port_security': True + 'enable_ml2_port_security': True, + 'enable_hyperv': False } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): @@ -378,7 +379,8 @@ class NeutronCCContextTest(CharmTestCase): 'vlan_ranges': 'physnet1:1000:2000', 'vni_ranges': '1001:2000,3001:4000', 'network_providers': 'physnet2,physnet3', - 'enable_ml2_port_security': True + 'enable_ml2_port_security': True, + 'enable_hyperv': False } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): @@ -420,7 +422,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_vip': 10, 'vlan_ranges': 'physnet1:1000:2000', 'vni_ranges': '1001:2000', - 'enable_ml2_port_security': True + 'enable_ml2_port_security': True, + 'enable_hyperv': False } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): @@ -456,7 +459,8 @@ class NeutronCCContextTest(CharmTestCase): 'quota_vip': 10, 'vlan_ranges': 'physnet1:1000:2000', 'vni_ranges': '1001:2000', - 'enable_ml2_port_security': True + 'enable_ml2_port_security': True, + 'enable_hyperv': False } napi_ctxt = context.NeutronCCContext() with patch.object(napi_ctxt, '_ensure_packages'): diff --git a/unit_tests/test_neutron_api_utils.py b/unit_tests/test_neutron_api_utils.py index 4eadd0eb..beadda59 100644 --- a/unit_tests/test_neutron_api_utils.py +++ b/unit_tests/test_neutron_api_utils.py @@ -145,7 +145,8 @@ class TestNeutronAPIUtils(CharmTestCase): self.get_os_codename_install_source.return_value = 'kilo' pkg_list = nutils.determine_packages() expect = deepcopy(nutils.BASE_PACKAGES) - expect.extend(['neutron-server', 'neutron-plugin-ml2']) + expect.extend(['neutron-server', 'neutron-plugin-ml2', + 'python-networking-hyperv']) expect.extend(nutils.KILO_PACKAGES) self.assertItemsEqual(pkg_list, expect)