aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mchucarr...@apache.org
Subject git commit: AURORA-108: make set_quota in aurora_admin require explicit units
Date Fri, 31 Jan 2014 19:47:24 GMT
Updated Branches:
  refs/heads/master a6f78b2e0 -> 4abccc3c0


AURORA-108: make set_quota in aurora_admin require explicit units

set_quota now requies a specific unit (M or G) as input.

This means that arguments to set_quote should resemble the following:
    set_quota(<cluster>, <role>, <cpu>, '50M', '20G')
    set_quota(<cluster>, <role>, <cpu>, '50G', '20G')

Testing Done:
Passes local tests. I could not find a test that tests the quota for the cli client so this
patch does not contain an dedicated test case.

Bugs closed: AURORA-136

Reviewed at https://reviews.apache.org/r/17581/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/4abccc3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/4abccc3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/4abccc3c

Branch: refs/heads/master
Commit: 4abccc3c01d2b41e2d464bf0be29fa51f986d6b0
Parents: a6f78b2
Author: Dan Norris <protochron@gmail.com>
Authored: Fri Jan 31 14:41:24 2014 -0500
Committer: Mark Chu-Carroll <mchucarroll@twitter.com>
Committed: Fri Jan 31 14:41:24 2014 -0500

----------------------------------------------------------------------
 .../python/apache/aurora/client/api/__init__.py     |  8 ++++----
 .../python/apache/aurora/client/commands/admin.py   | 16 +++++++++++-----
 2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4abccc3c/src/main/python/apache/aurora/client/api/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/__init__.py b/src/main/python/apache/aurora/client/api/__init__.py
index f829003..fbdf2b3 100644
--- a/src/main/python/apache/aurora/client/api/__init__.py
+++ b/src/main/python/apache/aurora/client/api/__init__.py
@@ -158,10 +158,10 @@ class AuroraClientAPI(object):
     log.info("Getting quota for: %s" % role)
     return self._scheduler_proxy.getQuota(role)
 
-  def set_quota(self, role, cpu, ram_mb, disk_mb):
-    log.info("Setting quota for user:%s cpu:%f ram_mb:%d disk_mb: %d"
-              % (role, cpu, ram_mb, disk_mb))
-    return self._scheduler_proxy.setQuota(role, Quota(cpu, ram_mb, disk_mb))
+  def set_quota(self, role, cpu, ram, disk):
+    log.info("Setting quota for user:%s cpu:%f ram:%d disk: %d"
+              % (role, cpu, ram, disk))
+    return self._scheduler_proxy.setQuota(role, Quota(cpu, ram, disk))
 
   def force_task_state(self, task_id, status):
     log.info("Requesting that task %s transition to state %s" % (task_id, status))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4abccc3c/src/main/python/apache/aurora/client/commands/admin.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/commands/admin.py b/src/main/python/apache/aurora/client/commands/admin.py
index 6d191f4..d8b9a44 100644
--- a/src/main/python/apache/aurora/client/commands/admin.py
+++ b/src/main/python/apache/aurora/client/commands/admin.py
@@ -161,16 +161,22 @@ def query(args, options):
 
 
 @app.command
-@requires.exactly('cluster', 'role', 'cpu', 'ramMb', 'diskMb')
-def set_quota(cluster, role, cpu_str, ram_mb_str, disk_mb_str):
-  """usage: set_quota cluster role cpu ramMb diskMb
+@requires.exactly('cluster', 'role', 'cpu', 'ram', 'disk')
+def set_quota(cluster, role, cpu_str, ram, disk):
+  """usage: set_quota cluster role cpu ram[MGT] disk[MGT]
 
   Alters the amount of production quota allocated to a user.
   """
   try:
+      ram_size = parse_data(ram).as_(Data.MB)
+      disk_size = parse_data(disk).as_(Data.MB)
+  except ValueError:
+      log.error('Invalid unit specification')
+
+  try:
     cpu = float(cpu_str)
-    ram_mb = int(ram_mb_str)
-    disk_mb = int(disk_mb_str)
+    ram_mb = int(ram_size)
+    disk_mb = int(disk_size)
   except ValueError:
     log.error('Invalid value')
 


Mime
View raw message