def nat64(self, **kwargs): ''' nat64 getter and setter format: { "enable": True, "ipv6": "64:ff9b::", "ipv6_prefix": 96, "ipv4": "0.0.0.0" } ''' import libs.login if False == libs.login.cklogin(): raise _.HTTPRedirect('/') import ml_w_nat64 as nat64 import json import libs.tools if "nat64" in kwargs: # setter res = {"enable": "enable" in kwargs, "ipv6": kwargs["ipv6"], "ipv6_prefix": kwargs["ipv6_prefix"], "ipv4": kwargs["ipv4"]} res = nat64.set(user = self.getUser(), cfg = res) if False == res[0]: return json.dumps([res[0], libs.tools.translateMessage(res[1])]) else: return json.dumps(res) else: # getter return json.dumps(nat64.get())
def test_nat64_g01(self): """ nat64_g01 """ if "json" == ml_system.CFG_TYPE: shutil.copyfile(os.path.join("unittest", "nat64-g01.json"), os.path.join("running", "nat64.txt")) if "jcfg" == ml_system.CFG_TYPE: shutil.copyfile(os.path.join("unittest", "nat64-g01.jcfg"), os.path.join("running", "nat64.txt")) if "pickle" == ml_system.CFG_TYPE: return self.maxDiff = None e = ml_w_nat64.get(None, threading.RLock()) self.assertEqual(e, (True, { "enable": True, "ipv6": "64:ff9b::", "ipv6_prefix": 96, "ipv4": "0.0.0.0" }))