Merge "Add http_response input for endpoint"
diff --git a/.kitchen.yml b/.kitchen.yml
index d144018..b762e23 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -78,6 +78,17 @@
       pillars-from-files:
         neutron.sls: tests/pillar/compute_sriov.sls
 
+  - name: compute_qos_sriov
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_qos_sriov.sls
+
+  - name: compute_qos
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/compute_qos.sls
+
+
   - name: control_cluster
     provisioner:
       pillars-from-files:
@@ -93,11 +104,21 @@
       pillars-from-files:
         neutron.sls: tests/pillar/control_nodvr.sls
 
+  - name: control_lbaas_octavia.sls
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_lbaas_octavia.sls
+
   - name: control_single
     provisioner:
       pillars-from-files:
         neutron.sls: tests/pillar/control_single.sls
 
+  - name: control_qos
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/control_qos.sls
+
   - name: gateway_dvr
     provisioner:
       pillars-from-files:
@@ -107,4 +128,10 @@
     provisioner:
       pillars-from-files:
         neutron.sls: tests/pillar/gateway_legacy.sls
+
+  - name: gateway_qos
+    provisioner:
+      pillars-from-files:
+        neutron.sls: tests/pillar/gateway_qos.sls
+
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/README.rst b/README.rst
index c01b822..9adbc21 100644
--- a/README.rst
+++ b/README.rst
@@ -73,7 +73,8 @@
           # Add key without value to remove line from policy.json
           'create_network:shared':
 
-Neutron lbaas provides on the controller node
+Neutron LBaaSv2 enablement
+--------------------------
 
 .. code-block:: yaml
 
@@ -82,9 +83,13 @@
       lbaas:
         enabled: true
         providers:
+          octavia:
+            engine: octavia
+            driver_path: 'neutron_lbaas.drivers.octavia.driver.OctaviaDriver'
+            base_url: 'http://127.0.0.1:9876'
           avi_adc:
-            enabled: true
             engine: avinetworks
+            driver_path: 'avi_lbaasv2.avi_driver.AviDriver'
             controller_address: 10.182.129.239
             controller_user: admin
             controller_password: Cloudlab2016
@@ -93,15 +98,15 @@
             engine: avinetworks
             ...
 
-Note: If you want contrail lbaas then backend is only required. Lbaas in
-pillar should be define only if it should be disabled.
+Note: If the Contrail backend is set, Opencontrail loadbalancer would be enabled
+automatically. In this case lbaas should disabled in pillar:
 
 .. code-block:: yaml
 
   neutron:
     server:
       lbaas:
-        enabled: disabled
+        enabled: false
 
 Enable CORS parameters
 
diff --git a/metadata/service/compute/single.yml b/metadata/service/compute/single.yml
index 3422e39..d20a391 100644
--- a/metadata/service/compute/single.yml
+++ b/metadata/service/compute/single.yml
@@ -18,6 +18,7 @@
       dvr: false
       external_access: false
       security_groups_enabled: true
+      qos: false
       metadata:
         host: ${_param:cluster_vip_address}
         password: ${_param:metadata_password}
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index 24b5a2f..e0c16e1 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -13,6 +13,7 @@
       dns_domain: novalocal
       tunnel_type: vxlan
       security_groups_enabled: true
+      qos: false
       version: ${_param:neutron_version}
       bind:
         address: ${_param:single_address}
diff --git a/metadata/service/gateway/single.yml b/metadata/service/gateway/single.yml
index a9628f0..fe7b886 100644
--- a/metadata/service/gateway/single.yml
+++ b/metadata/service/gateway/single.yml
@@ -18,6 +18,7 @@
       dvr: false
       external_access: True
       security_groups_enabled: true
+      qos: false
       metadata:
         host: ${_param:cluster_vip_address}
         password: ${_param:metadata_password}
diff --git a/neutron/files/ocata/ml2_conf.ini b/neutron/files/ocata/ml2_conf.ini
index ad4e100..cf94d56 100644
--- a/neutron/files/ocata/ml2_conf.ini
+++ b/neutron/files/ocata/ml2_conf.ini
@@ -137,7 +137,7 @@
 # neutron.ml2.extension_drivers namespace. For example: extension_drivers =
 # port_security,qos (list value)
 #extension_drivers =
-extension_drivers = port_security
+extension_drivers = port_security{% if server.get('qos', 'True') %},qos{% endif %}
 
 # Maximum size of an IP packet (MTU) that can traverse the underlying physical
 # network infrastructure without fragmentation when using an overlay/tunnel
diff --git a/neutron/files/ocata/neutron-server.conf.Debian b/neutron/files/ocata/neutron-server.conf.Debian
index 0047550..eb35f3d 100644
--- a/neutron/files/ocata/neutron-server.conf.Debian
+++ b/neutron/files/ocata/neutron-server.conf.Debian
@@ -44,9 +44,9 @@
 core_plugin = neutron.plugins.ml2.plugin.Ml2Plugin
 
 service_plugins =neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,neutron.services.metering.metering_plugin.MeteringPlugin,trunk{%- if server.lbaas is defined -%}
-,neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2
-{%- endif -%}
-
+,lbaasv2
+{%- endif -%}{% if server.get('qos', 'True') %},neutron.services.qos.qos_plugin.QoSPlugin
+{% endif %}
 {% endif %}
 
 # The service plugins Neutron will use (list value)
@@ -2160,10 +2160,24 @@
 
 {%- for lbaas_name, lbaas in server.lbaas.providers.iteritems() %}
 
-{%- if lbaas.engine == "avinetworks" -%}
 service_provider=LOADBALANCERV2:{{ lbaas_name }}:{{ lbaas.get('driver_path', 'avi_lbaasv2.avi_driver.AviDriver') }}:default
 
 [{{ lbaas_name }}]
+
+{% if lbaas.engine == "octavia" %}
+
+base_url = {{ lbaas.base_url }}
+request_poll_timeout = 3000
+
+[service_auth]
+auth_version = 2
+admin_password = {{ server.identity.password }}
+admin_user = {{ server.identity.user }}
+admin_tenant_name = {{ server.identity.tenant }}
+auth_url = http://{{ server.identity.host }}:35357/v2.0
+{%- endif -%}
+
+{% if lbaas.engine == "avinetworks" %}
 address={{ lbaas.controller_address }}
 user={{ lbaas.controller_user }}
 password={{ lbaas.controller_password }}
diff --git a/neutron/files/ocata/openvswitch_agent.ini b/neutron/files/ocata/openvswitch_agent.ini
index 2de0352..e69861c 100644
--- a/neutron/files/ocata/openvswitch_agent.ini
+++ b/neutron/files/ocata/openvswitch_agent.ini
@@ -195,8 +195,9 @@
 #agent_type = Open vSwitch agent
 
 # Extensions list to use (list value)
-#extensions =
-
+{% if server.get('qos', 'True') %}
+extensions = qos
+{% endif %}
 
 [ovs]
 
diff --git a/neutron/files/ocata/sriov_agent.ini b/neutron/files/ocata/sriov_agent.ini
index 5f78a0e..797352b 100644
--- a/neutron/files/ocata/sriov_agent.ini
+++ b/neutron/files/ocata/sriov_agent.ini
@@ -122,7 +122,9 @@
 #
 
 # Extensions list to use (list value)
-#extensions =
+{% if server.get('qos', 'True') %}
+extensions = qos
+{% endif %}
 
 
 [sriov_nic]
