Pino de Candia 3d1216ab30 Add new commands for ssh hosts and pats.
Signed-off-by: Pino de Candia <giuseppe.decandia@gmail.com>
2018-02-26 09:45:09 +00:00

45 lines
1.4 KiB
Python

# Copyright 2018 Huawei, Inc. All rights reserved.
#
# 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 argparse
import logging
from osc_lib.command import command
from tatuclient import utils
from tatuclient.v1.cli import common
from tatuclient.v1.utils import get_all
LOG = logging.getLogger(__name__)
_columns = ['IP', 'Chassis', 'LPort']
_names = ['IP', 'Chassis', 'Neutron Port ID']
class ListPATCommand(command.Lister):
"""List PATs"""
def get_parser(self, prog_name):
parser = super(ListPATCommand, self).get_parser(prog_name)
common.add_all_common_options(parser)
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.ssh
common.set_all_common_headers(client, parsed_args)
data = get_all(client.pat.list)
return _names, (utils.get_item_properties(s, _columns) for s in data)