Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to shutdown the vm gracefully ? #82

Closed
parthasarathi204 opened this issue Jun 5, 2017 · 4 comments
Closed

how to shutdown the vm gracefully ? #82

parthasarathi204 opened this issue Jun 5, 2017 · 4 comments

Comments

@parthasarathi204
Copy link

No description provided.

@ivandavidov
Copy link

I assume you've used the bosh2 CLI in order to provision your own bosh director VM in VirtualBox.

This is what to do in order to persist the state of any VM managed by VirtualBox:

  • Find all running VMs by issuing vboxmanage list runningvms. This will give you the list of all running VMs on your local machine. The list contains the VM name along with ID specifying the VM. You can use either the name or the ID when you issue the commands below. It's up to you to identify the VM with your running bosh director in it.
  • Pause & save the VM state by issuing vboxmanage controlvm <VM_name_or_ID> savestate. The machine's state will be persisted and when you start the VM the next time, all your settings will be exactly as they were. At this point the VM is no longer draining CPU and memory from the host machine.
  • Now you can start the VM again by issuing vboxmanage startvm <VM_name_or_ID> --type headless. The VM will be headless, i.e. the command prompt will be free to accept further commands. You can view your VM by issuing vboxmanage list runningvms.

More info here:

@jujoramos
Copy link

Hello @parthasarathi204,

You can also create a script to avoid doing this manually.
Here's the one I use (it assumes that you followed the steps to install BOSH-Lite in VirtualBox):

#!/bin/bash
set -x

WORKSPACE_DIRECTORY=~/deployments/vbox
BOSH_LITE_VM_ID=$(cat $WORKSPACE_DIRECTORY/state.json | python -c "import json,sys;obj=json.load(sys.stdin);print obj['current_vm_cid'];")

case $1 in
  ssh)
    ssh -i ~/.ssh/bosh-virtualbox.key jumpbox@192.168.50.6
    ;;
  pause)
    echo "Pausing Bosh_Lite VM with ID $BOSH_LITE_VM_ID..."
    VBoxManage controlvm $BOSH_LITE_VM_ID savestate
    echo "Pausing Bosh_Lite VM with ID $BOSH_LITE_VM_ID... Done!."
    ;;
  resume)
    echo "Resuming Bosh_Lite VM with ID $BOSH_LITE_VM_ID..."
    VBoxManage startvm $BOSH_LITE_VM_ID --type=headless
    echo "Resuming Bosh_Lite VM with ID $BOSH_LITE_VM_ID... Done!"
    ;;
  *)
    echo "Usage: bosh_vm {ssh|pause|resume}" ;;
esac

Hope it helps.
Cheers.

@aussielunix
Copy link

G`Day @parthasarathi204

I have just published my development chain for hacking on bosh locally.

There is a tutorial and the repo with @jujoramos script from above.

@parthasarathi204
Copy link
Author

Thanks for the ways given . I can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants