Uploading a custom image to Fujitsu K5 UK based Public Cloud

NOTE: All images must be uploaded to the Default Project in your contract (name ends with -prj). Once uploaded to the default project, the image can be shared with the other projects within the contract (domain).

As with all public clouds, Fujitsu’s K5 OpenStack based cloud provides several default images from RedHat, CentOS, Ubuntu and Microsoft to facilitate rapid server deployments out of the box.

However, often customers have already built their own OS vendor images with bespoke applications or corporate compliance baked in. These images simply need to be made “cloud ready” by ensuring that they are capable of running on the target hypervisor and have the cloud-init software configured. The image prep process is not covered here.

In this example I will use Ubuntu’s OpenStack ready 16.04 cloud image and upload it to K5 in the UK region. The host that I am using to drive the APIs is an Ubuntu 14.04 server.

  • Download the example image from Ubuntu.
ubuntu@gjl-v1:~/testimages$ wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
--2016-07-29 08:07:56--  http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
Resolving cloud-images.ubuntu.com (cloud-images.ubuntu.com)... 91.189.88.141, 2001:67c:1360:8001:ffff:ffff:ffff:fffe
Connecting to cloud-images.ubuntu.com (cloud-images.ubuntu.com)|91.189.88.141|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 309329920 (295M) [application/octet-stream]
Saving to: ‘xenial-server-cloudimg-amd64-disk1.img’

100%[=================================================================================>] 309,329,920 51.6MB/s   in 6.2s

2016-07-29 08:08:02 (47.6 MB/s) - ‘xenial-server-cloudimg-amd64-disk1.img’ saved [309329920/309329920]

ubuntu@gjl-v1:~/testimages$
  • Convert Image to VMDK Format

Although KVM uses QCOWS2 images and the image downloaded is of this format, the K5 image upload process requires the upload image to be in a VMDK format when importing it. The QEMU-IMAGE utility has the ability to convert the image format from QCOWS2 to VMDK. It may be necessary to first install the qemu-utils package (though this wasn’t necessary in my case).

ubuntu@gjl-v1:~/testimages$ sudo apt-get install qemu-utils
sudo: unable to resolve host gjl-v1
Reading package lists... Done
Building dependency tree
Reading state information... Done
qemu-utils is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 143 not upgraded.
ubuntu@gjl-v1:~/testimages$ qemu-img convert -O vmdk xenial-server-cloudimg-amd64-disk1.img xenial-server-cloudimg-amd64-disk1.vmdk
ubuntu@gjl-v1:~/testimages$ ls -l | grep xen
-rw-rw-r-- 1 ubuntu ubuntu  309329920 Jul 25 15:09 xenial-server-cloudimg-amd64-disk1.img
-rw-r--r-- 1 ubuntu ubuntu 1009451008 Jul 29 08:29 xenial-server-cloudimg-amd64-disk1.vmdk
ubuntu@gjl-v1:~/testimages$

We now have a custom image that is of the correct format and also is cloud-init ready.

  • Environmental Setup

We will use API calls now as documented here for the remainder of this process. We will initially setup some environment variables to make working with the API easier.

My k5Default.rc file (environment file) is shared below – please ensure to replace the “<replaceMe -my stuff>” with your own values if following along with this blog.

#!/bin/bash
# Account information.
export DOMAIN_NAME=<replaceMe -Contract ID>
export TENANT_ID=<replaceMe -Project ID - last section of login url>
export PROJECT_ID=$TENANT_ID
export USER_NAME=<replaceMe -user name details>
export USER_PW=<replaceMe -user password>
# Endpoint shortcut. echo "EP initial setup."
export TOKEN=https://identity.uk-1.cloud.global.fujitsu.com
export IDENTITY=$TOKEN
export NETWORK=https://networking.uk-1.cloud.global.fujitsu.com
export COMPUTE=https://compute.uk-1.cloud.global.fujitsu.com
export CEILOMETER=https://telemetry.uk-1.cloud.global.fujitsu.com
export TELEMETRY=$CEILOMETER
export DB=https://database.uk-1.cloud.global.fujitsu.com
export BLOCKSTORAGE=https://blockstorage.uk-1.cloud.global.fujitsu.com
export HOST_BLOCKSTORAGEV2=$BLOCKSTORAGE
export OBJECTSTORAGE=https://objectstorage.uk-1.cloud.global.fujitsu.com
export ORCHESTRATION=https://orchestration.uk-1.cloud.global.fujitsu.com
export ELB=https://loadbalancing.uk-1.cloud.global.fujitsu.com
export AUTOSCALE=https://autoscale.uk-1.cloud.global.fujitsu.com
export IMAGE=https://image.uk-1.cloud.global.fujitsu.com
export MAILSERVICE=https://mail.uk-1.cloud.global.fujitsu.com
export NETWORK_EX=https://networking-ex.uk-1.cloud.global.fujitsu.com
export DNS=https://dns.cloud.global.fujitsu.com
export VMIMPORT=https://vmimport.uk-1.cloud.global.fujitsu.com/v1/imageimport

