跳转到主要内容

OpenStack块存储API客户端库

项目描述

https://governance.openstack.org/tc/badges/python-cinderclient.svg

Python绑定到OpenStack Cinder API

Latest Version

这是一个OpenStack Cinder API的客户端。有一个Python API(cinderclient模块),还有一个命令行脚本(cinder)。每个都实现了100%的OpenStack Cinder API。

有关如何使用cinder命令行工具的信息,请参阅OpenStack CLI参考。您可能还想查看OpenStack API文档

该项目托管在Launchpad,可以在那里提交错误。代码托管在OpenStack。补丁必须使用Gerrit提交。

命令行API

安装此软件包会为您提供一个shell命令,cinder,您可以使用它来与任何兼容Rackspace的API(包括OpenStack)交互。

您需要提供OpenStack的用户名和密码。您可以使用--os-username--os-password--os-tenant-name参数来完成此操作,但直接将它们设置为环境变量更为便捷。

export OS_USERNAME=openstack
export OS_PASSWORD=yadayada
export OS_TENANT_NAME=myproject

您还需要使用--os-auth-url定义认证URL,以及使用--os-volume-api-version定义API的版本。也可以将它们作为环境变量设置。由于块存储API V2已正式弃用,建议设置OS_VOLUME_API_VERSION=3。如果您使用Keystone,则需要将OS_AUTH_URL设置为Keystone端点。

export OS_AUTH_URL=http://controller:5000/v3
export OS_VOLUME_API_VERSION=3

由于Keystone可以从服务目录返回多个区域,您可以使用--os-region-name(或export OS_REGION_NAME)指定您想要的区域。默认情况下,它将使用返回列表中的第一个区域。

通过运行cinder help,您可以在shell中找到完整的文档。

usage: cinder [--version] [-d] [--os-auth-system <auth-system>]
              [--service-type <service-type>] [--service-name <service-name>]
              [--volume-service-name <volume-service-name>]
              [--os-endpoint-type <os-endpoint-type>]
              [--endpoint-type <endpoint-type>]
              [--os-volume-api-version <volume-api-ver>]
              [--retries <retries>]
              [--profile HMAC_KEY] [--os-auth-strategy <auth-strategy>]
              [--os-username <auth-user-name>] [--os-password <auth-password>]
              [--os-tenant-name <auth-tenant-name>]
              [--os-tenant-id <auth-tenant-id>] [--os-auth-url <auth-url>]
              [--os-user-id <auth-user-id>]
              [--os-user-domain-id <auth-user-domain-id>]
              [--os-user-domain-name <auth-user-domain-name>]
              [--os-project-id <auth-project-id>]
              [--os-project-name <auth-project-name>]
              [--os-project-domain-id <auth-project-domain-id>]
              [--os-project-domain-name <auth-project-domain-name>]
              [--os-region-name <region-name>] [--os-token <token>]
              [--os-url <url>] [--insecure] [--os-cacert <ca-certificate>]
              [--os-cert <certificate>] [--os-key <key>] [--timeout <seconds>]
              <subcommand> ...

Command-line interface to the OpenStack Cinder API.

