Stopping an instance

Sometimes, an instance will need to be stopped for a number of reasons, for example, maintenance and offline migration, yet as an OpenStack administrator, you may not want to completely destroy the instance and data associated with it. Thus, you will want to stop the instance instead.

Getting ready

To stop an instance, you will need the following:

  • The openstack command-line client
  • The openrc file containing appropriate credentials
  • The name of the instance

How to do it…

In this example, we will be stopping the cookbook.test instance created in the Booting an instance recipe. To stop the instance, use the following steps:

  1. First, we list the running instances:
    openstack server list
    

    This will bring back a list of the running instances. Consider this example:

    How to do it…
  2. To stop the instance, simply issue the following command:
    openstack server stop cookbook.test
    

    Tip

    This command takes a few moments to complete and will not display the output if successful.

  3. Now list instances to confirm the status of the instances. Here we're looking for the states of SHUTOFF for our cookbook.test instance:
    openstack server list
    

    This gives the following output:

    How to do it…

How it works…

To stop an instance we use the openstack client's server stop command: openstack server stop [Name or ID]. This tells Nova to power off the instance. This is synonymous to holding the power button on your laptop, or unplugging a server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.31.41