From 1bde22f5bdf3428c23cd4aa3bf22c98717f053f2 Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Tue, 15 Apr 2014 00:15:31 +0000 Subject: [PATCH 1/7] Adding Support for Cisco Nexus 1000v --- config.yaml | 7 ++++ hooks/quantum_contexts.py | 14 ++++++-- hooks/quantum_hooks.py | 14 ++++++++ hooks/quantum_utils.py | 56 +++++++++++++++++++++++++++--- templates/havana/cisco_plugins.ini | 44 +++++++++++++++++++++++ templates/havana/dhcp_agent.ini | 13 ++++++- templates/havana/l3_agent.ini | 11 +++++- 7 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 templates/havana/cisco_plugins.ini diff --git a/config.yaml b/config.yaml index 63011664..0f83be5a 100644 --- a/config.yaml +++ b/config.yaml @@ -8,6 +8,7 @@ options: . ovs - OpenVSwitch nvp - Nicira NVP + n1kv - Cisco N1kv ext-port: type: string description: | @@ -62,3 +63,9 @@ options: within the cloud. This is useful in deployments where its not possible to increase MTU on switches and physical servers to accomodate the packet overhead of using GRE tunnels. + l3-agent: + type: string + default: enable + description: | + Optional configuration to support use of linux router + Note that this is used only for Cisco n1kv plugin. diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index 42766388..b627cbe7 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -38,10 +38,14 @@ QUANTUM_OVS_PLUGIN = \ "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" QUANTUM_NVP_PLUGIN = \ "quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2" +QUANTUM_N1KV_PLUGIN = \ + "quantum.plugins.cisco.n1kv.n1kv_quantum_plugin.N1kvQuantumPluginV2" NEUTRON_OVS_PLUGIN = \ "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2" NEUTRON_NVP_PLUGIN = \ "neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2" +NEUTRON_N1KV_PLUGIN = \ + "neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2" NEUTRON = 'neutron' QUANTUM = 'quantum' @@ -55,15 +59,18 @@ def networking_name(): OVS = 'ovs' NVP = 'nvp' +N1KV = 'n1kv' CORE_PLUGIN = { QUANTUM: { OVS: QUANTUM_OVS_PLUGIN, - NVP: QUANTUM_NVP_PLUGIN + NVP: QUANTUM_NVP_PLUGIN, + N1KV: QUANTUM_N1KV_PLUGIN }, NEUTRON: { OVS: NEUTRON_OVS_PLUGIN, - NVP: NEUTRON_NVP_PLUGIN + NVP: NEUTRON_NVP_PLUGIN, + N1KV: NEUTRON_N1KV_PLUGIN }, } @@ -121,6 +128,9 @@ class L3AgentContext(OSContextGenerator): if config('external-network-id'): ctxt['ext_net_id'] = config('external-network-id') + + if config('plugin'): + ctxt['plugin'] = config('plugin') return ctxt diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index df47e6c4..05c523e9 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -19,6 +19,9 @@ from charmhelpers.fetch import ( from charmhelpers.core.host import ( restart_on_change, lsb_release, + service_start, + service_stop, + service_running, ) from charmhelpers.contrib.hahelpers.cluster import( eligible_leader @@ -84,6 +87,13 @@ def config_changed(): else: log('Please provide a valid plugin config', level=ERROR) sys.exit(1) + if config('plugin') == 'n1kv': + if config('l3-agent') == 'enable': + if not service_running('neutron-l3-agent'): + service_start('neutron-l3-agent') + else: + if service_running('neutron-l3-agent'): + service_stop('neutron-l3-agent') @hooks.hook('upgrade-charm') @@ -138,6 +148,10 @@ def cluster_departed(): log('Unable to re-assign agent resources for failed nodes with nvp', level=WARNING) return + if config('plugin') == 'n1kv': + log('Unable to re-assign agent resources for failed nodes with n1kv', + level=WARNING) + return if eligible_leader(None): reassign_agent_resources() CONFIGS.write_all() diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 7e500c0f..aeb84d64 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -31,7 +31,7 @@ from charmhelpers.contrib.openstack.context import ( import charmhelpers.contrib.openstack.templating as templating from charmhelpers.contrib.openstack.neutron import headers_package from quantum_contexts import ( - CORE_PLUGIN, OVS, NVP, + CORE_PLUGIN, OVS, NVP, N1KV, NEUTRON, QUANTUM, networking_name, QuantumGatewayContext, @@ -49,18 +49,24 @@ QUANTUM_OVS_PLUGIN_CONF = \ "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini" QUANTUM_NVP_PLUGIN_CONF = \ "/etc/quantum/plugins/nicira/nvp.ini" +QUANTUM_N1KV_PLUGIN_CONF = \ + "/etc/quantum/plugins/cisco/cisco_plugins.ini" QUANTUM_PLUGIN_CONF = { OVS: QUANTUM_OVS_PLUGIN_CONF, - NVP: QUANTUM_NVP_PLUGIN_CONF + NVP: QUANTUM_NVP_PLUGIN_CONF, + N1KV: QUANTUM_N1KV_PLUGIN_CONF } NEUTRON_OVS_PLUGIN_CONF = \ "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini" NEUTRON_NVP_PLUGIN_CONF = \ "/etc/neutron/plugins/nicira/nvp.ini" +NEUTRON_N1KV_PLUGIN_CONF = \ + "/etc/neutron/plugins/cisco/cisco_plugins.ini" NEUTRON_PLUGIN_CONF = { OVS: NEUTRON_OVS_PLUGIN_CONF, - NVP: NEUTRON_NVP_PLUGIN_CONF + NVP: NEUTRON_NVP_PLUGIN_CONF, + N1KV: NEUTRON_N1KV_PLUGIN_CONF } QUANTUM_GATEWAY_PKGS = { @@ -76,6 +82,15 @@ QUANTUM_GATEWAY_PKGS = { "quantum-dhcp-agent", 'python-mysqldb', "nova-api-metadata" + ], + N1KV: [ + "neutron-plugin-cisco", + "openvswitch-switch", + "neutron-dhcp-agent", + "python-mysqldb", + "nova-api-metadata", + "neutron-common", + "quantum-l3-agent" ] } @@ -94,6 +109,14 @@ NEUTRON_GATEWAY_PKGS = { 'python-mysqldb', 'python-oslo.config', # Force upgrade "nova-api-metadata" + ], + N1KV: [ + "neutron-plugin-cisco", + "neutron-dhcp-agent", + "python-mysqldb", + "nova-api-metadata", + "neutron-common", + "neutron-l3-agent" ] } @@ -104,7 +127,8 @@ GATEWAY_PKGS = { EARLY_PACKAGES = { OVS: ['openvswitch-datapath-dkms'], - NVP: [] + NVP: [], + N1KV: [] } @@ -260,14 +284,38 @@ NEUTRON_NVP_CONFIG_FILES = { } NEUTRON_NVP_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) +QUANTUM_N1KV_CONFIG_FILES = { + QUANTUM_CONF: { + 'hook_contexts': [context.AMQPContext()], + 'services': ['quantum-dhcp-agent', 'quantum-metadata-agent'] + }, +} +QUANTUM_N1KV_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) + +NEUTRON_N1KV_CONFIG_FILES = { + NEUTRON_CONF: { + 'hook_contexts': [context.AMQPContext()], + 'services': ['neutron-dhcp-agent', + 'neutron-metadata-agent'] + }, + NEUTRON_L3_AGENT_CONF: { + 'hook_contexts': [NetworkServiceContext(), + L3AgentContext()], + 'services': ['neutron-l3-agent'] + }, +} +NEUTRON_N1KV_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) + CONFIG_FILES = { QUANTUM: { NVP: QUANTUM_NVP_CONFIG_FILES, OVS: QUANTUM_OVS_CONFIG_FILES, + N1KV: QUANTUM_N1KV_CONFIG_FILES, }, NEUTRON: { NVP: NEUTRON_NVP_CONFIG_FILES, OVS: NEUTRON_OVS_CONFIG_FILES, + N1KV: NEUTRON_N1KV_CONFIG_FILES, }, } diff --git a/templates/havana/cisco_plugins.ini b/templates/havana/cisco_plugins.ini new file mode 100644 index 00000000..12852268 --- /dev/null +++ b/templates/havana/cisco_plugins.ini @@ -0,0 +1,44 @@ +[CISCO_PLUGINS] +vswitch_plugin=neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2 + +[database] +{% if database_host -%} +connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }} +{% else -%} +connection = sqlite:////var/lib/neutron/neutron.sqlite +{% endif -%} +#sql_connection = mysql://quantum:quantum_pass@127.0.0.1/quantum?charset=utf8 +# Replace 127.0.0.1 above with the IP address of the database used by the +# main quantum server. (Leave it as is if the database runs on this host.) +#sql_connection=engine://user:pass@host/db_name +#mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }} +#mysql://{{ quantum_user }}:{{ quantum_password }}@{{ database_host }}/{{ quantum_db }}?charset=utf8 +#reconnect_interval = 2 + +[N1KV: {{ vsm_ip }} ] +username= {{ vsm_username }} +password= {{ vsm_password }} + +[cisco_n1kv] +integration_bridge=br-int +#enable_tunneling=True +tunnel_bridge=br-int +local_ip= {{ local_ip }} +tenant_network_type=local +#bridge_mappings= +#vxlan_id_ranges=5000:60000 +#network_vlan_ranges=vlan:1:4095 +# IMPORTANT: Comment out the following two lines for production deployments +default_policy_profile=havana_pp +network_node_policy_profile = dhcp_pp +poll_duration = 10 + +#[CISCO_TEST] +#host=testhost + +#[DRIVER] +#name=quantum.plugins.cisco.tests.unit.v2.nexus.fake_nexus_driver.CiscoNEXUSFakeDriver + +#[AGENT] +#polling_interval = 10 +#root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf diff --git a/templates/havana/dhcp_agent.ini b/templates/havana/dhcp_agent.ini index 6d76fac1..be88223e 100644 --- a/templates/havana/dhcp_agent.ini +++ b/templates/havana/dhcp_agent.ini @@ -7,7 +7,7 @@ state_path = /var/lib/neutron interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf -ovs_use_veth = True + {% if instance_mtu -%} dnsmasq_config_file = /etc/neutron/dnsmasq.conf {% endif %} @@ -15,3 +15,14 @@ dnsmasq_config_file = /etc/neutron/dnsmasq.conf enable_metadata_network = True enable_isolated_metadata = True {% endif %} + +{% if plugin == 'n1kv' %} +enable_metadata_network = True +enable_isolated_metadata = True +debug = False +resync_interval = 30 +use_namespaces = True +dhcp_lease_time=3600 +{% else %} +ovs_use_veth = True +{% endif %} diff --git a/templates/havana/l3_agent.ini b/templates/havana/l3_agent.ini index 44a1970c..1fa8ab3b 100644 --- a/templates/havana/l3_agent.ini +++ b/templates/havana/l3_agent.ini @@ -6,8 +6,17 @@ admin_tenant_name = {{ service_tenant }} admin_user = {{ service_username }} admin_password = {{ service_password }} root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf -ovs_use_veth = True handle_internal_only_routers = {{ handle_internal_only_router }} +{% if plugin == 'n1kv' %} +l3_agent_manager = neutron.agent.l3_agent.L3NATAgentWithStateReport +external_network_bridge = br-int +ovs_use_veth = False +use_namespaces = True +debug = True +verbose = True +{% else %} +ovs_use_veth = True +{% endif %} {% if ext_net_id %} gateway_external_network_id = {{ ext_net_id }} {% endif %} From 5248b66103a6b72a034672fc17902caedddd4dcd Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Thu, 24 Apr 2014 01:05:22 +0000 Subject: [PATCH 2/7] Making changes for use_syslog parameter for Cisco n1kv --- hooks/quantum_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index aeb84d64..41f93106 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -294,7 +294,8 @@ QUANTUM_N1KV_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) NEUTRON_N1KV_CONFIG_FILES = { NEUTRON_CONF: { - 'hook_contexts': [context.AMQPContext()], + 'hook_contexts': [context.AMQPContext(), + SyslogContext()], 'services': ['neutron-dhcp-agent', 'neutron-metadata-agent'] }, From b861dea3be68f4685e8ced56b5cb4a0ec1781767 Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Fri, 2 May 2014 19:42:14 +0000 Subject: [PATCH 3/7] l3-agent config parameter changed to boolean --- config.yaml | 6 +++--- hooks/quantum_hooks.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.yaml b/config.yaml index fe624ab2..5732c153 100644 --- a/config.yaml +++ b/config.yaml @@ -71,9 +71,9 @@ options: within the cloud. This is useful in deployments where its not possible to increase MTU on switches and physical servers to accomodate the packet overhead of using GRE tunnels. - l3-agent: - type: string - default: enable + enable-l3-agent: + type: boolean + default: True description: | Optional configuration to support use of linux router Note that this is used only for Cisco n1kv plugin. diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index ffe1daee..a2ffc61a 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -93,7 +93,7 @@ def config_changed(): log('Please provide a valid plugin config', level=ERROR) sys.exit(1) if config('plugin') == 'n1kv': - if config('l3-agent') == 'enable': + if config('enable-l3-agent'): if not service_running('neutron-l3-agent'): service_start('neutron-l3-agent') else: From d8cb89f07f9c407c28ddf7d81bc51da1b9c7f29d Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Wed, 21 May 2014 13:59:28 -0700 Subject: [PATCH 4/7] Removing < havana changes for N1kV --- hooks/quantum_contexts.py | 3 --- hooks/quantum_utils.py | 27 ++------------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index aa5ff896..0cec436f 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -38,8 +38,6 @@ QUANTUM_OVS_PLUGIN = \ "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" QUANTUM_NVP_PLUGIN = \ "quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2" -QUANTUM_N1KV_PLUGIN = \ - "quantum.plugins.cisco.n1kv.n1kv_quantum_plugin.N1kvQuantumPluginV2" NEUTRON_OVS_PLUGIN = \ "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2" NEUTRON_ML2_PLUGIN = \ @@ -67,7 +65,6 @@ CORE_PLUGIN = { QUANTUM: { OVS: QUANTUM_OVS_PLUGIN, NVP: QUANTUM_NVP_PLUGIN, - N1KV: QUANTUM_N1KV_PLUGIN }, NEUTRON: { OVS: NEUTRON_OVS_PLUGIN, diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 0b0bf1eb..f1a3d525 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -58,12 +58,9 @@ QUANTUM_OVS_PLUGIN_CONF = \ "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini" QUANTUM_NVP_PLUGIN_CONF = \ "/etc/quantum/plugins/nicira/nvp.ini" -QUANTUM_N1KV_PLUGIN_CONF = \ - "/etc/quantum/plugins/cisco/cisco_plugins.ini" QUANTUM_PLUGIN_CONF = { OVS: QUANTUM_OVS_PLUGIN_CONF, NVP: QUANTUM_NVP_PLUGIN_CONF, - N1KV: QUANTUM_N1KV_PLUGIN_CONF } NEUTRON_CONF_DIR = '/etc/neutron' @@ -97,16 +94,6 @@ QUANTUM_GATEWAY_PKGS = { 'python-mysqldb', 'python-psycopg2', "nova-api-metadata" - ], - N1KV: [ - "neutron-plugin-cisco", - "openvswitch-switch", - "neutron-dhcp-agent", - "python-mysqldb", - "python-psycopg2", - "nova-api-metadata", - "neutron-common", - "quantum-l3-agent" ] } @@ -343,22 +330,13 @@ NEUTRON_NVP_CONFIG_FILES = { } NEUTRON_NVP_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) -QUANTUM_N1KV_CONFIG_FILES = { - QUANTUM_CONF: { - 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), - QuantumGatewayContext(), - SyslogContext()], - 'services': ['quantum-dhcp-agent', 'quantum-metadata-agent'] - }, -} -QUANTUM_N1KV_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) - NEUTRON_N1KV_CONFIG_FILES = { NEUTRON_CONF: { 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), QuantumGatewayContext(), SyslogContext()], - 'services': ['neutron-dhcp-agent', + 'services': ['neutron-l3-agent', + 'neutron-dhcp-agent', 'neutron-metadata-agent'] }, NEUTRON_L3_AGENT_CONF: { @@ -374,7 +352,6 @@ CONFIG_FILES = { QUANTUM: { NVP: QUANTUM_NVP_CONFIG_FILES, OVS: QUANTUM_OVS_CONFIG_FILES, - N1KV: QUANTUM_N1KV_CONFIG_FILES, }, NEUTRON: { NVP: NEUTRON_NVP_CONFIG_FILES, From 40eef70f2321fa6c6038ff8423b62028b9f74936 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 17 Jun 2014 10:55:40 +0100 Subject: [PATCH 5/7] Cherry pick nsx fixes from next --- config.yaml | 2 +- hooks/quantum_contexts.py | 21 +++++++++++++++++--- hooks/quantum_hooks.py | 5 +++-- hooks/quantum_utils.py | 26 ++++++++++++++++++------- templates/havana/dhcp_agent.ini | 2 +- unit_tests/test_quantum_contexts.py | 30 +++++++++++++++++++++++++++-- unit_tests/test_quantum_utils.py | 23 +++++++++++++++++++++- 7 files changed, 92 insertions(+), 17 deletions(-) diff --git a/config.yaml b/config.yaml index 814aa1ec..1c542d2a 100644 --- a/config.yaml +++ b/config.yaml @@ -7,7 +7,7 @@ options: Supported values include: . ovs - OpenVSwitch - nvp - Nicira NVP + nvp|nsx - Nicira NVP/VMware NSX ext-port: type: string description: | diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index 5aa472fd..c8b635aa 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -44,6 +44,8 @@ NEUTRON_ML2_PLUGIN = \ "neutron.plugins.ml2.plugin.Ml2Plugin" NEUTRON_NVP_PLUGIN = \ "neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2" +NEUTRON_NSX_PLUGIN = "vmware" + NEUTRON = 'neutron' QUANTUM = 'quantum' @@ -57,6 +59,7 @@ def networking_name(): OVS = 'ovs' NVP = 'nvp' +NSX = 'nsx' CORE_PLUGIN = { QUANTUM: { @@ -65,18 +68,30 @@ CORE_PLUGIN = { }, NEUTRON: { OVS: NEUTRON_OVS_PLUGIN, - NVP: NEUTRON_NVP_PLUGIN + NVP: NEUTRON_NVP_PLUGIN, + NSX: NEUTRON_NSX_PLUGIN }, } +def remap_plugin(plugin): + ''' Remaps plugin name for renames/switches in packaging ''' + release = get_os_codename_install_source(config('openstack-origin')) + if plugin == 'nvp' and release >= 'icehouse': + plugin = 'nsx' + elif plugin == 'nsx' and release < 'icehouse': + plugin = 'nvp' + return plugin + + def core_plugin(): + plugin = remap_plugin(config('plugin')) if (get_os_codename_install_source(config('openstack-origin')) >= 'icehouse' - and config('plugin') == OVS): + and plugin == OVS): return NEUTRON_ML2_PLUGIN else: - return CORE_PLUGIN[networking_name()][config('plugin')] + return CORE_PLUGIN[networking_name()][plugin] class NetworkServiceContext(OSContextGenerator): diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index 8d0cac66..a7496802 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -161,8 +161,9 @@ def nm_changed(): @hooks.hook("cluster-relation-departed") @restart_on_change(restart_map()) def cluster_departed(): - if config('plugin') == 'nvp': - log('Unable to re-assign agent resources for failed nodes with nvp', + if config('plugin') in ['nvp', 'nsx']: + log('Unable to re-assign agent resources for' + ' failed nodes with nvp|nsx', level=WARNING) return if eligible_leader(None): diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 0da00f79..a70c224e 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -37,13 +37,14 @@ from charmhelpers.contrib.openstack.context import ( import charmhelpers.contrib.openstack.templating as templating from charmhelpers.contrib.openstack.neutron import headers_package from quantum_contexts import ( - CORE_PLUGIN, OVS, NVP, + CORE_PLUGIN, OVS, NVP, NSX, NEUTRON, QUANTUM, networking_name, QuantumGatewayContext, NetworkServiceContext, L3AgentContext, ExternalPortContext, + remap_plugin ) from copy import deepcopy @@ -71,9 +72,13 @@ NEUTRON_ML2_PLUGIN_CONF = \ "/etc/neutron/plugins/ml2/ml2_conf.ini" NEUTRON_NVP_PLUGIN_CONF = \ "/etc/neutron/plugins/nicira/nvp.ini" +NEUTRON_NSX_PLUGIN_CONF = \ + "/etc/neutron/plugins/vmware/nsx.ini" + NEUTRON_PLUGIN_CONF = { OVS: NEUTRON_OVS_PLUGIN_CONF, - NVP: NEUTRON_NVP_PLUGIN_CONF + NVP: NEUTRON_NVP_PLUGIN_CONF, + NSX: NEUTRON_NSX_PLUGIN_CONF, } QUANTUM_GATEWAY_PKGS = { @@ -116,6 +121,7 @@ NEUTRON_GATEWAY_PKGS = { "nova-api-metadata" ] } +NEUTRON_GATEWAY_PKGS[NSX] = NEUTRON_GATEWAY_PKGS[NVP] GATEWAY_PKGS = { QUANTUM: QUANTUM_GATEWAY_PKGS, @@ -138,9 +144,10 @@ def get_early_packages(): def get_packages(): '''Return a list of packages for install based on the configured plugin''' - packages = deepcopy(GATEWAY_PKGS[networking_name()][config('plugin')]) + plugin = remap_plugin(config('plugin')) + packages = deepcopy(GATEWAY_PKGS[networking_name()][plugin]) if (get_os_codename_install_source(config('openstack-origin')) - >= 'icehouse' and config('plugin') == 'ovs'): + >= 'icehouse' and plugin == 'ovs'): # NOTE(jamespage) neutron-vpn-agent supercedes l3-agent for icehouse packages.remove('neutron-l3-agent') packages.append('neutron-vpn-agent') @@ -298,7 +305,9 @@ NEUTRON_OVS_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) QUANTUM_NVP_CONFIG_FILES = { QUANTUM_CONF: { - 'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR)], + 'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR), + QuantumGatewayContext(), + SyslogContext()], 'services': ['quantum-dhcp-agent', 'quantum-metadata-agent'] }, } @@ -306,7 +315,9 @@ QUANTUM_NVP_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) NEUTRON_NVP_CONFIG_FILES = { NEUTRON_CONF: { - 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR)], + 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), + QuantumGatewayContext(), + SyslogContext()], 'services': ['neutron-dhcp-agent', 'neutron-metadata-agent'] }, } @@ -318,6 +329,7 @@ CONFIG_FILES = { OVS: QUANTUM_OVS_CONFIG_FILES, }, NEUTRON: { + NSX: NEUTRON_NVP_CONFIG_FILES, NVP: NEUTRON_NVP_CONFIG_FILES, OVS: NEUTRON_OVS_CONFIG_FILES, }, @@ -330,7 +342,7 @@ def register_configs(): configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) - plugin = config('plugin') + plugin = remap_plugin(config('plugin')) name = networking_name() if plugin == 'ovs': # NOTE: deal with switch to ML2 plugin for >= icehouse diff --git a/templates/havana/dhcp_agent.ini b/templates/havana/dhcp_agent.ini index 85e93864..059b26be 100644 --- a/templates/havana/dhcp_agent.ini +++ b/templates/havana/dhcp_agent.ini @@ -11,7 +11,7 @@ ovs_use_veth = True {% if instance_mtu -%} dnsmasq_config_file = /etc/neutron/dnsmasq.conf {% endif -%} -{% if plugin == 'nvp' -%} +{% if plugin == 'nvp' or plugin == 'nsx' -%} enable_metadata_network = True enable_isolated_metadata = True {% endif -%} diff --git a/unit_tests/test_quantum_contexts.py b/unit_tests/test_quantum_contexts.py index d5b79e43..3a6b48cc 100644 --- a/unit_tests/test_quantum_contexts.py +++ b/unit_tests/test_quantum_contexts.py @@ -290,10 +290,10 @@ class TestHostIP(CharmTestCase): _query.assert_called_with('myhost.example.com', 'A') -class TestNetworkingName(CharmTestCase): +class TestMisc(CharmTestCase): def setUp(self): - super(TestNetworkingName, + super(TestMisc, self).setUp(quantum_contexts, TO_PATCH) @@ -304,3 +304,29 @@ class TestNetworkingName(CharmTestCase): def test_ge_havana(self): self.get_os_codename_install_source.return_value = 'havana' self.assertEquals(quantum_contexts.networking_name(), 'neutron') + + def test_remap_plugin(self): + self.get_os_codename_install_source.return_value = 'havana' + self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nvp') + self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nvp') + + def test_remap_plugin_icehouse(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nsx') + self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nsx') + + def test_remap_plugin_noop(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.assertEquals(quantum_contexts.remap_plugin('ovs'), 'ovs') + + def test_core_plugin(self): + self.get_os_codename_install_source.return_value = 'havana' + self.config.return_value = 'ovs' + self.assertEquals(quantum_contexts.core_plugin(), + quantum_contexts.NEUTRON_OVS_PLUGIN) + + def test_core_plugin_ml2(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.config.return_value = 'ovs' + self.assertEquals(quantum_contexts.core_plugin(), + quantum_contexts.NEUTRON_ML2_PLUGIN) diff --git a/unit_tests/test_quantum_utils.py b/unit_tests/test_quantum_utils.py index f6841693..b83097a5 100644 --- a/unit_tests/test_quantum_utils.py +++ b/unit_tests/test_quantum_utils.py @@ -41,7 +41,8 @@ TO_PATCH = [ 'relations_of_type', 'service_stop', 'determine_dkms_package', - 'service_restart' + 'service_restart', + 'remap_plugin' ] @@ -62,6 +63,10 @@ class TestQuantumUtils(CharmTestCase): self.networking_name.return_value = 'neutron' self.headers_package.return_value = 'linux-headers-2.6.18' + def noop(value): + return value + self.remap_plugin.side_effect = noop + def tearDown(self): # Reset cached cache hookenv.cache = {} @@ -71,6 +76,8 @@ class TestQuantumUtils(CharmTestCase): self.assertTrue(quantum_utils.valid_plugin()) self.config.return_value = 'nvp' self.assertTrue(quantum_utils.valid_plugin()) + self.config.return_value = 'nsx' + self.assertTrue(quantum_utils.valid_plugin()) def test_invalid_plugin(self): self.config.return_value = 'invalid' @@ -212,6 +219,20 @@ class TestQuantumUtils(CharmTestCase): ['hook_contexts'] ) + def test_register_configs_nsx(self): + self.config.return_value = 'nsx' + configs = quantum_utils.register_configs() + confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF, + quantum_utils.NEUTRON_METADATA_AGENT_CONF, + quantum_utils.NOVA_CONF, + quantum_utils.NEUTRON_CONF] + for conf in confs: + configs.register.assert_any_call( + conf, + quantum_utils.CONFIG_FILES['neutron'][quantum_utils.NSX][conf] + ['hook_contexts'] + ) + def test_stop_services_nvp(self): self.config.return_value = 'nvp' quantum_utils.stop_services() From b066182040009bb0ba098afd5c5af6e0bfd8320d Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Thu, 21 Aug 2014 00:02:19 +0000 Subject: [PATCH 6/7] fixied unit_tests --- unit_tests/test_quantum_contexts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unit_tests/test_quantum_contexts.py b/unit_tests/test_quantum_contexts.py index 3a6b48cc..76e7a7f1 100644 --- a/unit_tests/test_quantum_contexts.py +++ b/unit_tests/test_quantum_contexts.py @@ -165,7 +165,8 @@ class TestL3AgentContext(CharmTestCase): self.test_config.set('external-network-id', '') self.eligible_leader.return_value = False self.assertEquals(quantum_contexts.L3AgentContext()(), - {'handle_internal_only_router': False}) + {'handle_internal_only_router': False, + 'plugin': 'ovs'}) def test_hior_leader(self): self.test_config.set('run-internal-router', 'leader') @@ -173,7 +174,8 @@ class TestL3AgentContext(CharmTestCase): self.eligible_leader.return_value = True self.assertEquals(quantum_contexts.L3AgentContext()(), {'handle_internal_only_router': True, - 'ext_net_id': 'netid'}) + 'ext_net_id': 'netid', + 'plugin': 'ovs'}) def test_hior_all(self): self.test_config.set('run-internal-router', 'all') @@ -181,7 +183,8 @@ class TestL3AgentContext(CharmTestCase): self.eligible_leader.return_value = True self.assertEquals(quantum_contexts.L3AgentContext()(), {'handle_internal_only_router': True, - 'ext_net_id': 'netid'}) + 'ext_net_id': 'netid', + 'plugin': 'ovs'}) class TestQuantumGatewayContext(CharmTestCase): From 1ff43d7e50c0e3a7b90721e5771dc630e569bd82 Mon Sep 17 00:00:00 2001 From: Shiva Prasad Rao Date: Wed, 8 Oct 2014 22:53:29 +0000 Subject: [PATCH 7/7] addressing review comments --- hooks/quantum_hooks.py | 4 ++- hooks/quantum_utils.py | 3 -- templates/havana/cisco_plugins.ini | 44 ------------------------------ templates/havana/dhcp_agent.ini | 1 - templates/havana/l3_agent.ini | 2 -- 5 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 templates/havana/cisco_plugins.ini diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index b7871c44..67b014cc 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -16,6 +16,7 @@ from charmhelpers.fetch import ( apt_update, apt_install, filter_installed_packages, + apt_purge, ) from charmhelpers.core.host import ( restart_on_change, @@ -97,10 +98,11 @@ def config_changed(): if config('plugin') == 'n1kv': if config('enable-l3-agent'): if not service_running('neutron-l3-agent'): + apt_install('neutron-l3-agent') service_start('neutron-l3-agent') else: if service_running('neutron-l3-agent'): - service_stop('neutron-l3-agent') + apt_purge('neutron-l3-agent') @hooks.hook('upgrade-charm') diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 670ffe85..e8d3082c 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -73,15 +73,12 @@ NEUTRON_ML2_PLUGIN_CONF = \ "/etc/neutron/plugins/ml2/ml2_conf.ini" NEUTRON_NVP_PLUGIN_CONF = \ "/etc/neutron/plugins/nicira/nvp.ini" -NEUTRON_N1KV_PLUGIN_CONF = \ - "/etc/neutron/plugins/cisco/cisco_plugins.ini" NEUTRON_NSX_PLUGIN_CONF = \ "/etc/neutron/plugins/vmware/nsx.ini" NEUTRON_PLUGIN_CONF = { OVS: NEUTRON_OVS_PLUGIN_CONF, NVP: NEUTRON_NVP_PLUGIN_CONF, - N1KV: NEUTRON_N1KV_PLUGIN_CONF, NSX: NEUTRON_NSX_PLUGIN_CONF, } diff --git a/templates/havana/cisco_plugins.ini b/templates/havana/cisco_plugins.ini deleted file mode 100644 index 12852268..00000000 --- a/templates/havana/cisco_plugins.ini +++ /dev/null @@ -1,44 +0,0 @@ -[CISCO_PLUGINS] -vswitch_plugin=neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2 - -[database] -{% if database_host -%} -connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }} -{% else -%} -connection = sqlite:////var/lib/neutron/neutron.sqlite -{% endif -%} -#sql_connection = mysql://quantum:quantum_pass@127.0.0.1/quantum?charset=utf8 -# Replace 127.0.0.1 above with the IP address of the database used by the -# main quantum server. (Leave it as is if the database runs on this host.) -#sql_connection=engine://user:pass@host/db_name -#mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }} -#mysql://{{ quantum_user }}:{{ quantum_password }}@{{ database_host }}/{{ quantum_db }}?charset=utf8 -#reconnect_interval = 2 - -[N1KV: {{ vsm_ip }} ] -username= {{ vsm_username }} -password= {{ vsm_password }} - -[cisco_n1kv] -integration_bridge=br-int -#enable_tunneling=True -tunnel_bridge=br-int -local_ip= {{ local_ip }} -tenant_network_type=local -#bridge_mappings= -#vxlan_id_ranges=5000:60000 -#network_vlan_ranges=vlan:1:4095 -# IMPORTANT: Comment out the following two lines for production deployments -default_policy_profile=havana_pp -network_node_policy_profile = dhcp_pp -poll_duration = 10 - -#[CISCO_TEST] -#host=testhost - -#[DRIVER] -#name=quantum.plugins.cisco.tests.unit.v2.nexus.fake_nexus_driver.CiscoNEXUSFakeDriver - -#[AGENT] -#polling_interval = 10 -#root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf diff --git a/templates/havana/dhcp_agent.ini b/templates/havana/dhcp_agent.ini index c11d318f..0ef4acf4 100644 --- a/templates/havana/dhcp_agent.ini +++ b/templates/havana/dhcp_agent.ini @@ -19,7 +19,6 @@ enable_isolated_metadata = True {% if plugin == 'n1kv' %} enable_metadata_network = True enable_isolated_metadata = True -debug = False resync_interval = 30 use_namespaces = True dhcp_lease_time=3600 diff --git a/templates/havana/l3_agent.ini b/templates/havana/l3_agent.ini index c8d8e4de..e64591a4 100644 --- a/templates/havana/l3_agent.ini +++ b/templates/havana/l3_agent.ini @@ -16,8 +16,6 @@ l3_agent_manager = neutron.agent.l3_agent.L3NATAgentWithStateReport external_network_bridge = br-int ovs_use_veth = False use_namespaces = True -debug = True -verbose = True {% else %} ovs_use_veth = True {% endif %}