blob: dba1a41378317234d987b61f52003ac890bdeb88 [file] [log] [blame]
Radek Krejcib2feaac2017-09-21 13:16:54 +02001"""
2Manipulation with the YANG schemas.
3File: schemas.py
4Author: Radek Krejci <rkrejci@cesnet.cz>
5"""
6
Radek Krejci67c922d2017-09-21 13:56:41 +02007import os
8import errno
9
10from liberouterapi import config
Radek Krejcib2feaac2017-09-21 13:16:54 +020011
12from .error import NetopeerException
13
Radek Krejci2b9bbc22017-09-21 13:20:48 +020014INVENTORY = config.modules['netopeer']['usersdata_path']
15
Radek Krejcib2feaac2017-09-21 13:16:54 +020016def inventory_check(path):
17 try:
18 os.makedirs(path, mode=0o750)
19 except OSError as e:
20 if e.errno == errno.EEXIST and os.path.isdir(path):
21 pass
22 elif e.errno == errno.EEXIST:
23 raise NetopeerException('User\'s inventory (' + path + ') already exists and it\'s not a directory.')
24 else:
25 raise NetopeerException('Unable to use inventory path ' + path +' (' + str(e) + ').')
26