diff --git a/tests/pillar/compute_qos.sls b/tests/pillar/compute_qos.sls
new file mode 100644
index 0000000..ca1f186
--- /dev/null
+++ b/tests/pillar/compute_qos.sls
@@ -0,0 +1,25 @@
+neutron:
+  compute:
+    agent_mode: legacy
+    backend:
+      engine: ml2
+      tenant_network_types: "flat,vxlan"
+      mechanism:
+        ovs:
+          driver: openvswitch
+    dvr: false
+    enabled: true
+    qos: true
+    external_access: false
+    local_ip: 10.1.0.105
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      password: workshop
+      port: 5672
+      user: openstack
+      virtual_host: /openstack
+    metadata:
+      host: 127.0.0.1
+      password: password
+    version: mitaka
\ No newline at end of file
diff --git a/tests/pillar/compute_qos_sriov.sls b/tests/pillar/compute_qos_sriov.sls
new file mode 100644
index 0000000..11fb212
--- /dev/null
+++ b/tests/pillar/compute_qos_sriov.sls
@@ -0,0 +1,29 @@
+neutron:
+  compute:
+    agent_mode: legacy
+    backend:
+      engine: ml2
+      tenant_network_types: "flat,vxlan"
+      sriov:
+        nic_one:
+          devname: eth1
+          physical_network: physnet3
+      mechanism:
+        ovs:
+          driver: openvswitch
+    dvr: false
+    enabled: true
+    qos: true
+    external_access: false
+    local_ip: 10.1.0.105
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      password: workshop
+      port: 5672
+      user: openstack
+      virtual_host: /openstack
+    metadata:
+      host: 127.0.0.1
+      password: password
+    version: mitaka
diff --git a/tests/pillar/control_lbaas_octavia.sls b/tests/pillar/control_lbaas_octavia.sls
new file mode 100644
index 0000000..5209b2d
--- /dev/null
+++ b/tests/pillar/control_lbaas_octavia.sls
@@ -0,0 +1,59 @@
+neutron:
+  server:
+    backend:
+      engine: ml2
+      external_mtu: 1500
+      mechanism:
+        ovs:
+          driver: openvswitch
+      tenant_network_types: flat,vxlan
+    bind:
+      address: 172.16.10.101
+      port: 9696
+    compute:
+      host: 127.0.0.1
+      password: workshop
+      region: RegionOne
+      tenant: service
+      user: nova
+    database:
+      engine: mysql
+      host: 127.0.0.1
+      name: neutron
+      password: workshop
+      port: 3306
+      user: neutron
+    version: ocata
+    dns_domain: novalocal
+    dvr: false
+    enabled: true
+    global_physnet_mtu: 1500
+    lbaas:
+      enabled: true
+      providers:
+        octavia:
+          engine: octavia
+          driver_path: 'neutron_lbaas.drivers.octavia.driver.OctaviaDriver'
+          base_url: 'http://127.0.0.1:9876'
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      password: workshop
+      port: 35357
+      region: RegionOne
+      tenant: service
+      user: neutron
+      endpoint_type: internal
+    l3_ha: false
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      password: workshop
+      port: 5672
+      user: openstack
+      virtual_host: /openstack
+    plugin: ml2
+    policy:
+      create_subnet: 'rule:admin_or_network_owner'
+      'get_network:queue_id': 'rule:admin_only'
+      'create_network:shared':
diff --git a/tests/pillar/control_qos.sls b/tests/pillar/control_qos.sls
new file mode 100644
index 0000000..3c24ccf
--- /dev/null
+++ b/tests/pillar/control_qos.sls
@@ -0,0 +1,53 @@
+neutron:
+  server:
+    backend:
+      engine: ml2
+      external_mtu: 1500
+      mechanism:
+        ovs:
+          driver: openvswitch
+      tenant_network_types: flat,vxlan
+    bind:
+      address: 172.16.10.101
+      port: 9696
+    compute:
+      host: 127.0.0.1
+      password: workshop
+      region: RegionOne
+      tenant: service
+      user: nova
+    database:
+      engine: mysql
+      host: 127.0.0.1
+      name: neutron
+      password: workshop
+      port: 3306
+      user: neutron
+    dns_domain: novalocal
+    dvr: false
+    enabled: true
+    qos: true
+    global_physnet_mtu: 1500
+    identity:
+      engine: keystone
+      host: 127.0.0.1
+      password: workshop
+      port: 35357
+      region: RegionOne
+      tenant: service
+      user: neutron
+      endpoint_type: internal
+    l3_ha: False
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      password: workshop
+      port: 5672
+      user: openstack
+      virtual_host: /openstack
+    plugin: ml2
+    version: ocata
+    policy:
+      create_subnet: 'rule:admin_or_network_owner'
+      'get_network:queue_id': 'rule:admin_only'
+      'create_network:shared':
diff --git a/tests/pillar/gateway_qos.sls b/tests/pillar/gateway_qos.sls
new file mode 100644
index 0000000..0447011
--- /dev/null
+++ b/tests/pillar/gateway_qos.sls
@@ -0,0 +1,25 @@
+neutron:
+  gateway:
+    agent_mode: legacy
+    backend:
+      engine: ml2
+      tenant_network_types: "flat,vxlan"
+      mechanism:
+        ovs:
+          driver: openvswitch
+    dvr: false
+    enabled: true
+    qos: true
+    external_access: True
+    local_ip: 10.1.0.110
+    message_queue:
+      engine: rabbitmq
+      host: 127.0.0.1
+      password: workshop
+      port: 5672
+      user: openstack
+      virtual_host: /openstack
+    metadata:
+      host: 127.0.0.1
+      password: password
+    version: mitaka