diff options
Diffstat (limited to 'nova/tests')
18 files changed, 108 insertions, 28 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_createserverext.py b/nova/tests/api/openstack/compute/contrib/test_createserverext.py index a37c6889d..9ec866172 100644 --- a/nova/tests/api/openstack/compute/contrib/test_createserverext.py +++ b/nova/tests/api/openstack/compute/contrib/test_createserverext.py @@ -99,7 +99,7 @@ class CreateserverextTest(test.TestCase): osapi_compute_extension=[ 'nova.api.openstack.compute.contrib.select_extensions'], osapi_compute_ext_list=['Createserverext', 'User_data', - 'Security_groups', 'Networks']) + 'Security_groups', 'Os_networks']) def _make_stub_method(self, canned_return): def stub_method(*args, **kwargs): diff --git a/nova/tests/api/openstack/compute/contrib/test_networks.py b/nova/tests/api/openstack/compute/contrib/test_networks.py index 5cd522f72..ba65e8f6a 100644 --- a/nova/tests/api/openstack/compute/contrib/test_networks.py +++ b/nova/tests/api/openstack/compute/contrib/test_networks.py @@ -21,7 +21,7 @@ import uuid import webob -from nova.api.openstack.compute.contrib import networks +from nova.api.openstack.compute.contrib import admin_networks as networks from nova.api.openstack.compute.contrib import networks_associate from nova import exception from nova.openstack.common import cfg @@ -177,7 +177,8 @@ class NetworksTest(test.TestCase): def setUp(self): super(NetworksTest, self).setUp() self.fake_network_api = FakeNetworkAPI() - self.controller = networks.NetworkController(self.fake_network_api) + self.controller = networks.AdminNetworkController( + self.fake_network_api) self.associate_controller = networks_associate\ .NetworkAssociateActionController(self.fake_network_api) fakes.stub_out_networking(self.stubs) diff --git a/nova/tests/api/openstack/compute/contrib/test_quota_classes.py b/nova/tests/api/openstack/compute/contrib/test_quota_classes.py index a8d651977..a72f5bf0f 100644 --- a/nova/tests/api/openstack/compute/contrib/test_quota_classes.py +++ b/nova/tests/api/openstack/compute/contrib/test_quota_classes.py @@ -91,8 +91,7 @@ class QuotaClassSetsTest(test.TestCase): 'injected_file_path_bytes': 255, 'security_groups': 10, 'security_group_rules': 20, - 'key_pairs': 100, - }} + 'key_pairs': 100}} req = fakes.HTTPRequest.blank( '/v2/fake4/os-quota-class-sets/test_class', diff --git a/nova/tests/api/openstack/compute/contrib/test_quotas.py b/nova/tests/api/openstack/compute/contrib/test_quotas.py index 47761b6a1..dab8c136e 100644 --- a/nova/tests/api/openstack/compute/contrib/test_quotas.py +++ b/nova/tests/api/openstack/compute/contrib/test_quotas.py @@ -51,8 +51,7 @@ class QuotaSetsTest(test.TestCase): 'injected_file_content_bytes': 10240, 'security_groups': 10, 'security_group_rules': 20, - 'key_pairs': 100, - } + 'key_pairs': 100} quota_set = self.controller._format_quota_set('1234', raw_quota_set) qs = quota_set['quota_set'] @@ -88,8 +87,7 @@ class QuotaSetsTest(test.TestCase): 'injected_file_content_bytes': 10240, 'security_groups': 10, 'security_group_rules': 20, - 'key_pairs': 100, - }} + 'key_pairs': 100}} self.assertEqual(res_dict, expected) diff --git a/nova/tests/api/openstack/compute/test_extensions.py b/nova/tests/api/openstack/compute/test_extensions.py index ebb3baf95..b52953569 100644 --- a/nova/tests/api/openstack/compute/test_extensions.py +++ b/nova/tests/api/openstack/compute/test_extensions.py @@ -186,7 +186,7 @@ class ExtensionControllerTest(ExtensionTestCase): "Keypairs", "Multinic", "MultipleCreate", - "Networks", + "OSNetworks", "QuotaClasses", "Quotas", "Rescue", diff --git a/nova/tests/fake_policy.py b/nova/tests/fake_policy.py index 58ff3289c..c5d160209 100644 --- a/nova/tests/fake_policy.py +++ b/nova/tests/fake_policy.py @@ -136,9 +136,10 @@ policy_data = """ "compute_extension:instance_usage_audit_log": "", "compute_extension:keypairs": "", "compute_extension:multinic": "", - "compute_extension:networks": "", - "compute_extension:networks:view": "", + "compute_extension:admin_networks": "", + "compute_extension:admin_networks:view": "", "compute_extension:networks_associate": "", + "compute_extension:os-networks": "", "compute_extension:quotas:show": "", "compute_extension:quotas:update": "", "compute_extension:quota_classes": "", @@ -191,6 +192,7 @@ policy_data = """ "network:get_all_networks": "", "network:get_network": "", + "network:create_networks": "", "network:delete_network": "", "network:disassociate_network": "", "network:get_vifs_by_instance": "", diff --git a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl index 3021bac56..0dd777fe2 100644 --- a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.json.tpl @@ -305,11 +305,19 @@ "updated": "%(timestamp)s" }, { + "alias": "os-admin-networks", + "description": "%(text)s", + "links": [], + "name": "AdminNetworks", + "namespace": "http://docs.openstack.org/compute/ext/os-admin-networks/api/v1.1", + "updated": "%(timestamp)s" + }, + { "alias": "os-networks", "description": "%(text)s", "links": [], - "name": "Networks", - "namespace": "http://docs.openstack.org/compute/ext/networks/api/v1.1", + "name": "OSNetworks", + "namespace": "http://docs.openstack.org/compute/ext/os-networks/api/v1.1", "updated": "%(timestamp)s" }, { diff --git a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl index d78d1ba93..fe34f369b 100644 --- a/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/extensions-get-resp.xml.tpl @@ -114,7 +114,10 @@ <extension alias="os-multiple-create" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/multiplecreate/api/v1.1" name="MultipleCreate"> <description>%(text)s</description> </extension> - <extension alias="os-networks" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/networks/api/v1.1" name="Networks"> + <extension alias="os-admin-networks" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/os-admin-networks/api/v1.1" name="AdminNetworks"> + <description>%(text)s</description> + </extension> + <extension alias="os-networks" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/os-networks/api/v1.1" name="OSNetworks"> <description>%(text)s</description> </extension> <extension alias="os-networks-associate" updated="%(timestamp)s" namespace="http://docs.openstack.org/compute/ext/networks_associate/api/v2" name="NetworkAssociationSupport"> diff --git a/nova/tests/integrated/api_samples/os-networks/networks-list-res.json.tpl b/nova/tests/integrated/api_samples/os-networks/networks-list-res.json.tpl new file mode 100644 index 000000000..757084d2f --- /dev/null +++ b/nova/tests/integrated/api_samples/os-networks/networks-list-res.json.tpl @@ -0,0 +1,14 @@ +{ + "networks": [ + { + "cidr": "10.0.0.0/29", + "id": "%(id)s", + "label": "test_0" + }, + { + "cidr": "10.0.0.8/29", + "id": "%(id)s", + "label": "test_1" + } + ] +} diff --git a/nova/tests/integrated/api_samples/os-networks/networks-post-req.json.tpl b/nova/tests/integrated/api_samples/os-networks/networks-post-req.json.tpl new file mode 100644 index 000000000..fb1c2d3d0 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-networks/networks-post-req.json.tpl @@ -0,0 +1,9 @@ +{ + "network": { + "label": "public", + "cidr": "172.0.0.0/24", + "vlan_start": 1, + "num_networks": 1, + "network_size": 255 + } +} diff --git a/nova/tests/integrated/api_samples/os-networks/networks-post-res.json.tpl b/nova/tests/integrated/api_samples/os-networks/networks-post-res.json.tpl new file mode 100644 index 000000000..ff9e2273d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-networks/networks-post-res.json.tpl @@ -0,0 +1,7 @@ +{ + "network": { + "cidr": "172.0.0.0/24", + "id": "%(id)s", + "label": "public" + } +} diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl index 70d4b66eb..ee1f6a397 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl @@ -13,4 +13,4 @@ "security_group_rules": 20, "security_groups": 10 } -}
\ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl index 7dfdddeb2..6a39c8506 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl @@ -11,4 +11,4 @@ <ram>51200</ram> <security_group_rules>20</security_group_rules> <security_groups>10</security_groups> -</quota_set>
\ No newline at end of file +</quota_set> diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl index 70d4b66eb..ee1f6a397 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl @@ -13,4 +13,4 @@ "security_group_rules": 20, "security_groups": 10 } -}
\ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl index 7dfdddeb2..6a39c8506 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl @@ -11,4 +11,4 @@ <ram>51200</ram> <security_group_rules>20</security_group_rules> <security_groups>10</security_groups> -</quota_set>
\ No newline at end of file +</quota_set> diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl index 6581c6354..c16dc6bb5 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl @@ -12,4 +12,4 @@ "security_group_rules": 20, "security_groups": 45 } -}
\ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl index aef4761f8..126c3fced 100644 --- a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl @@ -11,4 +11,4 @@ <ram>51200</ram> <security_group_rules>20</security_group_rules> <security_groups>45</security_groups> -</quota_set>
\ No newline at end of file +</quota_set> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index c15767a82..877ed4af6 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -16,6 +16,7 @@ import base64 import datetime import inspect +import json import os import re import urllib @@ -29,7 +30,6 @@ from nova.api.openstack.compute.contrib import coverage_ext # Import extensions to pull in osapi_compute_extension CONF option used below. from nova.api.openstack.compute import extensions from nova.cloudpipe.pipelib import CloudPipe -from nova.compute import api from nova import context from nova import db from nova.db.sqlalchemy import models @@ -41,6 +41,7 @@ from nova.openstack.common import importutils from nova.openstack.common import jsonutils from nova.openstack.common.log import logging from nova.openstack.common import timeutils +import nova.quota from nova.scheduler import driver from nova import test from nova.tests import fake_network @@ -139,6 +140,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): return cls._get_sample_path(name, dirname, suffix='.tpl') def _read_template(self, name): + template = self._get_template(name) if self.generate_samples and not os.path.exists(template): with open(template, 'w') as outf: @@ -371,7 +373,7 @@ class ApiSamplesTrap(ApiSampleTestBase): do_not_approve_additions.append('os-fping') do_not_approve_additions.append('os-hypervisors') do_not_approve_additions.append('os-instance_usage_audit_log') - do_not_approve_additions.append('os-networks') + do_not_approve_additions.append('os-admin-networks') do_not_approve_additions.append('os-services') do_not_approve_additions.append('os-volumes') @@ -2308,6 +2310,43 @@ class DiskConfigXmlTest(DiskConfigJsonTest): ctype = 'xml' +class OsNetworksJsonTests(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.os_networks" + ".Os_networks") + + def setUp(self): + super(OsNetworksJsonTests, self).setUp() + CONF.set_override("enable_network_quota", True) + + def fake(*args, **kwargs): + pass + + self.stubs.Set(nova.quota.QUOTAS, "reserve", fake) + self.stubs.Set(nova.quota.QUOTAS, "commit", fake) + self.stubs.Set(nova.quota.QUOTAS, "rollback", fake) + self.stubs.Set(nova.quota.QuotaEngine, "reserve", fake) + self.stubs.Set(nova.quota.QuotaEngine, "commit", fake) + self.stubs.Set(nova.quota.QuotaEngine, "rollback", fake) + + def test_list_networks(self): + response = self._do_get('os-networks') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('networks-list-res', subs, response) + + def test_create_network(self): + response = self._do_post('os-networks', "networks-post-req", {}) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + self._verify_response('networks-post-res', subs, response) + + def test_delete_networK(self): + response = self._do_post('os-networks', "networks-post-req", {}) + net = json.loads(response.read()) + response = self._do_delete('os-networks/%s' % net["network"]["id"]) + self.assertEqual(response.status, 202) + + class NetworksAssociateJsonTests(ApiSampleTestBase): extension_name = ("nova.api.openstack.compute.contrib" ".networks_associate.Networks_associate") @@ -2319,7 +2358,7 @@ class NetworksAssociateJsonTests(ApiSampleTestBase): f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] # Networks_associate requires Networks to be update f['osapi_compute_extension'].append( - 'nova.api.openstack.compute.contrib.networks.Networks') + 'nova.api.openstack.compute.contrib.admin_networks.Admin_networks') return f def setUp(self): @@ -2333,25 +2372,25 @@ class NetworksAssociateJsonTests(ApiSampleTestBase): self.stubs.Set(api.API, "associate", fake_associate) def test_disassociate(self): - response = self._do_post('os-networks/1/action', + response = self._do_post('os-admin-networks/1/action', 'network-disassociate-req', {}) self.assertEqual(response.status, 202) def test_disassociate_host(self): - response = self._do_post('os-networks/1/action', + response = self._do_post('os-admin-networks/1/action', 'network-disassociate-host-req', {}) self.assertEqual(response.status, 202) def test_disassociate_project(self): - response = self._do_post('os-networks/1/action', + response = self._do_post('os-admin-networks/1/action', 'network-disassociate-project-req', {}) self.assertEqual(response.status, 202) def test_associate_host(self): - response = self._do_post('os-networks/1/action', + response = self._do_post('os-admin-networks/1/action', 'network-associate-host-req', {"host": "testHost"}) self.assertEqual(response.status, 202) |
