+ return ex.message, 500, CORS_HEADER
+
+ def _update_resources(self, dc_label, compute_name):
+
+ # get URL parameters
+ params = request.args
+ # then no data
+ if params is None:
+ params = {}
+ logging.debug("REST CALL: update container resources {0}".format(params))
+ #check if container exists
+ d = dcs.get(dc_label).net.getNodeByName(compute_name)
+
+ # general request of cpu percentage
+ # create a mutable copy
+ params = params.to_dict()
+ if 'cpu_bw' in params:
+ cpu_period = int(dcs.get(dc_label).net.cpu_period)
+ value = params.get('cpu_bw')
+ cpu_quota = int(cpu_period * float(value))
+ #put default values back
+ if float(value) <= 0:
+ cpu_period = 100000
+ cpu_quota = -1
+ params['cpu_period'] = cpu_period
+ params['cpu_quota'] = cpu_quota
+ #d.updateCpuLimit(cpu_period=cpu_period, cpu_quota=cpu_quota)
+
+ # only pass allowed keys to docker
+ allowed_keys = ['blkio_weight', 'cpu_period', 'cpu_quota', 'cpu_shares', 'cpuset_cpus',
+ 'cpuset_mems', 'mem_limit', 'mem_reservation', 'memswap_limit',
+ 'kernel_memory', 'restart_policy']
+ filtered_params = {key:params[key] for key in allowed_keys if key in params}
+
+ d.update_resources(**filtered_params)
+
+ return d