blob: 3bb0d238c46d6181eeffe477c85743954600c3c9 [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 Krejcid1fa33b2017-10-17 14:41:36 +020014INVENTORY = config['netopeer'].get('usersdata_path', './')
Radek Krejci2b9bbc22017-09-21 13:20:48 +020015
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