Skip to content

Commit 47a0b9d

Browse files
committed
Changed handling of yang modeules from drafts with errors, to not place them in separate directories, due to possible follow-on effects. Added use of IANA-held modules when validating, and regular rsyncing from IANA.
- Legacy-Id: 14389
1 parent 8a43f7a commit 47a0b9d

6 files changed

Lines changed: 21 additions & 59 deletions

File tree

bin/daily

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ source $DTDIR/env/bin/activate
2222
# Update our information about the current version of some commands we use
2323
$DTDIR/ietf/manage.py update_external_command_info
2424

25+
# Get IANA-registered yang models
26+
YANG_IANA_DIR=$(python -c 'import ietf.settings; print ietf.settings.SUBMIT_YANG_IANA_MODEL_DIR')
27+
rsync -avz --delete rsync.ietf.org::iana/yang-parameters $YANG_IANA_DIR/
28+
2529
# Populate the yang repositories
2630
$DTDIR/ietf/manage.py populate_yang_model_dirs
2731

ietf/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def check_yang_model_directories(app_configs, **kwargs):
145145
return []
146146
#
147147
errors = []
148-
for s in ("SUBMIT_YANG_RFC_MODEL_DIR", "SUBMIT_YANG_DRAFT_MODEL_DIR", "SUBMIT_YANG_INVAL_MODEL_DIR", ):
148+
for s in ("SUBMIT_YANG_RFC_MODEL_DIR", "SUBMIT_YANG_DRAFT_MODEL_DIR", "SUBMIT_YANG_IANA_MODEL_DIR", ):
149149
p = getattr(settings, s)
150150
if not os.path.exists(p):
151151
errors.append(checks.Critical(

ietf/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,14 @@ def skip_unreadable_post(record):
677677
# they (mainly) belong. So here, SUBMIT_, rather than IDSUBMIT_
678678
SUBMIT_YANG_RFC_MODEL_DIR = '/a/www/ietf-ftp/yang/rfcmod/'
679679
SUBMIT_YANG_DRAFT_MODEL_DIR = '/a/www/ietf-ftp/yang/draftmod/'
680-
SUBMIT_YANG_INVAL_MODEL_DIR = '/a/www/ietf-ftp/yang/invalmod/'
680+
SUBMIT_YANG_IANA_MODEL_DIR = '/a/www/ietf-ftp/yang/ianamod/'
681681

682682
IDSUBMIT_REPOSITORY_PATH = INTERNET_DRAFT_PATH
683683
IDSUBMIT_STAGING_PATH = '/a/www/www6s/staging/'
684684
IDSUBMIT_STAGING_URL = '//www.ietf.org/staging/'
685685
IDSUBMIT_IDNITS_BINARY = '/a/www/ietf-datatracker/scripts/idnits'
686686
SUBMIT_PYANG_COMMAND = 'pyang --verbose --ietf -p {libs} {model}'
687-
SUBMIT_YANGLINT_COMMAND = 'yanglint --verbose -p {tmplib} -p {rfclib} -p {draftlib} -p {invallib} {model} -i'
687+
SUBMIT_YANGLINT_COMMAND = 'yanglint --verbose -p {tmplib} -p {rfclib} -p {draftlib} -p {ianalib} {model} -i'
688688
SUBMIT_YANGLINT_COMMAND = None # use the value above if you have yanglint installed
689689

690690
SUBMIT_YANG_CATALOG_MODULEARG = "modules[]={module}"

ietf/submit/checkers.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def check_file_txt(self, path):
192192
workdir,
193193
settings.SUBMIT_YANG_RFC_MODEL_DIR,
194194
settings.SUBMIT_YANG_DRAFT_MODEL_DIR,
195-
settings.SUBMIT_YANG_INVAL_MODEL_DIR,
195+
settings.SUBMIT_YANG_IANA_MODEL_DIR,
196196
])
197197
if os.path.exists(path):
198198
with open(path) as file:
@@ -230,7 +230,7 @@ def check_file_txt(self, path):
230230
command = [ w for w in cmd_template.split() if not '=' in w ][0]
231231
cmd_version = VersionInfo.objects.get(command=command).version
232232
cmd = cmd_template.format(model=path, rfclib=settings.SUBMIT_YANG_RFC_MODEL_DIR, tmplib=workdir,
233-
draftlib=settings.SUBMIT_YANG_DRAFT_MODEL_DIR, invallib=settings.SUBMIT_YANG_INVAL_MODEL_DIR, )
233+
draftlib=settings.SUBMIT_YANG_DRAFT_MODEL_DIR, ianalib=settings.SUBMIT_YANG_IANA_MODEL_DIR, )
234234
code, out, err = pipe(cmd)
235235
if code > 0 or len(err.strip()) > 0:
236236
error_lines = err.splitlines()
@@ -248,14 +248,9 @@ def check_file_txt(self, path):
248248
else:
249249
errors += 1
250250
message += "No such file: %s\nPossible mismatch between extracted xym file name and returned module name?\n" % (path)
251-
252251

253-
if errors==0 and warnings==0:
254-
dest = os.path.join(settings.SUBMIT_YANG_DRAFT_MODEL_DIR, model)
255-
shutil.move(path, dest)
256-
else:
257-
dest = os.path.join(settings.SUBMIT_YANG_INVAL_MODEL_DIR, model)
258-
shutil.move(path, dest)
252+
dest = os.path.join(settings.SUBMIT_YANG_DRAFT_MODEL_DIR, model)
253+
shutil.move(path, dest)
259254

