2016-01-09 13:35:30 +09:00
|
|
|
# Copyright 2016 NEC Corporation
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
import abc
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from cliff import command
|
|
|
|
from cliff import lister
|
|
|
|
from cliff import show
|
2016-06-08 14:17:14 -05:00
|
|
|
from osc_lib import exceptions
|
2016-01-09 13:35:30 +09:00
|
|
|
import six
|
|
|
|
|
2016-06-02 09:53:55 -05:00
|
|
|
from openstackclient.i18n import _
|
|
|
|
|
2016-01-09 13:35:30 +09:00
|
|
|
|
|
|
|
class CommandMeta(abc.ABCMeta):
|
2016-02-23 10:38:58 -06:00
|
|
|
|
2016-01-09 13:35:30 +09:00
|
|
|
def __new__(mcs, name, bases, cls_dict):
|
|
|
|
if 'log' not in cls_dict:
|
|
|
|
cls_dict['log'] = logging.getLogger(
|
|
|
|
cls_dict['__module__'] + '.' + name)
|
|
|
|
return super(CommandMeta, mcs).__new__(mcs, name, bases, cls_dict)
|
|
|
|
|
|
|
|
|
|
|
|
@six.add_metaclass(CommandMeta)
|
|
|
|
class Command(command.Command):
|
2016-01-10 21:54:53 +09:00
|
|
|
|
|
|
|
def run(self, parsed_args):
|
|
|
|
self.log.debug('run(%s)', parsed_args)
|
|
|
|
return super(Command, self).run(parsed_args)
|
2016-01-09 13:35:30 +09:00
|
|
|
|
2016-06-02 09:53:55 -05:00
|
|
|
def validate_os_beta_command_enabled(self):
|
|
|
|
if not self.app.options.os_beta_command:
|
|
|
|
msg = _('Caution: This is a beta command and subject to '
|
|
|
|
'change. Use global option --os-beta-command '
|
|
|
|
'to enable this command.')
|
|
|
|
raise exceptions.CommandError(msg)
|
|
|
|
|
2016-01-09 13:35:30 +09:00
|
|
|
|
|
|
|
class Lister(Command, lister.Lister):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ShowOne(Command, show.ShowOne):
|
|
|
|
pass
|