Merge "Change '_' to '-' in options"
This commit is contained in:
commit
a153f10b2b
54
README.rst
54
README.rst
@ -40,14 +40,14 @@ Installing this package gets you a shell command, ``cinder``, that you
|
||||
can use to interact with any Rackspace compatible API (including OpenStack).
|
||||
|
||||
You'll need to provide your OpenStack username and password. You can do this
|
||||
with the ``--os_username``, ``--os_password`` and ``--os_tenant_name``
|
||||
with the ``--os-username``, ``--os-password`` and ``--os-tenant-name``
|
||||
params, but it's easier to just set them as environment variables::
|
||||
|
||||
export OS_USERNAME=openstack
|
||||
export OS_PASSWORD=yadayada
|
||||
export OS_TENANT_NAME=myproject
|
||||
|
||||
You will also need to define the authentication url with ``--os_auth_url``
|
||||
You will also need to define the authentication url with ``--os-auth-url``
|
||||
and the version of the API with ``--version``. Or set them as an environment
|
||||
variables as well::
|
||||
|
||||
@ -60,20 +60,21 @@ endpoint::
|
||||
export OS_AUTH_URL=http://example.com:5000/v2.0/
|
||||
|
||||
Since Keystone can return multiple regions in the Service Catalog, you
|
||||
can specify the one you want with ``--os_region_name`` (or
|
||||
can specify the one you want with ``--os-region-name`` (or
|
||||
``export OS_REGION_NAME``). It defaults to the first in the list returned.
|
||||
|
||||
You'll find complete documentation on the shell by running
|
||||
``cinder help``::
|
||||
|
||||
usage: cinder [--debug] [--os_username OS_USERNAME] [--os_password OS_PASSWORD]
|
||||
[--os_tenant_name OS_TENANT_NAME] [--os_auth_url OS_AUTH_URL]
|
||||
[--os_region_name OS_REGION_NAME] [--service_type SERVICE_TYPE]
|
||||
[--service_name SERVICE_NAME] [--endpoint_type ENDPOINT_TYPE]
|
||||
[--version VERSION] [--username USERNAME]
|
||||
[--region_name REGION_NAME] [--apikey APIKEY]
|
||||
[--projectid PROJECTID] [--url URL]
|
||||
<subcommand> ...
|
||||
usage: cinder [--debug] [--os-username <auth-user-name>]
|
||||
[--os-password <auth-password>]
|
||||
[--os-tenant-name <auth-tenant-name>] [--os-auth-url <auth-url>]
|
||||
[--os-region-name <region-name>] [--service-type <service-type>]
|
||||
[--service-name <service-name>]
|
||||
[--volume-service-name <volume-service-name>]
|
||||
[--endpoint-type <endpoint-type>]
|
||||
[--os-volume-api-version <compute-api-ver>]
|
||||
<subcommand> ...
|
||||
|
||||
Command-line interface to the OpenStack Nova API.
|
||||
|
||||
@ -100,33 +101,26 @@ You'll find complete documentation on the shell by running
|
||||
|
||||
Optional arguments:
|
||||
--debug Print debugging output
|
||||
--os_username OS_USERNAME
|
||||
--os-username <auth-user-name>
|
||||
Defaults to env[OS_USERNAME].
|
||||
--os_password OS_PASSWORD
|
||||
--os-password <auth-password>
|
||||
Defaults to env[OS_PASSWORD].
|
||||
--os_tenant_name OS_TENANT_NAME
|
||||
--os-tenant-name <auth-tenant-name>
|
||||
Defaults to env[OS_TENANT_NAME].
|
||||
--os_auth_url OS_AUTH_URL
|
||||
--os-auth-url <auth-url>
|
||||
Defaults to env[OS_AUTH_URL].
|
||||
--os_region_name OS_REGION_NAME
|
||||
--os-region-name <region-name>
|
||||
Defaults to env[OS_REGION_NAME].
|
||||
--service_type SERVICE_TYPE
|
||||
--service-type <service-type>
|
||||
Defaults to compute for most actions
|
||||
--service_name SERVICE_NAME
|
||||
--service-name <service-name>
|
||||
Defaults to env[CINDER_SERVICE_NAME]
|
||||
--endpoint_type ENDPOINT_TYPE
|
||||
--volume-service-name <volume-service-name>
|
||||
Defaults to env[CINDER_VOLUME_SERVICE_NAME]
|
||||
--endpoint-type <endpoint-type>
|
||||
Defaults to env[CINDER_ENDPOINT_TYPE] or publicURL.
|
||||
--os_compute_api_version VERSION
|
||||
Accepts 1.1, defaults to env[OS_COMPUTE_API_VERSION].
|
||||
--username USERNAME Deprecated
|
||||
--region_name REGION_NAME
|
||||
Deprecated
|
||||
--apikey APIKEY, --password APIKEY
|
||||
Deprecated
|
||||
--projectid PROJECTID, --tenant_name PROJECTID
|
||||
Deprecated
|
||||
--url URL, --auth_url URL
|
||||
Deprecated
|
||||
--os-volume-api-version <compute-api-ver>
|
||||
Accepts 1, defaults to env[OS_VOLUME_API_VERSION].
|
||||
|
||||
See "cinder help COMMAND" for help on a specific command.
|
||||
|
||||
|
@ -85,53 +85,83 @@ class OpenStackCinderShell(object):
|
||||
action='store_true',
|
||||
help="Print debugging output")
|
||||
|
||||
parser.add_argument('--os_username',
|
||||
parser.add_argument('--os-username',
|
||||
metavar='<auth-user-name>',
|
||||
default=utils.env('OS_USERNAME',
|
||||
'CINDER_USERNAME'),
|
||||
help='Defaults to env[OS_USERNAME].')
|
||||
parser.add_argument('--os_username',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os_password',
|
||||
parser.add_argument('--os-password',
|
||||
metavar='<auth-password>',
|
||||
default=utils.env('OS_PASSWORD',
|
||||
'CINDER_PASSWORD'),
|
||||
help='Defaults to env[OS_PASSWORD].')
|
||||
parser.add_argument('--os_password',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os_tenant_name',
|
||||
parser.add_argument('--os-tenant-name',
|
||||
metavar='<auth-tenant-name>',
|
||||
default=utils.env('OS_TENANT_NAME',
|
||||
'CINDER_PROJECT_ID'),
|
||||
help='Defaults to env[OS_TENANT_NAME].')
|
||||
parser.add_argument('--os_tenant_name',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os_auth_url',
|
||||
parser.add_argument('--os-auth-url',
|
||||
metavar='<auth-url>',
|
||||
default=utils.env('OS_AUTH_URL',
|
||||
'CINDER_URL'),
|
||||
help='Defaults to env[OS_AUTH_URL].')
|
||||
parser.add_argument('--os_auth_url',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os_region_name',
|
||||
parser.add_argument('--os-region-name',
|
||||
metavar='<region-name>',
|
||||
default=utils.env('OS_REGION_NAME',
|
||||
'CINDER_REGION_NAME'),
|
||||
help='Defaults to env[OS_REGION_NAME].')
|
||||
parser.add_argument('--os_region_name',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--service_type',
|
||||
parser.add_argument('--service-type',
|
||||
metavar='<service-type>',
|
||||
help='Defaults to compute for most actions')
|
||||
parser.add_argument('--service_type',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--service_name',
|
||||
parser.add_argument('--service-name',
|
||||
metavar='<service-name>',
|
||||
default=utils.env('CINDER_SERVICE_NAME'),
|
||||
help='Defaults to env[CINDER_SERVICE_NAME]')
|
||||
parser.add_argument('--service_name',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--volume_service_name',
|
||||
parser.add_argument('--volume-service-name',
|
||||
metavar='<volume-service-name>',
|
||||
default=utils.env('CINDER_VOLUME_SERVICE_NAME'),
|
||||
help='Defaults to env[CINDER_VOLUME_SERVICE_NAME]')
|
||||
parser.add_argument('--volume_service_name',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--endpoint_type',
|
||||
parser.add_argument('--endpoint-type',
|
||||
metavar='<endpoint-type>',
|
||||
default=utils.env('CINDER_ENDPOINT_TYPE',
|
||||
default=DEFAULT_CINDER_ENDPOINT_TYPE),
|
||||
help='Defaults to env[CINDER_ENDPOINT_TYPE] or '
|
||||
+ DEFAULT_CINDER_ENDPOINT_TYPE + '.')
|
||||
parser.add_argument('--endpoint_type',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os_volume_api_version',
|
||||
parser.add_argument('--os-volume-api-version',
|
||||
metavar='<compute-api-ver>',
|
||||
default=utils.env('OS_VOLUME_API_VERSION',
|
||||
default=DEFAULT_OS_VOLUME_API_VERSION),
|
||||
help='Accepts 1,defaults '
|
||||
'to env[OS_VOLUME_API_VERSION].')
|
||||
parser.add_argument('--os_volume_api_version',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--insecure',
|
||||
default=utils.env('CINDERCLIENT_INSECURE',
|
||||
@ -142,28 +172,28 @@ class OpenStackCinderShell(object):
|
||||
# FIXME(dtroyer): The args below are here for diablo compatibility,
|
||||
# remove them in folsum cycle
|
||||
|
||||
# alias for --os_username, left in for backwards compatibility
|
||||
# alias for --os-username, left in for backwards compatibility
|
||||
parser.add_argument('--username',
|
||||
help='Deprecated')
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# alias for --os_region_name, left in for backwards compatibility
|
||||
# alias for --os-region_name, left in for backwards compatibility
|
||||
parser.add_argument('--region_name',
|
||||
help='Deprecated')
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# alias for --os_password, left in for backwards compatibility
|
||||
# alias for --os-password, left in for backwards compatibility
|
||||
parser.add_argument('--apikey', '--password', dest='apikey',
|
||||
default=utils.env('CINDER_API_KEY'),
|
||||
help='Deprecated')
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# alias for --os_tenant_name, left in for backward compatibility
|
||||
# alias for --os-tenant-name, left in for backward compatibility
|
||||
parser.add_argument('--projectid', '--tenant_name', dest='projectid',
|
||||
default=utils.env('CINDER_PROJECT_ID'),
|
||||
help='Deprecated')
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# alias for --os_auth_url, left in for backward compatibility
|
||||
# alias for --os-auth-url, left in for backward compatibility
|
||||
parser.add_argument('--url', '--auth_url', dest='url',
|
||||
default=utils.env('CINDER_URL'),
|
||||
help='Deprecated')
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
return parser
|
||||
|
||||
@ -274,7 +304,7 @@ class OpenStackCinderShell(object):
|
||||
httplib2.debuglevel = 1
|
||||
|
||||
def main(self, argv):
|
||||
# Parse args once to find version
|
||||
# Parse args once to find version and debug settings
|
||||
parser = self.get_base_parser()
|
||||
(options, args) = parser.parse_known_args(argv)
|
||||
self.setup_debugging(options.debug)
|
||||
@ -330,14 +360,14 @@ class OpenStackCinderShell(object):
|
||||
if not username:
|
||||
raise exc.CommandError(
|
||||
"You must provide a username "
|
||||
"via either --os_username or env[OS_USERNAME]")
|
||||
"via either --os-username or env[OS_USERNAME]")
|
||||
else:
|
||||
os_username = username
|
||||
|
||||
if not os_password:
|
||||
if not apikey:
|
||||
raise exc.CommandError("You must provide a password "
|
||||
"via either --os_password or via "
|
||||
"via either --os-password or via "
|
||||
"env[OS_PASSWORD]")
|
||||
else:
|
||||
os_password = apikey
|
||||
@ -345,7 +375,7 @@ class OpenStackCinderShell(object):
|
||||
if not os_tenant_name:
|
||||
if not projectid:
|
||||
raise exc.CommandError("You must provide a tenant name "
|
||||
"via either --os_tenant_name or "
|
||||
"via either --os-tenant-name or "
|
||||
"env[OS_TENANT_NAME]")
|
||||
else:
|
||||
os_tenant_name = projectid
|
||||
@ -354,7 +384,7 @@ class OpenStackCinderShell(object):
|
||||
if not url:
|
||||
raise exc.CommandError(
|
||||
"You must provide an auth url "
|
||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||
"via either --os-auth-url or env[OS_AUTH_URL]")
|
||||
else:
|
||||
os_auth_url = url
|
||||
|
||||
@ -364,12 +394,12 @@ class OpenStackCinderShell(object):
|
||||
if not os_tenant_name:
|
||||
raise exc.CommandError(
|
||||
"You must provide a tenant name "
|
||||
"via either --os_tenant_name or env[OS_TENANT_NAME]")
|
||||
"via either --os-tenant-name or env[OS_TENANT_NAME]")
|
||||
|
||||
if not os_auth_url:
|
||||
raise exc.CommandError(
|
||||
"You must provide an auth url "
|
||||
"via either --os_auth_url or env[OS_AUTH_URL]")
|
||||
"via either --os-auth-url or env[OS_AUTH_URL]")
|
||||
|
||||
self.cs = client.Client(options.os_volume_api_version, os_username,
|
||||
os_password, os_tenant_name, os_auth_url,
|
||||
|
@ -15,6 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@ -101,14 +102,21 @@ def _extract_metadata(arg_list):
|
||||
return metadata
|
||||
|
||||
|
||||
@utils.arg('--all_tenants',
|
||||
dest='all_tenants',
|
||||
metavar='<0|1>',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
default=0,
|
||||
help='Display information from all tenants (Admin only).')
|
||||
@utils.arg(
|
||||
'--all-tenants',
|
||||
dest='all_tenants',
|
||||
metavar='<0|1>',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
default=0,
|
||||
help='Display information from all tenants (Admin only).')
|
||||
@utils.arg(
|
||||
'--all_tenants',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.service_type('volume')
|
||||
def do_list(cs, args):
|
||||
"""List all the volumes."""
|
||||
@ -137,33 +145,59 @@ def do_show(cs, args):
|
||||
metavar='<size>',
|
||||
type=int,
|
||||
help='Size of volume in GB')
|
||||
@utils.arg(
|
||||
'--snapshot-id',
|
||||
metavar='<snapshot-id>',
|
||||
default=None,
|
||||
help='Create volume from snapshot id (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--snapshot_id',
|
||||
metavar='<snapshot_id>',
|
||||
help='Optional snapshot id to create the volume from. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--image_id',
|
||||
metavar='<image_id>',
|
||||
help='Optional image id to create the volume from. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--display_name', metavar='<display_name>',
|
||||
help='Optional volume name. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--display_description', metavar='<display_description>',
|
||||
help='Optional volume description. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--volume_type',
|
||||
metavar='<volume_type>',
|
||||
help='Optional volume type. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--availability_zone', metavar='<availability_zone>',
|
||||
help='Optional availability zone for volume. (Default=None)',
|
||||
default=None)
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--image-id',
|
||||
metavar='<image-id>',
|
||||
default=None,
|
||||
help='Create volume from image id (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--image_id',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--display-name',
|
||||
metavar='<display-name>',
|
||||
default=None,
|
||||
help='Volume name (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--display_name',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--display-description',
|
||||
metavar='<display-description>',
|
||||
default=None,
|
||||
help='Volume description (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--display_description',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--volume-type',
|
||||
metavar='<volume-type>',
|
||||
default=None,
|
||||
help='Volume type (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--volume_type',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--availability-zone',
|
||||
metavar='<availability-zone>',
|
||||
default=None,
|
||||
help='Availability zone for volume (Optional, Default=None)')
|
||||
@utils.arg(
|
||||
'--availability_zone',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg('--metadata',
|
||||
type=str,
|
||||
nargs='*',
|
||||
metavar='<key=value>',
|
||||
help='Optional metadata kv pairs. (Default=None)',
|
||||
help='Metadata key=value pairs (Optional, Default=None)',
|
||||
default=None)
|
||||
@utils.service_type('volume')
|
||||
def do_create(cs, args):
|
||||
@ -191,14 +225,21 @@ def do_delete(cs, args):
|
||||
volume.delete()
|
||||
|
||||
|
||||
@utils.arg('--all_tenants',
|
||||
dest='all_tenants',
|
||||
metavar='<0|1>',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
default=0,
|
||||
help='Display information from all tenants (Admin only).')
|
||||
@utils.arg(
|
||||
'--all-tenants',
|
||||
dest='all_tenants',
|
||||
metavar='<0|1>',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
default=0,
|
||||
help='Display information from all tenants (Admin only).')
|
||||
@utils.arg(
|
||||
'--all_tenants',
|
||||
nargs='?',
|
||||
type=int,
|
||||
const=1,
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.service_type('volume')
|
||||
def do_snapshot_list(cs, args):
|
||||
"""List all the snapshots."""
|
||||
@ -220,7 +261,7 @@ def do_snapshot_show(cs, args):
|
||||
|
||||
|
||||
@utils.arg('volume_id',
|
||||
metavar='<volume_id>',
|
||||
metavar='<volume-id>',
|
||||
help='ID of the volume to snapshot')
|
||||
@utils.arg('--force',
|
||||
metavar='<True|False>',
|
||||
@ -228,12 +269,22 @@ def do_snapshot_show(cs, args):
|
||||
'to snapshot a volume even if its '
|
||||
'attached to an instance. (Default=False)',
|
||||
default=False)
|
||||
@utils.arg('--display_name', metavar='<display_name>',
|
||||
help='Optional snapshot name. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg('--display_description', metavar='<display_description>',
|
||||
help='Optional snapshot description. (Default=None)',
|
||||
default=None)
|
||||
@utils.arg(
|
||||
'--display-name',
|
||||
metavar='<display-name>',
|
||||
default=None,
|
||||
help='Optional snapshot name. (Default=None)')
|
||||
@utils.arg(
|
||||
'--display_name',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.arg(
|
||||
'--display-description',
|
||||
metavar='<display-description>',
|
||||
default=None,
|
||||
help='Optional snapshot description. (Default=None)')
|
||||
@utils.arg(
|
||||
'--display_description',
|
||||
help=argparse.SUPPRESS)
|
||||
@utils.service_type('volume')
|
||||
def do_snapshot_create(cs, args):
|
||||
"""Add a new snapshot."""
|
||||
@ -244,7 +295,7 @@ def do_snapshot_create(cs, args):
|
||||
|
||||
|
||||
@utils.arg('snapshot_id',
|
||||
metavar='<snapshot_id>',
|
||||
metavar='<snapshot-id>',
|
||||
help='ID of the snapshot to delete.')
|
||||
@utils.service_type('volume')
|
||||
def do_snapshot_delete(cs, args):
|
||||
|
@ -11,8 +11,8 @@ First, you'll need an OpenStack Nova account and an API key. You get this
|
||||
by using the `cinder-manage` command in OpenStack Nova.
|
||||
|
||||
You'll need to provide :program:`cinder` with your OpenStack username and
|
||||
API key. You can do this with the :option:`--os_username`, :option:`--os_password`
|
||||
and :option:`--os_tenant_id` options, but it's easier to just set them as
|
||||
API key. You can do this with the :option:`--os-username`, :option:`--os-password`
|
||||
and :option:`--os-tenant-id` options, but it's easier to just set them as
|
||||
environment variables by setting two environment variables:
|
||||
|
||||
.. envvar:: OS_USERNAME
|
||||
|
Loading…
Reference in New Issue
Block a user