Files
python-neutronclient/neutronclient/neutron/v2_0/credential.py
Akihiro Motoki 647b0847b2 neutron v2 command module cleanup #1
Purge "body[resource].update({key: value})" pattern
and use "body[key] = value" pattern.
The purged pattern is a bad convention in neutronclient and
I commented not to use it many times but I got tired of it.

Change-Id: I2fe0be30d648f59fa45c5951ccc5060c35527aff
2015-09-30 14:02:16 +09:00

69 lines
2.2 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from neutronclient.i18n import _
from neutronclient.neutron import v2_0 as neutronV20
class ListCredential(neutronV20.ListCommand):
"""List credentials that belong to a given tenant."""
resource = 'credential'
_formatters = {}
list_columns = ['credential_id', 'credential_name', 'user_name',
'password', 'type']
class ShowCredential(neutronV20.ShowCommand):
"""Show information of a given credential."""
resource = 'credential'
allow_names = False
class CreateCredential(neutronV20.CreateCommand):
"""Create a credential."""
resource = 'credential'
def add_known_arguments(self, parser):
parser.add_argument(
'credential_name',
help=_('Name/IP address for credential.'))
parser.add_argument(
'credential_type',
help=_('Type of the credential.'))
parser.add_argument(
'--username',
help=_('Username for the credential.'))
parser.add_argument(
'--password',
help=_('Password for the credential.'))
def args2body(self, parsed_args):
body = {'credential_name': parsed_args.credential_name}
if parsed_args.credential_type:
body['type'] = parsed_args.credential_type
if parsed_args.username:
body['user_name'] = parsed_args.username
if parsed_args.password:
body['password'] = parsed_args.password
return {'credential': body}
class DeleteCredential(neutronV20.DeleteCommand):
"""Delete a given credential."""
resource = 'credential'
allow_names = False