Check for migration branch dir

Currently, neutron_migrations_facts ensures the migrations dir exists,
but doesn't check if the branch dir for the given release exists.  This
commit updates neutron_migrations_facts to handle cases where a branch
dir may not exist (as is the case on mitaka).

Change-Id: I4b0d15ae6a0c2a840e66f81994f0956382130abc
Closes-Bug: #1527582
This commit is contained in:
Matt Thompson 2015-12-18 12:02:28 +00:00 committed by Jesse Pretorius
parent 1f2c572574
commit 209b11a63b

View File

@ -139,9 +139,13 @@ def get_branch(release, revision, library_path, project):
migration_dir = os.path.join(
get_abs_path(migrations_dir), branch
)
for file in os.listdir(migration_dir):
if file.endswith('.py') and file.split('_')[0] == revision:
return branch
# If a release has no migrations for a given branch, the branch
# directory will not exist.
if os.path.isdir(migration_dir):
for file in os.listdir(migration_dir):
if (file.endswith('.py') and
file.split('_')[0] == revision):
return branch
def get_abs_path(path):