- def get_rlimit_limit(self,type):
- """Generic get resource configuration function for vserver"""
- global RLIMITS
- resource_type = RLIMITS[type]
- try:
- ret = vserverimpl.getrlimit(self.ctx,resource_type)
- except OSError, e:
- self.log("Unexpected error with getrlimit for context %d" % self.ctx)
- ret = self.get_rlimit_config(type)
- return ret
+ if self.is_running() and update:
+ resource_type = RLIMITS[type]
+ try:
+ vserverimpl.setrlimit(self.ctx, resource_type, hard, soft, min)
+ if hasattr(resource, 'RLIMIT_' + type):
+ lim = resource.getrlimit(resource_type)
+ lim = adjust_lim((hard, soft, min), lim)
+ resource.setrlimit(resource_type, lim)
+ except OSError, e:
+ self.log("Error: setrlimit(%d, %s, %d, %d, %d): %s"
+ % (self.ctx, type.lower(), hard, soft, min))
+
+ return update
+
+ def get_prefix_from_capabilities(self, capabilities, prefix):
+ split_caps = capabilities.split(',')
+ return ",".join(["%s" % (c) for c in split_caps if c.startswith(prefix.upper()) or c.startswith(prefix.lower())])