From b3e6c1ed03bc50f25d03ca8f13aa5bca7419206f Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Sat, 9 Mar 2013 17:16:27 -0500 Subject: [PATCH] trim capability prefix to allow setting single bit M-Lab has added a new ccapability to enable/disable web100 statistics collection per vserver. vserverimpl.text2ccaps() recognizes strings such as "raw_icmp", "vxc_raw_icmp", and "^28" to set a specific bit in the CCaps bit field, but it does not recognize "vxc_^28". All bcap and ccap names defined by util-vserver are recognized with or without the cap_ and vxc_ prefixes. So, this patch will allow an administrator to enable arbitrary bit fields in the CCaps or BCaps of a vserver without harming compatibility with existing capabilities. The admin would add, for example vxc_^28 or cap_^28, to the 'capabililties' slice tag and the prefixes would be stripped before being passed to text2*caps() as simply "^28". --- python/vserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/vserver.py b/python/vserver.py index c847072..b2ad6a8 100644 --- a/python/vserver.py +++ b/python/vserver.py @@ -194,7 +194,7 @@ class VServer: 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())]) + return ",".join(["%s" % (c[len(prefix):]) for c in split_caps if c.startswith(prefix.upper()) or c.startswith(prefix.lower())]) def get_bcaps_from_capabilities(self, capabilities): return self.get_prefix_from_capabilities(capabilities, "cap_") -- 2.43.0