Added hosts_shell, tests_hosts_shell, and common package for cliutils to support handling hosts-list sub command with no arguments. In parallel, the ability to handle subcommand parsing was implemented in a basic form in order to implement and test "craton host-list" with no additional args. Added optional arguments to craton shell and accompanying unit tests for username, password, and url to enable creating a session and instantiate the client properly to enable other unit tests without hardcoding dummy values. Change-Id: I05a42a06e0436e7a0de6b898d4d6e50168e6dd36
24 lines
911 B
Python
24 lines
911 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
# 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.
|
|
"""Hosts resource and resource shell wrapper."""
|
|
from cratonclient.common import cliutils
|
|
|
|
|
|
def do_host_list(cc, args):
|
|
"""Print list of hosts which are registered with the Craton service."""
|
|
params = {}
|
|
columns = ['id', 'name']
|
|
hosts = cc.hosts.list(args.craton_project_id, **params)
|
|
cliutils.print_list(hosts, columns)
|