Merge "Migrated 6 network clients from tempest"
This commit is contained in:
commit
62d0411064
0
tempest_lib/services/network/__init__.py
Normal file
0
tempest_lib/services/network/__init__.py
Normal file
71
tempest_lib/services/network/base.py
Normal file
71
tempest_lib/services/network/base.py
Normal file
@ -0,0 +1,71 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
from tempest_lib.common import rest_client
|
||||
|
||||
|
||||
class BaseNetworkClient(rest_client.RestClient):
|
||||
|
||||
"""Base class for Tempest REST clients for Neutron.
|
||||
|
||||
Child classes use v2 of the Neutron API, since the V1 API has been
|
||||
removed from the code base.
|
||||
"""
|
||||
|
||||
version = '2.0'
|
||||
uri_prefix = "v2.0"
|
||||
|
||||
def list_resources(self, uri, **filters):
|
||||
req_uri = self.uri_prefix + uri
|
||||
if filters:
|
||||
req_uri += '?' + urllib.urlencode(filters, doseq=1)
|
||||
resp, body = self.get(req_uri)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_resource(self, uri):
|
||||
req_uri = self.uri_prefix + uri
|
||||
resp, body = self.delete(req_uri)
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_resource(self, uri, **fields):
|
||||
# fields is a dict which key is 'fields' and value is a
|
||||
# list of field's name. An example:
|
||||
# {'fields': ['id', 'name']}
|
||||
req_uri = self.uri_prefix + uri
|
||||
if fields:
|
||||
req_uri += '?' + urllib.urlencode(fields, doseq=1)
|
||||
resp, body = self.get(req_uri)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_resource(self, uri, post_data):
|
||||
req_uri = self.uri_prefix + uri
|
||||
req_post_data = json.dumps(post_data)
|
||||
resp, body = self.post(req_uri, req_post_data)
|
||||
body = json.loads(body)
|
||||
self.expected_success(201, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_resource(self, uri, post_data):
|
||||
req_uri = self.uri_prefix + uri
|
||||
req_post_data = json.dumps(post_data)
|
||||
resp, body = self.put(req_uri, req_post_data)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
38
tempest_lib/services/network/floating_ips_client.py
Normal file
38
tempest_lib/services/network/floating_ips_client.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class FloatingIPsClient(base.BaseNetworkClient):
|
||||
|
||||
def create_floatingip(self, **kwargs):
|
||||
uri = '/floatingips'
|
||||
post_data = {'floatingip': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def update_floatingip(self, floatingip_id, **kwargs):
|
||||
uri = '/floatingips/%s' % floatingip_id
|
||||
post_data = {'floatingip': kwargs}
|
||||
return self.update_resource(uri, post_data)
|
||||
|
||||
def show_floatingip(self, floatingip_id, **fields):
|
||||
uri = '/floatingips/%s' % floatingip_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_floatingip(self, floatingip_id):
|
||||
uri = '/floatingips/%s' % floatingip_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_floatingips(self, **filters):
|
||||
uri = '/floatingips'
|
||||
return self.list_resources(uri, **filters)
|
33
tempest_lib/services/network/metering_label_rules_client.py
Normal file
33
tempest_lib/services/network/metering_label_rules_client.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class MeteringLabelRulesClient(base.BaseNetworkClient):
|
||||
|
||||
def create_metering_label_rule(self, **kwargs):
|
||||
uri = '/metering/metering-label-rules'
|
||||
post_data = {'metering_label_rule': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def show_metering_label_rule(self, metering_label_rule_id, **fields):
|
||||
uri = '/metering/metering-label-rules/%s' % metering_label_rule_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_metering_label_rule(self, metering_label_rule_id):
|
||||
uri = '/metering/metering-label-rules/%s' % metering_label_rule_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_metering_label_rules(self, **filters):
|
||||
uri = '/metering/metering-label-rules'
|
||||
return self.list_resources(uri, **filters)
|
33
tempest_lib/services/network/metering_labels_client.py
Normal file
33
tempest_lib/services/network/metering_labels_client.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class MeteringLabelsClient(base.BaseNetworkClient):
|
||||
|
||||
def create_metering_label(self, **kwargs):
|
||||
uri = '/metering/metering-labels'
|
||||
post_data = {'metering_label': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def show_metering_label(self, metering_label_id, **fields):
|
||||
uri = '/metering/metering-labels/%s' % metering_label_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_metering_label(self, metering_label_id):
|
||||
uri = '/metering/metering-labels/%s' % metering_label_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_metering_labels(self, **filters):
|
||||
uri = '/metering/metering-labels'
|
||||
return self.list_resources(uri, **filters)
|
38
tempest_lib/services/network/networks_client.py
Normal file
38
tempest_lib/services/network/networks_client.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class NetworksClient(base.BaseNetworkClient):
|
||||
|
||||
def create_network(self, **kwargs):
|
||||
uri = '/networks'
|
||||
post_data = {'network': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def update_network(self, network_id, **kwargs):
|
||||
uri = '/networks/%s' % network_id
|
||||
post_data = {'network': kwargs}
|
||||
return self.update_resource(uri, post_data)
|
||||
|
||||
def show_network(self, network_id, **fields):
|
||||
uri = '/networks/%s' % network_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_network(self, network_id):
|
||||
uri = '/networks/%s' % network_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_networks(self, **filters):
|
||||
uri = '/networks'
|
||||
return self.list_resources(uri, **filters)
|
38
tempest_lib/services/network/ports_client.py
Normal file
38
tempest_lib/services/network/ports_client.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class PortsClient(base.BaseNetworkClient):
|
||||
|
||||
def create_port(self, **kwargs):
|
||||
uri = '/ports'
|
||||
post_data = {'port': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def update_port(self, port_id, **kwargs):
|
||||
uri = '/ports/%s' % port_id
|
||||
post_data = {'port': kwargs}
|
||||
return self.update_resource(uri, post_data)
|
||||
|
||||
def show_port(self, port_id, **fields):
|
||||
uri = '/ports/%s' % port_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_port(self, port_id):
|
||||
uri = '/ports/%s' % port_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_ports(self, **filters):
|
||||
uri = '/ports'
|
||||
return self.list_resources(uri, **filters)
|
38
tempest_lib/services/network/subnets_client.py
Normal file
38
tempest_lib/services/network/subnets_client.py
Normal file
@ -0,0 +1,38 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest_lib.services.network import base
|
||||
|
||||
|
||||
class SubnetsClient(base.BaseNetworkClient):
|
||||
|
||||
def create_subnet(self, **kwargs):
|
||||
uri = '/subnets'
|
||||
post_data = {'subnet': kwargs}
|
||||
return self.create_resource(uri, post_data)
|
||||
|
||||
def update_subnet(self, subnet_id, **kwargs):
|
||||
uri = '/subnets/%s' % subnet_id
|
||||
post_data = {'subnet': kwargs}
|
||||
return self.update_resource(uri, post_data)
|
||||
|
||||
def show_subnet(self, subnet_id, **fields):
|
||||
uri = '/subnets/%s' % subnet_id
|
||||
return self.show_resource(uri, **fields)
|
||||
|
||||
def delete_subnet(self, subnet_id):
|
||||
uri = '/subnets/%s' % subnet_id
|
||||
return self.delete_resource(uri)
|
||||
|
||||
def list_subnets(self, **filters):
|
||||
uri = '/subnets'
|
||||
return self.list_resources(uri, **filters)
|
Loading…
Reference in New Issue
Block a user