Export Image

You can export an image on both Windows OS and Linux OS by following the steps below.

Prerequisite

  • ต้องมี image อยู่ใน project

If you want to export using Windows OS, follow these steps:

  1. Download & Install Python

    • Download Python from this link: https://www.python.org/ftp/python/3.13.3/python-3.13.3-amd64.exe

    • Check the box for "Add python.exe to PATH" and click "Install Now".

  2. Test if Python is working correctly by opening cmd and running the following command:

C:\Users\OhmzPC>python --version
Python 3.13.3
  1. Create a venv to use for the OpenStack client.

C:\Users\OhmzPC>cd Documents

C:\Users\OhmzPC\Documents>mkdir Export_Image

C:\Users\OhmzPC\Documents>cd Export_Image

C:\Users\OhmzPC\Documents\Export_Image>python -m venv osclient

C:\Users\OhmzPC\Documents\Export_Image>osclient\Scripts\activate

(osclient) C:\Users\OhmzPC\Documents\Export_Image>pip install --upgrade pip
Requirement already satisfied: pip in c:\users\ohmzpc\documents\export_image\osclient\lib\site-packages (25.0.1)

(osclient) C:\Users\OhmzPC\Documents\Export_Image>pip install python-openstackclient

(osclient) C:\Users\OhmzPC\Documents\Export_Image>openstack --version
openstack 8.0.0
  1. Download your Public API RC File.

  1. Modify the RC file from .sh to .bat

  • Change #!/usr/bin/env bash to @echo off

  • Change # to rem

  • Change export to set

  • Change if [ -z "$<Variable>" ]; then unset <Variable>; fi to if "%<Variable>%"=="" set <Variable>=

    • Example: if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi becomes if "%OS_USER_DOMAIN_NAME%"=="" set OS_USER_DOMAIN_NAME=

  • Change read -sr OS_PASSWORD_INPUT to set /p OS_PASSWORD_INPUT=

  • Open the file in a text editor to make these changes. For example: notepad your_project_RC_file.bat

From (osclient) C:\Users\OhmzPC\Documents\Export_Image>notepad test_project_RC_file.sh

#!/usr/bin/env bash
# To use NIPA Cloud Space public API you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/project has
# access to - such as Compute Instance, Compute Image, Block Storage, Networking.

export OS_AUTH_URL=https://identity-api.nipa.cloud/
# Co-working project identity
export OS_PROJECT_ID=834995e704b44fa888b7xxxxxxxxxxxx
export OS_PROJECT_NAME="test_project"
export OS_USER_DOMAIN_NAME="nipacloud"
if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi
export OS_PROJECT_DOMAIN_ID="c6b00adf4ed04fc5a958121fadb0e401"
if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi
# unset v2.0 items in case set
unset OS_TENANT_ID
unset OS_TENANT_NAME
# performing the action as the **user**.
export OS_USERNAME="test_user@nipa.cloud"
echo "Please enter your NIPA Cloud Space user's password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
# NIPA Cloud Space only have 1 region "NCP-TH"
export OS_REGION_NAME="NCP-TH"
# Don't leave a blank variable, unset it if it was empty
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3

To (osclient) C:\Users\OhmzPC\Documents\Export_Image>notepad test_project_RC_file.bat

@echo off
rem To use NIPA Cloud Space public API you need to authenticate against the Identity
rem service named keystone, which returns a **Token** and **Service Catalog**.
rem The catalog contains the endpoints for all services the user/project has
rem access to - such as Compute Instance, Compute Image, Block Storage, Networking.

set OS_AUTH_URL=https://identity-api.nipa.cloud/
rem Co-working project identity
set OS_PROJECT_ID=834995e704b44fa888b7xxxxxxxxxxxx
set OS_PROJECT_NAME=test_project
set OS_USER_DOMAIN_NAME=nipacloud
if "%OS_USER_DOMAIN_NAME%"=="" set OS_USER_DOMAIN_NAME=
set OS_PROJECT_DOMAIN_ID=c6b00adf4ed04fc5a958121fadb0e401
if "%OS_PROJECT_DOMAIN_ID%"=="" set OS_PROJECT_DOMAIN_ID=
rem unset v2.0 items in case set
set OS_TENANT_ID=
set OS_TENANT_NAME=
rem performing the action as the **user**.
set OS_USERNAME=test_user@nipa.cloud
echo Please enter your NIPA Cloud Space user's password for project %OS_PROJECT_NAME% as user %OS_USERNAME%:
set /p OS_PASSWORD_INPUT= 
set OS_PASSWORD=%OS_PASSWORD_INPUT%
rem NIPA Cloud Space only have 1 region "NCP-TH"
set OS_REGION_NAME=NCP-TH
rem Don't leave a blank variable, unset it if it was empty
if "%OS_REGION_NAME%"=="" set OS_REGION_NAME=
set OS_INTERFACE=public
set OS_IDENTITY_API_VERSION=3
  1. Run the .bat file and check if you can use the OpenStack client in your project.