Notes:

(a) This sets up my environment to use the default domain’s project. All images must be uploaded to this project and then they can be shared with the other projects within this contract/domain.

(b) If you’re using a K5 region other than uk-1 please ensure to change all the endpoints to align with your region.

Getting a token to ensure we are authorized to use the API. I’ll use the script below to get this token as this will be a repeatable process.

#!/bin/bash
## Script to retrieve token
. ~/testimages/k5Default.rc
export OS_AUTH_TOKEN=`curl -k -X POST -si $TOKEN/v3/auth/tokens -H "Content-Type:application/json" -H "Accept:application/json" -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"domain":{"name":"'$DOMAIN_NAME'"}, "name":"'$USER_NAME'", "password": "'"$USER_PW"'"}}}, "scope": { "project": {"id":"'$PROJECT_ID'"}}}}' | awk '/X-Subject-Token/ {print $2}'`
echo Token set: $OS_AUTH_TOKEN
  • Create a K5 Openstack based Swift Container to store the image

This API call requires a container name variable, CONTAINER, to be set. In this case we will use “myContainer” for the container name as follows:

ubuntu@gjl-v1:~/testimages$ source get_token.sh
Token set: 9fe31993695449c9961c907409621ab0
ubuntu@gjl-v1:~/testimages$ export CONTAINER=myContainer
ubuntu@gjl-v1:~/testimages$ curl -i $OBJECTSTORAGE/v1/AUTH_$PROJECT_ID/$CONTAINER -X PUT -H "X-Auth-Token: $OS_AUTH_TOKEN" -H "Content-Type:  application/json"
HTTP/1.1 201 Created
X-Fcx-Endpoint-Request: EXECUTED_REQ000988766_201
X-Trans-Id: tx8b28cb6db20e4f2c95d88-00579b2ecc
Date: Fri, 29 Jul 2016 10:24:12 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 0

ubuntu@gjl-v1:~/testimages$
  • Upload the image to a K5 Openstack based Swift Container

Next we’ll define the path to the image and the image (object) name to be uploaded and then upload the image to K5 Swift Object Storage as follows:

ubuntu@gjl-v1:~/testimages$ export FILE_PATH=/home/ubuntu/testimages/xenial-server-cloudimg-amd64-disk1.vmdk
ubuntu@gjl-v1:~/testimages$ export OBJECT=xenial-server-cloudimg-amd64-disk1.vmdk
ubuntu@gjl-v1:~/testimages$ source get_token.sh
Token set: ede8204db8c448d79445016cc7c5d131
ubuntu@gjl-v1:~/testimages$ curl -i $OBJECTSTORAGE/v1/AUTH_$PROJECT_ID/$CONTAINER/$OBJECT -X PUT -T "$FILE_PATH" -H "X-Auth-Token: $OS_AUTH_TOKEN"
HTTP/1.1 100 Continue

HTTP/1.1 201 Created
X-Fcx-Endpoint-Request: EXECUTED_REQ000987297_201
Last-Modified: Fri, 29 Jul 2016 10:30:15 GMT
Etag: 71c521a7b4d622ec7e39076c7a5cabdc
X-Trans-Id: txff993696748b468e95ba3-00579b3036
Date: Fri, 29 Jul 2016 10:31:45 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 0

ubuntu@gjl-v1:~/testimages$

