summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/common/clientmanager.py25
-rw-r--r--openstackclient/common/command.py8
-rw-r--r--openstackclient/common/exceptions.py57
-rw-r--r--openstackclient/common/openstackkeyring.py26
-rw-r--r--openstackclient/common/utils.py4
-rw-r--r--openstackclient/compute/client.py9
-rw-r--r--openstackclient/compute/v2/server.py175
-rw-r--r--openstackclient/identity/client.py13
-rw-r--r--openstackclient/identity/v2_0/endpoint.py26
-rw-r--r--openstackclient/identity/v2_0/role.py86
-rw-r--r--openstackclient/identity/v2_0/service.py25
-rw-r--r--openstackclient/identity/v2_0/tenant.py58
-rw-r--r--openstackclient/identity/v2_0/user.py78
-rw-r--r--openstackclient/identity/v3/group.py53
-rw-r--r--openstackclient/identity/v3/project.py70
-rw-r--r--openstackclient/image/client.py3
-rw-r--r--openstackclient/shell.py72
17 files changed, 298 insertions, 490 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index f6f6642e..830ecde7 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -13,8 +13,7 @@
# under the License.
#
-"""Manage access to the clients, including authenticating when needed.
-"""
+"""Manage access to the clients, including authenticating when needed."""
import logging
@@ -22,13 +21,12 @@ from openstackclient.compute import client as compute_client
from openstackclient.identity import client as identity_client
from openstackclient.image import client as image_client
+
LOG = logging.getLogger(__name__)
class ClientCache(object):
- """Descriptor class for caching created client handles.
- """
-
+ """Descriptor class for caching created client handles."""
def __init__(self, factory):
self.factory = factory
self._handle = None
@@ -41,20 +39,14 @@ class ClientCache(object):
class ClientManager(object):
- """Manages access to API clients, including authentication.
- """
-
+ """Manages access to API clients, including authentication."""
compute = ClientCache(compute_client.make_client)
identity = ClientCache(identity_client.make_client)
image = ClientCache(image_client.make_client)
- def __init__(self, token=None, url=None,
- auth_url=None,
- tenant_name=None, tenant_id=None,
- username=None, password=None,
- region_name=None,
- api_version=None,
- ):
+ def __init__(self, token=None, url=None, auth_url=None, tenant_name=None,
+ tenant_id=None, username=None, password=None,
+ region_name=None, api_version=None):
self._token = token
self._url = url
self._auth_url = auth_url
@@ -74,8 +66,7 @@ class ClientManager(object):
return
def get_endpoint_for_service_type(self, service_type):
- """Return the endpoint URL for the service type.
- """
+ """Return the endpoint URL for the service type."""
# See if we are using password flow auth, i.e. we have a
# service catalog to select endpoints from
if self._service_catalog:
diff --git a/openstackclient/common/command.py b/openstackclient/common/command.py
index cfcb605c..64e855df 100644
--- a/openstackclient/common/command.py
+++ b/openstackclient/common/command.py
@@ -13,17 +13,13 @@
# under the License.
#
-"""
-OpenStack base command
-"""
+"""OpenStack base command"""
from cliff.command import Command
class OpenStackCommand(Command):
- """Base class for OpenStack commands
- """
-
+ """Base class for OpenStack commands."""
api = None
def run(self, parsed_args):
diff --git a/openstackclient/common/exceptions.py b/openstackclient/common/exceptions.py
index 9dfb4bc7..ab043db0 100644
--- a/openstackclient/common/exceptions.py
+++ b/openstackclient/common/exceptions.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Exception definitions.
-"""
+"""Exception definitions."""
class CommandError(Exception):
@@ -27,8 +25,7 @@ class AuthorizationFailure(Exception):
class NoTokenLookupException(Exception):
- """This form of authentication does not support looking up
- endpoints from an existing token."""
+ """This does not support looking up endpoints from an existing token."""
pass
@@ -38,15 +35,12 @@ class EndpointNotFound(Exception):
class UnsupportedVersion(Exception):
- """Indicates that the user is trying to use an unsupported
- version of the API"""
+ """The user is trying to use an unsupported version of the API"""
pass
class ClientException(Exception):
- """
- The base exception class for all exceptions this library raises.
- """
+ """The base exception class for all exceptions this library raises."""
def __init__(self, code, message=None, details=None):
self.code = code
self.message = message or self.__class__.message
@@ -57,59 +51,44 @@ class ClientException(Exception):
class BadRequest(ClientException):
- """
- HTTP 400 - Bad request: you sent some malformed data.
- """
+ """HTTP 400 - Bad request: you sent some malformed data."""
http_status = 400
message = "Bad request"
class Unauthorized(ClientException):
- """
- HTTP 401 - Unauthorized: bad credentials.
- """
+ """HTTP 401 - Unauthorized: bad credentials."""
http_status = 401
message = "Unauthorized"
class Forbidden(ClientException):
- """
- HTTP 403 - Forbidden: your credentials don't give you access to this
- resource.
- """
+ """HTTP 403 - Forbidden: not authorized to access to this resource."""
http_status = 403
message = "Forbidden"
class NotFound(ClientException):
- """
- HTTP 404 - Not found
- """
+ """HTTP 404 - Not found"""
http_status = 404
message = "Not found"
class Conflict(ClientException):
- """
- HTTP 409 - Conflict
- """
+ """HTTP 409 - Conflict"""
http_status = 409
message = "Conflict"
class OverLimit(ClientException):
- """
- HTTP 413 - Over limit: you're over the API limits for this time period.
- """
+ """HTTP 413 - Over limit: reached the API limits for this time period."""
http_status = 413
message = "Over limit"
# NotImplemented is a python keyword.
class HTTPNotImplemented(ClientException):
- """
- HTTP 501 - Not Implemented: the server does not support this operation.
- """
+ """HTTP 501 - Not Implemented: server does not support this operation."""
http_status = 501
message = "Not Implemented"
@@ -120,14 +99,18 @@ class HTTPNotImplemented(ClientException):
# for c in ClientException.__subclasses__())
#
# Instead, we have to hardcode it:
-_code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
- Forbidden, NotFound, OverLimit, HTTPNotImplemented])
+_code_map = dict((c.http_status, c) for c in [
+ BadRequest,
+ Unauthorized,
+ Forbidden,
+ NotFound,
+ OverLimit,
+ HTTPNotImplemented
+])
def from_response(response, body):
- """
- Return an instance of a ClientException or subclass
- based on an httplib2 response.
+ """Return an instance of a ClientException based on an httplib2 response.
Usage::
diff --git a/openstackclient/common/openstackkeyring.py b/openstackclient/common/openstackkeyring.py
index 78c74b8f..e7431e54 100644
--- a/openstackclient/common/openstackkeyring.py
+++ b/openstackclient/common/openstackkeyring.py
@@ -13,50 +13,48 @@
# under the License.
#
-"""
-Keyring backend for Openstack, to store encrypted password in a file.
-"""
+"""Keyring backend for Openstack, to store encrypted password in a file."""
from Crypto.Cipher import AES
import keyring
import os
+
KEYRING_FILE = os.path.join(os.path.expanduser('~'), '.openstack-keyring.cfg')
class OpenstackKeyring(keyring.backend.BasicFileKeyring):
- """ Openstack Keyring to store encrypted password """
-
+ """Openstack Keyring to store encrypted password."""
filename = KEYRING_FILE
def supported(self):
- """ applicable for all platforms, but not recommend """
+ """Applicable for all platforms, but not recommend."""
pass
def _init_crypter(self):
- """ initialize the crypter using the class name """
+ """Initialize the crypter using the class name."""
block_size = 32
padding = '0'
# init the cipher with the class name, upto block_size
password = __name__[block_size:]
- password = password + (block_size - len(password) % \
- block_size) * padding
+ password = password + (block_size - len(password) %
+ block_size) * padding
return AES.new(password, AES.MODE_CFB)
def encrypt(self, password):
- """ encrypt the given password """
+ """Encrypt the given password."""
crypter = self._init_crypter()
return crypter.encrypt(password)
def decrypt(self, password_encrypted):
- """ decrypt the given password """
+ """Decrypt the given password."""
crypter = self._init_crypter()
return crypter.decrypt(password_encrypted)
def os_keyring():
- """ initialize the openstack keyring """
- return keyring.core.load_keyring(None,
- 'openstackclient.common.openstackkeyring.OpenstackKeyring')
+ """Initialize the openstack keyring."""
+ keyring = 'openstackclient.common.openstackkeyring.OpenstackKeyring'
+ return keyring.core.load_keyring(None, keyring)
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index 19cca3f5..6477285e 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Common client utilities
-"""
+"""Common client utilities"""
import os
import sys
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py
index e1db22c8..f7ebfe3e 100644
--- a/openstackclient/compute/client.py
+++ b/openstackclient/compute/client.py
@@ -27,13 +27,11 @@ API_VERSIONS = {
def make_client(instance):
- """Returns a compute service client.
- """
+ """Returns a compute service client."""
compute_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
- API_VERSIONS,
- )
+ API_VERSIONS)
LOG.debug('instantiating compute client: %s' % compute_client)
client = compute_client(
username=instance._username,
@@ -49,8 +47,7 @@ def make_client(instance):
extensions=[],
service_type=API_NAME,
# FIXME(dhellmann): what is service_name?
- service_name='',
- )
+ service_name='')
# Populate the Nova client to skip another auth query to Identity
if instance._url:
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index a334e198..24566a66 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Server action implementations
-"""
+"""Server action implementations"""
import logging
import os
@@ -128,109 +126,93 @@ class CreateServer(show.ShowOne):
parser.add_argument(
'server_name',
metavar='<server-name>',
- help='New server name',
- )
+ help='New server name')
parser.add_argument(
'--image',
metavar='<image>',
required=True,
- help='Create server from this image',
- )
+ help='Create server from this image')
parser.add_argument(
'--flavor',
metavar='<flavor>',
required=True,
- help='Create server with this flavor',
- )
+ help='Create server with this flavor')
parser.add_argument(
'--security-group',
metavar='<security-group-name>',
action='append',
default=[],
- help='Security group to assign to this server ' \
- '(repeat for multiple groups)',
- )
+ help='Security group to assign to this server '
+ '(repeat for multiple groups)')
parser.add_argument(
'--key-name',
metavar='<key-name>',
- help='Keypair to inject into this server (optional extension)',
- )
+ help='Keypair to inject into this server (optional extension)')
parser.add_argument(
'--meta-data',
metavar='<key=value>',
action='append',
default=[],
- help='Metadata to store for this server ' \
- '(repeat for multiple values)',
- )
+ help='Metadata to store for this server '
+ '(repeat for multiple values)')
parser.add_argument(
'--file',
metavar='<dest-filename=source-filename>',
action='append',
default=[],
- help='File to inject into image before boot ' \
- '(repeat for multiple files)',
- )
+ help='File to inject into image before boot '
+ '(repeat for multiple files)')
parser.add_argument(
'--user-data',
metavar='<user-data>',
- help='User data file to be serverd by the metadata server',
- )
+ help='User data file to be serverd by the metadata server')
parser.add_argument(
'--availability-zone',
metavar='<zone-name>',
- help='Keypair to inject into this server',
- )
+ help='Keypair to inject into this server')
parser.add_argument(
'--block-device-mapping',
metavar='<dev-name=mapping>',
action='append',
default=[],
- help='Map block devices; map is ' \
- '<id>:<type>:<size(GB)>:<delete_on_terminate> ' \
- '(optional extension)',
- )
+ help='Map block devices; map is '
+ '<id>:<type>:<size(GB)>:<delete_on_terminate> '
+ '(optional extension)')
parser.add_argument(
'--nic',
metavar='<nic-config-string>',
action='append',
default=[],
- help='Specify NIC configuration (optional extension)',
- )
+ help='Specify NIC configuration (optional extension)')
parser.add_argument(
'--hint',
metavar='<key=value>',
action='append',
default=[],
- help='Hints for the scheduler (optional extension)',
- )
+ help='Hints for the scheduler (optional extension)')
parser.add_argument(
'--config-drive',
metavar='<config-drive-volume>|True',
default=False,
- help='Use specified volume as the config drive, ' \
- 'or \'True\' to use an ephemeral drive',
- )
+ help='Use specified volume as the config drive, '
+ 'or \'True\' to use an ephemeral drive')
parser.add_argument(
'--min',
metavar='<count>',
type=int,
default=1,
- help='Minimum number of servers to launch (default=1)',
- )
+ help='Minimum number of servers to launch (default=1)')
parser.add_argument(
'--max',
metavar='<count>',
type=int,
default=1,
- help='Maximum number of servers to launch (default=1)',
- )
+ help='Maximum number of servers to launch (default=1)')
parser.add_argument(
'--wait',
dest='wait',
action='store_true',
- help='Wait for server to become active to return',
- )
+ help='Wait for server to become active to return')
return parser
def take_action(self, parsed_args):
@@ -239,11 +221,11 @@ class CreateServer(show.ShowOne):
# Lookup parsed_args.image
image = utils.find_resource(compute_client.images,
- parsed_args.image)
+ parsed_args.image)
# Lookup parsed_args.flavor
flavor = utils.find_resource(compute_client.flavors,
- parsed_args.flavor)
+ parsed_args.flavor)
boot_args = [parsed_args.server_name, image, flavor]
@@ -259,7 +241,7 @@ class CreateServer(show.ShowOne):
if parsed_args.min > parsed_args.max:
raise exceptions.CommandError("min instances should be <= "
- "max instances")
+ "max instances")
if parsed_args.min < 1:
raise exceptions.CommandError("min instances should be > 0")
if parsed_args.max < 1:
@@ -270,17 +252,17 @@ class CreateServer(show.ShowOne):
try:
userdata = open(parsed_args.user_data)
except IOError, e:
- raise exceptions.CommandError("Can't open '%s': %s" % \
- (parsed_args.user_data, e))
+ raise exceptions.CommandError("Can't open '%s': %s" %
+ (parsed_args.user_data, e))
block_device_mapping = dict(v.split('=', 1)
- for v in parsed_args.block_device_mapping)
+ for v in parsed_args.block_device_mapping)
nics = []
for nic_str in parsed_args.nic:
nic_info = {"net-id": "", "v4-fixed-ip": ""}
nic_info.update(dict(kv_str.split("=", 1)
- for kv_str in nic_str.split(",")))
+ for kv_str in nic_str.split(",")))
nics.append(nic_info)
hints = {}
@@ -301,7 +283,7 @@ class CreateServer(show.ShowOne):
if str(parsed_args.config_drive).lower() in ("true", "1"):
config_drive = True
elif str(parsed_args.config_drive).lower() in ("false", "0",
- "", "none"):
+ "", "none"):
config_drive = None
else:
config_drive = parsed_args.config_drive
@@ -319,8 +301,7 @@ class CreateServer(show.ShowOne):
block_device_mapping=block_device_mapping,
nics=nics,
scheduler_hints=hints,
- config_drive=config_drive,
- )
+ config_drive=config_drive)
self.log.debug('boot_args: %s' % boot_args)
self.log.debug('boot_kwargs: %s' % boot_kwargs)
@@ -328,7 +309,7 @@ class CreateServer(show.ShowOne):
if parsed_args.wait:
_wait_for_status(compute_client.servers.get, server._info['id'],
- ['active'])
+ ['active'])
details = _prep_server_detail(compute_client, server)
return zip(*sorted(details.iteritems()))
@@ -345,8 +326,7 @@ class DeleteServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to delete',
- )
+ help='Name or ID of server to delete')
return parser
def take_action(self, parsed_args):
@@ -369,55 +349,45 @@ class ListServer(lister.Lister):
parser.add_argument(
'--reservation-id',
metavar='<reservation-id>',
- help='only return instances that match the reservation',
- )
+ help='only return instances that match the reservation')
parser.add_argument(
'--ip',
metavar='<ip-address-regex>',
- help='regular expression to match IP address',
- )
+ help='regular expression to match IP address')
parser.add_argument(
'--ip6',
metavar='<ip-address-regex>',
- help='regular expression to match IPv6 address',
- )
+ help='regular expression to match IPv6 address')
parser.add_argument(
'--name',
metavar='<name>',
- help='regular expression to match name',
- )
+ help='regular expression to match name')
parser.add_argument(
'--instance-name',
metavar='<server-name>',
- help='regular expression to match instance name',
- )
+ help='regular expression to match instance name')
parser.add_argument(
'--status',
metavar='<status>',
- help='search by server status',
# FIXME(dhellmann): Add choices?
- )
+ help='search by server status')
parser.add_argument(
'--flavor',
metavar='<flavor>',
- help='search by flavor ID',
- )
+ help='search by flavor ID')
parser.add_argument(
'--image',
metavar='<image>',
- help='search by image ID',
- )
+ help='search by image ID')
parser.add_argument(
'--host',
metavar='<hostname>',
- help='search by hostname',
- )
+ help='search by hostname')
parser.add_argument(
'--all-tenants',
action='store_true',
default=bool(int(os.environ.get("ALL_TENANTS", 0))),
- help='display information from all tenants (admin only)',
- )
+ help='display information from all tenants (admin only)')
return parser
def take_action(self, parsed_args):
@@ -434,7 +404,7 @@ class ListServer(lister.Lister):
'image': parsed_args.image,
'host': parsed_args.host,
'all_tenants': parsed_args.all_tenants,
- }
+ }
self.log.debug('search options: %s', search_opts)
# FIXME(dhellmann): Consider adding other columns
columns = ('ID', 'Name', 'Status', 'Networks')
@@ -443,8 +413,7 @@ class ListServer(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={'Networks': _format_servers_list_networks},
- ) for s in data),
- )
+ ) for s in data))
class PauseServer(command.Command):
@@ -458,8 +427,7 @@ class PauseServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to pause',
- )
+ help='Name or ID of server to pause')
return parser
def take_action(self, parsed_args):
@@ -482,8 +450,7 @@ class RebootServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to reboot',
- )
+ help='Name or ID of server to reboot')
group = parser.add_mutually_exclusive_group()
group.add_argument(
'--hard',
@@ -491,22 +458,19 @@ class RebootServer(command.Command):
action='store_const',
const=servers.REBOOT_HARD,
default=servers.REBOOT_SOFT,
- help='Perform a hard reboot',
- )
+ help='Perform a hard reboot')
group.add_argument(
'--soft',
dest='reboot_type',
action='store_const',
const=servers.REBOOT_SOFT,
default=servers.REBOOT_SOFT,
- help='Perform a soft reboot',
- )
+ help='Perform a soft reboot')
parser.add_argument(
'--wait',
dest='wait',
action='store_true',
- help='Wait for server to become active to return',
- )
+ help='Wait for server to become active to return')
return parser
def take_action(self, parsed_args):
@@ -518,7 +482,7 @@ class RebootServer(command.Command):
if parsed_args.wait:
_wait_for_status(compute_client.servers.get, server.id,
- ['active'])
+ ['active'])
return
@@ -534,26 +498,22 @@ class RebuildServer(show.ShowOne):
parser.add_argument(
'server',
metavar='<server>',
- help='Server name or ID',
- )
+ help='Server name or ID')
parser.add_argument(
'--image',
metavar='<image>',
required=True,
- help='Recreate server from this image',
- )
+ help='Recreate server from this image')
parser.add_argument(
'--rebuild-password',
metavar='<rebuild_password>',
default=False,
- help="Set the provided password on the rebuild instance",
- )
+ help="Set the provided password on the rebuild instance")
parser.add_argument(
'--wait',
dest='wait',
action='store_true',
- help='Wait for server to become active to return',
- )
+ help='Wait for server to become active to return')
return parser
def take_action(self, parsed_args):
@@ -576,7 +536,7 @@ class RebuildServer(show.ShowOne):
# TODO(dtroyer): force silent=True if output filter != table
if parsed_args.wait:
_wait_for_status(compute_client.servers.get, server._info['id'],
- ['active'])
+ ['active'])
details = _prep_server_detail(compute_client, server)
return zip(*sorted(details.iteritems()))
@@ -593,8 +553,7 @@ class ResumeServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to resume',
- )
+ help='Name or ID of server to resume')
return parser
def take_action(self, parsed_args):
@@ -617,14 +576,14 @@ class ShowServer(show.ShowOne):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to display'),
+ help='Name or ID of server to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
compute_client = self.app.client_manager.compute
server = utils.find_resource(compute_client.servers,
- parsed_args.server)
+ parsed_args.server)
details = _prep_server_detail(compute_client, server)
return zip(*sorted(details.iteritems()))
@@ -641,15 +600,14 @@ class SuspendServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to suspend',
- )
+ help='Name or ID of server to suspend')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
compute_client = self.app.client_manager.compute
- server = utils.find_resource(
- compute_client.servers, parsed_args.server)
+ server = utils.find_resource(compute_client.servers,
+ parsed_args.server)
server.suspend()
return
@@ -665,14 +623,13 @@ class UnpauseServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
- help='Name or ID of server to unpause',
- )
+ help='Name or ID of server to unpause')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
compute_client = self.app.client_manager.compute
- server = utils.find_resource(
- compute_client.servers, parsed_args.server)
+ server = utils.find_resource(compute_client.servers,
+ parsed_args.server)
server.unpause()
return
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py
index 84ff2b05..748d1666 100644
--- a/openstackclient/identity/client.py
+++ b/openstackclient/identity/client.py
@@ -17,6 +17,7 @@ import logging
from openstackclient.common import utils
+
LOG = logging.getLogger(__name__)
API_NAME = 'identity'
@@ -27,19 +28,16 @@ API_VERSIONS = {
def make_client(instance):
- """Returns an identity service client.
- """
+ """Returns an identity service client."""
identity_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
- API_VERSIONS,
- )
+ API_VERSIONS)
if instance._url:
LOG.debug('instantiating identity client: token flow')
client = identity_client(
endpoint=instance._url,
- token=instance._token,
- )
+ token=instance._token)
else:
LOG.debug('instantiating identity client: password flow')
client = identity_client(
@@ -48,6 +46,5 @@ def make_client(instance):
tenant_name=instance._tenant_name,
tenant_id=instance._tenant_id,
auth_url=instance._auth_url,
- region_name=instance._region_name,
- )
+ region_name=instance._region_name)
return client
diff --git a/openstackclient/identity/v2_0/endpoint.py b/openstackclient/identity/v2_0/endpoint.py
index f9c689ec..4ce4fcb2 100644
--- a/openstackclient/identity/v2_0/endpoint.py
+++ b/openstackclient/identity/v2_0/endpoint.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Endpoint action implementations
-"""
+"""Endpoint action implementations"""
import logging
@@ -61,15 +59,14 @@ class CreateEndpoint(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- service = utils.find_resource(
- identity_client.services, parsed_args.service)
+ service = utils.find_resource(identity_client.services,
+ parsed_args.service)
endpoint = identity_client.endpoints.create(
parsed_args.region,
service.id,
parsed_args.publicurl,
parsed_args.adminurl,
- parsed_args.internalurl,
- )
+ parsed_args.internalurl,)
info = {}
info.update(endpoint._info)
@@ -119,7 +116,7 @@ class ListEndpoint(lister.Lister):
identity_client = self.app.client_manager.identity
if parsed_args.long:
columns = ('ID', 'Region', 'Service Name', 'Service Type',
- 'PublicURL', 'AdminURL', 'InternalURL')
+ 'PublicURL', 'AdminURL', 'InternalURL')
else:
columns = ('ID', 'Region', 'Service Name', 'Service Type')
data = identity_client.endpoints.list()
@@ -133,8 +130,7 @@ class ListEndpoint(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class ShowEndpoint(show.ShowOne):
@@ -154,7 +150,7 @@ class ShowEndpoint(show.ShowOne):
metavar='<endpoint-type>',
default='publicURL',
help='Endpoint type: publicURL, internalURL, adminURL ' +
- '(default publicURL)')
+ '(default publicURL)')
parser.add_argument(
'--attr',
metavar='<endpoint-attribute>',
@@ -196,8 +192,8 @@ class ShowEndpoint(show.ShowOne):
# The Identity 2.0 API doesn't support retrieving a single
# endpoint so we have to do this ourselves
try:
- service = utils.find_resource(
- identity_client.services, parsed_args.service)
+ service = utils.find_resource(identity_client.services,
+ parsed_args.service)
except exceptions.CommandError:
try:
# search for service type
@@ -215,8 +211,8 @@ class ShowEndpoint(show.ShowOne):
if ep.service_id == service.id:
info = {}
info.update(ep._info)
- service = utils.find_resource(
- identity_client.services, ep.service_id)
+ service = utils.find_resource(identity_client.services,
+ ep.service_id)
info['service_name'] = service.name
info['service_type'] = service.type
return zip(*sorted(info.iteritems()))
diff --git a/openstackclient/identity/v2_0/role.py b/openstackclient/identity/v2_0/role.py
index 49e03653..5c905d91 100644
--- a/openstackclient/identity/v2_0/role.py
+++ b/openstackclient/identity/v2_0/role.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Role action implementations
-"""
+"""Role action implementations"""
import logging
@@ -37,36 +35,30 @@ class AddRole(show.ShowOne):
parser.add_argument(
'role',
metavar='<role>',
- help='Role name or ID to add to user',
- )
+ help='Role name or ID to add to user')
parser.add_argument(
'--tenant',
metavar='<tenant>',
required=True,
- help='Name or ID of tenant to include',
- )
+ help='Name or ID of tenant to include')
parser.add_argument(
'--user',
metavar='<user>',
required=True,
- help='Name or ID of user to include',
- )
+ help='Name or ID of user to include')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- role = utils.find_resource(
- identity_client.roles, parsed_args.role)
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ role = utils.find_resource(identity_client.roles, parsed_args.role)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
role = identity_client.roles.add_user_role(
user,
role,
- tenant,
- )
+ tenant)
info = {}
info.update(role._info)
@@ -84,16 +76,13 @@ class CreateRole(show.ShowOne):
parser.add_argument(
'role_name',
metavar='<role-name>',
- help='New role name',
- )
+ help='New role name')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- role = identity_client.roles.create(
- parsed_args.role_name,
- )
+ role = identity_client.roles.create(parsed_args.role_name)
info = {}
info.update(role._info)
@@ -111,15 +100,13 @@ class DeleteRole(command.Command):
parser.add_argument(
'role',
metavar='<role>',
- help='Name or ID of role to delete',
- )
+ help='Name or ID of role to delete')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- role = utils.find_resource(
- identity_client.roles, parsed_args.role)
+ role = utils.find_resource(identity_client.roles, parsed_args.role)
identity_client.roles.delete(role.id)
return
@@ -138,8 +125,7 @@ class ListRole(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class ListUserRole(lister.Lister):
@@ -154,13 +140,11 @@ class ListUserRole(lister.Lister):
'user',
metavar='<user>',
nargs='?',
- help='Name or ID of user to include',
- )
+ help='Name or ID of user to include')
parser.add_argument(
'--tenant',
metavar='<tenant>',
- help='Name or ID of tenant to include',
- )
+ help='Name or ID of tenant to include')
return parser
def take_action(self, parsed_args):
@@ -176,10 +160,9 @@ class ListUserRole(lister.Lister):
if not parsed_args.user:
parsed_args.user = identity_client.auth_user_id
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
data = identity_client.roles.roles_for_user(user.id, tenant.id)
@@ -192,8 +175,7 @@ class ListUserRole(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class RemoveRole(command.Command):
@@ -207,36 +189,30 @@ class RemoveRole(command.Command):
parser.add_argument(
'role',
metavar='<role>',
- help='Role name or ID to remove from user',
- )
+ help='Role name or ID to remove from user')
parser.add_argument(
'--tenant',
metavar='<tenant>',
required=True,
- help='Name or ID of tenant',
- )
+ help='Name or ID of tenant')
parser.add_argument(
'--user',
metavar='<user>',
required=True,
- help='Name or ID of user',
- )
+ help='Name or ID of user')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- role = utils.find_resource(
- identity_client.roles, parsed_args.role)
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ role = utils.find_resource(identity_client.roles, parsed_args.role)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
identity_client.roles.remove_user_role(
user.id,
role.id,
- tenant.id,
- )
+ tenant.id)
class ShowRole(show.ShowOne):
@@ -250,15 +226,13 @@ class ShowRole(show.ShowOne):
parser.add_argument(
'role',
metavar='<role>',
- help='Name or ID of role to display',
- )
+ help='Name or ID of role to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- role = utils.find_resource(
- identity_client.roles, parsed_args.role)
+ role = utils.find_resource(identity_client.roles, parsed_args.role)
info = {}
info.update(role._info)
diff --git a/openstackclient/identity/v2_0/service.py b/openstackclient/identity/v2_0/service.py
index 89fe605a..21e32a51 100644
--- a/openstackclient/identity/v2_0/service.py
+++ b/openstackclient/identity/v2_0/service.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Service action implementations
-"""
+"""Service action implementations"""
import logging
@@ -44,13 +42,11 @@ class CreateService(show.ShowOne):
'--type',
metavar='<service-type>',
required=True,
- help='New service type',
- )
+ help='New service type')
parser.add_argument(
'--description',
metavar='<service-description>',
- help='New service description',
- )
+ help='New service description')
return parser
def take_action(self, parsed_args):
@@ -59,8 +55,7 @@ class CreateService(show.ShowOne):
service = identity_client.services.create(
parsed_args.name,
parsed_args.type,
- parsed_args.description,
- )
+ parsed_args.description)
info = {}
info.update(service._info)
@@ -78,8 +73,7 @@ class DeleteService(command.Command):
parser.add_argument(
'service',
metavar='<service-id>',
- help='ID of service to delete',
- )
+ help='ID of service to delete')
return parser
def take_action(self, parsed_args):
@@ -115,8 +109,7 @@ class ListService(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class ShowService(show.ShowOne):
@@ -138,8 +131,8 @@ class ShowService(show.ShowOne):
identity_client = self.app.client_manager.identity
try:
# search for the usual ID or name
- service = utils.find_resource(
- identity_client.services, parsed_args.service)
+ service = utils.find_resource(identity_client.services,
+ parsed_args.service)
except exceptions.CommandError:
try:
# search for service type
@@ -149,7 +142,7 @@ class ShowService(show.ShowOne):
# common client exceptions
except identity_exc.NotFound:
msg = "No service with a type, name or ID of '%s' exists." % \
- name_or_id
+ name_or_id
raise exceptions.CommandError(msg)
info = {}
diff --git a/openstackclient/identity/v2_0/tenant.py b/openstackclient/identity/v2_0/tenant.py
index f24bc726..8a2f738f 100644
--- a/openstackclient/identity/v2_0/tenant.py
+++ b/openstackclient/identity/v2_0/tenant.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Tenant action implementations
-"""
+"""Tenant action implementations"""
import logging
@@ -37,27 +35,23 @@ class CreateTenant(show.ShowOne):
parser.add_argument(
'tenant_name',
metavar='<tenant-name>',
- help='New tenant name',
- )
+ help='New tenant name')
parser.add_argument(
'--description',
metavar='<tenant-description>',
- help='New tenant description',
- )
+ help='New tenant description')
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--enable',
dest='enabled',
action='store_true',
default=True,
- help='Enable tenant',
- )
+ help='Enable tenant')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable tenant',
- )
+ help='Disable tenant')
return parser
def take_action(self, parsed_args):
@@ -66,8 +60,7 @@ class CreateTenant(show.ShowOne):
tenant = identity_client.tenants.create(
parsed_args.tenant_name,
description=parsed_args.description,
- enabled=parsed_args.enabled,
- )
+ enabled=parsed_args.enabled)
info = {}
info.update(tenant._info)
@@ -85,15 +78,14 @@ class DeleteTenant(command.Command):
parser.add_argument(
'tenant',
metavar='<tenant>',
- help='Name or ID of tenant to delete',
- )
+ help='Name or ID of tenant to delete')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
identity_client.tenants.delete(tenant.id)
return
@@ -110,8 +102,7 @@ class ListTenant(lister.Lister):
'--long',
action='store_true',
default=False,
- help='Additional fields are listed in output',
- )
+ help='Additional fields are listed in output')
return parser
def take_action(self, parsed_args):
@@ -125,8 +116,7 @@ class ListTenant(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class SetTenant(command.Command):
@@ -140,39 +130,34 @@ class SetTenant(command.Command):
parser.add_argument(
'tenant',
metavar='<tenant>',
- help='Name or ID of tenant to change',
- )
+ help='Name or ID of tenant to change')
parser.add_argument(
'--name',
metavar='<new-tenant-name>',
- help='New tenant name',
- )
+ help='New tenant name')
parser.add_argument(
'--description',
metavar='<tenant-description>',
- help='New tenant description',
- )
+ help='New tenant description')
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--enable',
dest='enabled',
action='store_true',
default=True,
- help='Enable tenant (default)',
- )
+ help='Enable tenant (default)')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable tenant',
- )
+ help='Disable tenant')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
kwargs = {}
if parsed_args.name:
kwargs['name'] = parsed_args.name
@@ -199,15 +184,14 @@ class ShowTenant(show.ShowOne):
parser.add_argument(
'tenant',
metavar='<tenant>',
- help='Name or ID of tenant to display',
- )
+ help='Name or ID of tenant to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- tenant = utils.find_resource(
- identity_client.tenants, parsed_args.tenant)
+ tenant = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant)
info = {}
info.update(tenant._info)
diff --git a/openstackclient/identity/v2_0/user.py b/openstackclient/identity/v2_0/user.py
index cf69d73f..2017e5e3 100644
--- a/openstackclient/identity/v2_0/user.py
+++ b/openstackclient/identity/v2_0/user.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-User action implementations
-"""
+"""User action implementations"""
import logging
@@ -37,45 +35,39 @@ class CreateUser(show.ShowOne):
parser.add_argument(
'name',
metavar='<user-name>',
- help='New user name',
- )
+ help='New user name')
parser.add_argument(
'--password',
metavar='<user-password>',
- help='New user password',
- )
+ help='New user password')
parser.add_argument(
'--email',
metavar='<user-email>',
- help='New user email address',
- )
+ help='New user email address')
parser.add_argument(
'--tenant',
metavar='<tenant>',
- help='New default tenant name or ID',
- )
+ help='New default tenant name or ID')
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--enable',
dest='enabled',
action='store_true',
default=True,
- help='Enable user',
- )
+ help='Enable user')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable user',
- )
+ help='Disable user')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
if parsed_args.tenant:
- tenant_id = utils.find_resource(
- identity_client.tenants, parsed_args.tenant).id
+ tenant_id = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant).id
else:
tenant_id = None
user = identity_client.users.create(
@@ -83,8 +75,7 @@ class CreateUser(show.ShowOne):
parsed_args.password,
parsed_args.email,
tenant_id=tenant_id,
- enabled=parsed_args.enabled,
- )
+ enabled=parsed_args.enabled)
info = {}
info.update(user._info)
@@ -102,15 +93,13 @@ class DeleteUser(command.Command):
parser.add_argument(
'user',
metavar='<user>',
- help='Name or ID of user to delete',
- )
+ help='Name or ID of user to delete')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
identity_client.users.delete(user.id)
return
@@ -126,14 +115,12 @@ class ListUser(lister.Lister):
parser.add_argument(
'--tenant',
metavar='<tenant>',
- help='Name or ID of tenant to filter users',
- )
+ help='Name or ID of tenant to filter users')
parser.add_argument(
'--long',
action='store_true',
default=False,
- help='Additional fields are listed in output',
- )
+ help='Additional fields are listed in output')
return parser
def take_action(self, parsed_args):
@@ -147,8 +134,7 @@ class ListUser(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class SetUser(command.Command):
@@ -162,57 +148,49 @@ class SetUser(command.Command):
parser.add_argument(
'user',
metavar='<user>',
- help='Name or ID of user to change',
- )
+ help='Name or ID of user to change')
parser.add_argument(
'--name',
metavar='<new-user-name>',
- help='New user name',
- )
+ help='New user name')
parser.add_argument(
'--password',
metavar='<user-password>',
- help='New user password',
- )
+ help='New user password')
parser.add_argument(
'--email',
metavar='<user-email>',
- help='New user email address',
- )
+ help='New user email address')
parser.add_argument(
'--tenant',
metavar='<tenant>',
- help='New default tenant name or ID',
- )
+ help='New default tenant name or ID')
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--enable',
dest='enabled',
action='store_true',
default=True,
- help='Enable user (default)',
- )
+ help='Enable user (default)')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable user',
- )
+ help='Disable user')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
kwargs = {}
if parsed_args.name:
kwargs['name'] = parsed_args.name
if parsed_args.email:
kwargs['email'] = parsed_args.email
if parsed_args.tenant:
- tenant_id = utils.find_resource(
- identity_client.tenants, parsed_args.tenant).id
+ tenant_id = utils.find_resource(identity_client.tenants,
+ parsed_args.tenant).id
kwargs['tenantId'] = tenant_id
if 'enabled' in parsed_args:
kwargs['enabled'] = parsed_args.enabled
@@ -235,15 +213,13 @@ class ShowUser(show.ShowOne):
parser.add_argument(
'user',
metavar='<user>',
- help='Name or ID of user to display',
- )
+ help='Name or ID of user to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- user = utils.find_resource(
- identity_client.users, parsed_args.user)
+ user = utils.find_resource(identity_client.users, parsed_args.user)
info = {}
info.update(user._info)
diff --git a/openstackclient/identity/v3/group.py b/openstackclient/identity/v3/group.py
index f783eb4f..3a9b80ed 100644
--- a/openstackclient/identity/v3/group.py
+++ b/openstackclient/identity/v3/group.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Group action implementations
-"""
+"""Group action implementations"""
import logging
@@ -37,18 +35,15 @@ class CreateGroup(show.ShowOne):
parser.add_argument(
'name',
metavar='<group-name>',
- help='New group name',
- )
+ help='New group name')
parser.add_argument(
'--description',
metavar='<group-description>',
- help='New group description',
- )
+ help='New group description')
parser.add_argument(
'--domain',
metavar='<group-domain>',
- help='References the domain ID or name which owns the group',
- )
+ help='References the domain ID or name which owns the group')
return parser
@@ -56,15 +51,14 @@ class CreateGroup(show.ShowOne):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
if parsed_args.domain:
- domain = utils.find_resource(
- identity_client.domains, parsed_args.domain).id
+ domain = utils.find_resource(identity_client.domains,
+ parsed_args.domain).id
else:
domain = None
group = identity_client.groups.create(
parsed_args.name,
domain=domain,
- description=parsed_args.description,
- )
+ description=parsed_args.description)
info = {}
info.update(group._info)
@@ -82,15 +76,13 @@ class DeleteGroup(command.Command):
parser.add_argument(
'group',
metavar='<group>',
- help='Name or ID of group to delete',
- )
+ help='Name or ID of group to delete')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- group = utils.find_resource(
- identity_client.groups, parsed_args.group)
+ group = utils.find_resource(identity_client.groups, parsed_args.group)
identity_client.groups.delete(group.id)
return
@@ -107,8 +99,7 @@ class ListGroup(lister.Lister):
'--long',
action='store_true',
default=False,
- help='Additional fields are listed in output',
- )
+ help='Additional fields are listed in output')
return parser
def take_action(self, parsed_args):
@@ -122,8 +113,7 @@ class ListGroup(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class SetGroup(command.Command):
@@ -137,30 +127,25 @@ class SetGroup(command.Command):
parser.add_argument(
'group',
metavar='<group>',
- help='Name or ID of group to change',
- )
+ help='Name or ID of group to change')
parser.add_argument(
'--name',
metavar='<new-group-name>',
- help='New group name',
- )
+ help='New group name')
parser.add_argument(
'--domain',
metavar='<group-domain>',
- help='New domain name or ID that will now own the group',
- )
+ help='New domain name or ID that will now own the group')
parser.add_argument(
'--description',
metavar='<group-description>',
- help='New group description',
- )
+ help='New group description')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- group = utils.find_resource(
- identity_client.groups, parsed_args.group)
+ group = utils.find_resource(identity_client.groups, parsed_args.group)
kwargs = {}
if parsed_args.name:
kwargs['name'] = parsed_args.name
@@ -189,15 +174,13 @@ class ShowGroup(show.ShowOne):
parser.add_argument(
'group',
metavar='<group>',
- help='Name or ID of group to display',
- )
+ help='Name or ID of group to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- group = utils.find_resource(
- identity_client.groups, parsed_args.group)
+ group = utils.find_resource(identity_client.groups, parsed_args.group)
info = {}
info.update(group._info)
diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py
index 06022e45..d1e67acc 100644
--- a/openstackclient/identity/v3/project.py
+++ b/openstackclient/identity/v3/project.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Project action implementations
-"""
+"""Project action implementations"""
import logging
@@ -37,18 +35,15 @@ class CreateProject(show.ShowOne):
parser.add_argument(
'project_name',
metavar='<project-name>',
- help='New project name',
- )
+ help='New project name')
parser.add_argument(
'--domain',
metavar='<project-domain>',
- help='References the domain name or ID which owns the project',
- )
+ help='References the domain name or ID which owns the project')
parser.add_argument(
'--description',
metavar='<project-description>',
- help='New project description',
- )
+ help='New project description')
# FIXME (stevemar): need to update enabled/disabled as per Dolph's
# comments in 19999/4
enable_group = parser.add_mutually_exclusive_group()
@@ -57,30 +52,29 @@ class CreateProject(show.ShowOne):
dest='enabled',
action='store_true',
default=True,
- help='Enable project',
- )
+ help='Enable project')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable project',
- )
+ help='Disable project')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
+
if parsed_args.domain:
- domain = utils.find_resource(
- identity_client.domains, parsed_args.domain).id
+ domain = utils.find_resource(identity_client.domains,
+ parsed_args.domain).id
else:
domain = None
+
project = identity_client.projects.create(
parsed_args.project_name,
domain=domain,
description=parsed_args.description,
- enabled=parsed_args.enabled,
- )
+ enabled=parsed_args.enabled)
info = {}
info.update(project._info)
@@ -98,15 +92,14 @@ class DeleteProject(command.Command):
parser.add_argument(
'project',
metavar='<project>',
- help='Name or ID of project to delete',
- )
+ help='Name or ID of project to delete')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- project = utils.find_resource(
- identity_client.projects, parsed_args.project)
+ project = utils.find_resource(identity_client.projects,
+ parsed_args.project)
identity_client.projects.delete(project.id)
return
@@ -123,8 +116,7 @@ class ListProject(lister.Lister):
'--long',
action='store_true',
default=False,
- help='Additional fields are listed in output',
- )
+ help='Additional fields are listed in output')
return parser
def take_action(self, parsed_args):
@@ -138,8 +130,7 @@ class ListProject(lister.Lister):
(utils.get_item_properties(
s, columns,
formatters={},
- ) for s in data),
- )
+ ) for s in data))
class SetProject(command.Command):
@@ -153,44 +144,38 @@ class SetProject(command.Command):
parser.add_argument(
'project',
metavar='<project>',
- help='Name or ID of project to change',
- )
+ help='Name or ID of project to change')
parser.add_argument(
'--name',
metavar='<new-project-name>',
- help='New project name',
- )
+ help='New project name')
parser.add_argument(
'--domain',
metavar='<project-domain>',
- help='New domain name or ID that will now own the project',
- )
+ help='New domain name or ID that will now own the project')
parser.add_argument(
'--description',
metavar='<project-description>',
- help='New project description',
- )
+ help='New project description')
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--enable',
dest='enabled',
action='store_true',
default=True,
- help='Enable project (default)',
- )
+ help='Enable project (default)')
enable_group.add_argument(
'--disable',
dest='enabled',
action='store_false',
- help='Disable project',
- )
+ help='Disable project')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- project = utils.find_resource(
- identity_client.projects, parsed_args.project)
+ project = utils.find_resource(identity_client.projects,
+ parsed_args.project)
kwargs = {}
if parsed_args.name:
kwargs['name'] = parsed_args.name
@@ -221,15 +206,14 @@ class ShowProject(show.ShowOne):
parser.add_argument(
'project',
metavar='<project>',
- help='Name or ID of project to display',
- )
+ help='Name or ID of project to display')
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)' % parsed_args)
identity_client = self.app.client_manager.identity
- project = utils.find_resource(
- identity_client.projects, parsed_args.project)
+ project = utils.find_resource(identity_client.projects,
+ parsed_args.project)
info = {}
info.update(project._info)
diff --git a/openstackclient/image/client.py b/openstackclient/image/client.py
index 5285e6d7..23e9a3e9 100644
--- a/openstackclient/image/client.py
+++ b/openstackclient/image/client.py
@@ -32,8 +32,7 @@ def make_client(instance):
image_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
- API_VERSIONS
- )
+ API_VERSIONS)
if not instance._url:
instance._url = instance.get_endpoint_for_service_type(API_NAME)
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index c007fc53..5dc04572 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Command-line interface to the OpenStack APIs
-"""
+"""Command-line interface to the OpenStack APIs"""
import getpass
import logging
@@ -59,8 +57,7 @@ class OpenStackShell(App):
super(OpenStackShell, self).__init__(
description=__doc__.strip(),
version=VERSION,
- command_manager=CommandManager('openstack.cli'),
- )
+ command_manager=CommandManager('openstack.cli'))
# This is instantiated in initialize_app() only when using
# password flow auth
@@ -69,57 +66,64 @@ class OpenStackShell(App):
def build_option_parser(self, description, version):
parser = super(OpenStackShell, self).build_option_parser(
description,
- version,
- )
+ version)
# Global arguments
- parser.add_argument('--os-auth-url', metavar='<auth-url>',
+ parser.add_argument(
+ '--os-auth-url',
+ metavar='<auth-url>',
default=env('OS_AUTH_URL'),
help='Authentication URL (Env: OS_AUTH_URL)')
-
- parser.add_argument('--os-tenant-name', metavar='<auth-tenant-name>',
+ parser.add_argument(
+ '--os-tenant-name',
+ metavar='<auth-tenant-name>',
default=env('OS_TENANT_NAME'),
help='Authentication tenant name (Env: OS_TENANT_NAME)')
-
- parser.add_argument('--os-tenant-id', metavar='<auth-tenant-id>',
+ parser.add_argument(
+ '--os-tenant-id',
+ metavar='<auth-tenant-id>',
default=env('OS_TENANT_ID'),
help='Authentication tenant ID (Env: OS_TENANT_ID)')
-
- parser.add_argument('--os-username', metavar='<auth-username>',
+ parser.add_argument(
+ '--os-username',
+ metavar='<auth-username>',
default=utils.env('OS_USERNAME'),
help='Authentication username (Env: OS_USERNAME)')
-
- parser.add_argument('--os-password', metavar='<auth-password>',
+ parser.add_argument(
+ '--os-password',
+ metavar='<auth-password>',
default=utils.env('OS_PASSWORD'),
help='Authentication password (Env: OS_PASSWORD)')
-
- parser.add_argument('--os-region-name', metavar='<auth-region-name>',
+ parser.add_argument(
+ '--os-region-name',
+ metavar='<auth-region-name>',
default=env('OS_REGION_NAME'),
help='Authentication region name (Env: OS_REGION_NAME)')
-
- parser.add_argument('--os-identity-api-version',
+ parser.add_argument(
+ '--os-identity-api-version',
metavar='<identity-api-version>',
default=env('OS_IDENTITY_API_VERSION', default='2.0'),
help='Identity API version, default=2.0 '
- '(Env: OS_IDENTITY_API_VERSION)')
-
- parser.add_argument('--os-compute-api-version',
+ '(Env: OS_IDENTITY_API_VERSION)')
+ parser.add_argument(
+ '--os-compute-api-version',
metavar='<compute-api-version>',
default=env('OS_COMPUTE_API_VERSION', default='2'),
help='Compute API version, default=2 '
- '(Env: OS_COMPUTE_API_VERSION)')
-
- parser.add_argument('--os-image-api-version',
+ '(Env: OS_COMPUTE_API_VERSION)')
+ parser.add_argument(
+ '--os-image-api-version',
metavar='<image-api-version>',
default=env('OS_IMAGE_API_VERSION', default='1.0'),
- help='Image API version, default=1.0 '
- '(Env: OS_IMAGE_API_VERSION)')
-
- parser.add_argument('--os-token', metavar='<token>',
+ help='Image API version, default=1.0 (Env: OS_IMAGE_API_VERSION)')
+ parser.add_argument(
+ '--os-token',
+ metavar='<token>',
default=env('OS_TOKEN'),
help='Defaults to env[OS_TOKEN]')
-
- parser.add_argument('--os-url', metavar='<url>',
+ parser.add_argument(
+ '--os-url',
+ metavar='<url>',
default=env('OS_URL'),
help='Defaults to env[OS_URL]')
@@ -198,8 +202,7 @@ class OpenStackShell(App):
username=self.options.os_username,
password=self.options.os_password,
region_name=self.options.os_region_name,
- api_version=self.api_version,
- )
+ api_version=self.api_version)
return
def init_keyring_backend(self):
@@ -260,7 +263,6 @@ class OpenStackShell(App):
def prepare_to_run_command(self, cmd):
"""Set up auth and API versions"""
self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
-
self.log.debug("api: %s" % cmd.api if hasattr(cmd, 'api') else None)
return