Working with the selvpc Console Clients

A selvpc console application based on the python-cliff framework is provided together with the python-selvpcclient library for working with the Selectel Cloud platform.

The selvpc utility allows you to work with the Cloud Config API and manage projects, quotas, and users to get started with the Cloud platform resources. All further actions with virtual machines, volumes, images, and other resources are performed through the OpenStack API and the OpenStack console clients.

Installation

To work with selvpc CLI, configure access to the project from the local system:

  1. Create an API token according to the API Keys article.
  2. Get the current API URL of the https://api.selectel.ru/vpc/resell/v2 format.
  3. Set environment variables:

    export SEL_TOKEN=token
    export SEL_URL=api_url
    export SEL_API_VERSION=api_version

    Example:

    export SEL_TOKEN=3sDasKl7HetVaKfz7tLOLFDm4_123456
    export SEL_URL=https://api.selectel.ru/vpc/resell
    export SEL_API_VERSION=2
  4. Install the python-selvpcclient library by running the following command:

    pip install python-selvpcclient

After configuring the authentication parameters, you can run the selvpc utility.

Working with selvpc

Selvpc commands look as follows:

selvpc <object> <command> [arguments...]

A full list of commands and arguments can be found in the python-selvpcclient documentation on GitHub.

Creating a Project

To create a project, run the following command:

selvpc project create --name <project name>

The output will look as follows:

+---------+----------------------------------+
| Field   | Value                            |
+---------+----------------------------------+
| id      | 1a0e275a4e1f408074f4f685e662da7c |
| name    | project                          |
| url     | https://123456.selvpc.ru         |
| enabled | True                             |
+---------+----------------------------------+

Creating a User

To create a user, run:

selvpc user create --name <username> --password <password>
+---------+----------------------------------+
| Field   | Value                            |
+---------+----------------------------------+
| id      | 00c41ee8561445bc8bb604316d5d096d |
| name    | user                             |
| enabled | True                             |
+---------+----------------------------------+

Adding a User to the Project

To add a user to a project, run:

selvpc role create -p <project ID> -u <user ID>

Example:

selvpc role create -p 1a0e275a4e1f408074f4f685e662da7c -u 00c41ee8561445bc8bb604316d5d096d

+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| project_id | 1a0e275a4e1f408074f4f685e662da7c |
| user_id    | 00c41ee8561445bc8bb604316d5d096d |
+------------+----------------------------------+

SSH Key

You can use an SSH key to connect to virtual machines via SSH.

In the Control panel on the Access tab, SSH keys are added for the project, not for the user, so they may not be displayed when using the openstack keypair list utility. In this case, you can create a user in the project and add a key to them, or use the selvpc console client to create keys.

To create an SSH key, run:

selvpc keypair add --name <keypair name> --user <user ID> --key <file>

To view a list of created keys:

selvpc keypair list

Now, when creating a new cloud server through the OpenStack CLI, you can add this key as the --key-name argument.

To delete the key, run:

selvpc keypair delete <keypair name> ... --user <user ID> --yes-i-really-want-to-delete