Merge remote-tracking branch 'origin/feature/qos' into merge-branch

Change-Id: I7a78ea4a8b3a03ef2013d41f9788e554f73c990b
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 4958bc5..f811abe 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -65,7 +65,10 @@
             'metering_label_rules': 'metering',
             'firewall_rules': 'fw',
             'firewall_policies': 'fw',
-            'firewalls': 'fw'
+            'firewalls': 'fw',
+            'policies': 'qos',
+            'bandwidth_limit_rules': 'qos',
+            'rule_types': 'qos',
         }
         service_prefix = service_resource_prefix_map.get(
             plural_name)
@@ -90,7 +93,8 @@
             'ikepolicy': 'ikepolicies',
             'ipsec_site_connection': 'ipsec-site-connections',
             'quotas': 'quotas',
-            'firewall_policy': 'firewall_policies'
+            'firewall_policy': 'firewall_policies',
+            'qos_policy': 'policies'
         }
         return resource_plural_map.get(resource_name, resource_name + 's')
 
@@ -620,3 +624,84 @@
         self.expected_success(200, resp.status)
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
+
+    def list_qos_policies(self):
+        uri = '%s/qos/policies' % self.uri_prefix
+        resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
+        body = json.loads(body)
+        return service_client.ResponseBody(resp, body)
+
+    def create_qos_policy(self, name, description, shared, tenant_id=None):
+        uri = '%s/qos/policies' % self.uri_prefix
+        post_data = {'policy': {
+                'name': name,
+                'description': description,
+                'shared': shared
+            }}
+        if tenant_id is not None:
+            post_data['policy']['tenant_id'] = tenant_id
+        resp, body = self.post(uri, self.serialize(post_data))
+        body = self.deserialize_single(body)
+        self.expected_success(201, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def update_qos_policy(self, policy_id, **kwargs):
+        uri = '%s/qos/policies/%s' % (self.uri_prefix, policy_id)
+        post_data = self.serialize({'policy': kwargs})
+        resp, body = self.put(uri, post_data)
+        body = self.deserialize_single(body)
+        self.expected_success(200, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def create_bandwidth_limit_rule(self, policy_id, max_kbps, max_burst_kbps):
+        uri = '%s/qos/policies/%s/bandwidth_limit_rules' % (
+            self.uri_prefix, policy_id)
+        post_data = self.serialize(
+            {'bandwidth_limit_rule': {
+                'max_kbps': max_kbps,
+                'max_burst_kbps': max_burst_kbps}
+            })
+        resp, body = self.post(uri, post_data)
+        self.expected_success(201, resp.status)
+        body = json.loads(body)
+        return service_client.ResponseBody(resp, body)
+
+    def list_bandwidth_limit_rules(self, policy_id):
+        uri = '%s/qos/policies/%s/bandwidth_limit_rules' % (
+            self.uri_prefix, policy_id)
+        resp, body = self.get(uri)
+        body = self.deserialize_single(body)
+        self.expected_success(200, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def show_bandwidth_limit_rule(self, policy_id, rule_id):
+        uri = '%s/qos/policies/%s/bandwidth_limit_rules/%s' % (
+            self.uri_prefix, policy_id, rule_id)
+        resp, body = self.get(uri)
+        body = self.deserialize_single(body)
+        self.expected_success(200, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def update_bandwidth_limit_rule(self, policy_id, rule_id, **kwargs):
+        uri = '%s/qos/policies/%s/bandwidth_limit_rules/%s' % (
+            self.uri_prefix, policy_id, rule_id)
+        post_data = {'bandwidth_limit_rule': kwargs}
+        resp, body = self.put(uri, json.dumps(post_data))
+        body = self.deserialize_single(body)
+        self.expected_success(200, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def delete_bandwidth_limit_rule(self, policy_id, rule_id):
+        uri = '%s/qos/policies/%s/bandwidth_limit_rules/%s' % (
+            self.uri_prefix, policy_id, rule_id)
+        resp, body = self.delete(uri)
+        self.expected_success(204, resp.status)
+        return service_client.ResponseBody(resp, body)
+
+    def list_qos_rule_types(self):
+        uri = '%s/qos/rule-types' % self.uri_prefix
+        resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
+        body = json.loads(body)
+        return service_client.ResponseBody(resp, body)