Difference between revisions of "Share An Image In Openstack"

From CAC Documentation wiki
Jump to navigation Jump to search
(Created page with "__TOC__ == Introduction == You can share an image from your project with a collaborator in a different project in Openstack cloud so you can both launch instances using the...")
 
(Added some more details to the process of sharing an image)
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__TOC__
+
You can share an image from your project with a collaborator in a different project in OpenStack cloud so you can both launch instances using the same image.  As the owner of the image, you can revoke the sharing privilege at any time.  You can also use these methods to share an image with yourself in other projects, just think of yourself as the collaborator.
  
== Introduction ==
+
'''Prerequisites:'''
You can share an image from your project with a collaborator in a different project in Openstack cloud so you can both launch instances using the shared image. You as the owner of the image can revoke the sharing privilege at any time.  
+
# Both you and your collaborator need to use the [[OpenStack CLI]].
 
+
#* You will need to set up the CLI to work with the project where the image to be shared is located.
To accomplish this,
+
#* If you are sharing an image with yourself, you will need to download the [[OpenStack_CLI#Download_OpenStack_RC_File|RC File]] for both projects (the one you are sharing from and to).
 +
# You will need to know the project name or ID of your collaborator.
  
# Both you and your collaborator need to use the [[OpenStack_CLI | Openstack CLI client]], and
+
=== Share an Image With Another Project ===
# You will need to know the project name or ID of your collaborator.
 
  
== Share an Image ==
+
'''1. Find the project ID of your collaborator first:'''
* Find the project ID of your collaborator. Run
+
:The project ID is the string of the format <code>xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</code> composed of lowercase letters and numbers.  The project name in the typical format will not work in the below commands. You will need to have sourced the [[OpenStack_CLI#Download_OpenStack_RC_File|RC File]] of the project where the image is located before running the [[OpenStack CLI]]  command to get the project ID:
  openstack project list | grep <collaborator's project name>
+
  openstack project list
:and the first field of the output is the ID of your collaborator's project ID.
+
:and the first field of the output is the ID of your collaborator's project ID.  If you know the name of your collaborator's project, you can find the ID by adding <code>| grep <collaborator's project name></code> to the above command.
* Find the ID of the image you want to share:
+
'''2. Find the ID of the image you want to share:'''
 
  openstack image show <image name>
 
  openstack image show <image name>
* Share the image with your collaborator's project:
+
:Similar to project ID, this will be a long string of letters and numbers next to the name of your image.  You will use the image ID, rather than the name, in the commands below.
 +
'''3. Share the image with your collaborator's project:'''
 +
openstack image set --shared <image ID>
 
  openstack image add project <image ID> <collaborator's project ID>
 
  openstack image add project <image ID> <collaborator's project ID>
* Verify the image is now shared. The status field should say <code>pending</code> until your collaborator accepts the image.
+
'''4. Verify the image is now shared:'''
 +
openstack image member list <image ID>
 +
:The status field should say <code>pending</code> until your collaborator accepts the image.
 +
'''5. Give the ID of the shared image to your collaborator''' so they can follow the steps in the [[#Accept a Shared Image|Accept a Shared Image]] section to add the image to their project.  If you are sharing the image with yourself, you will need to source the [[OpenStack_CLI#Download_OpenStack_RC_File|RC File]] of the second project and then perform the acceptance yourself.
 +
 
 +
=== Share an Image with All Projects ===
 +
 
 +
* Currently this action can only be performed by cloud administrators.
 +
* This generally shouldn't be done unless creating something that is a public resource that is intended to be used with any project.
 +
* Additionally, don't use such an image from a third party unless you trust the source.
 +
  openstack image set --public <image ID>
 +
 
 +
=== Accept a Shared Image ===
 +
'''1. Get the ID of the shared image from the owner'''. Make sure the owner has performed the steps in the [[#Share_an_Image | Share an Image]] section above, and source the [[OpenStack_CLI#Download_OpenStack_RC_File|RC File]] of your project.
 +
'''2. Accept the shared image:'''
 +
openstack image set --accept <image ID>
 +
'''3. Verify the image is now available to your project:'''
 +
openstack image list
 +
:If the image is listed in the output, it should also appear in OpenStack web console (Horizon).
 +
 
 +
=== Unshare an Image ===
 +
* An image's owner can see which projects have access to the image:
 
  openstack image member list <image ID>
 
  openstack image member list <image ID>
* Give the ID of the shared image to your collaborator.
 
  
== Accept a Shared Image ==
+
* The owner can unshare an image like this:
* Get the ID of the shared image from the owner of the image. Make sure the owner has performed the steps in the Share an Image section above.
+
openstack image remove project <image ID> <project ID>

Latest revision as of 10:57, 11 June 2021

You can share an image from your project with a collaborator in a different project in OpenStack cloud so you can both launch instances using the same image. As the owner of the image, you can revoke the sharing privilege at any time. You can also use these methods to share an image with yourself in other projects, just think of yourself as the collaborator.

Prerequisites:

  1. Both you and your collaborator need to use the OpenStack CLI.
    • You will need to set up the CLI to work with the project where the image to be shared is located.
    • If you are sharing an image with yourself, you will need to download the RC File for both projects (the one you are sharing from and to).
  2. You will need to know the project name or ID of your collaborator.

Share an Image With Another Project

1. Find the project ID of your collaborator first:

The project ID is the string of the format xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx composed of lowercase letters and numbers. The project name in the typical format will not work in the below commands. You will need to have sourced the RC File of the project where the image is located before running the OpenStack CLI command to get the project ID:
openstack project list
and the first field of the output is the ID of your collaborator's project ID. If you know the name of your collaborator's project, you can find the ID by adding | grep <collaborator's project name> to the above command.

2. Find the ID of the image you want to share:

openstack image show <image name>
Similar to project ID, this will be a long string of letters and numbers next to the name of your image. You will use the image ID, rather than the name, in the commands below.

3. Share the image with your collaborator's project:

openstack image set --shared <image ID>
openstack image add project <image ID> <collaborator's project ID>

4. Verify the image is now shared:

openstack image member list <image ID>
The status field should say pending until your collaborator accepts the image.

5. Give the ID of the shared image to your collaborator so they can follow the steps in the Accept a Shared Image section to add the image to their project. If you are sharing the image with yourself, you will need to source the RC File of the second project and then perform the acceptance yourself.

Share an Image with All Projects

  • Currently this action can only be performed by cloud administrators.
  • This generally shouldn't be done unless creating something that is a public resource that is intended to be used with any project.
  • Additionally, don't use such an image from a third party unless you trust the source.
 openstack image set --public <image ID>

Accept a Shared Image

1. Get the ID of the shared image from the owner. Make sure the owner has performed the steps in the Share an Image section above, and source the RC File of your project. 2. Accept the shared image:

openstack image set --accept <image ID>

3. Verify the image is now available to your project:

openstack image list
If the image is listed in the output, it should also appear in OpenStack web console (Horizon).

Unshare an Image

  • An image's owner can see which projects have access to the image:
openstack image member list <image ID>
  • The owner can unshare an image like this:
openstack image remove project <image ID> <project ID>