add initial files for shell
Implements: blueprint vitrage-cli Change-Id: I555152c53f4b27d95a215cea0fedf782daa446cf
This commit is contained in:
parent
cb99346606
commit
287aa41c50
@ -4,3 +4,5 @@
|
|||||||
|
|
||||||
pbr>=1.6
|
pbr>=1.6
|
||||||
Babel>=1.3
|
Babel>=1.3
|
||||||
|
cliff>=1.14.0
|
||||||
|
oslo.utils>=2.0.0
|
@ -20,6 +20,14 @@ classifier =
|
|||||||
packages =
|
packages =
|
||||||
vitrageclient
|
vitrageclient
|
||||||
|
|
||||||
|
[global]
|
||||||
|
setup-hooks =
|
||||||
|
pbr.hooks.setup_hook
|
||||||
|
|
||||||
|
[entry_points]
|
||||||
|
console_scripts =
|
||||||
|
vitrage = vitrageclient.shell:main
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
build-dir = doc/build
|
build-dir = doc/build
|
||||||
|
@ -11,5 +11,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
from vitrageclient.common import utils
|
||||||
pass
|
|
||||||
|
|
||||||
|
def get_client_class(version, *args, **kwargs):
|
||||||
|
module = utils.import_versioned_module(version, 'client')
|
||||||
|
client_class = getattr(module, 'Client')
|
||||||
|
return client_class(*args, **kwargs)
|
||||||
|
0
vitrageclient/common/__init__.py
Normal file
0
vitrageclient/common/__init__.py
Normal file
21
vitrageclient/common/utils.py
Normal file
21
vitrageclient/common/utils.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#
|
||||||
|
# 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 oslo_utils import importutils
|
||||||
|
|
||||||
|
|
||||||
|
def import_versioned_module(version, submodule=None):
|
||||||
|
module = 'vitrageclient.v%s' % version
|
||||||
|
if submodule:
|
||||||
|
module = '.'.join((module, submodule))
|
||||||
|
return importutils.import_module(module)
|
@ -19,3 +19,7 @@ class VitrageBaseException(Exception):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.message or self.__class__.__doc__
|
return self.message or self.__class__.__doc__
|
||||||
|
|
||||||
|
|
||||||
|
class VitrageClientException(VitrageBaseException):
|
||||||
|
pass
|
||||||
|
@ -11,5 +11,55 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
class VitrageShell(object):
|
"""
|
||||||
pass
|
Vitrage command line interface
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
from cliff import app
|
||||||
|
from cliff import commandmanager
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from v1 import topology
|
||||||
|
from vitrageclient import __version__
|
||||||
|
|
||||||
|
|
||||||
|
class VitrageCommandManager(commandmanager.CommandManager):
|
||||||
|
COMMANDS = {
|
||||||
|
"topology list": topology.TopologyList,
|
||||||
|
"topology show": topology.TopologyShow,
|
||||||
|
}
|
||||||
|
|
||||||
|
def load_commands(self, namespace):
|
||||||
|
for k, v in self.COMMANDS.items():
|
||||||
|
self.add_command(k, v)
|
||||||
|
|
||||||
|
|
||||||
|
class VitrageShell(app.App):
|
||||||
|
def __init__(self):
|
||||||
|
super(VitrageShell, self).__init__(
|
||||||
|
description=__doc__,
|
||||||
|
version=__version__,
|
||||||
|
command_manager=VitrageCommandManager(None),
|
||||||
|
deferred_help=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main(args=None):
|
||||||
|
try:
|
||||||
|
if args is None:
|
||||||
|
args = sys.argv[1:]
|
||||||
|
return VitrageShell().run(args)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("... terminating vitrage client", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
24
vitrageclient/v1/topology.py
Normal file
24
vitrageclient/v1/topology.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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 cliff import lister
|
||||||
|
from cliff import show
|
||||||
|
|
||||||
|
|
||||||
|
class TopologyList(lister.Lister):
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TopologyShow(show.ShowOne):
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user