Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Ensured the container is created when running provision or shell subc…
Browse files Browse the repository at this point in the history
…ommands
  • Loading branch information
Morgan Aubert committed Apr 4, 2017
1 parent 17f5aae commit f557419
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lxdock/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
logger = logging.getLogger(__name__)


def must_be_running(method):
def must_be_created_and_running(method):
@wraps(method)
def wrapper(self, *args, **kwargs):
if not self.is_running:
if not self.exists:
logger.error('The container is not created.')
return
elif not self.is_running:
logger.error('The container is not running.')
return
return method(self, *args, **kwargs)
Expand Down Expand Up @@ -74,7 +77,7 @@ def halt(self):
logger.warn("Can't stop the container. Forcing...")
self._container.stop(force=True, wait=True)

@must_be_running
@must_be_created_and_running
def provision(self, barebone=None):
""" Provisions the container. """
# We run this in case our lxdock.yml config was modified since our last `lxdock up`.
Expand Down Expand Up @@ -104,7 +107,7 @@ def provision(self, barebone=None):
self._container.config['user.lxdock.provisioned'] = 'true'
self._container.save(wait=True)

@must_be_running
@must_be_created_and_running
def shell(self, username=None):
""" Opens a new interactive shell in the container. """
# We run this in case our lxdock.yml config was modified since our last `lxdock up`.
Expand Down

0 comments on commit f557419

Please sign in to comment.