Improving novaclient CLI. Boot server with specific key.

Before now there was only one way to specify ssh-key when booting a new server: by passing path to the public key file in the local machine (if you don’t specify that path then taking public key file from the /home/.ssh/ directory occurs). That way you couldn’t use keypairs which you have created earlier by nova add-keypair command. But starting from now you can do it!

$ nova boot <server_name> --image <image_id> --flavor <flavor_id> [--key_path [<path_to_the_public_key>], --key_name <keypair_name>]

As you can see you are free to use both methods (old and new) and it is up to you what the way you go.

Here is a sample sequence of commands to work with the new feature:

$ nova keypair-add key1 > private_key_file — save returned private key to the file.

$ chmod 600 private_key_file — only owner shoud have access to the private key (-rw-------).

$ nova boot <server_name> --image 3 --flavor 1 --key_name key1 — boot new server with specified image id, flavor id and also inject previously created private key by its name.

$ nova list – show available servers. Check the status of the newly created server and if it is BUILD (creating in progress) perform this command until the status becomes ACTIVE. After that you can connect to the server by ssh. Let’s say servers’s ip is 172.30.254.4 (You can find out ip from the same table as the status).

$ ssh -i private_key_file root@172.30.254.4 — it is done — you are in the created server’s shell.

You can see sources on

https://github.com/griddynamics/osc-robot-python-novaclient

or binaries for RHEL

http://yum.griddynamics.net/yum/diablo/

and for CentOS

http://yum.griddynamics.net/yum/diablo-centos/

2 thoughts on “Improving novaclient CLI. Boot server with specific key.

  1. Андрей Клочков

    What version of OpenStack does support “nova add-keypairs” command? I’m trying to use it with Diablo release, getting “‘add-keypairs’ is not a valid subcommand”. Also there’s no “–key-name” parameter for “boot” command in my version.

    Reply
    1. Pavel Shkitin Post author

      All our changes are accessible from the repositories mentioned above. But some command options described in this post were changed during pull request acceptance. We fixed command examples in the text. Thanks for pointing that. The command “nova add-keypairs” is named as “nova keypair-add” now.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s