Positional arguments:
  <subcommand>
    absolute-limits     Lists absolute limits for a user.
    api-version         Display the server API version information. (Supported
                        by API versions 3.0 - 3.latest)
    availability-zone-list
                        Lists all availability zones.
    backup-create       Creates a volume backup.
    backup-delete       Removes one or more backups.
    backup-export       Export backup metadata record.
    backup-import       Import backup metadata record.
    backup-list         Lists all backups.
    backup-reset-state  Explicitly updates the backup state.
    backup-restore      Restores a backup.
    backup-show         Shows backup details.
    cgsnapshot-create   Creates a cgsnapshot.
    cgsnapshot-delete   Removes one or more cgsnapshots.
    cgsnapshot-list     Lists all cgsnapshots.
    cgsnapshot-show     Shows cgsnapshot details.
    consisgroup-create  Creates a consistency group.
    consisgroup-create-from-src
                        Creates a consistency group from a cgsnapshot or a
                        source CG.
    consisgroup-delete  Removes one or more consistency groups.
    consisgroup-list    Lists all consistency groups.
    consisgroup-show    Shows details of a consistency group.
    consisgroup-update  Updates a consistency group.
    create              Creates a volume.
    credentials         Shows user credentials returned from auth.
    delete              Removes one or more volumes.
    encryption-type-create
                        Creates encryption type for a volume type. Admin only.
    encryption-type-delete
                        Deletes encryption type for a volume type. Admin only.
    encryption-type-list
                        Shows encryption type details for volume types. Admin
                        only.
    encryption-type-show
                        Shows encryption type details for a volume type. Admin
                        only.
    encryption-type-update
                        Update encryption type information for a volume type
                        (Admin Only).
    endpoints           Discovers endpoints registered by authentication
                        service.
    extend              Attempts to extend size of an existing volume.
    extra-specs-list    Lists current volume types and extra specs.
    failover-host       Failover a replicating cinder-volume host.
    force-delete        Attempts force-delete of volume, regardless of state.
    freeze-host         Freeze and disable the specified cinder-volume host.
    get-capabilities    Show backend volume stats and properties. Admin only.
    get-pools           Show pool information for backends. Admin only.
    image-metadata      Sets or deletes volume image metadata.
    image-metadata-show
                        Shows volume image metadata.
    list                Lists all volumes.
    manage              Manage an existing volume.
    metadata            Sets or deletes volume metadata.
    metadata-show       Shows volume metadata.
    metadata-update-all
                        Updates volume metadata.
    migrate             Migrates volume to a new host.
    qos-associate       Associates qos specs with specified volume type.
    qos-create          Creates a qos specs.
    qos-delete          Deletes a specified qos specs.
    qos-disassociate    Disassociates qos specs from specified volume type.
    qos-disassociate-all
                        Disassociates qos specs from all its associations.
    qos-get-association
                        Lists all associations for specified qos specs.
    qos-key             Sets or unsets specifications for a qos spec.
    qos-list            Lists qos specs.
    qos-show            Shows qos specs details.
    quota-class-show    Lists quotas for a quota class.
    quota-class-update  Updates quotas for a quota class.
    quota-defaults      Lists default quotas for a tenant.
    quota-delete        Delete the quotas for a tenant.
    quota-show          Lists quotas for a tenant.
    quota-update        Updates quotas for a tenant.
    quota-usage         Lists quota usage for a tenant.
    rate-limits         Lists rate limits for a user.
    readonly-mode-update
                        Updates volume read-only access-mode flag.
    rename              Renames a volume.
    reset-state         Explicitly updates the volume state in the Cinder
                        database.
    retype              Changes the volume type for a volume.
    service-disable     Disables the service.
    service-enable      Enables the service.
    service-list        Lists all services. Filter by host and service binary.
                        (Supported by API versions 3.0 - 3.latest)
    set-bootable        Update bootable status of a volume.
    show                Shows volume details.
    snapshot-create     Creates a snapshot.
    snapshot-delete     Removes one or more snapshots.
    snapshot-list       Lists all snapshots.
    snapshot-manage     Manage an existing snapshot.
    snapshot-metadata   Sets or deletes snapshot metadata.
    snapshot-metadata-show
                        Shows snapshot metadata.
    snapshot-metadata-update-all
                        Updates snapshot metadata.
    snapshot-rename     Renames a snapshot.
    snapshot-reset-state
                        Explicitly updates the snapshot state.
    snapshot-show       Shows snapshot details.
    snapshot-unmanage   Stop managing a snapshot.
    thaw-host           Thaw and enable the specified cinder-volume host.
    transfer-accept     Accepts a volume transfer.
    transfer-create     Creates a volume transfer.
    transfer-delete     Undoes a transfer.
    transfer-list       Lists all transfers.
    transfer-show       Shows transfer details.
    type-access-add     Adds volume type access for the given project.
    type-access-list    Print access information about the given volume type.
    type-access-remove  Removes volume type access for the given project.
    type-create         Creates a volume type.
    type-default        List the default volume type.
    type-delete         Deletes volume type or types.
    type-key            Sets or unsets extra_spec for a volume type.
    type-list           Lists available 'volume types'.
    type-show           Show volume type details.
    type-update         Updates volume type name, description, and/or
                        is_public.
    unmanage            Stop managing a volume.
    upload-to-image     Uploads volume to Image Service as an image.
    version-list        List all API versions. (Supported by API versions 3.0
                        - 3.latest)
    bash-completion     Prints arguments for bash_completion.
    help                Shows help about this program or one of its
                        subcommands.
    list-extensions