(osclient) C:\Users\OhmzPC\Documents\Export_Image>test_project_RC_file.bat
Please enter your NIPA Cloud Space user's password for project test_project as user test_user@nipa.cloud: <ใส่ password>
(osclient) C:\Users\OhmzPC\Documents\Export_Image>openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field      | Value                                                                                                                                                                                   |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires    | 2025-04-26T03:59:41+0000                                                                                                                                                                |
| id         | gAAAAABoCwithNSV3tPsaDzi54VvrSxIz6V9rreRJBurlVV2e4Ii5aolilEBRWtUnargn4iKPu8ru-Rt0XqXJl3HHs1x5ZzmH-oM-XQoFRRi7ov_ofiuhryudjdbvSmKHX7d0ZsrEOIvrbCkAqH4gnPNlpsbNc6dnnY5P1s5vmqDrXsOAOB9ywY |
| project_id | 834995e704b44fa888b7xxxxxxxxxxxx                                                                                                                                                     |
| user_id    | e6275119d15648bfb7c2xxxxxxxxxxxx                                                                                                                                                        |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  1. List the images in your project with the command:

(osclient) C:\Users\OhmzPC\Documents\Export_Image>openstack image list
+--------------------------------------+--------------------------------------+--------+
| ID                                   | Name                                 | Status |
+--------------------------------------+--------------------------------------+--------+
| d00037bf-85f6-4bc3-b271-xxxxxxxxxxxx | ubuntu-24-v250307                    | active |
+--------------------------------------+--------------------------------------+--------+
  1. Download the desired image from your project with the command:

(osclient) C:\Users\OhmzPC\Documents\Export_Image>openstack image save --file <ชื่อ file image>.qcow2 <image_ID>

ตัวอย่าง
(osclient) C:\Users\OhmzPC\Documents\Export_Image>openstack image save --file ubuntu-24-v250307.qcow2 d00037bf-85f6-4bc3-b271-xxxxxxxxxxxx
  1. Once the download is complete, you will have the image file.

(osclient) C:\Users\OhmzPC\Documents\Export_Image>dir
 Volume in drive C is Windows
 Volume Serial Number is XXXX-XXXX

 Directory of C:\Users\OhmzPC\Documents\Export_Image

04/25/2025  11:08 AM    <DIR>          .
04/25/2025  10:43 AM    <DIR>          ..
04/25/2025  10:57 AM             1,270 test_project_RC_file.bat
04/25/2025  10:49 AM             1,343 test_project_RC_file.sh
04/25/2025  10:51 AM    <DIR>          osclient
04/25/2025  11:09 AM     1,243,992,064 ubuntu-24-v250307.qcow2
               3 File(s)  1,243,994,677 bytes
               3 Dir(s)  326,236,172,288 bytes free

If you want to export using Linux, follow these steps:

First, prepare the environment for your specific OS.

For macOS:

  1. Download & Install Python.

1.1 Install Homebrew (if not already installed).

$ /bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"

1.2 Install Python via Homebrew.

$ brew update
$ brew install python3

1.3 Test if Python is working correctly with the command:

$ python3 --version
Python 3.12.3
  1. Create a venv to use for the OpenStack client.

$ cd ~/
$ python3 -m venv osclient
$ source osclient/bin/activate
(osclient) $ pip install --upgrade pip
(osclient) $ pip install python-openstackclient
(osclient) $ openstack --version
openstack 8.0.0

For Ubuntu/Debian:

  1. Download & Install Python.

root@test-export-image:~# apt update -y
root@test-export-image:~# apt install -y python3 python3-pip python3-venv
  1. Test if Python is working correctly with the command:

root@test-export-image:~# python3 --version
Python 3.12.3
  1. Create a venv to use for the OpenStack client.

root@test-export-image:~# mkdir /opt/osclient
root@test-export-image:~# cd /opt/osclient/
root@test-export-image:/opt/osclient# python3 -m venv osclient
root@test-export-image:/opt/osclient# source /opt/osclient/osclient/bin/activate
(osclient) root@test-export-image:/opt/osclient# pip install --upgrade pip
(osclient) root@test-export-image:/opt/osclient# pip install python-openstackclient
(osclient) root@test-export-image:/opt/osclient# openstack --version
openstack 8.0.0

