From 0212c62c3445be54ca2dc033298a817e392c03ba Mon Sep 17 00:00:00 2001 From: Jordan Singleton Date: Wed, 9 Sep 2015 15:11:28 -0400 Subject: [PATCH] initialize correctly on disk --- dusty/commands/disk.py | 6 +++--- dusty/systems/virtualbox/__init__.py | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dusty/commands/disk.py b/dusty/commands/disk.py index 8380889d..42caa59e 100644 --- a/dusty/commands/disk.py +++ b/dusty/commands/disk.py @@ -6,7 +6,7 @@ from ..log import log_to_client from ..path import dir_modified_time, set_mac_user_ownership from ..systems.docker.cleanup import remove_exited_dusty_containers, remove_images -from ..systems.virtualbox import get_docker_vm_disk_info, ensure_docker_vm_is_started +from ..systems.virtualbox import get_docker_vm_disk_info, ensure_docker_vm_is_started, initialize_docker_vm from ..systems.rsync import sync_local_path_to_vm, sync_local_path_from_vm from ..payload import daemon_command @@ -41,7 +41,7 @@ def _ensure_backup_dir_exists(destination_path): def backup(path): destination_path = _full_destination_dir(path) _ensure_backup_dir_exists(destination_path) - ensure_docker_vm_is_started() + initialize_docker_vm() log_to_client("Syncing data from your VM to {}...".format(destination_path)) sync_local_path_from_vm(destination_path, constants.VM_PERSIST_DIR) set_mac_user_ownership(destination_path) @@ -51,6 +51,6 @@ def restore(source_path): if not os.path.exists(source_path): log_to_client("Can't find backup data to restore at {}".format(source_path)) return - ensure_docker_vm_is_started() + initialize_docker_vm() log_to_client("Restoring your backup last modified at {}".format(dir_modified_time(source_path))) sync_local_path_to_vm(source_path, constants.VM_PERSIST_DIR) diff --git a/dusty/systems/virtualbox/__init__.py b/dusty/systems/virtualbox/__init__.py index 4cf36ed0..02bd5a23 100644 --- a/dusty/systems/virtualbox/__init__.py +++ b/dusty/systems/virtualbox/__init__.py @@ -64,12 +64,9 @@ def _init_docker_vm(): check_call_demoted(['docker-machine', 'create'] + machine_options + [constants.VM_MACHINE_NAME], redirect_stderr=True) -def _docker_vm_is_running(): - return check_output_demoted(['docker-machine', 'status', constants.VM_MACHINE_NAME]).rstrip() == 'Running' - def _start_docker_vm(): """Start the Dusty VM if it is not already running.""" - if not _docker_vm_is_running(): + if not docker_vm_is_running(): logging.info('Starting docker-machine VM {}'.format(constants.VM_MACHINE_NAME)) check_and_log_output_and_error_demoted(['docker-machine', 'start', constants.VM_MACHINE_NAME], quiet_on_success=True)