# -*- 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 __future__ import print_function from cratonclient.common import cliutils from cratonclient import exceptions as exc DEFAULT_HOST_FIELDS = [ 'id', 'name', 'active', 'device_type', 'ip_address', 'cloud_id', 'region_id', 'cell_id', 'created_at', ] HOST_FIELDS = DEFAULT_HOST_FIELDS + [ 'updated_at', 'note', 'variables', 'labels', 'parent_id', 'project_id', ] @cliutils.arg('id', metavar='', type=int, help='ID of the host.') def do_host_show(cc, args): """Show detailed information about a host.""" host = cc.hosts.get(args.id) args.formatter.configure(wrap=72).handle(host) @cliutils.arg('-r', '--region', metavar='', type=int, help='ID of the region that the host belongs to.') @cliutils.arg('--cloud', metavar='', type=int, help='ID of the cloud that the host belongs to.') @cliutils.arg('-c', '--cell', metavar='', type=int, help='Integer ID of the cell that contains ' 'the desired list of hosts.') @cliutils.arg('--detail', action='store_true', default=False, help='Show detailed information about the hosts.') @cliutils.arg('--sort-key', metavar='', help='Host field that will be used for sorting.') @cliutils.arg('--sort-dir', metavar='', default='asc', choices=('asc', 'desc'), help='Sort direction: "asc" (default) or "desc".') @cliutils.arg('--fields', nargs='+', metavar='', default=DEFAULT_HOST_FIELDS, help='Space-separated list of fields to display. ' 'Only these fields will be fetched from the server. ' 'Can not be used when "--detail" is specified') @cliutils.arg('--all', action='store_true', default=False, help='Retrieve and show all hosts. This will override ' 'the provided value for --limit and automatically ' 'retrieve each page of results.') @cliutils.arg('--limit', metavar='', type=int, help='Maximum number of hosts to return.') @cliutils.arg('--marker', metavar='', default=None, help='ID of the cell to use to resume listing hosts.') @cliutils.arg('--device-type', metavar='', default=None, help='Device type to use as filter.') @cliutils.arg('--vars', metavar='', default=None, help='Variables to use as filter in the form of key:value.') @cliutils.arg('--label', metavar='