How can I start an instance in a stopped status? [closed]

asked 2013-12-26 11:42:22 -0600

SamYaple gravatar image

updated 2013-12-26 15:21:40 -0600

I want to be able to create an instance with an initial status of "SHUTOFF". More accurately I want to allocate resources on any compute node so I know what node this will start up on and have an instance id to run commands against.

I am currently using the following to achieve what I want, but it is not ideal.

nova stop $(nova boot --flavor 2 --image test --nic net-id=XXX --poll test | grep -oe "[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}")

This will start the instance and wait for the build process to be finished (thanks to the --poll option). The output is parsed by grep to search for the instance id. The instance id is then used in the nova stop $id command.


I also wanted to add why this isn't a good solution for me. This needs to be done for Horizon launched instances. They need to stop immediately after creation, or preferably be created in a shutdown state.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by koolhead17
close date 2014-06-05 08:55:12.577793

1 answer

Sort by ยป oldest newest most voted

answered 2013-12-27 10:04:12 -0600

SamYaple gravatar image

updated 2013-12-27 10:38:41 -0600

I have found a solution to this issue. It is not ideal, but it works alright for me.

When a new instance is launched, a row is added to the database at nova->instances. I setup a trigger against Inserts on the table instances that will launch an external script and stop the instance with nova stop $id and trigger our other script.

edit flag offensive delete link more


But does this actually shut the instance off on the compute node?

jtopjian gravatar imagejtopjian ( 2013-12-27 10:21:27 -0600 )edit

Good question. It looks like it doesn't. I changed the trigger to call an external script which calls the appropriate `nova stop` command as well as our other script. Thanks for the catch!

SamYaple gravatar imageSamYaple ( 2013-12-27 10:37:43 -0600 )edit

This may be a working (albeit fragile, I guess it's race-condition-prone) workaround, I think it should be asked from dev team to add such an option directly in "nova boot". Care to report that as a bug ?

vincent-legoll gravatar imagevincent-legoll ( 2015-09-29 02:02:55 -0600 )edit

wow. this takes me back. This was a while ago for sure. Its not a bug so much as a feature request and unfortunately an API change as well. Luckily the micro-api stuff should make that easier to add.

I will look into adding this in the Mitaka cycle

SamYaple gravatar imageSamYaple ( 2015-10-14 05:15:48 -0600 )edit

Thanks that would be great

vincent-legoll gravatar imagevincent-legoll ( 2015-10-14 05:45:11 -0600 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2013-12-26 11:42:22 -0600

Seen: 1,502 times

Last updated: Dec 27 '13