Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #279 from gamechanger/js-disk-ensures-vm-running
Browse files Browse the repository at this point in the history
ensure vm is started before disk commands
  • Loading branch information
jsingle committed Jun 23, 2015
2 parents b8f28dc + 278769f commit 035e8c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 7 additions & 1 deletion dusty/commands/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@

from ..log import log_to_client
from ..systems.docker.cleanup import remove_exited_dusty_containers, remove_images
from ..systems.virtualbox import get_docker_vm_disk_info
from ..systems.virtualbox import get_docker_vm_disk_info, ensure_docker_vm_is_started

def cleanup_inactive_containers():
log_to_client("Ensuring virtualbox vm is running")
ensure_docker_vm_is_started()
log_to_client("Cleaning up exited containers:")
containers = remove_exited_dusty_containers()
log_to_client("Done cleaning {} containers".format(len(containers)))

def cleanup_images():
log_to_client("Ensuring virtualbox vm is running")
ensure_docker_vm_is_started()
log_to_client("Cleaning up docker images without containers:")
images = remove_images()
log_to_client("Done removing {} images".format(len(images)))

def inspect_vm_disk():
log_to_client("Ensuring virtualbox vm is running")
ensure_docker_vm_is_started()
log_to_client("Boot2Docker VM Disk Usage:")
log_to_client(get_docker_vm_disk_info())

11 changes: 7 additions & 4 deletions dusty/systems/virtualbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ def _ensure_cp_dir_exists():
mkdir_if_cmd = 'if [ ! -d {0} ]; then sudo mkdir {0}; fi'.format(constants.VM_CP_DIR)
check_and_log_output_and_error_demoted(['boot2docker', 'ssh', mkdir_if_cmd])

def _ensure_docker_vm_exists():
def _init_docker_vm():
"""Initialize the boot2docker VM if it does not already exist."""
logging.info('Initializing boot2docker, this will take a while the first time it runs')
check_call_demoted(['boot2docker', 'init'], redirect_stderr=True)

def _ensure_docker_vm_is_started():
def _start_docker_vm():
"""Start the boot2docker VM if it is not already running."""
logging.info('Making sure the boot2docker VM is started')
check_call_demoted(['boot2docker', 'start'], redirect_stderr=True)

def ensure_docker_vm_is_started():
_init_docker_vm()
_start_docker_vm()

def initialize_docker_vm():
_ensure_docker_vm_exists()
_ensure_docker_vm_is_started()
ensure_docker_vm_is_started()
_ensure_rsync_is_installed()
_ensure_persist_dir_is_linked()
_ensure_cp_dir_exists()
Expand Down

0 comments on commit 035e8c0

Please sign in to comment.