Add commands to view PATs and Hosts.
This commit is contained in:
parent
ea431b2011
commit
f06901a2ac
23
setup.cfg
23
setup.cfg
@ -36,22 +36,27 @@ openstack.cli.extension =
|
|||||||
ssh = tatuclient.osc.plugin
|
ssh = tatuclient.osc.plugin
|
||||||
|
|
||||||
openstack.ssh.v1 =
|
openstack.ssh.v1 =
|
||||||
usercert_create = tatuclient.v1.cli.usercert:CreateUserCertCommand
|
ssh_usercert_create = tatuclient.v1.cli.usercert:CreateUserCertCommand
|
||||||
usercert_list = tatuclient.v1.cli.usercert:ListUserCertCommand
|
ssh_usercert_list = tatuclient.v1.cli.usercert:ListUserCertCommand
|
||||||
usercert_show = tatuclient.v1.cli.usercert:ShowUserCertCommand
|
ssh_usercert_show = tatuclient.v1.cli.usercert:ShowUserCertCommand
|
||||||
usercert_cert_show = tatuclient.v1.cli.usercert:ShowUserCertCertCommand
|
usercert_cert_show = tatuclient.v1.cli.usercert:ShowUserCertCertCommand
|
||||||
usercert_revoke = tatuclient.v1.cli.usercert:RevokeUserCertCommand
|
ssh_usercert_revoke = tatuclient.v1.cli.usercert:RevokeUserCertCommand
|
||||||
|
|
||||||
hostcert_list = tatuclient.v1.cli.hostcert:ListHostCertCommand
|
ssh_host_list = tatuclient.v1.cli.host:ListHostCommand
|
||||||
hostcert_show = tatuclient.v1.cli.hostcert:ShowHostCertCommand
|
ssh_host_show = tatuclient.v1.cli.host:ShowHostCommand
|
||||||
|
|
||||||
|
ssh_hostcert_list = tatuclient.v1.cli.hostcert:ListHostCertCommand
|
||||||
|
ssh_hostcert_show = tatuclient.v1.cli.hostcert:ShowHostCertCommand
|
||||||
hostcert_cert_show = tatuclient.v1.cli.hostcert:ShowHostCertCertCommand
|
hostcert_cert_show = tatuclient.v1.cli.hostcert:ShowHostCertCertCommand
|
||||||
|
|
||||||
sshca_create = tatuclient.v1.cli.ca:CreateCACommand
|
ssh_ca_create = tatuclient.v1.cli.ca:CreateCACommand
|
||||||
sshca_list = tatuclient.v1.cli.ca:ListCACommand
|
ssh_ca_list = tatuclient.v1.cli.ca:ListCACommand
|
||||||
sshca_show = tatuclient.v1.cli.ca:ShowCACommand
|
ssh_ca_show = tatuclient.v1.cli.ca:ShowCACommand
|
||||||
sshca_user_key_show = tatuclient.v1.cli.ca:ShowCAUserKeyCommand
|
sshca_user_key_show = tatuclient.v1.cli.ca:ShowCAUserKeyCommand
|
||||||
sshca_host_key_show = tatuclient.v1.cli.ca:ShowCAHostKeyCommand
|
sshca_host_key_show = tatuclient.v1.cli.ca:ShowCAHostKeyCommand
|
||||||
|
|
||||||
|
ssh_pat_list = tatuclient.v1.cli.pat:ListPATCommand
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
builders = html,man
|
builders = html,man
|
||||||
all-files = 1
|
all-files = 1
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from tatuclient.v1.base import V1Controller
|
from tatuclient.v1.base import V1Controller
|
||||||
from tatuclient.v1 import utils as v1_utils
|
|
||||||
|
|
||||||
|
|
||||||
class CAController(V1Controller):
|
class CAController(V1Controller):
|
||||||
|
62
tatuclient/v1/cli/host.py
Normal file
62
tatuclient/v1/cli/host.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# 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 = ['id', 'name', 'srv_url', 'pat_bastions']
|
||||||
|
_names = ['Instance ID', 'Hostname', 'SRV URL', 'PAT Bastions']
|
||||||
|
|
||||||
|
|
||||||
|
class ListHostCommand(command.Lister):
|
||||||
|
"""List Hosts"""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ListHostCommand, 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.host.list)
|
||||||
|
return _names, (utils.get_item_properties(s, _columns) for s in data)
|
||||||
|
|
||||||
|
|
||||||
|
class ShowHostCommand(command.ShowOne):
|
||||||
|
"""Show Host details"""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ShowHostCommand, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('id', help="Instance ID")
|
||||||
|
common.add_all_common_options(parser)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def _get_data(self, parsed_args):
|
||||||
|
client = self.app.client_manager.ssh
|
||||||
|
common.set_all_common_headers(client, parsed_args)
|
||||||
|
return client.host.get(parsed_args.id)
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
data = self._get_data(parsed_args)
|
||||||
|
return _names, utils.get_item_properties(data, _columns)
|
@ -24,8 +24,8 @@ from tatuclient.v1.utils import get_all
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
_columns = ['host_id', 'srv_url', 'pat_bastions', 'fingerprint']
|
_columns = ['host_id', 'fingerprint', 'hostname', 'created_at', 'expires_at']
|
||||||
_names = ['Instance ID', 'SRV URL', 'PAT Bastions', 'Fingerprint']
|
_names = ['Instance ID', 'Fingerprint', 'Hostname', 'Created', 'Expires']
|
||||||
|
|
||||||
|
|
||||||
class ListHostCertCommand(command.Lister):
|
class ListHostCertCommand(command.Lister):
|
||||||
|
43
tatuclient/v1/cli/pat.py
Normal file
43
tatuclient/v1/cli/pat.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# 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']
|
||||||
|
|
||||||
|
|
||||||
|
class ListPATCommand(command.Lister):
|
||||||
|
"""List PATs"""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ListCACommand, 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 _columns, (utils.get_item_properties(s, _columns) for s in data)
|
@ -24,8 +24,8 @@ from tatuclient.v1.utils import get_all
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
_columns = ['serial', 'revoked', 'user_id', 'auth_id', 'fingerprint']
|
_columns = ['serial', 'revoked', 'user_name', 'user_id', 'fingerprint', 'created_at', 'expires_at']
|
||||||
_names = ['Serial Number', 'Revoked', 'User ID', 'Project/CA ID', 'Fingerprint']
|
_names = ['Serial Number', 'Revoked', 'User Name', 'User ID', 'Fingerprint', 'Created', 'Expires']
|
||||||
|
|
||||||
|
|
||||||
class ListUserCertCommand(command.Lister):
|
class ListUserCertCommand(command.Lister):
|
||||||
|
@ -108,5 +108,7 @@ class Client(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.ca = CAController(self)
|
self.ca = CAController(self)
|
||||||
|
self.host = HostController
|
||||||
self.hostcert = HostCertController(self)
|
self.hostcert = HostCertController(self)
|
||||||
self.usercert = UserCertController(self)
|
self.usercert = UserCertController(self)
|
||||||
|
self.pat = PATController(self)
|
||||||
|
25
tatuclient/v1/host.py
Normal file
25
tatuclient/v1/host.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
from tatuclient.v1.base import V1Controller
|
||||||
|
|
||||||
|
|
||||||
|
class PATController(V1Controller):
|
||||||
|
|
||||||
|
def list(self, criterion=None, marker=None, limit=None):
|
||||||
|
url = self.build_url('/noauth/hosts', criterion, marker, limit)
|
||||||
|
return self._get(url, response_key='pats')
|
||||||
|
|
||||||
|
def get(self, host_id):
|
||||||
|
return self._get('/noauth/hosts/%s' % (host_id))
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from tatuclient.v1.base import V1Controller
|
from tatuclient.v1.base import V1Controller
|
||||||
from tatuclient.v1 import utils as v1_utils
|
|
||||||
|
|
||||||
|
|
||||||
class HostCertController(V1Controller):
|
class HostCertController(V1Controller):
|
||||||
|
22
tatuclient/v1/pat.py
Normal file
22
tatuclient/v1/pat.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
from tatuclient.v1.base import V1Controller
|
||||||
|
|
||||||
|
|
||||||
|
class PATController(V1Controller):
|
||||||
|
|
||||||
|
def list(self, criterion=None, marker=None, limit=None):
|
||||||
|
url = self.build_url('/noauth/pats', criterion, marker, limit)
|
||||||
|
return self._get(url, response_key='pats')
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from tatuclient.v1.base import V1Controller
|
from tatuclient.v1.base import V1Controller
|
||||||
from tatuclient.v1 import utils as v1_utils
|
|
||||||
|
|
||||||
|
|
||||||
class UserCertController(V1Controller):
|
class UserCertController(V1Controller):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user