File: utils.py

package info (click to toggle)
netplan.io 0.106-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,896 kB
  • sloc: python: 23,210; ansic: 11,382; xml: 4,600; sh: 225; makefile: 190
file content (14 lines) | stat: -rw-r--r-- 391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
import netplan.libnetplan as libnetplan


def state_from_yaml(confdir, yaml, filename="a.yml"):
    os.makedirs(confdir, exist_ok=True)
    conf = os.path.join(confdir, filename)
    with open(conf, "w+") as f:
        f.write(yaml)
    parser = libnetplan.Parser()
    parser.load_yaml(conf)
    state = libnetplan.State()
    state.import_parser_results(parser)
    return state