Skip to content

Commit ed07ac3

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "network/v2 quota resource"
2 parents 7ed4744 + c63f2a8 commit ed07ac3

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

openstack/network/v2/quota.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from openstack.network import network_service
14+
from openstack import resource
15+
16+
17+
class Quota(resource.Resource):
18+
resource_key = 'quota'
19+
resources_key = 'quotas'
20+
base_path = '/v2.0/quotas'
21+
service = network_service.NetworkService()
22+
23+
# capabilities
24+
allow_list = True
25+
26+
# Properties
27+
floating_ip = resource.prop('floatingip', type=int)
28+
network = resource.prop('network', type=int)
29+
port = resource.prop('port', type=int)
30+
project_id = resource.prop('tenant_id')
31+
router = resource.prop('router', type=int)
32+
subnet = resource.prop('subnet', type=int)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import testtools
14+
15+
from openstack.network.v2 import quota
16+
17+
IDENTIFIER = 'IDENTIFIER'
18+
EXAMPLE = {
19+
'floatingip': 1,
20+
'network': 2,
21+
'port': 3,
22+
'tenant_id': '4',
23+
'router': 5,
24+
'subnet': 6,
25+
}
26+
27+
28+
class TestQuota(testtools.TestCase):
29+
30+
def test_basic(self):
31+
sot = quota.Quota()
32+
self.assertEqual('quota', sot.resource_key)
33+
self.assertEqual('quotas', sot.resources_key)
34+
self.assertEqual('/v2.0/quotas', sot.base_path)
35+
self.assertEqual('network', sot.service.service_type)
36+
self.assertFalse(sot.allow_create)
37+
self.assertFalse(sot.allow_retrieve)
38+
self.assertFalse(sot.allow_update)
39+
self.assertFalse(sot.allow_delete)
40+
self.assertTrue(sot.allow_list)
41+
42+
def test_make_it(self):
43+
sot = quota.Quota(EXAMPLE)
44+
self.assertEqual(EXAMPLE['floatingip'], sot.floating_ip)
45+
self.assertEqual(EXAMPLE['network'], sot.network)
46+
self.assertEqual(EXAMPLE['port'], sot.port)
47+
self.assertEqual(EXAMPLE['tenant_id'], sot.project_id)
48+
self.assertEqual(EXAMPLE['router'], sot.router)
49+
self.assertEqual(EXAMPLE['subnet'], sot.subnet)

0 commit comments

Comments
 (0)