diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index c6c94284b5..c9a73a391c 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -517,6 +517,7 @@ enable_neutron_bgp_dragent: "no" enable_neutron_provider_networks: "no" enable_neutron_segments: "no" enable_neutron_sfc: "no" +enable_neutron_metering: "no" enable_neutron_infoblox_ipam_agent: "no" enable_nova_serialconsole_proxy: "no" enable_nova_ssh: "yes" diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 0fd9e7425f..abf78d4726 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -306,6 +306,9 @@ neutron [neutron-infoblox-ipam-agent:children] neutron +[neutron-metering-agent:children] +neutron + [ironic-neutron-agent:children] neutron diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 6c23e0b83a..bd10275140 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -325,6 +325,9 @@ neutron [neutron-infoblox-ipam-agent:children] neutron +[neutron-metering-agent:children] +neutron + [ironic-neutron-agent:children] neutron diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml index c8a9118a39..1af74f0ecd 100644 --- a/ansible/roles/neutron/defaults/main.yml +++ b/ansible/roles/neutron/defaults/main.yml @@ -193,6 +193,19 @@ neutron_services: - "/run:/run:shared" - "kolla_logs:/var/log/kolla/" dimensions: "{{ neutron_infoblox_ipam_agent_dimensions }}" + neutron-metering-agent: + container_name: "neutron_metering_agent" + image: "{{ neutron_metering_agent_image_full }}" + privileged: True + enabled: "{{ enable_neutron_metering | bool }}" + group: "neutron-metering-agent" + host_in_groups: "{{ inventory_hostname in groups['neutron-metering-agent'] }}" + volumes: + - "{{ node_config_directory }}/neutron-metering-agent/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "/run:/run:shared" + - "kolla_logs:/var/log/kolla/" + dimensions: "{{ neutron_metering_agent_dimensions }}" ironic-neutron-agent: container_name: "ironic_neutron_agent" image: "{{ ironic_neutron_agent_image_full }}" @@ -260,6 +273,10 @@ neutron_infoblox_ipam_agent_image: "{{ docker_registry ~ '/' if docker_registry neutron_infoblox_ipam_agent_tag: "{{ neutron_tag }}" neutron_infoblox_ipam_agent_image_full: "{{ neutron_infoblox_ipam_agent_image }}:{{ neutron_infoblox_ipam_agent_tag }}" +neutron_metering_agent_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ neutron_install_type }}-neutron-metering-agent" +neutron_metering_agent_tag: "{{ neutron_tag }}" +neutron_metering_agent_image_full: "{{ neutron_metering_agent_image }}:{{ neutron_metering_agent_tag }}" + ironic_neutron_agent_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ neutron_install_type }}-ironic-neutron-agent" ironic_neutron_agent_tag: "{{ neutron_tag }}" ironic_neutron_agent_image_full: "{{ ironic_neutron_agent_image }}:{{ ironic_neutron_agent_tag }}" @@ -275,6 +292,7 @@ neutron_server_dimensions: "{{ default_container_dimensions }}" neutron_bgp_dragent_dimensions: "{{ default_container_dimensions }}" neutron_infoblox_ipam_agent_dimensions: "{{ default_container_dimensions }}" neutron_openvswitch_agent_xenapi_dimensions: "{{ default_container_dimensions }}" +neutron_metering_agent_dimensions: "{{ default_container_dimensions }}" ironic_neutron_agent_dimensions: "{{ default_container_dimensions }}" @@ -332,6 +350,8 @@ service_plugins: enabled: "{{ enable_neutron_lbaas | bool and not enable_octavia | bool }}" - name: "lbaasv2-proxy" enabled: "{{ enable_neutron_lbaas | bool and enable_octavia | bool }}" + - name: "metering" + enabled: "{{ enable_neutron_metering | bool }}" - name: "neutron_dynamic_routing.services.bgp.bgp_plugin.BgpPlugin" enabled: "{{ enable_neutron_bgp_dragent | bool }}" - name: "qos" diff --git a/ansible/roles/neutron/handlers/main.yml b/ansible/roles/neutron/handlers/main.yml index a9c95df438..0184532972 100644 --- a/ansible/roles/neutron/handlers/main.yml +++ b/ansible/roles/neutron/handlers/main.yml @@ -344,6 +344,31 @@ or neutron_ml2_conf | changed or neutron_infoblox_ipam_agent_container | changed +- name: Restart neutron-metering-agent container + vars: + service_name: "neutron-metering-agent" + service: "{{ neutron_services[service_name] }}" + config_json: "{{ neutron_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}" + neutron_conf: "{{ neutron_confs.results|selectattr('item.key', 'equalto', service_name)|first }}" + neutron_metering_agent_container: "{{ check_neutron_containers.results|selectattr('item.key', 'equalto', service_name)|first }}" + become: true + kolla_docker: + action: "recreate_or_restart_container" + common_options: "{{ docker_common_options }}" + name: "{{ service.container_name }}" + image: "{{ service.image }}" + volumes: "{{ service.volumes }}" + dimensions: "{{ service.dimensions }}" + privileged: "{{ service.privileged | default(False) }}" + when: + - kolla_action != "config" + - service.enabled | bool + - service.host_in_groups | bool + - config_json | changed + or neutron_conf | changed + or neutron_metering_agent_ini | changed + or neutron_metering_agent_container | changed + - name: Restart ironic-neutron-agent container vars: service_name: "ironic-neutron-agent" diff --git a/ansible/roles/neutron/tasks/config.yml b/ansible/roles/neutron/tasks/config.yml index 8f06a93001..c52b75934d 100644 --- a/ansible/roles/neutron/tasks/config.yml +++ b/ansible/roles/neutron/tasks/config.yml @@ -55,6 +55,7 @@ - "neutron-l3-agent" - "neutron-linuxbridge-agent" - "neutron-metadata-agent" + - "neutron-metering-agent" - "neutron-openvswitch-agent" - "neutron-openvswitch-agent-xenapi" - "neutron-server" @@ -306,6 +307,24 @@ notify: - "Restart {{ service_name }} container" +- name: Copying over metering_agent.ini + become: true + vars: + service_name: "neutron-metering-agent" + neutron_metering_agent: "{{ neutron_services[service_name] }}" + merge_configs: + sources: + - "{{ role_path }}/templates/metering_agent.ini.j2" + - "{{ node_custom_config }}/neutron/metering_agent.ini" + dest: "{{ node_config_directory }}/{{ service_name }}/metering_agent.ini" + mode: "0660" + register: neutron_metering_agent_ini + when: + - neutron_metering_agent.enabled | bool + - neutron_metering_agent.host_in_groups | bool + notify: + - "Restart {{ service_name }} container" + - name: Copying over ironic_neutron_agent.ini become: true vars: @@ -373,6 +392,7 @@ - "neutron-l3-agent" - "neutron-linuxbridge-agent" - "neutron-metadata-agent" + - "neutron-metering-agent" - "neutron-openvswitch-agent" - "neutron-openvswitch-agent-xenapi" - "neutron-server" diff --git a/ansible/roles/neutron/templates/metering_agent.ini.j2 b/ansible/roles/neutron/templates/metering_agent.ini.j2 new file mode 100644 index 0000000000..3a8cc72543 --- /dev/null +++ b/ansible/roles/neutron/templates/metering_agent.ini.j2 @@ -0,0 +1,3 @@ +[DEFAULT] +interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver diff --git a/ansible/roles/neutron/templates/neutron-metering-agent.json.j2 b/ansible/roles/neutron/templates/neutron-metering-agent.json.j2 new file mode 100644 index 0000000000..ad8272975e --- /dev/null +++ b/ansible/roles/neutron/templates/neutron-metering-agent.json.j2 @@ -0,0 +1,36 @@ +{ + "command": "neutron-metering-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/metering_agent.ini", + "config_files": [ + { + "source": "{{ container_config_directory }}/neutron.conf", + "dest": "/etc/neutron/neutron.conf", + "owner": "neutron", + "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/metering_agent.ini", + "dest": "/etc/neutron/metering_agent.ini", + "owner": "neutron", + "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/policy.json", + "dest": "/etc/neutron/policy.json", + "owner": "neutron", + "perm": "0600", + "optional": true + } + ], + "permissions": [ + { + "path": "/var/log/kolla/neutron", + "owner": "neutron:neutron", + "recurse": true + }, + { + "path": "/var/lib/neutron/kolla", + "owner": "neutron:neutron", + "recurse": true + } + ] +} diff --git a/ansible/site.yml b/ansible/site.yml index 3ccdb53699..7c4c54ebdd 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -654,6 +654,7 @@ - neutron-lbaas-agent - ironic-neutron-agent - neutron-metadata-agent + - neutron-metering-agent - compute - manila-share serial: '{{ kolla_serial|default("0") }}' diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 8244143758..d430bf0ab6 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -255,6 +255,7 @@ kolla_internal_vip_address: "10.10.10.254" #enable_neutron_vpnaas: "no" #enable_neutron_sriov: "no" #enable_neutron_sfc: "no" +#enable_neutron_metering: "no" #enable_nova_fake: "no" #enable_nova_serialconsole_proxy: "no" #enable_nova_ssh: "yes" diff --git a/releasenotes/notes/add-neutron-metering-support-4266364hudc5l80c.yaml b/releasenotes/notes/add-neutron-metering-support-4266364hudc5l80c.yaml new file mode 100644 index 0000000000..24697566c4 --- /dev/null +++ b/releasenotes/notes/add-neutron-metering-support-4266364hudc5l80c.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add neutron-metering-agent into kolla-ansible diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index d3e00d0c0d..e42ae35215 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -302,6 +302,9 @@ neutron [neutron-infoblox-ipam-agent:children] neutron +[neutron-metering-agent:children] +neutron + [ironic-neutron-agent:children] neutron