summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/common
diff options
context:
space:
mode:
authorhackertron <jayadityagupta11@gmail.com>2020-03-19 14:35:54 +0100
committerjay <jayadityagupta11@gmail.com>2020-04-14 22:59:52 +0200
commitb328cf74df7f94a20de85b3c0992dcb65e818458 (patch)
treef1ec12b333ae6ec57574da70e864dae87feadfa9 /openstackclient/tests/functional/common
parent8c4ecbe35dbf95ab91e693caff85132d9b881044 (diff)
downloadpython-openstackclient-b328cf74df7f94a20de85b3c0992dcb65e818458.tar.gz
Add '--force; parameter to 'openstack quota set'
The compute service allows us to to force set a quota, setting a quota value that is less than the amount of the resource currently consumed. Expose this feature by way of a '--force' boolean parameter. Change-Id: I1d1ac1ac46f49f64794ffc8631e166935537966c
Diffstat (limited to 'openstackclient/tests/functional/common')
-rw-r--r--openstackclient/tests/functional/common/test_quota.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/common/test_quota.py b/openstackclient/tests/functional/common/test_quota.py
index 9c057460..4c2fc0e3 100644
--- a/openstackclient/tests/functional/common/test_quota.py
+++ b/openstackclient/tests/functional/common/test_quota.py
@@ -165,3 +165,47 @@ class QuotaTests(base.TestCase):
# returned attributes
self.assertTrue(cmd_output["key-pairs"] >= 0)
self.assertTrue(cmd_output["snapshots"] >= 0)
+
+ def test_quota_set_force(self):
+ """Test to set instance value by force """
+ json_output = json.loads(self.openstack(
+ 'quota list -f json --detail --compute'
+ ))
+ in_use = limit = None
+ for j in json_output:
+ if j["Resource"] == "instances":
+ in_use = j["In Use"]
+ limit = j["Limit"]
+
+ # Reduce count of in_use
+ in_use = in_use - 1
+ # cannot have negative instances limit
+ if in_use < 0:
+ in_use = 0
+
+ # set the limit by force now
+ self.openstack(
+ 'quota set ' + self.PROJECT_NAME +
+ '--instances ' + str(in_use) + ' --force'
+ )
+ cmd_output = json.loads(self.openstack(
+ 'quota show -f json ' + self.PROJECT_NAME
+ ))
+ self.assertIsNotNone(cmd_output)
+ self.assertEqual(
+ in_use,
+ cmd_output["instances"]
+ )
+
+ # Set instances limit to original limit now
+ self.openstack(
+ 'quota set ' + self.PROJECT_NAME + '--instances ' + str(limit)
+ )
+ cmd_output = json.loads(self.openstack(
+ 'quota show -f json ' + self.PROJECT_NAME
+ ))
+ self.assertIsNotNone(cmd_output)
+ self.assertEqual(
+ limit,
+ cmd_output["instances"]
+ )