Optional arguments:
  --version             show program's version number and exit
  -d, --debug           Shows debugging output.
  --os-auth-system <auth-system>
                        Defaults to env[OS_AUTH_SYSTEM].
  --service-type <service-type>
                        Service type. For most actions, default is volume.
  --service-name <service-name>
                        Service name. Default=env[CINDER_SERVICE_NAME].
  --volume-service-name <volume-service-name>
                        Volume service name.
                        Default=env[CINDER_VOLUME_SERVICE_NAME].
  --os-endpoint
                        Use this API endpoint instead of the Service Catalog.
                        Default=env[CINDER_ENDPOINT]
  --os-endpoint-type <os-endpoint-type>
                        Endpoint type, which is publicURL or internalURL.
                        Default=env[OS_ENDPOINT_TYPE] or nova
                        env[CINDER_ENDPOINT_TYPE] or publicURL.
  --endpoint-type <endpoint-type>
                        DEPRECATED! Use --os-endpoint-type.
  --os-volume-api-version <volume-api-ver>
                        Block Storage API version. Accepts X, X.Y (where X is
                        major and Y is minor
                        part).Default=env[OS_VOLUME_API_VERSION].
  --retries <retries>   Number of retries.
  --profile HMAC_KEY    HMAC key to use for encrypting context data for
                        performance profiling of operation. This key needs to
                        match the one configured on the cinder api server.
                        Without key the profiling will not be triggered even
                        if osprofiler is enabled on server side.
                        Defaults to env[OS_PROFILE].
  --os-auth-strategy <auth-strategy>
                        Authentication strategy (Env: OS_AUTH_STRATEGY,
                        default keystone). For now, any other value will
                        disable the authentication.
  --os-username <auth-user-name>
                        OpenStack user name. Default=env[OS_USERNAME].
  --os-password <auth-password>
                        Password for OpenStack user. Default=env[OS_PASSWORD].
  --os-tenant-name <auth-tenant-name>
                        Tenant name. Default=env[OS_TENANT_NAME].
  --os-tenant-id <auth-tenant-id>
                        ID for the tenant. Default=env[OS_TENANT_ID].
  --os-auth-url <auth-url>
                        URL for the authentication service.
                        Default=env[OS_AUTH_URL].
  --os-user-id <auth-user-id>
                        Authentication user ID (Env: OS_USER_ID).
  --os-user-domain-id <auth-user-domain-id>
                        OpenStack user domain ID. Defaults to
                        env[OS_USER_DOMAIN_ID].
  --os-user-domain-name <auth-user-domain-name>
                        OpenStack user domain name. Defaults to
                        env[OS_USER_DOMAIN_NAME].
  --os-project-id <auth-project-id>
                        Another way to specify tenant ID. This option is
                        mutually exclusive with --os-tenant-id. Defaults to
                        env[OS_PROJECT_ID].
  --os-project-name <auth-project-name>
                        Another way to specify tenant name. This option is
                        mutually exclusive with --os-tenant-name. Defaults to
                        env[OS_PROJECT_NAME].
  --os-project-domain-id <auth-project-domain-id>
                        Defaults to env[OS_PROJECT_DOMAIN_ID].
  --os-project-domain-name <auth-project-domain-name>
                        Defaults to env[OS_PROJECT_DOMAIN_NAME].
  --os-region-name <region-name>
                        Region name. Default=env[OS_REGION_NAME].
  --os-token <token>    Defaults to env[OS_TOKEN].
  --os-url <url>        Defaults to env[OS_URL].

API Connection Options:
  Options controlling the HTTP API Connections

  --insecure            Explicitly allow client to perform "insecure" TLS
                        (https) requests. The server's certificate will not be
                        verified against any certificate authorities. This
                        option should be used with caution.
  --os-cacert <ca-certificate>
                        Specify a CA bundle file to use in verifying a TLS
                        (https) server certificate. Defaults to
                        env[OS_CACERT].
  --os-cert <certificate>
                        Defaults to env[OS_CERT].
  --os-key <key>        Defaults to env[OS_KEY].
  --timeout <seconds>   Set request timeout (in seconds).

Run "cinder help SUBCOMMAND" for help on a subcommand.

如果您想获取特定版本的API帮助信息,可以在帮助命令中添加--os-volume-api-version <volume-api-ver>,如下所示:

cinder --os-volume-api-version 3.28 help

Python API

此外,还有一个完整的Python API,但尚未进行文档记录。

使用keystone快速启动

# use v3 auth with http://controller:5000/v3
>>> from cinderclient.v3 import client
>>> nt = client.Client(USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
>>> nt.volumes.list()
[...]

有关发布说明和其他信息,请参阅https://docs.openstack.org/python-cinderclient/latest/

项目详情


发布历史 发布通知 | RSS源

下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。

源代码分发

python-cinderclient-9.6.0.tar.gz (237.2 kB 查看哈希值)

上传时间: 源代码

构建版本

python_cinderclient-9.6.0-py3-none-any.whl (256.2 kB 查看哈希值)

上传时间: Python 3

由以下组织支持