Fixed flake8 errors
This commit is contained in:
parent
a45014b691
commit
d3c4b191db
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
|
||||||
from openstack import exceptions as sdkexc
|
from openstack import exceptions as sdkexc
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from senlinclient.common.i18n import _
|
from senlinclient.common.i18n import _
|
||||||
|
|
||||||
@ -64,7 +64,8 @@ class HTTPException(BaseException):
|
|||||||
{'message': message, 'traceback': traceback})
|
{'message': message, 'traceback': traceback})
|
||||||
else:
|
else:
|
||||||
code = self.error['error'].get('code', 'Unknown')
|
code = self.error['error'].get('code', 'Unknown')
|
||||||
return _('ERROR(%s): %s') % (code, message)
|
return _('ERROR(%(code)s): %(message)s') % {'code': code,
|
||||||
|
'message': message}
|
||||||
|
|
||||||
|
|
||||||
class ClientError(HTTPException):
|
class ClientError(HTTPException):
|
||||||
@ -238,7 +239,7 @@ def parse_exception(exc):
|
|||||||
record['error']['code'] = code
|
record['error']['code'] = code
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
print(_('Malformed exception record, missing field "%s"') % err)
|
print(_('Malformed exception record, missing field "%s"') % err)
|
||||||
print(_('Original error record: %s' % record))
|
print(_('Original error record: %s') % record)
|
||||||
return
|
return
|
||||||
|
|
||||||
if code in _EXCEPTION_MAP:
|
if code in _EXCEPTION_MAP:
|
||||||
|
@ -15,17 +15,16 @@ import os
|
|||||||
|
|
||||||
from openstack import connection
|
from openstack import connection
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
from openstack import user_preference
|
|
||||||
from openstack.identity import identity_service
|
|
||||||
from openstack import resource as base
|
from openstack import resource as base
|
||||||
|
from openstack import user_preference
|
||||||
from senlinclient.common import exc
|
from senlinclient.common import exc
|
||||||
|
|
||||||
# Alias here for consistency
|
# Alias here for consistency
|
||||||
prop = base.prop
|
prop = base.prop
|
||||||
|
|
||||||
|
|
||||||
class UserPreferenceAction(argparse.Action):
|
class UserPreferenceAction(argparse.Action):
|
||||||
'''
|
'''A custom action to parse user preferences as key=value pairs
|
||||||
A custom action to parse user preferences as key=value pairs
|
|
||||||
|
|
||||||
Stores results in users preferences object.
|
Stores results in users preferences object.
|
||||||
'''
|
'''
|
||||||
@ -77,16 +76,14 @@ class UserPreferenceAction(argparse.Action):
|
|||||||
|
|
||||||
|
|
||||||
class Resource(base.Resource):
|
class Resource(base.Resource):
|
||||||
'''
|
'''Senlin version of resource.
|
||||||
Senlin version of resource.
|
|
||||||
|
|
||||||
These classes are here because the OpenStack SDK base version is making
|
These classes are here because the OpenStack SDK base version is making
|
||||||
some assumptions about operations that cannot be satisfied in Senlin.
|
some assumptions about operations that cannot be satisfied in Senlin.
|
||||||
'''
|
'''
|
||||||
@classmethod
|
@classmethod
|
||||||
def list_short(cls, session, path_args=None, **params):
|
def list_short(cls, session, path_args=None, **params):
|
||||||
'''
|
'''Return a generator that will page through results of GET requests.
|
||||||
Return a generator that will page through results of GET requests.
|
|
||||||
|
|
||||||
This method bypasses the DB session support and retrieves list that
|
This method bypasses the DB session support and retrieves list that
|
||||||
is directly exposed by server.
|
is directly exposed by server.
|
||||||
@ -108,8 +105,8 @@ class Resource(base.Resource):
|
|||||||
yield value
|
yield value
|
||||||
|
|
||||||
def create(self, session):
|
def create(self, session):
|
||||||
'''
|
'''Overriden version of the create method.
|
||||||
Overriden version of the create method.
|
|
||||||
We want to know more about the object being created, so the response
|
We want to know more about the object being created, so the response
|
||||||
should not be just thrown away
|
should not be just thrown away
|
||||||
'''
|
'''
|
||||||
|
@ -33,7 +33,7 @@ from senlinclient.common import sdk
|
|||||||
from senlinclient.common import utils
|
from senlinclient.common import utils
|
||||||
|
|
||||||
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
osprofiler_profiler = importutils.try_import("osprofiler.profiler")
|
||||||
USER_AGENT='python-senlinclient'
|
USER_AGENT = 'python-senlinclient'
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -164,19 +164,19 @@ class SenlinShell(object):
|
|||||||
'user ID for authentication')
|
'user ID for authentication')
|
||||||
print(_('WARNING: %s') % msg)
|
print(_('WARNING: %s') % msg)
|
||||||
|
|
||||||
if (args.username and not args.user_id) and (not
|
if (args.username and not args.user_id):
|
||||||
args.user_domain_id or args.user_domain_name):
|
if not (args.user_domain_id or args.user_domain_name):
|
||||||
msg = _('Either user domain ID (--user-domain-id / '
|
msg = _('Either user domain ID (--user-domain-id / '
|
||||||
'env[OS_USER_DOMAIN_ID]) or user domain name '
|
'env[OS_USER_DOMAIN_ID]) or user domain name '
|
||||||
'(--user-domain-name / env[OS_USER_DOMAIN_NAME '
|
'(--user-domain-name / env[OS_USER_DOMAIN_NAME '
|
||||||
'must be specified, because user name may not be '
|
'must be specified, because user name may not be '
|
||||||
'unique.')
|
'unique.')
|
||||||
raise exc.CommandError(msg)
|
raise exc.CommandError(msg)
|
||||||
|
|
||||||
# password is needed if username or user_id is present
|
# password is needed if username or user_id is present
|
||||||
if (args.username or args.user_id) and not (args.password):
|
if (args.username or args.user_id) and not (args.password):
|
||||||
msg = _('You must provide a password for user %s') % (
|
msg = _('You must provide a password for user %s') % (
|
||||||
args.username or args.user_id)
|
args.username or args.user_id)
|
||||||
raise exc.CommandError(msg)
|
raise exc.CommandError(msg)
|
||||||
|
|
||||||
# project name or ID is needed, or else sdk may find the wrong project
|
# project name or ID is needed, or else sdk may find the wrong project
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import uuid
|
|
||||||
|
|
||||||
from openstack import exceptions as exc
|
from openstack import exceptions as exc
|
||||||
from openstack.identity import identity_service
|
from openstack.identity import identity_service
|
||||||
@ -20,6 +19,7 @@ from openstack.network.v2 import thin as thins
|
|||||||
from openstack import transport as trans
|
from openstack import transport as trans
|
||||||
from senlinclient.common import exc as client_exc
|
from senlinclient.common import exc as client_exc
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
def __init__(self, session):
|
def __init__(self, session):
|
||||||
self.session = session
|
self.session = session
|
||||||
|
@ -16,7 +16,6 @@ from oslo_serialization import jsonutils
|
|||||||
|
|
||||||
from senlinclient.common import exc
|
from senlinclient.common import exc
|
||||||
from senlinclient.common.i18n import _
|
from senlinclient.common.i18n import _
|
||||||
from senlinclient.common import sdk
|
|
||||||
from senlinclient.common import utils
|
from senlinclient.common import utils
|
||||||
from senlinclient.v1 import models
|
from senlinclient.v1 import models
|
||||||
|
|
||||||
@ -557,8 +556,10 @@ def do_node_create(sc, args):
|
|||||||
}
|
}
|
||||||
|
|
||||||
node, resp = sc.create(models.Node, params)
|
node, resp = sc.create(models.Node, params)
|
||||||
print(_('Action NODE_CREATE(%s) scheduled for '
|
print(_('Action NODE_CREATE(%(action)s) scheduled for '
|
||||||
'node %s') % (resp['action_id'], resp['id']))
|
'node %(node)s') % {
|
||||||
|
'action': resp['action_id'],
|
||||||
|
'node': resp['id']})
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('id', metavar='<NODE ID>',
|
@utils.arg('id', metavar='<NODE ID>',
|
||||||
@ -590,7 +591,7 @@ def do_node_delete(sc, args):
|
|||||||
try:
|
try:
|
||||||
query = {'id': nid}
|
query = {'id': nid}
|
||||||
sc.delete(models.Node, query)
|
sc.delete(models.Node, query)
|
||||||
except exc.HTTPNotFound as ex:
|
except exc.HTTPNotFound:
|
||||||
failure_count += 1
|
failure_count += 1
|
||||||
print('Node id "%s" not found' % nid)
|
print('Node id "%s" not found' % nid)
|
||||||
if failure_count == len(args.id):
|
if failure_count == len(args.id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user