Warning! The OpenStack at legat.ii.pw.edu.pl is deprecated. Please see ai.ii.pw.edu.pl/net/openstack for early access to the new OpenStack deployment.
This guide describes a way to create a new OpenStack instance (virtual machine) and connect to it to perform a computational task of checking is a number is prime.
Please note that our OpenStack instance must only be used for ephemeral computational jobs due to limited hardware resources. You must free resources as soon as your workload has finished.
Old (but still useful) manual in Polish is available here.
Log in at https://legat.ii.pw.edu.pl/horizon/ with domain default
, your username and password.
Allowing SSH access
Before creating an instance, you need to allow connecting to your instances through SSH. Perform the following steps.
- Go to
Project
>Security Groups
using the sidebar on the left. - Click
Manage Rules
near thedefault
group. - Click
Add Rule
at the top of the list. - Select
SSH
underRule
and clickAdd
at the bottom.
Generate and configure SSH keys for OpenStack and sal
Due to the OpenStack network architecture instances cannot be reached directly from your computer. They can be accessed via a proxy server sal.ii.pw.edu.pl
. That’s why you need two keys. One for access to OpenStack instances and one for the sal server. Generate two keys by executing the following commands on your computer.
-N ""
causes a key to be generated without a password. If you’d like a password for your key(s), omit this part and you will be asked to provide a password.
ssh-keygen -f "~/.ssh/openstack" -N ""
ssh-keygen -f "~/.ssh/sal" -N ""
Let’s now tell your SSH client to use these keys. Create file ~/.ssh/config
and add the following contents or add them to the end of this file if it exists. Replace YOUR-USERNAME
with your OpenStack username.
The first block in this configuration tells the client to use username YOUR-USERNAME
and key ~/.ssh/sal
when connecting to the sal server.
The second block is the same, but with username ubuntu
and the respective key while connecting to OpenStack instances which have IP addresses in the form of 192.168.130.*
, where *
is any number between 1 and 255. The ProxyJump
directive tells the client to always connect to these instances via the sal server.
Host sal.ii.pw.edu.pl
User YOUR-USERNAME
IdentityFile ~/.ssh/sal
Host 192.168.130.*
User ubuntu
IdentityFile ~/.ssh/openstack
ProxyJump sal.ii.pw.edu.pl
For sal you need to add the key to the server like this. Execute this command and enter your OpenStack password.
ssh-copy-id -i ~/.ssh/sal.pub sal.ii.pw.edu.pl
For the OpenStack key you need to add the key via the web interface. Go to https://legat.ii.pw.edu.pl/horizon/ and perform the following steps.
- Go to
Project
>Compute
>Key Pairs
using the sidebar on the left. - Click
Import Public Key
. - Input any
Key Pair Name
e.g.default
. - Select
SSH Key
underKey Type
. - Specify your new key by clicking
Browse
and selecting they key~/.ssh/openstack.pub
. - Click
Import Public Key
.
Creating an instance
Now create a new OpenStack instance.
Click if you prefer CLI
SSH into sal.ii.pw.edu.pl
and run the following command.
openstack server create isprime \
--image ubuntu20.04 \
--flavor nogpu-cpu4-ram16G \
--key-name default \
--config-drive True
- Go to
Project
>Compute
>Instances
using the sidebar on the left. - Click on
Launch Instance
on the right. - Input the
Instance Name
and clickNext
. - Choose an image for instance creation by clicking the arrow next to an image. The reccomended image is
ubuntu20.04
. ClickNext
. - Choose the instance flavor based on GPU, CPUs, RAM and disk size and click
Next
. If you don’t know what to choose,nogpu-cpu4-ram16G
is a great first choice. - Default network configuration should be sufficient. Click
Next
. - Default ports configuration should be sufficient. Click
Next
. - Default security configuration should be sufficient. Click
Next
. - Move your SSH key from
Available
toAllocated
by clicking the arrow next to it. ClickNext
. - Check the
Configuration Drive
checkbox and clickLaunch Instance
. This is very important because you won’t be able to connect if you don’t check it.
Logging into the instance
After the instance is spawned (Status: Active, Power State: Running) you should be able to log in.
Run the following command, replacing the address for a correct one found in the IP Address column in the instance list in the web interface.
ssh 192.168.130.xxx
If you see a shell prompt with hostname matching your instance name you succeeded.
Now exit
the shell and let’s run some computational task.
Run a computational task
Let’s check if 45142362775469261 is a prime number. Here is a python script that tests primality of a prime number in a simple way. Let’s download it and run it on your new instance.
cat isprime.py
reads the script from your computer. Then the contents are passed through a pipe (|
) to the python3
interpreter that is launched on the instance. -
means that Python will read the script from the standard input (pipe) and 45142362775469261
is the prime we want to test.
wget https://staff.elka.pw.edu.pl/~kchachu2/openstack/user-manual/isprime.py
cat isprime.py | ssh 192.168.130.xxx python3 - 45142362775469261
The program should print True
after around 10 seconds.
Now you can generalize this guide to run your own computational jobs.
Freeing resources
Having a running instance reserves resources, so after your workload has finished you are obliged to free them so that other users can use them. If your instance is idle for a significant amount of time, you will get an email that it will be automatically killed after some time.
Freeing resources can be done two different ways. It depends on if you want to use this instance in the future (shelving) or not (deleting). Shutting off is not enough to free resources. Instance has to be either shelved or deleted.
Shelving
- Go to
Project
>Compute
>Instances
using the sidebar on the left. - Click the arrow on the right next to your instance.
- Click
Shelve Instance
.
A shelved instance can be later unshelved by clicking Unshelve Instance
in the same menu.
Deleting
- Go to
Project
>Compute
>Instances
using the sidebar on the left. - Click the arrow on the right next to your instance.
- Click
Delete Instance
.
Unshelving instances
If you shelved your unused instance you can bring it back to the Active Running
state by performing the following steps.
- Go to
Project
>Compute
>Instances
using the sidebar on the left. - Click the arrow on the right next to your instance.
- Click
Unshelve Instance
.