[Manila] Add context for Manila quotas
Add context for following Manila quotas: - shares - gigabytes - snapshots - snapshot_gigabytes - share_networks And set default values as unlimited (-1). Change-Id: Ie92f9ba03b5229984ee8b148d4bef715693c31e7
This commit is contained in:
parent
b86d1aaad9
commit
840a396945
@ -1,4 +1,22 @@
|
||||
---
|
||||
Dummy.dummy:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
manila:
|
||||
shares: -1
|
||||
gigabytes: -1
|
||||
snapshots: -1
|
||||
snapshot_gigabytes: -1
|
||||
share_networks: -1
|
||||
|
||||
ManilaShares.list_shares:
|
||||
-
|
||||
args:
|
||||
|
@ -1,4 +1,22 @@
|
||||
---
|
||||
Dummy.dummy:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 1
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
quotas:
|
||||
manila:
|
||||
shares: -1
|
||||
gigabytes: -1
|
||||
snapshots: -1
|
||||
snapshot_gigabytes: -1
|
||||
share_networks: -1
|
||||
|
||||
ManilaShares.list_shares:
|
||||
-
|
||||
args:
|
||||
|
54
rally/plugins/openstack/context/quotas/manila_quotas.py
Normal file
54
rally/plugins/openstack/context/quotas/manila_quotas.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
class ManilaQuotas(object):
|
||||
"""Management of Manila quotas."""
|
||||
|
||||
QUOTAS_SCHEMA = {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {
|
||||
"shares": {
|
||||
"type": "integer",
|
||||
"minimum": -1
|
||||
},
|
||||
"gigabytes": {
|
||||
"type": "integer",
|
||||
"minimum": -1
|
||||
},
|
||||
"snapshots": {
|
||||
"type": "integer",
|
||||
"minimum": -1
|
||||
},
|
||||
"snapshot_gigabytes": {
|
||||
"type": "integer",
|
||||
"minimum": -1
|
||||
},
|
||||
"share_networks": {
|
||||
"type": "integer",
|
||||
"minimum": -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, clients):
|
||||
self.clients = clients
|
||||
|
||||
def update(self, tenant_id, **kwargs):
|
||||
self.clients.manila().quotas.update(tenant_id, **kwargs)
|
||||
|
||||
def delete(self, tenant_id):
|
||||
self.clients.manila().quotas.delete(tenant_id)
|
@ -21,6 +21,7 @@ from rally import consts
|
||||
from rally import osclients
|
||||
from rally.plugins.openstack.context.quotas import cinder_quotas
|
||||
from rally.plugins.openstack.context.quotas import designate_quotas
|
||||
from rally.plugins.openstack.context.quotas import manila_quotas
|
||||
from rally.plugins.openstack.context.quotas import neutron_quotas
|
||||
from rally.plugins.openstack.context.quotas import nova_quotas
|
||||
|
||||
@ -39,6 +40,7 @@ class Quotas(context.Context):
|
||||
"properties": {
|
||||
"nova": nova_quotas.NovaQuotas.QUOTAS_SCHEMA,
|
||||
"cinder": cinder_quotas.CinderQuotas.QUOTAS_SCHEMA,
|
||||
"manila": manila_quotas.ManilaQuotas.QUOTAS_SCHEMA,
|
||||
"designate": designate_quotas.DesignateQuotas.QUOTAS_SCHEMA,
|
||||
"neutron": neutron_quotas.NeutronQuotas.QUOTAS_SCHEMA
|
||||
}
|
||||
@ -51,6 +53,7 @@ class Quotas(context.Context):
|
||||
self.manager = {
|
||||
"nova": nova_quotas.NovaQuotas(self.clients),
|
||||
"cinder": cinder_quotas.CinderQuotas(self.clients),
|
||||
"manila": manila_quotas.ManilaQuotas(self.clients),
|
||||
"designate": designate_quotas.DesignateQuotas(self.clients),
|
||||
"neutron": neutron_quotas.NeutronQuotas(self.clients)
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
# Copyright 2015 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context.quotas import manila_quotas
|
||||
from tests.unit import test
|
||||
|
||||
CLIENTS_CLASS = (
|
||||
"rally.plugins.openstack.context.quotas.quotas.osclients.Clients")
|
||||
|
||||
|
||||
class ManilaQuotasTestCase(test.TestCase):
|
||||
|
||||
@mock.patch(CLIENTS_CLASS)
|
||||
def test_update(self, mock_clients):
|
||||
instance = manila_quotas.ManilaQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas_values = {
|
||||
"shares": 10,
|
||||
"gigabytes": 13,
|
||||
"snapshots": 7,
|
||||
"snapshot_gigabytes": 51,
|
||||
"share_networks": 1014,
|
||||
}
|
||||
|
||||
instance.update(tenant_id, **quotas_values)
|
||||
|
||||
mock_clients.manila.return_value.quotas.update.assert_called_once_with(
|
||||
tenant_id, **quotas_values)
|
||||
|
||||
@mock.patch(CLIENTS_CLASS)
|
||||
def test_delete(self, mock_clients):
|
||||
instance = manila_quotas.ManilaQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
|
||||
instance.delete(tenant_id)
|
||||
|
||||
mock_clients.manila.return_value.quotas.delete.assert_called_once_with(
|
||||
tenant_id)
|
@ -16,13 +16,17 @@
|
||||
import copy
|
||||
import random
|
||||
|
||||
import ddt
|
||||
import jsonschema
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context.quotas import quotas
|
||||
from tests.unit import test
|
||||
|
||||
QUOTAS_PATH = "rally.plugins.openstack.context.quotas."
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class QuotasTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -261,32 +265,29 @@ class QuotasTestCase(test.TestCase):
|
||||
self.assertFalse(mock_nova_quotas.delete.called)
|
||||
self.assertFalse(mock_neutron_quota.delete.called)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context"
|
||||
".quotas.nova_quotas.NovaQuotas")
|
||||
def test_exception_during_cleanup_nova(self, mock_nova_quotas):
|
||||
@ddt.data(
|
||||
{"quotas_ctxt": {"nova": {"cpu": 1}},
|
||||
"quotas_class_path": "nova_quotas.NovaQuotas"},
|
||||
{"quotas_ctxt": {"neutron": {"network": 2}},
|
||||
"quotas_class_path": "neutron_quotas.NeutronQuotas"},
|
||||
{"quotas_ctxt": {"cinder": {"volumes": 3}},
|
||||
"quotas_class_path": "cinder_quotas.CinderQuotas"},
|
||||
{"quotas_ctxt": {"manila": {"shares": 4}},
|
||||
"quotas_class_path": "manila_quotas.ManilaQuotas"},
|
||||
{"quotas_ctxt": {"designate": {"domains": 5}},
|
||||
"quotas_class_path": "designate_quotas.DesignateQuotas"},
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_exception_during_cleanup(self, quotas_ctxt, quotas_class_path):
|
||||
with mock.patch(QUOTAS_PATH + quotas_class_path) as mock_quotas:
|
||||
mock_quotas.delete.side_effect = type(
|
||||
"ExceptionDuringCleanup", (Exception, ), {})
|
||||
|
||||
mock_nova_quotas.delete.side_effect = Exception("boom")
|
||||
ctx = copy.deepcopy(self.context)
|
||||
ctx["config"]["quotas"] = quotas_ctxt
|
||||
|
||||
ctx = copy.deepcopy(self.context)
|
||||
ctx["config"]["quotas"] = {"nova": {"cpu": 1}}
|
||||
# NOTE(boris-42): ensure that cleanup didn't raise exceptions.
|
||||
quotas.Quotas(ctx).cleanup()
|
||||
|
||||
# NOTE(boris-42): ensure that cleanup didn't raise exceptions.
|
||||
quotas.Quotas(ctx).cleanup()
|
||||
|
||||
self.assertEqual(mock_nova_quotas().delete.call_count,
|
||||
len(self.context["tenants"]))
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context"
|
||||
".quotas.neutron_quotas.NeutronQuotas")
|
||||
def test_exception_during_cleanup_neutron(self, mock_neutron_quota):
|
||||
|
||||
mock_neutron_quota.delete.side_effect = Exception("boom")
|
||||
|
||||
ctx = copy.deepcopy(self.context)
|
||||
ctx["config"]["quotas"] = {"neutron": {"cpu": 1}}
|
||||
|
||||
# NOTE(boris-42): ensure that cleanup didn't raise exceptions.
|
||||
quotas.Quotas(ctx).cleanup()
|
||||
|
||||
self.assertEqual(mock_neutron_quota().delete.call_count,
|
||||
len(self.context["tenants"]))
|
||||
self.assertEqual(mock_quotas.return_value.delete.call_count,
|
||||
len(self.context["tenants"]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user