Exemplo n.º 1
0
 def test_write(self):
     o = OpenWrt({"general": {"hostname": "test"}})
     o.write(name='test', path='/tmp')
     tar = tarfile.open('/tmp/test.tar.gz', mode='r')
     self.assertEqual(len(tar.getmembers()), 1)
     tar.close()
     os.remove('/tmp/test.tar.gz')
Exemplo n.º 2
0
 def test_write(self):
     o = OpenWrt({
         "general": {
             "hostname": "test"
         }
     })
     o.write(name='test', path='/tmp')
     tar = tarfile.open('/tmp/test.tar.gz', mode='r')
     self.assertEqual(len(tar.getmembers()), 1)
     tar.close()
     os.remove('/tmp/test.tar.gz')
Exemplo n.º 3
0
 def test_parse(self):
     o = OpenWrt({
         "type": "DeviceConfiguration",
         "general": {
             "hostname": "parse-test",
             "timezone": "UTC"
         },
     })
     o.write(self._test_file.replace('.tar.gz', ''))
     command = """netjsonconfig -n %s -b openwrt -m json""" % self._test_file
     output = subprocess.check_output(command, shell=True)
     netjson = json.loads(output.decode())
     self.assertDictEqual(o.config, netjson)
Exemplo n.º 4
0
 def test_parse_tar_file(self):
     o = OpenWrt({"general": {"hostname": "parse-tar-file"}})
     o.write(name='test', path='/tmp')
     o = OpenWrt(native=open('/tmp/test.tar.gz'))
     expected = {
         "system": [{
             ".type": "system",
             ".name": "system",
             "hostname": "parse-tar-file"
         }]
     }
     os.remove('/tmp/test.tar.gz')
     self.assertDictEqual(o.intermediate_data, expected)
def edit_backup():
    params = request.get_data()
    o = OpenWrt(params)
    o.write('backup', path='/var/opt/openmptcprouter/')
    return jsonify({'result': 'done'})