- # For every resource key listed in the limit table, add in a
- # new method with which one can get/set the resource's hard,
- # soft, minimum limits.
- limits = {"CPU": RLIMIT_CPU,
- "RSS": RLIMIT_RSS,
- "NPROC": RLIMIT_NPROC,
- "NOFILE": RLIMIT_NOFILE,
- "MEMLOCK": RLIMIT_MEMLOCK,
- "AS": RLIMIT_AS,
- "LOCKS": RLIMIT_LOCKS,
- "SIGPENDING": RLIMIT_SIGPENDING,
- "MSGQUEUE": RLIMIT_MSGQUEUE,
- "NSOCK": VLIMIT_NSOCK,
- "OPENFD": VLIMIT_OPENFD,
- "ANON": VLIMIT_ANON,
- "SHMEM": VLIMIT_SHMEM}
- for meth in limits.keys():
- resource_type = limits[meth]
- func = lambda \
- hard=VC_LIM_KEEP,\
- soft=VC_LIM_KEEP,\
- minimum=VC_LIM_KEEP:\
- self.__set_vserver_limit(resource_type,\
- hard, \
- soft,\
- minimum)
- self.__dict__["set_%s_limit"%meth] = func
-
- func = lambda \
- hard=VC_LIM_KEEP,\
- soft=VC_LIM_KEEP,\
- minimum=VC_LIM_KEEP:\
- self.__set_vserver_config(meth, resource_type, \
- hard, \
- soft,\
- minimum)
- self.__dict__["set_%s_config"%meth] = func
-
- func = lambda : self.__get_vserver_limit(resource_type)
- self.__dict__["get_%s_limit"%meth] = func
-
- func = lambda : self.__get_vserver_config(meth,resource_type)
- self.__dict__["get_%s_config"%meth] = func
-