Note: The token should last 3 hours and so it’s not necessary to run get_token.sh before every API call. My blogging activity doesn’t tend to be linear and there can be significant breaks between my steps hence my ‘habit’.

  • Verify the upload has completed – compare the file sizes
ubuntu@gjl-v1:~/testimages$ ls -l xenial-server-cloudimg-amd64-disk1.vmdk
-rw-r--r-- 1 ubuntu ubuntu 1009451008 Jul 29 08:29 xenial-server-cloudimg-amd64-disk1.vmdk
ubuntu@gjl-v1:~/testimages$ curl -s $OBJECTSTORAGE/v1/AUTH_$PROJECT_ID/$CONTAINER?format=json -X GET -H  "X-Auth-Token: $OS_AUTH_TOKEN" | jq .
# Output from above command
[
  {
    "content_type": "application/octet-stream",
    "name": "xenial-server-cloudimg-amd64-disk1.vmdk",
    "bytes": 1009451008,
    "last_modified": "2016-07-29T10:30:14.139190",
    "hash": "71c521a7b4d622ec7e39076c7a5cabdc"
  }
]
ubuntu@gjl-v1:~/testimages$
  • Register and Import the image into K5 OpenStack

Before we do the final steps let’s quickly get a list of all the images currently available as follows:

ubuntu@gjl-v1:~/testimages$ curl -H "X-Auth-Token: $OS_AUTH_TOKEN" https://image.uk-1.cloud.global.fujitsu.com/v2/images | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5082  100  5082    0     0   4185      0  0:00:01  0:00:01 --:--:--  4186
{
  "first": "/v2/images",
  "schema": "/v2/schemas/images",
  "images": [
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "fcx.win": "true",
      "size": 24226693120,
      "visibility": "public",
      "updated_at": "2016-07-15T04:56:49Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-15T04:28:24Z",
      "container_format": "bare",
      "tags": [],
      "name": "Windows Server 2008 R2 SE SP1 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "self": "/v2/images/20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "min_disk": 80,
      "protected": true,
      "id": "20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "file": "/v2/images/20403cb8-4ada-4c5a-b524-d1ff393f0bb7/file",
      "checksum": "4096a8f17c82e5ce9118c7d9a3e0a20b",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "fcx.win": "true",
      "size": 15858139136,
      "visibility": "public",
      "updated_at": "2016-07-15T05:07:04Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-15T02:28:28Z",
      "container_format": "bare",
      "tags": [],
      "name": "Windows Server 2012 R2 SE 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "6e1610db-1115-4260-8dc2-bcdd526a54be",
      "self": "/v2/images/6e1610db-1115-4260-8dc2-bcdd526a54be",
      "min_disk": 80,
      "protected": true,
      "id": "6e1610db-1115-4260-8dc2-bcdd526a54be",
      "file": "/v2/images/6e1610db-1115-4260-8dc2-bcdd526a54be/file",
      "checksum": "56a7fca10e650e7510cdd75012167095",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 1024983040,
      "min_disk": 30,
      "visibility": "public",
      "updated_at": "2016-07-12T07:32:28Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-12T06:44:04Z",
      "container_format": "bare",
      "tags": [],
      "name": "CentOS 7.2 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "self": "/v2/images/58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "fcx.centos": "true",
      "protected": true,
      "id": "58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "file": "/v2/images/58fd966f-b055-4cd0-9012-cf6af7a4c32b/file",
      "checksum": "72e90ec33fb5b91cf709e1f2010c4054",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 1815281664,
      "min_disk": 30,
      "visibility": "public",
      "updated_at": "2016-04-26T02:41:44Z",
      "disk_format": "qcow2",
      "created_at": "2016-04-26T02:41:44Z",
      "container_format": "bare",
      "tags": [],
      "name": "CentOS 6.5 64bit (English) 04",
      "status": "active",
      "fcx.base_image_id": "2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "self": "/v2/images/2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "fcx.centos": "true",
      "protected": true,
      "id": "2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "file": "/v2/images/2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c/file",
      "checksum": "d18e84467ee301a5e18a2c8bc50753d2",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 258474496,
      "id": "ffa17298-537d-40b2-a848-0a4d22b49df5",
      "visibility": "public",
      "updated_at": "2016-04-26T02:41:18Z",
      "disk_format": "qcow2",
      "created_at": "2016-04-26T02:41:17Z",
      "container_format": "bare",
      "tags": [],
      "name": "Ubuntu Server 14.04 LTS (English) 01",
      "status": "active",
      "fcx.base_image_id": "ffa17298-537d-40b2-a848-0a4d22b49df5",
      "self": "/v2/images/ffa17298-537d-40b2-a848-0a4d22b49df5",
      "min_disk": 3,
      "protected": true,
      "fcx.ubuntu": "true",
      "file": "/v2/images/ffa17298-537d-40b2-a848-0a4d22b49df5/file",
      "checksum": "89d768444e2f254e76555f8d3bfaed20",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "fcx.rhel": "true",
      "min_ram": 0,
      "owner": "31ceb599e8ff48aeb66f2fd748988960",
      "updated_at": "2016-04-26T02:39:27Z",
      "disk_format": "qcow2",
      "size": 13928759296,
      "created_at": "2016-04-26T02:39:26Z",
      "container_format": "bare",
      "tags": [],
      "name": "Red Hat Enterprise Linux 6.5 64bit (English) 02",
      "status": "active",
      "visibility": "public",
      "fcx.base_image_id": "db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "self": "/v2/images/db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "min_disk": 40,
      "protected": true,
      "id": "db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "file": "/v2/images/db9766f0-c95c-4f1c-bb29-304a90405e3e/file",
      "checksum": "82bc5085232ec45eae6951e5e2ac99cd"
    }
  ]
}
ubuntu@gjl-v1:~/testimages$