260255
# summary result
261256
results.append({

ietf/submit/tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,24 @@ def setUp(self):
9292
self.yang_draft_model_dir = self.tempdir('yang-draft-model')
9393
settings.SUBMIT_YANG_DRAFT_MODEL_DIR = self.yang_draft_model_dir
9494

95-
self.saved_yang_inval_model_dir = settings.SUBMIT_YANG_INVAL_MODEL_DIR
96-
self.yang_inval_model_dir = self.tempdir('yang-inval-model')
97-
settings.SUBMIT_YANG_INVAL_MODEL_DIR = self.yang_inval_model_dir
95+
self.saved_yang_iana_model_dir = settings.SUBMIT_YANG_IANA_MODEL_DIR
96+
self.yang_iana_model_dir = self.tempdir('yang-iana-model')
97+
settings.SUBMIT_YANG_IANA_MODEL_DIR = self.yang_iana_model_dir
9898

9999
def tearDown(self):
100100
shutil.rmtree(self.staging_dir)
101101
shutil.rmtree(self.repository_dir)
102102
shutil.rmtree(self.archive_dir)
103103
shutil.rmtree(self.yang_rfc_model_dir)
104104
shutil.rmtree(self.yang_draft_model_dir)
105-
shutil.rmtree(self.yang_inval_model_dir)
105+
shutil.rmtree(self.yang_iana_model_dir)
106106
settings.IDSUBMIT_STAGING_PATH = self.saved_idsubmit_staging_path
107107
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
108108
settings.IDSUBMIT_REPOSITORY_PATH = self.saved_idsubmit_repository_path
109109
settings.INTERNET_DRAFT_ARCHIVE_DIR = self.saved_archive_dir
110110
settings.SUBMIT_YANG_RFC_MODEL_DIR = self.saved_yang_rfc_model_dir
111111
settings.SUBMIT_YANG_DRAFT_MODEL_DIR = self.saved_yang_draft_model_dir
112-
settings.SUBMIT_YANG_INVAL_MODEL_DIR = self.saved_yang_inval_model_dir
112+
settings.SUBMIT_YANG_IANA_MODEL_DIR = self.saved_yang_iana_model_dir
113113

114114

115115
def do_submission(self, name, rev, group=None, formats=["txt",], author=None):

ietf/utils/management/commands/populate_yang_model_dirs.py

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class Command(BaseCommand):
2020
2121
Extracts yang models from RFCs (found in settings.RFC_PATH and places
2222
them in settings.SUBMIT_YANG_RFC_MODEL_DIR, and from active drafts, placed in
23-
settings.SUBMIT_YANG_DRAFT_MODEL_DIR if valid and settings.SUBMIT_YANG_INVAL_MODEL_DIR
24-
if not.
23+
settings.SUBMIT_YANG_DRAFT_MODEL_DIR.
2524
2625
"""
2726

@@ -142,14 +141,14 @@ def active(item):
142141
for item in draftdir.iterdir():
143142
try:
144143
if item.is_file() and item.name.startswith('draft') and item.name.endswith('.txt') and active(item):
145-
model_list = extract_from(item, moddir)
144+
model_list = extract_from(item, moddir, strict=False)
146145
for name in model_list:
147146
if not name.startswith('example'):
148147
if verbosity > 1:
149-
print(" Extracted valid module from %s: %s" % (item, name))
148+
print(" Extracted module from %s: %s" % (item, name))
150149
else:
151-
sys.stdout.write('.')
152-
sys.stdout.flush()
150+
sys.stdout.write('.')
151+
sys.stdout.flush()
153152
else:
154153
modfile = moddir / name
155154
modfile.unlink()
@@ -161,39 +160,3 @@ def active(item):
161160
sys.stderr.write('\n')
162161
print("")
163162

164-
# Extract invalid modules from drafts
165-
valdir = moddir
166-
moddir = Path(settings.SUBMIT_YANG_INVAL_MODEL_DIR)
167-
if not moddir.exists():
168-
moddir.mkdir(parents=True)
169-
print("Emptying %s ..." % moddir)
170-
for item in moddir.iterdir():
171-
item.unlink()
172-
173-
print("Extracting to %s ..." % moddir)
174-
for item in draftdir.iterdir():
175-
try:
176-
if item.is_file() and item.name.startswith('draft') and item.name.endswith('.txt') and active(item):
177-
model_list = extract_from(item, moddir, strict=False)
178-
for name in model_list:
179-
modfile = moddir / name
180-
if (valdir/name).exists():
181-
modfile.unlink()
182-
if verbosity > 1:
183-
print(" Skipped valid module from %s: %s" % (item, name))
184-
elif not name.startswith('example'):
185-
if verbosity > 1:
186-
print(" Extracted invalid module from %s: %s" % (item, name))
187-
else:
188-
sys.stdout.write('.')
189-
sys.stdout.flush()
190-
else:
191-
modfile.unlink()
192-
if verbosity > 1:
193-
print(" Skipped module from %s: %s" % (item, name))
194-
except UnicodeDecodeError as e:
195-
sys.stderr.write('\nError: %s\n' % (e, ))
196-
sys.stderr.write(item.name)
197-
sys.stderr.write('\n')
198-
199-
print("")

0 commit comments

Comments
 (0)