Skip to content

Commit

Permalink
Fuel-devops dos.py show env occurs exception
Browse files Browse the repository at this point in the history
The Environment.DoesNotExist exception will be generated
because django will not found corresponding model.
shell.py will be invoked by dos.py and
shell.py module gets 'env' by name which was passed through CI
where 'env' object shall be taken from settings
stored in database before.
If requested 'env' is not presented in database then
django lib throw exception but shell.py module
don't intercept it and it is root cause.

The Environment.DoesNotExist shall be intercepted
in shell.py in init function and reasonable message
shall be shown in this case.
We will be blocked to continue work with odd 'env'
which is not presented in database because 'env' is
shell.py public methods.
in this case we have to return error to CI and let to know
another processes that we was failed.

Closes-Bug: #1515258

Change-Id: I15c3e47867c5d4c168ae510110c46acde8933841
  • Loading branch information
krozin committed Nov 20, 2015
1 parent e307383 commit a215be8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion devops/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def __init__(self, args):
self.params = self.get_params()
if (getattr(self.params, 'name', None) and
getattr(self.params, 'command', None) != 'create'):
self.env = Environment.get(name=self.params.name)
try:
self.env = Environment.get(name=self.params.name)
except Environment.DoesNotExist:
self.env = None
sys.exit("Enviroment with name {} doesn't exist."
"".format(self.params.name))

def execute(self):
self.commands.get(self.params.command)(self)
Expand Down

0 comments on commit a215be8

Please sign in to comment.