2

I am using Openstack Icehouse running on Ubuntu.

After rebooting Compute node all instances that were running there will be in shutoff state. Is there way to restart them all at once?

Only thing I found from the documentation was starting them individually with

nova start instance_id

which is really impractical if I have large number of instances.

Web interface Dashboard is no better. I would still have to click each instances individually to get them started.

What would be the best way to handle this?

Abhijeet Kasurde
  • 983
  • 9
  • 20
Madoc Comadrin
  • 570
  • 4
  • 11
  • 29

2 Answers2

2

Why is it impractical to use the 'nova start' command to start the instances? You don't have to do lots of typing, if that's what you're thinking. You could always pipe the output of 'nova list' to grep to find the instances you want to start, then pipe to a tool like cut, awk, sed or perl to obtain just the UUIDs, then 'nova start' each UUID. Something like:

nova list | grep SHUTOFF | cut '-d|' -fFIELDNUM | xargs nova start

  • I considered it impractical because I don't have sufficient knowledge to create command to do it and was unable to find existing ones. Example above solves that tough. – Madoc Comadrin Dec 03 '14 at 07:59
  • 1
    Suggested command needs editing to make it work. This will work: `nova list | grep SHUTOFF | cut '-d|' -f3 | xargs -I '{}' bash -c 'nova start {}'` – Madoc Comadrin Dec 03 '14 at 09:33
  • Nice work! Glad you got it working mate. – AnotherSmellyGeek Jan 02 '15 at 04:35
  • In my case I needed something like `nova list | grep SHUTOFF | cut -d '|' -f 2 | xargs -n 1 nova start`, could be due to different version: 2.17.0 that the output may be different, and for xargs I needed the `-n 1` because `nova start ` only supports one server per call. – Ray Burgemeestre Jul 13 '15 at 13:21
1
nova list | grep SHUTOFF | cut '-d|' -fFIELDNUM

as the same as

openstack server list --status SHUTOFF -f value -c ID

use one call without grep, cut and pipes.

Call to exec all instances:

openstack server list --status SHUTOFF -f value -c ID|xargs nova start
e42d3
  • 75
  • 2