Finally we need to set the following environment variables to complete the import process and then execute the API call –

  1. ID – unique image id (generated using uuigen – see below)
  2. PASSOWRD – a base64 encoded version of your user password (details below)
  3. NAME – the image name that will be seen by the end users
  4. LOCATION – the location of the object container hosting the image
  5. OS_TYPE – the base OS used
  6. CONVERSION – must be set to true, images will be converted from VMDK to QCOWS2 automatically
ubuntu@gjl-v1:~/testimages$ uuidgen
7db7298c-859a-45b5-821b-65a2f2d1a38d
ubuntu@gjl-v1:~/testimages$ export ID=7db7298c-859a-45b5-821b-65a2f2d1a38d
ubuntu@gjl-v1:~/testimages$ echo -n <replaceME - your user password> | base64
Generated-Hex-64Encoded-Password
ubuntu@gjl-v1:~/testimages$ export PASSWORD=<replaceMe -Generated-Hex-64Encoded-Password>
ubuntu@gjl-v1:~/testimages$ export NAME=K5CustomImageDemo
ubuntu@gjl-v1:~/testimages$ export LOCATION=/v1/AUTH_$PROJECT_ID/$CONTAINER/$OBJECT
ubuntu@gjl-v1:~/testimages$ export CONVERSION=true
ubuntu@gjl-v1:~/testimages$ export OS_TYPE=ubuntu
ubuntu@gjl-v1:~/testimages$ source get_token.sh
Token set: b539e00c1a15469ca3a6006aeea59155
ubuntu@gjl-v1:~/testimages$ curl -X POST -H "X-Auth-Token: $OS_AUTH_TOKEN" -H "Content-Type: application/json" https://vmimport.uk-1.cloud.global.fujitsu.com/v1/imageimport -d '{"name":"'$NAME'", "location":"'$LOCATION'", "id":"'$ID'", "conversion":'$CONVERSION', "os_type":"'$OS_TYPE'", "user_name":"'$USER_NAME'", "password":"'$PASSWORD'", "domain_name":"'$DOMAIN_NAME'"}'
{"import_id": "e88ce041-210f-4702-85a6-3c885aca27c9"}ubuntu@gjl-v1:~/testimages$

Now it’s just a waiting game for the image to be converted from VMDK back to QCOWS and then registered and imported into the K5 OpenStack Glance image service.

Verify the image import status as follows by first setting the new IMPORT_ID variable outputted above and then making another API call:

ubuntu@gjl-v1:~/testimages$ export IMPORT_ID=e88ce041-210f-4702-85a6-3c885aca27c9
ubuntu@gjl-v1:~/testimages$ curl -H "X-Auth-Token: $OS_AUTH_TOKEN" https://vmimport.uk-1.cloud.global.fujitsu.com/v1/imageimport/$IMPORT_ID/status | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   441  100   441    0     0    260      0  0:00:01  0:00:01 --:--:--   260
{
  "import_status": "processing",
  "id": "7db7298c-859a-45b5-821b-65a2f2d1a38d",
  "user_name": "landg",
  "password": "*",
  "os_type": "ubuntu",
  "progress": 70,
  "min_disk": "0",
  "conversion": true,
  "name": "K5CustomImageDemo",
  "container_format": "bare",
  "min_ram": "0",
  "ovf_location": "",
  "disk_format": "raw",
  "domain_name": "YssmW1yI",
  "location": "/v1/AUTH_eadb882573ac40b1b101eac93009a313/myContainer/xenial-server-cloudimg-amd64-disk1.vmdk"
}
ubuntu@gjl-v1:~/testimages$

Once completed the same call should result in a similar output to the following:

ubuntu@gjl-v1:~/testimages$ curl -H "X-Auth-Token: $OS_AUTH_TOKEN" https://vmimport.uk-1.cloud.global.fujitsu.com/v1/imageimport/$IMPORT_ID/status | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   882  100   882    0     0    517      0  0:00:01  0:00:01 --:--:--   517
{
  "os_type": "ubuntu",
  "protected": false,
  "fcx.centos": "true",
  "ovf_location": "",
  "created_at": "2016-07-29T11:40:14Z",
  "name": "K5CustomImageDemo",
  "password": "*",
  "min_disk": 0,
  "BaseImageId": "415b3a0a513aebc27d34c68bd8cdae8c",
  "visibility": "private",
  "tags": [],
  "import_status": "succeeded",
  "conversion": true,
  "size": 2361393152,
  "id": "7db7298c-859a-45b5-821b-65a2f2d1a38d",
  "owner": "eadb882573ac40b1b101eac93009a313",
  "file": "/v2/images/7db7298c-859a-45b5-821b-65a2f2d1a38d/file",
  "updated_at": "2016-07-29T11:40:20Z",
  "min_ram": 0,
  "container_format": "bare",
  "self": "/v2/images/7db7298c-859a-45b5-821b-65a2f2d1a38d",
  "disk_format": "raw",
  "domain_name": "YssmW1yI",
  "location": "/v1/AUTH_eadb882573ac40b1b101eac93009a313/myContainer/xenial-server-cloudimg-amd64-disk1.vmdk",
  "progress": 100,
  "user_name": "landg",
  "schema": "/v2/schemas/image",
  "status": "active"
}
ubuntu@gjl-v1:~/testimages$

And now when we list our available images the new image will be available for use in the Default tenant.