For Rocky/AlmaLinux:

  1. Download & Install Python.

[root@test-export-image ~]# yum update -y
[root@test-export-image ~]# yum install -y python3 python3-pip python3-virtualenv
  1. Test if Python is working correctly with the command:

[root@test-export-image ~]# python3 --version
Python 3.12.3
  1. Create a venv to use for the OpenStack client.

[root@test-export-image ~]# mkdir /opt/osclient
[root@test-export-image ~]# cd /opt/osclient/
[root@test-export-image osclient]# python3 -m venv osclient
[root@test-export-image osclient]# source /opt/osclient/osclient/bin/activate
(osclient) [root@test-export-image osclient]# pip install --upgrade pip
(osclient) [root@test-export-image osclient]# pip install python-openstackclient
(osclient) [root@test-export-image osclient]# openstack --version
openstack 8.0.0

After preparing the environment for your OS, follow these steps:

  1. After preparing the environment for your OS, follow these steps:

  1. Review the RC_file.sh.

(osclient) root@test-export-image:/opt/osclient# vim test_project_RC_file.sh
#!/usr/bin/env bash
# To use NIPA Cloud Space public API you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/project has
# access to - such as Compute Instance, Compute Image, Block Storage, Networking.

export OS_AUTH_URL=https://identity-api.nipa.cloud/
# Co-working project identity
export OS_PROJECT_ID=834995e704b44fa888b7xxxxxxxxxxxx
export OS_PROJECT_NAME="test_project"
export OS_USER_DOMAIN_NAME="nipacloud"
if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi
export OS_PROJECT_DOMAIN_ID="c6b00adf4ed04fc5a958121fadb0e401"
if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi
# unset v2.0 items in case set
unset OS_TENANT_ID
unset OS_TENANT_NAME
# performing the action as the **user**.
export OS_USERNAME="test_user@nipa.cloud"
echo "Please enter your NIPA Cloud Space user's password for project $OS_PROJECT_NAME as user $OS_USERNAME: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
# NIPA Cloud Space only have 1 region "NCP-TH"
export OS_REGION_NAME="NCP-TH"
# Don't leave a blank variable, unset it if it was empty
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
  1. Source the .sh file and check if you can use the OpenStack client in your project.

(osclient) root@test-export-image:/opt/osclient# source test_project_RC_file.sh
Please enter your NIPA Cloud Space user's password for project test_project as user test_user@nipa.cloud:<ใส่ password>
(osclient) root@test-export-image:/opt/osclient# openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field      | Value                                                                                                                                                                                   |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires    | 2025-04-26T04:36:06+0000                                                                                                                                                                |
| id         | gAAAAABoCxE24s4f-T2MOyOFsLcfGWvbf1zwQBZfwC3KcqiKSpod1OuDJa3xdWaBvtMui7w9Hr3B0OHkQYx8u1aQYKodxhyKSLIcazwG1JbwAbt-Vgx8KAcU5zWQGAkPoOUmWuyNFW0ZkzONKU0HOmISAr8DM1bErVjWL7Il595Xmzmjr_889Uo |
| project_id | 834995e704b44fa888b7xxxxxxxxxxxx                                                                                                                                                        |
| user_id    | e6275119d15648bfb7c2xxxxxxxxxxxx                                                                                                                                                        |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(osclient) root@test-export-image:/opt/osclient#
  1. List the images in your project with the command:

(osclient) root@test-export-image:/opt/osclient# openstack image list
+--------------------------------------+--------------------------------------+--------+
| ID                                   | Name                                 | Status |
+--------------------------------------+--------------------------------------+--------+
| d00037bf-85f6-4bc3-b271-xxxxxxxxxxxx | ubuntu-24-v250307                    | active |
+--------------------------------------+--------------------------------------+--------+
  1. Download the desired image from your project with the command:

(osclient) root@test-export-image:/opt/osclient# openstack image save --file <ชื่อ file image> <image_ID>

ตัวอย่าง
(osclient) root@test-export-image:/opt/osclient# openstack image save --file ubuntu-24-v250307.qcow2 d00037bf-85f6-4bc3-b271-xxxxxxxxxxxx
  1. Once the download is complete, you will have the image file.

(osclient) root@test-export-image:/opt/osclient# ls -lh
total 1.2G
-rw-r--r-- 1 root root 1.4K Apr 25 11:31 test_project_RC_file.sh
drwxr-xr-x 5 root root 4.0K Apr 25 11:26 osclient
-rw-r--r-- 1 root root 1.2G Apr 25 11:38 ubuntu-24-v250307.qcow2
(osclient) root@test-export-image:/opt/osclient#

Last updated

Was this helpful?