File: utils.py

package info (click to toggle)
netplan.io 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,268 kB
  • sloc: python: 34,640; ansic: 14,096; xml: 4,989; javascript: 2,165; sh: 513; makefile: 118
file content (14 lines) | stat: -rw-r--r-- 360 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
import netplan


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 = netplan.Parser()
    parser.load_yaml(conf)
    state = netplan.State()
    state.import_parser_results(parser)
    return state