ubuntu@gjl-v1:~/testimages$ curl -H "X-Auth-Token: $OS_AUTH_TOKEN" https://image.uk-1.cloud.global.fujitsu.com/v2/images | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5645  100  5645    0     0   1576      0  0:00:03  0:00:03 --:--:--  1576
{
  "first": "/v2/images",
  "schema": "/v2/schemas/images",
  "images": [
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 2361393152,
      "updated_at": "2016-07-29T11:40:21Z",
      "disk_format": "raw",
      "created_at": "2016-07-29T11:40:17Z",
      "container_format": "bare",
      "tags": [],
      "name": "K5CustomImageDemo",
      "BaseImageId": "415b3a0a513aebc27d34c68bd8cdae8c",
      "status": "active",
      "visibility": "private",
      "self": "/v2/images/7db7298c-859a-45b5-821b-65a2f2d1a38d",
      "fcx.centos": "true",
      "protected": false,
      "id": "7db7298c-859a-45b5-821b-65a2f2d1a38d",
      "file": "/v2/images/7db7298c-859a-45b5-821b-65a2f2d1a38d/file",
      "owner": "eadb882573ac40b1b101eac93009a313",
      "min_disk": 0
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "fcx.win": "true",
      "size": 24226693120,
      "visibility": "public",
      "updated_at": "2016-07-15T04:56:49Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-15T04:28:24Z",
      "container_format": "bare",
      "tags": [],
      "name": "Windows Server 2008 R2 SE SP1 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "self": "/v2/images/20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "min_disk": 80,
      "protected": true,
      "id": "20403cb8-4ada-4c5a-b524-d1ff393f0bb7",
      "file": "/v2/images/20403cb8-4ada-4c5a-b524-d1ff393f0bb7/file",
      "checksum": "4096a8f17c82e5ce9118c7d9a3e0a20b",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "fcx.win": "true",
      "size": 15858139136,
      "visibility": "public",
      "updated_at": "2016-07-15T05:07:04Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-15T02:28:28Z",
      "container_format": "bare",
      "tags": [],
      "name": "Windows Server 2012 R2 SE 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "6e1610db-1115-4260-8dc2-bcdd526a54be",
      "self": "/v2/images/6e1610db-1115-4260-8dc2-bcdd526a54be",
      "min_disk": 80,
      "protected": true,
      "id": "6e1610db-1115-4260-8dc2-bcdd526a54be",
      "file": "/v2/images/6e1610db-1115-4260-8dc2-bcdd526a54be/file",
      "checksum": "56a7fca10e650e7510cdd75012167095",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 1024983040,
      "min_disk": 30,
      "visibility": "public",
      "updated_at": "2016-07-12T07:32:28Z",
      "disk_format": "qcow2",
      "created_at": "2016-07-12T06:44:04Z",
      "container_format": "bare",
      "tags": [],
      "name": "CentOS 7.2 64bit (English) 01",
      "status": "active",
      "fcx.base_image_id": "58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "self": "/v2/images/58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "fcx.centos": "true",
      "protected": true,
      "id": "58fd966f-b055-4cd0-9012-cf6af7a4c32b",
      "file": "/v2/images/58fd966f-b055-4cd0-9012-cf6af7a4c32b/file",
      "checksum": "72e90ec33fb5b91cf709e1f2010c4054",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
   {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 1815281664,
      "min_disk": 30,
      "visibility": "public",
      "updated_at": "2016-04-26T02:41:44Z",
      "disk_format": "qcow2",
      "created_at": "2016-04-26T02:41:44Z",
      "container_format": "bare",
      "tags": [],
      "name": "CentOS 6.5 64bit (English) 04",
      "status": "active",
      "fcx.base_image_id": "2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "self": "/v2/images/2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "fcx.centos": "true",
      "protected": true,
      "id": "2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c",
      "file": "/v2/images/2d1b7b6b-93cf-4a9b-aacc-43ce61b8073c/file",
      "checksum": "d18e84467ee301a5e18a2c8bc50753d2",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "min_ram": 0,
      "size": 258474496,
      "id": "ffa17298-537d-40b2-a848-0a4d22b49df5",
      "visibility": "public",
      "updated_at": "2016-04-26T02:41:18Z",
      "disk_format": "qcow2",
      "created_at": "2016-04-26T02:41:17Z",
      "container_format": "bare",
      "tags": [],
      "name": "Ubuntu Server 14.04 LTS (English) 01",
      "status": "active",
      "fcx.base_image_id": "ffa17298-537d-40b2-a848-0a4d22b49df5",
      "self": "/v2/images/ffa17298-537d-40b2-a848-0a4d22b49df5",
      "min_disk": 3,
      "protected": true,
      "fcx.ubuntu": "true",
      "file": "/v2/images/ffa17298-537d-40b2-a848-0a4d22b49df5/file",
      "checksum": "89d768444e2f254e76555f8d3bfaed20",
      "owner": "31ceb599e8ff48aeb66f2fd748988960"
    },
    {
      "schema": "/v2/schemas/image",
      "fcx.rhel": "true",
      "min_ram": 0,
      "owner": "31ceb599e8ff48aeb66f2fd748988960",
      "updated_at": "2016-04-26T02:39:27Z",
      "disk_format": "qcow2",
      "size": 13928759296,
      "created_at": "2016-04-26T02:39:26Z",
      "container_format": "bare",
      "tags": [],
      "name": "Red Hat Enterprise Linux 6.5 64bit (English) 02",
      "status": "active",
      "visibility": "public",
      "fcx.base_image_id": "db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "self": "/v2/images/db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "min_disk": 40,
      "protected": true,
      "id": "db9766f0-c95c-4f1c-bb29-304a90405e3e",
      "file": "/v2/images/db9766f0-c95c-4f1c-bb29-304a90405e3e/file",
      "checksum": "82bc5085232ec45eae6951e5e2ac99cd"
    }
  ]
}
ubuntu@gjl-v1:~/testimages$

