# Overview
**azure-img-utils** provides a command line utility and API for publishing
images in the Azure Cloud. This includes helper functions for uploading
image blobs, creating compute images and publish/share images across
all available regions.
See the [Azure docs](https://docs.microsoft.com/en-us/azure/) to get
more info on the Azure cloud.
# Requirements
The requirements for the project can be found in the following repo files:
- [requirements](requirement.txt)
- [requirements for testing](requirement-test.txt)
- [requirements for development](requirement-dev.txt)
# Installation
To install the package on openSUSE and SLES use the following commands as root:
```shell
# zypper ar https://download.opensuse.org/repositories/Cloud:Tools:CI/<distribution>
# zypper refresh
# zypper in python3-azure-img-utils
```
To install from PyPI:
```shell
$ pip install azure-img-utils
```
# Configuration
**azure-img-utils** can be configured with yaml based profiles. The configuration
directory is `~/.config/azure_img_utils` and the default profile is default.yaml
(~/.config/azure_img_utils/default.yaml).
The following configration options are available in a configuration profile:
- no_color
- log_level
- credentials_file
- resource_group
- region
- container
- storage_account
An example configuration profile may look like:
```yaml
region: westus
no_color: True
credentials_file: mycredentials.json
container: my_container
```
When running any command the profile can be chosen via the *--profile* option.
For example, *azure-img-utils image blobexists --profile production* would pull
configuration from ~/.config/azure_img_utils/production.yaml.
# CLI
The CLI is broken into multiple distinct subcommands that handle different
steps of creating and publishing images in the Azure cloud framework.
## Authentication
This cli tool expects the user to provide a json file containing the
credentials of a service principal to access his/her Azure services.
Per Azure documentation:
> An Azure service principal is an identity created for use with applications,
> hosted services, and automated tools to access Azure resources.
[Here](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli)
you can find how to create a service principal with the azure cli.
With your subscriptionId, the resourceGroupId and the required permissions, you can
create the service principal with the following command:
```sh
az ad sp create-for-rbac \
--sdk-auth \
--role Contributor \
--scopes /subscriptions/{YOUR_SUSCRI_ID}/resourceGroups/{YOUR_RES_GROUP_ID} \
--name "YOUR_SP_NAME" > mycredentials.json
```
The expected format for the json file is the output for that *create-for-rbac* az
command. Note that the API this repo provides allows additional methods of
authentication, but these are not supported in this CLI tool.
## blob command
Group of commands for blob management.
### exists subcommand
This subcommand allows the user to check if a blob exists in the storage
container specified. The subcommand is *azure-img-utils blob exists*.
The *required* parameters for the execution of the command (authentication
aside):
- --storage-account
- --blob-name
- --container
Example:
```shell
$ azure-img-utils blob exists --storage-account myStorageAccount \
--blob-name myBlobName \
--container myContainerName
```
This command will output *true* or *false* depending on the existence of the
blob.
For more information about the blob exists command see the help message:
```shell
$ azure-img-utils blob exists --help
```
### upload subcommand
This subcommand allows the user to upload a file as a blob to the storage
container specified. The subcommand is *azure-img-utils blob upload*.
The *required* parameters for the execution of the command (authentication
aside):
- --storage-account
- --blob-name
- --container
- --image-file
Some *optional* parameters for the execution of the command include:
- --force-replace-image (defaults to False)
- --page-blob (defaults to False)
- --expand-image (defaults to False)
- --max-workers (defaults to 5(no limit))
- --max-attempts (defaults to 5(no limit))
Example:
```shell
$ azure-img-utils blob upload --storage-account myStorageAccount \
--blob-name myBlobName \
--container myContainerName \
--image-file myImageFile.qcow2
```
This command will output if the upload has been successful or not.
For more information about the blob upload command see the help message:
```shell
$ azure-img-utils blob upload --help
```
### delete subcommand
This subcommand allows the user to delete a blob file from the storage
container specified. The subcommand is *azure-img-utils blob delete*.
The *required* parameters for the execution of the command (authentication
aside):
- --storage-account
- --blob-name
- --container
Some *optional* parameters for the execution of the command:
- --yes (avoids interactive confirmation for the deletion)
Example:
```shell
$ azure-img-utils blob delete --storage-account myStorageAccount \
--blob-name myBlobName \
--container myContainerName \
--yes
```
This command will output if the deletion has been successful or not.
For more information about the blob delete command see the help message:
```shell
$ azure-img-utils blob delete --help
```
## image command
Group of commands for image management.
### exists subcommand
This subcommand allows the user to check if an image exists.
The subcommand is *azure-img-utils image exists*.
The *required* parameters for the execution of the command (authentication
aside):
- --image-name
Example:
```shell
$ azure-img-utils image exists --image-name myImageName
```
This command will output *true* or *false* depending on the existence of the
image.
For more information about the image exists command see the help message:
```shell
$ azure-img-utils image exists --help
```
### create subcommand
This subcommand allows the user to create an image based in one blob.
The subcommand is *azure-img-utils image create*.
The *required* parameters for the execution of the command (authentication
aside):
- --blob-name
- --image-name
- --container
- --resource-group
- --storage-account
Some *optional* parameters for the execution of the command include:
- --force-replace-image (defaults to False)
- --hyper-v-generation (defaults to 'V1'(legacy bios).)
(Use 'V2' for uefi boot.)
Example:
```shell
$ azure-img-utils image create --blob-name myBlobName \
--image-name myImageName
```
For more information about the image create command see the help message:
```shell
$ azure-img-utils image create --help
```
### delete subcommand
This subcommand allows the user to delete an existing image.
The subcommand is *azure-img-utils image delete*.
The *required* parameters for the execution of the command (authentication
aside):
- --image-name
Example:
```shell
$ azure-img-utils image delete --image-name myImageName
```
For more information about the image delete command see the help message:
```shell
$ azure-img-utils image delete --help
```
## gallery-image-version command
Group of commands for gallery image version management.
### exists subcommand
This subcommand allows the user to check if a gallery image version exists in a
gallery.
The subcommand is *azure-img-utils gallery-image-version exists*.
The *required* parameters for the execution of the command (authentication
aside):
- --gallery-image-name
- --gallery-name
- --gallery-image-version
Example:
```shell
$ azure-img-utils gallery-image-version exists \
--gallery-image-name myImageName \
--gallery-name myGalleryName \
--gallery-image-version 0.0.1
```
This command will output *true* or *false* depending on the existence of the
gallery image version in the gallery.
For more information about the gallery image version exists command see the
help message:
```shell
$ azure-img-utils gallery-image-version exists --help
```
### create subcommand
This subcommand allows the user to create a gallery image version in a gallery based
on a blob.
The subcommand is *azure-img-utils gallery-image-version create*.
The *required* parameters for the execution of the command (authentication
aside):
- --blob-name
- --gallery-name
- --gallery-image-name
- --gallery-image-version
- --resource-group
Some *optional* parameters for the execution of the command include:
- --force-replace-image (defaults to False)
Example:
```shell
$ azure-img-utils gallery-image-version create \
--blob-name myBlobName \
--gallery-image-name myImageName \
--gallery-name myGalleryName \
--image-version 0.0.1 \
--resource-group myResourceGroup
```
For more information about the gallery image version create command see the help
message:
```shell
$ azure-img-utils gallery-image-version create --help
```
### delete subcommand
This subcommand allows the user to delete an existing gallery image version of
a gallery image.
The subcommand is *azure-img-utils gallery-image-version delete*.
The *required* parameters for the execution of the command (authentication
aside):
- --gallery-name
- --gallery-image-name
- --gallery-image-version
Example:
```shell
$ azure-img-utils gallery-image-version delete \
--gallery-image-name myImageName \
--gallery-name myGalleryName \
--gallery-image-version 0.0.1
```
For more information about the gallery image version delete command see the
help message:
```shell
$ azure-img-utils gallery-image-version delete --help
```
## cloud-partner-offer command
Group of commands for cloud partner offer management.
### publish subcommand
This subcommand allows the user to publish a cloud partner offer.
The subcommand is *azure-img-utils cloud-partner-offer publish*.
The *required* parameters for the execution of the command (authentication
aside):
- --offer-id
Example:
```shell
$ azure-img-utils cloud-partner-offer publish \
--offer-id myOfferId
```
This command will output the job id for the published cloud partner offer
operation if successful.
For more information about the cloud partner offer publish command see the
help message:
```shell
$ azure-img-utils cloud-partner-offer publish --help
### go-live subcommand
This subcommand allows the user to set a cloud partner offer as go-live.
The subcommand is *azure-img-utils cloud-partner-offer go-live*.
The *required* parameters for the execution of the command (authentication
aside):
- --offer-id
The result of the subcommand is that all new changes made to the offer are
publicly visible.
Example:
```shell
$ azure-img-utils cloud-partner-offer go-live \
--offer-id myOfferId
```
This command will output the URI for the cloud partner offer go-live operation
if successful.
For more information about the cloud partner offer go-live command see the
help message:
```shell
$ azure-img-utils cloud-partner-offer go-live --help
```
### upload-offer-document subcommand
This subcommand allows the user to upload an offer document to a cloud
partner offer.
The subcommand is *azure-img-utils cloud-partner-offer upload-offer-document*.
The *required* parameters for the execution of the command (authentication
aside):
- --offer-id
- --offer-document-file
The '--offer-document-file' parameter has to contain the path for a text file
containing the json document for the offer.
Example:
```shell
$ azure-img-utils cloud-partner-offer upload-offer-document \
--offer-id myOfferId \
--offer-document-file /path/to/my/documentfile.json
```
This command will output only if there's any problem uploading the document for
the offer.
For more information about the cloud partner offer upload-offer-document
command see the help message:
```shell
$ azure-img-utils cloud-partner-offer upload-offer-document --help
```
### add-image-to-offer subcommand
This subcommand allows the user to add an image to a cloud partner offer.
The subcommand is *azure-img-utils cloud-partner-offer add-image-to-offer*.
The *required* parameters for the execution of the command (authentication
aside):
- --blob-name
- --image-name
- --offer-id
- --sku
Some *optional* parameters for the execution of the command include:
- --blob-url (A blob-url is generated if not provided)
- --generation-id
Example:
```shell
$ azure-img-utils cloud-partner-offer add-image-to-offer \
--blob-name myBlobName \
--image-name myImageName \
--offer-id myOfferId \
--sku mySKU
```
This command will output only if there's any problem adding the image
to the offer.
For more information about the cloud partner offer add-image-to-offer
command see the help message:
```shell
$ azure-img-utils cloud-partner-offer add-image-to-offer --help
```
### remove-image-from-offer subcommand
This subcommand allows the user to remove an image from a cloud partner offer.
The subcommand is *azure-img-utils cloud-partner-offer remove-image-from-offer*.
The *required* parameters for the execution of the command (authentication
aside):
- --image-urn
Example:
```shell
$ azure-img-utils cloud-partner-offer remove-image-to-offer \
--image-urn myImageUrn
```
This command will output only if there's any problem removing the image
from the offer.
For more information about the cloud partner offer remove-image-from-offer
command see the help message:
```shell
$ azure-img-utils cloud-partner-offer remove-image-from-offer --help
```
# API
The AzureImage class can be instantiated and used as an API from code.
This provides all the same functions as the CLI with a few additional
helpers. For example there are waiter functions which will wait for
a compute image to be created and/or deleted.
To create an instance of AzureImage you need a *storage_account*,
*credentials dictionary object* or *credentials file* or *sas token*
*container* and *resource group*. Optionally you can pass
in a Python log object and/or a *log_level* and/or a *timeout* value.
Note that you can provide authentication credentials in 3 different ways:
- with a sas_token
- with a dictionary of credentials containing the required key values
- with the credentials file name
Providing just one of these options is enough to perform the authentication
in the Azure API.
```python
azure_image = AzureImage(
container="my_container_name",
storage_account="my_storage_account",
credentials=my_credentials_dict,
credentials_file="my_credentials_file.json",
resource_group="my_resource_group",
sas_token="my_sas_token",
log_level=my_log_level,
log_callback=logger
timeout=myTimeout
)
```
## Code examples
With an instance of AzureImage you can perform any of the image functions
which are available through the CLI.
```python
azure_image = AzureImage(
container="my_container",
storage_account="my_storage_account",
credentials_file="my_credentials.json",
resource_gropu="my_resource_group",
sas_token="my_sas_token"
)
```
### Check if image blob exists
```python
blob_exists = azure_image.image_blob_exists("my_blob_name")
```
# Delete storage blob
```python
blob_deleted = azure_image.delete_storage_blob("my_blob_name")
```
### Upload image blob
```python
blob_name = azure_image.upload_image_blob(
"my_image_file.qcow2",
blob_name="my_blob_name"
)
```
### Check if image exists
```python
image_exists = azure_image.image_exists("my_image_name")
```
### Check if gallery image version exists
```python
gallery_image_version_exists = azure_image.gallery_image_version_exists(
"my_gallery_name",
"my_gallery_image_name",
"my_image_version",
gallery_resource_group="my_gallery_resource_group"
)
```
### Delete compute image
```python
azure_image.delete_compute_image("my_image_name")
```
### Delete gallery image version
```python
azure_image.delete_gallery_image_version(
"my_gallery_name",
"my_gallery_image_name",
"my_image_version",
gallery_resource_group="my_gallery_resource_group"
)
```
### Get compute image dictionary
```python
image_dict = azure_image.get_compute_image("my_image_name")
```
### Get gallery image version
```python
image_dict = azure_image.get_gallery_image_version(
"my_gallery_name",
"my_gallery_image_name",
"my_image_version",
gallery_resource_group="my_gallery_resource_group"
)
```
### Create compute image
```python
image_name = azure_image.create_compute_image(
"my_blob_name",
"my_image_name",
"my_region",
force_replace_image=True,
hyper_v_generation='V1'
)
```
### Create gallery image version
```python
image_name = azure_image.create_gallery_image_version(
"my_blob_name",
"my_gallery_name",
"my_gallery_image_name",
"my_image_version",
"my_region",
force_replace_image=True,
gallery_resource_group="my_gallery_resource_group"
)
```
### Get offer doc dictionary
```python
offer_doc = azure_image.get_offer_doc(
"my_offer_id"
)
```
### Upload offer doc
```python
azure_image.upload_offer_doc(
"my_offer_id",
my_offer_doc_dict
)
```
### Add image to offer
```python
azure_image.add_image_to_offer(
"my_blob_name",
"my_image_name",
"my_offer_id",
"my_sku",
blob_url="https://my.blob.url",
generation_id="my_generation_id"
)
```
### Remove image from offer
```python
azure_image.remove_image_from_offer("my_image_urn")
```
### Publish offer
```python
operation_uri = azure_image.publish_offer(
"my_offer_id"
)
```
### Go live with offer
```python
operation_uri = azure_image.go_live_with_offer(
"my_offer_id"
)
```
### Get offer status
```python
offer_status = azure_image.get_offer_status(
"my_offer_id"
)
```
### Get operation
```python
operation_status = azure_image.get_operation("my_operation")
```
# Issues/Enhancements
Please submit issues and requests to
[Github](https://github.com/SUSE-Enceladus/azure-img-utils/issues).
# Contributing
Contributions to **azure-img-utils** are welcome and encouraged. See
[CONTRIBUTING](https://github.com/SUSE-Enceladus/azure-img-utils/blob/master/CONTRIBUTING.md)
for info on getting started.
# License
Copyright (c) 2022 SUSE LLC.
Distributed under the terms of GPL-3.0+ license, see
[LICENSE](https://github.com/SUSE-Enceladus/azure-img-utils/blob/master/LICENSE)
for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/SUSE-Enceladus/azure-img-utils",
"name": "azure-img-utils",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "azure-img-utils azure_img_utils",
"author": "SUSE",
"author_email": "public-cloud-dev@susecloud.net",
"download_url": "https://files.pythonhosted.org/packages/f9/02/ebb841e90dc468862829e7f9505b7629723c3e64cb3d99bff22e808c9934/azure-img-utils-2.2.0.tar.gz",
"platform": null,
"description": "\n# Overview\n\n**azure-img-utils** provides a command line utility and API for publishing\nimages in the Azure Cloud. This includes helper functions for uploading\nimage blobs, creating compute images and publish/share images across\nall available regions.\n\nSee the [Azure docs](https://docs.microsoft.com/en-us/azure/) to get\nmore info on the Azure cloud.\n\n# Requirements\n\nThe requirements for the project can be found in the following repo files:\n- [requirements](requirement.txt)\n- [requirements for testing](requirement-test.txt)\n- [requirements for development](requirement-dev.txt)\n\n# Installation\n\nTo install the package on openSUSE and SLES use the following commands as root:\n\n```shell\n# zypper ar https://download.opensuse.org/repositories/Cloud:Tools:CI/<distribution>\n# zypper refresh\n# zypper in python3-azure-img-utils\n```\n\nTo install from PyPI:\n\n```shell\n$ pip install azure-img-utils\n```\n\n# Configuration\n\n**azure-img-utils** can be configured with yaml based profiles. The configuration\ndirectory is `~/.config/azure_img_utils` and the default profile is default.yaml\n(~/.config/azure_img_utils/default.yaml).\n\nThe following configration options are available in a configuration profile:\n\n- no_color\n- log_level\n- credentials_file\n- resource_group\n- region\n- container\n- storage_account\n\n\nAn example configuration profile may look like:\n\n```yaml\nregion: westus\nno_color: True\ncredentials_file: mycredentials.json\ncontainer: my_container\n```\n\nWhen running any command the profile can be chosen via the *--profile* option.\nFor example, *azure-img-utils image blobexists --profile production* would pull\nconfiguration from ~/.config/azure_img_utils/production.yaml.\n\n\n# CLI\n\nThe CLI is broken into multiple distinct subcommands that handle different\nsteps of creating and publishing images in the Azure cloud framework.\n\n## Authentication\n\nThis cli tool expects the user to provide a json file containing the\ncredentials of a service principal to access his/her Azure services.\n\nPer Azure documentation:\n> An Azure service principal is an identity created for use with applications,\n> hosted services, and automated tools to access Azure resources.\n\n[Here](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli)\nyou can find how to create a service principal with the azure cli.\n\nWith your subscriptionId, the resourceGroupId and the required permissions, you can\ncreate the service principal with the following command:\n\n```sh\naz ad sp create-for-rbac \\\n --sdk-auth \\\n --role Contributor \\\n --scopes /subscriptions/{YOUR_SUSCRI_ID}/resourceGroups/{YOUR_RES_GROUP_ID} \\\n --name \"YOUR_SP_NAME\" > mycredentials.json\n```\n\nThe expected format for the json file is the output for that *create-for-rbac* az\ncommand. Note that the API this repo provides allows additional methods of\nauthentication, but these are not supported in this CLI tool.\n\n\n## blob command\n\nGroup of commands for blob management.\n\n### exists subcommand\n\nThis subcommand allows the user to check if a blob exists in the storage\ncontainer specified. The subcommand is *azure-img-utils blob exists*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --storage-account\n- --blob-name\n- --container\n\nExample:\n\n```shell\n$ azure-img-utils blob exists --storage-account myStorageAccount \\\n --blob-name myBlobName \\\n --container myContainerName\n```\n\nThis command will output *true* or *false* depending on the existence of the\nblob.\n\nFor more information about the blob exists command see the help message:\n\n```shell\n$ azure-img-utils blob exists --help\n```\n\n### upload subcommand\n\nThis subcommand allows the user to upload a file as a blob to the storage\ncontainer specified. The subcommand is *azure-img-utils blob upload*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --storage-account\n- --blob-name\n- --container\n- --image-file\n\nSome *optional* parameters for the execution of the command include:\n- --force-replace-image (defaults to False)\n- --page-blob (defaults to False)\n- --expand-image (defaults to False)\n- --max-workers (defaults to 5(no limit))\n- --max-attempts (defaults to 5(no limit))\n\n\nExample:\n\n```shell\n$ azure-img-utils blob upload --storage-account myStorageAccount \\\n --blob-name myBlobName \\\n --container myContainerName \\\n --image-file myImageFile.qcow2\n```\n\nThis command will output if the upload has been successful or not.\n\nFor more information about the blob upload command see the help message:\n\n```shell\n$ azure-img-utils blob upload --help\n```\n\n### delete subcommand\n\nThis subcommand allows the user to delete a blob file from the storage\ncontainer specified. The subcommand is *azure-img-utils blob delete*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --storage-account\n- --blob-name\n- --container\n\nSome *optional* parameters for the execution of the command:\n- --yes (avoids interactive confirmation for the deletion)\n\nExample:\n\n```shell\n$ azure-img-utils blob delete --storage-account myStorageAccount \\\n --blob-name myBlobName \\\n --container myContainerName \\\n --yes\n```\n\nThis command will output if the deletion has been successful or not.\n\nFor more information about the blob delete command see the help message:\n\n```shell\n$ azure-img-utils blob delete --help\n```\n\n## image command\n\nGroup of commands for image management.\n\n### exists subcommand\n\nThis subcommand allows the user to check if an image exists.\nThe subcommand is *azure-img-utils image exists*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --image-name\n\nExample:\n\n```shell\n$ azure-img-utils image exists --image-name myImageName\n```\n\nThis command will output *true* or *false* depending on the existence of the\nimage.\n\nFor more information about the image exists command see the help message:\n\n```shell\n$ azure-img-utils image exists --help\n```\n\n### create subcommand\n\nThis subcommand allows the user to create an image based in one blob.\nThe subcommand is *azure-img-utils image create*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --blob-name\n- --image-name\n- --container\n- --resource-group\n- --storage-account\n\nSome *optional* parameters for the execution of the command include:\n- --force-replace-image (defaults to False)\n- --hyper-v-generation (defaults to 'V1'(legacy bios).)\n (Use 'V2' for uefi boot.)\n\nExample:\n\n```shell\n$ azure-img-utils image create --blob-name myBlobName \\\n --image-name myImageName\n```\n\nFor more information about the image create command see the help message:\n\n```shell\n$ azure-img-utils image create --help\n```\n\n### delete subcommand\n\nThis subcommand allows the user to delete an existing image.\nThe subcommand is *azure-img-utils image delete*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --image-name\n\nExample:\n\n```shell\n$ azure-img-utils image delete --image-name myImageName\n```\n\nFor more information about the image delete command see the help message:\n\n```shell\n$ azure-img-utils image delete --help\n```\n\n## gallery-image-version command\n\nGroup of commands for gallery image version management.\n\n### exists subcommand\n\nThis subcommand allows the user to check if a gallery image version exists in a\n gallery.\nThe subcommand is *azure-img-utils gallery-image-version exists*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --gallery-image-name\n- --gallery-name\n- --gallery-image-version\n\nExample:\n\n```shell\n$ azure-img-utils gallery-image-version exists \\\n --gallery-image-name myImageName \\\n --gallery-name myGalleryName \\\n --gallery-image-version 0.0.1\n```\n\nThis command will output *true* or *false* depending on the existence of the\ngallery image version in the gallery.\n\nFor more information about the gallery image version exists command see the\n help message:\n\n```shell\n$ azure-img-utils gallery-image-version exists --help\n```\n\n### create subcommand\n\nThis subcommand allows the user to create a gallery image version in a gallery based\n on a blob.\nThe subcommand is *azure-img-utils gallery-image-version create*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --blob-name\n- --gallery-name\n- --gallery-image-name\n- --gallery-image-version\n- --resource-group\n\nSome *optional* parameters for the execution of the command include:\n- --force-replace-image (defaults to False)\n\nExample:\n\n```shell\n$ azure-img-utils gallery-image-version create \\\n --blob-name myBlobName \\\n --gallery-image-name myImageName \\\n --gallery-name myGalleryName \\\n --image-version 0.0.1 \\\n --resource-group myResourceGroup\n```\n\nFor more information about the gallery image version create command see the help\n message:\n\n```shell\n$ azure-img-utils gallery-image-version create --help\n```\n\n### delete subcommand\n\nThis subcommand allows the user to delete an existing gallery image version of\na gallery image.\n\nThe subcommand is *azure-img-utils gallery-image-version delete*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --gallery-name\n- --gallery-image-name\n- --gallery-image-version\n\nExample:\n\n```shell\n$ azure-img-utils gallery-image-version delete \\\n --gallery-image-name myImageName \\\n --gallery-name myGalleryName \\\n --gallery-image-version 0.0.1\n```\n\nFor more information about the gallery image version delete command see the\nhelp message:\n\n```shell\n$ azure-img-utils gallery-image-version delete --help\n```\n\n## cloud-partner-offer command\n\nGroup of commands for cloud partner offer management.\n\n### publish subcommand\n\nThis subcommand allows the user to publish a cloud partner offer.\n\nThe subcommand is *azure-img-utils cloud-partner-offer publish*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --offer-id\n\nExample:\n\n```shell\n$ azure-img-utils cloud-partner-offer publish \\\n --offer-id myOfferId\n```\n\nThis command will output the job id for the published cloud partner offer\n operation if successful.\n\nFor more information about the cloud partner offer publish command see the\n help message:\n\n```shell\n$ azure-img-utils cloud-partner-offer publish --help\n\n### go-live subcommand\n\nThis subcommand allows the user to set a cloud partner offer as go-live.\n\nThe subcommand is *azure-img-utils cloud-partner-offer go-live*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --offer-id\n\nThe result of the subcommand is that all new changes made to the offer are\n publicly visible.\n\nExample:\n\n```shell\n$ azure-img-utils cloud-partner-offer go-live \\\n --offer-id myOfferId\n```\n\nThis command will output the URI for the cloud partner offer go-live operation\nif successful.\n\nFor more information about the cloud partner offer go-live command see the\n help message:\n\n```shell\n$ azure-img-utils cloud-partner-offer go-live --help\n```\n\n### upload-offer-document subcommand\n\nThis subcommand allows the user to upload an offer document to a cloud\n partner offer.\n\nThe subcommand is *azure-img-utils cloud-partner-offer upload-offer-document*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --offer-id\n- --offer-document-file\n\nThe '--offer-document-file' parameter has to contain the path for a text file\ncontaining the json document for the offer.\n\nExample:\n\n```shell\n$ azure-img-utils cloud-partner-offer upload-offer-document \\\n --offer-id myOfferId \\\n --offer-document-file /path/to/my/documentfile.json\n```\n\nThis command will output only if there's any problem uploading the document for\nthe offer.\n\nFor more information about the cloud partner offer upload-offer-document\ncommand see the help message:\n\n```shell\n$ azure-img-utils cloud-partner-offer upload-offer-document --help\n```\n\n### add-image-to-offer subcommand\n\nThis subcommand allows the user to add an image to a cloud partner offer.\n\nThe subcommand is *azure-img-utils cloud-partner-offer add-image-to-offer*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --blob-name\n- --image-name\n- --offer-id\n- --sku\n\nSome *optional* parameters for the execution of the command include:\n- --blob-url (A blob-url is generated if not provided)\n- --generation-id\n\nExample:\n\n```shell\n$ azure-img-utils cloud-partner-offer add-image-to-offer \\\n --blob-name myBlobName \\\n --image-name myImageName \\\n --offer-id myOfferId \\\n --sku mySKU\n```\n\nThis command will output only if there's any problem adding the image\n to the offer.\n\nFor more information about the cloud partner offer add-image-to-offer\ncommand see the help message:\n\n```shell\n$ azure-img-utils cloud-partner-offer add-image-to-offer --help\n```\n\n### remove-image-from-offer subcommand\n\nThis subcommand allows the user to remove an image from a cloud partner offer.\n\nThe subcommand is *azure-img-utils cloud-partner-offer remove-image-from-offer*.\n\nThe *required* parameters for the execution of the command (authentication\n aside):\n- --image-urn\n\nExample:\n\n```shell\n$ azure-img-utils cloud-partner-offer remove-image-to-offer \\\n --image-urn myImageUrn\n```\n\nThis command will output only if there's any problem removing the image\n from the offer.\n\nFor more information about the cloud partner offer remove-image-from-offer\ncommand see the help message:\n\n```shell\n$ azure-img-utils cloud-partner-offer remove-image-from-offer --help\n```\n\n# API\n\nThe AzureImage class can be instantiated and used as an API from code.\nThis provides all the same functions as the CLI with a few additional\nhelpers. For example there are waiter functions which will wait for\na compute image to be created and/or deleted.\n\nTo create an instance of AzureImage you need a *storage_account*,\n*credentials dictionary object* or *credentials file* or *sas token*\n*container* and *resource group*. Optionally you can pass\nin a Python log object and/or a *log_level* and/or a *timeout* value.\n\nNote that you can provide authentication credentials in 3 different ways:\n- with a sas_token\n- with a dictionary of credentials containing the required key values\n- with the credentials file name\nProviding just one of these options is enough to perform the authentication\nin the Azure API.\n\n```python\nazure_image = AzureImage(\n container=\"my_container_name\",\n storage_account=\"my_storage_account\",\n credentials=my_credentials_dict,\n credentials_file=\"my_credentials_file.json\",\n resource_group=\"my_resource_group\",\n sas_token=\"my_sas_token\",\n log_level=my_log_level,\n log_callback=logger\n timeout=myTimeout\n)\n```\n\n## Code examples\n\nWith an instance of AzureImage you can perform any of the image functions\nwhich are available through the CLI.\n\n```python\nazure_image = AzureImage(\n container=\"my_container\",\n storage_account=\"my_storage_account\",\n credentials_file=\"my_credentials.json\",\n resource_gropu=\"my_resource_group\",\n sas_token=\"my_sas_token\"\n)\n```\n\n### Check if image blob exists\n```python\nblob_exists = azure_image.image_blob_exists(\"my_blob_name\")\n```\n\n# Delete storage blob\n```python\nblob_deleted = azure_image.delete_storage_blob(\"my_blob_name\")\n```\n\n### Upload image blob\n```python\nblob_name = azure_image.upload_image_blob(\n \"my_image_file.qcow2\",\n blob_name=\"my_blob_name\"\n)\n```\n\n### Check if image exists\n```python\nimage_exists = azure_image.image_exists(\"my_image_name\")\n```\n\n### Check if gallery image version exists\n```python\ngallery_image_version_exists = azure_image.gallery_image_version_exists(\n \"my_gallery_name\",\n \"my_gallery_image_name\",\n \"my_image_version\",\n gallery_resource_group=\"my_gallery_resource_group\"\n)\n```\n\n### Delete compute image\n```python\nazure_image.delete_compute_image(\"my_image_name\")\n```\n\n### Delete gallery image version\n```python\nazure_image.delete_gallery_image_version(\n \"my_gallery_name\",\n \"my_gallery_image_name\",\n \"my_image_version\",\n gallery_resource_group=\"my_gallery_resource_group\"\n)\n```\n\n### Get compute image dictionary\n```python\nimage_dict = azure_image.get_compute_image(\"my_image_name\")\n```\n\n### Get gallery image version\n```python\nimage_dict = azure_image.get_gallery_image_version(\n \"my_gallery_name\",\n \"my_gallery_image_name\",\n \"my_image_version\",\n gallery_resource_group=\"my_gallery_resource_group\"\n)\n```\n\n### Create compute image\n```python\nimage_name = azure_image.create_compute_image(\n \"my_blob_name\",\n \"my_image_name\",\n \"my_region\",\n force_replace_image=True,\n hyper_v_generation='V1'\n)\n```\n\n### Create gallery image version\n```python\nimage_name = azure_image.create_gallery_image_version(\n \"my_blob_name\",\n \"my_gallery_name\",\n \"my_gallery_image_name\",\n \"my_image_version\",\n \"my_region\",\n force_replace_image=True,\n gallery_resource_group=\"my_gallery_resource_group\"\n)\n```\n\n### Get offer doc dictionary\n```python\noffer_doc = azure_image.get_offer_doc(\n \"my_offer_id\"\n)\n```\n\n### Upload offer doc\n```python\nazure_image.upload_offer_doc(\n \"my_offer_id\",\n my_offer_doc_dict\n)\n```\n\n### Add image to offer\n```python\nazure_image.add_image_to_offer(\n \"my_blob_name\",\n \"my_image_name\",\n \"my_offer_id\",\n \"my_sku\",\n blob_url=\"https://my.blob.url\",\n generation_id=\"my_generation_id\"\n)\n```\n\n### Remove image from offer\n```python\nazure_image.remove_image_from_offer(\"my_image_urn\")\n```\n\n### Publish offer\n```python\noperation_uri = azure_image.publish_offer(\n \"my_offer_id\"\n)\n```\n\n### Go live with offer\n```python\noperation_uri = azure_image.go_live_with_offer(\n \"my_offer_id\"\n)\n```\n\n### Get offer status\n```python\noffer_status = azure_image.get_offer_status(\n \"my_offer_id\"\n)\n```\n\n### Get operation\n```python\noperation_status = azure_image.get_operation(\"my_operation\")\n```\n\n# Issues/Enhancements\n\nPlease submit issues and requests to\n[Github](https://github.com/SUSE-Enceladus/azure-img-utils/issues).\n\n# Contributing\n\nContributions to **azure-img-utils** are welcome and encouraged. See\n[CONTRIBUTING](https://github.com/SUSE-Enceladus/azure-img-utils/blob/master/CONTRIBUTING.md)\nfor info on getting started.\n\n# License\n\nCopyright (c) 2022 SUSE LLC.\n\nDistributed under the terms of GPL-3.0+ license, see\n[LICENSE](https://github.com/SUSE-Enceladus/azure-img-utils/blob/master/LICENSE)\nfor details.\n",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "Package that provides utilities for handling images in Azure Cloud.",
"version": "2.2.0",
"project_urls": {
"Homepage": "https://github.com/SUSE-Enceladus/azure-img-utils"
},
"split_keywords": [
"azure-img-utils",
"azure_img_utils"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7449f103be00f5f18bfb90304697cc72323283ce7d95108504bf76ca052e567a",
"md5": "e83e61a380d060308fca438a5fce0459",
"sha256": "8cdf2d7a8de2b025b63204e526e8c1926a6aff2b980fed1fa6f634b017897ff0"
},
"downloads": -1,
"filename": "azure_img_utils-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e83e61a380d060308fca438a5fce0459",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 43843,
"upload_time": "2024-03-08T19:10:44",
"upload_time_iso_8601": "2024-03-08T19:10:44.855465Z",
"url": "https://files.pythonhosted.org/packages/74/49/f103be00f5f18bfb90304697cc72323283ce7d95108504bf76ca052e567a/azure_img_utils-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f902ebb841e90dc468862829e7f9505b7629723c3e64cb3d99bff22e808c9934",
"md5": "8e85947b420a563c8fbd720baebc4032",
"sha256": "e56a05fd7176e434a9653f48ec6bab25e278467146b7101e6a0f066da7dd44a0"
},
"downloads": -1,
"filename": "azure-img-utils-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "8e85947b420a563c8fbd720baebc4032",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 48512,
"upload_time": "2024-03-08T19:10:46",
"upload_time_iso_8601": "2024-03-08T19:10:46.972021Z",
"url": "https://files.pythonhosted.org/packages/f9/02/ebb841e90dc468862829e7f9505b7629723c3e64cb3d99bff22e808c9934/azure-img-utils-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-08 19:10:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SUSE-Enceladus",
"github_project": "azure-img-utils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "click",
"specs": []
},
{
"name": "msal",
"specs": []
},
{
"name": "azure-identity",
"specs": []
},
{
"name": "azure-mgmt-compute",
"specs": [
[
">=",
"26.1.0"
]
]
},
{
"name": "azure-mgmt-storage",
"specs": []
},
{
"name": "azure-storage-blob",
"specs": [
[
">=",
"12.0.0"
]
]
},
{
"name": "requests",
"specs": []
},
{
"name": "jmespath",
"specs": []
},
{
"name": "pyyaml",
"specs": []
}
],
"lcname": "azure-img-utils"
}