This is all great I hear you say…but I don’t want my users all using the Default tenant.

  • Sharing images from the Default Project within the same domain/contract

If this image needs to be used by a project (tenant) other than the Default project these final few steps need to be taken.

Configure these environment variables:

  1. MEMBER – the ID of the project with which you wish to share the image
  2. IMAGE_ID – the ID of the image to be shared
  3. STATUS – set to accepted

Now on the Default project request sharing :

ubuntu@gjl-v1:~/testimages$ export IMAGE_ID=7db7298c-859a-45b5-821b-65a2f2d1a38d
ubuntu@gjl-v1:~/testimages$ export STATUS=accepted
ubuntu@gjl-v1:~/testimages$ export MEMBER=3cef1071f8ff432989f18aa14ce3cc66
ubuntu@gjl-v1:~/testimages$ curl -X POST -s $IMAGE/v2/images/$IMAGE_ID/members -H "X-Auth-Token:  $OS_AUTH_TOKEN" -H "Content-Type:  application/json" -d '{"member": "'$MEMBER'"}' | jq .
{
  "schema": "/v2/schemas/member",
  "member_id": "3cef1071f8ff432989f18aa14ce3cc66",
  "image_id": "7db7298c-859a-45b5-821b-65a2f2d1a38d",
  "updated_at": "2016-07-29T13:20:52Z",
  "created_at": "2016-07-29T13:20:52Z",
  "status": "pending"
}
ubuntu@gjl-v1:~/testimages$

NOTE: Now we need to switch to the project that needs access to the image by modifying the settings (TENANT_ID) in the rc file.

I quickly created a new rc file for demo purposes.

Get a newly scoped token and accept the image sharing by issuing the following commands:

ubuntu@gjl-v1:~/testimages$ source get_token_other.sh
Token set: ff45e8c63af44936bbc533c94025b348
ubuntu@gjl-v1:~/testimages$ curl -X PUT -i $IMAGE/v2/images/$IMAGE_ID/members/$MEMBER -H "X-Auth-Token:  $OS_AUTH_TOKEN" -H "Content-Type:  application/json" -d '{"status": "'$STATUS'"}'
HTTP/1.1 200 OK
X-Fcx-Endpoint-Request: EXECUTED_REQ001021747_200
Date: Fri, 29 Jul 2016 13:29:04 GMT
Server: Apache
x-openstack-request-id: req-defe3185-7269-4cbd-af63-e521ddcc7270
ETag: "259d0715692c99fa52a81ae571c061a1"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 95cfe28d-1e45-49a5-bd1a-119ae8ee6f32
X-Runtime: 0.659000
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json;charset=UTF-8
Content-Length: 220

{"status":"accepted","created_at":"2016-07-29T13:20:52Z","updated_at":"2016-07-29T13:29:04Z","image_id":"7db7298c-859a-45b5-821b-65a2f2d1a38d","member_id":"3cef1071f8ff432989f18aa14ce3cc66","schema":"/v2/schemas/member"}ubuntu@gjl-v1:~/testimages$

Now we can verify the images has been accepted by issuing the following API call

ubuntu@gjl-v1:~/testimages$ curl -X GET -s $IMAGE/v2/images/$IMAGE_ID/members/$MEMBER -H "X-Auth-Token:  $OS_AUTH_TOKEN" | jq .
{
  "schema": "/v2/schemas/member",
  "member_id": "3cef1071f8ff432989f18aa14ce3cc66",
  "image_id": "7db7298c-859a-45b5-821b-65a2f2d1a38d",
  "updated_at": "2016-07-29T13:29:04Z",
  "created_at": "2016-07-29T13:20:52Z",
  "status": "accepted"
}
ubuntu@gjl-v1:~/testimages$

And that’s it folks.

Happy Stacking!

 

One thought on “Uploading a custom image to Fujitsu K5 UK based Public Cloud

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