hammer Cheat Sheet

Red Hat Satellite 6.9

Red Hat Satellite 的 Hammer CLI Cheat Sheet

Red Hat Satellite Documentation Team

摘要

本文档包含 Red Hat Satellite 的hammer CLI 命令。

第 1 章 简介

Hammer 是随 Red Hat Satellite 6 提供的命令行工具。您可以使用 Hammer 命令或 shell 脚本自动化来配置和管理红帽卫星服务器。以下 cheat 表格概述了基本 Hammer 命令。

有关 Hammer 的更多信息,请参见 Red Hat Hammer CLI 指南

第 2 章 常规信息

表 2.1. 常规信息

子命令描述和任务

--help

显示 hammer 命令和选项,在子命令后附加以获取更多信息

org

这个设置特定于机构,附加 --organization org_name,或使用以下命令设置默认机构:

hammer defaults add \
--param-name organization_id \
--param-value org_ID

loc

这个设置特定于位置,附加 --location loc_name,或使用以下内容设置默认位置:

hammer defaults add \
--param-name location_id \
--param-value loc_ID

注: 此 cheat sheet 假设将凭证保存在 ~/.hammer/cli_config.yml 中。有关更多信息,请参阅 Red Hat Hammer CLI 指南中的 身份验证。

第 3 章 机构、位置和存储库

表 3.1. 机构、位置和存储库

子命令描述和任务

机构

创建机构:

hammer organization create \
--name org_name

列出机构:

hammer organization list

位置

查看机构的选项

subscription
org

上传订阅清单:

hammer subscription upload \
--file path

repository-set
org

启用存储库:

hammer repository-set enable \
--product prod_name \
--basearch base_arch \
--releasever rel_v \
--name repo_name

软件仓库
机构

同步存储库:

hammer repository synchronize \
--product prod_name \
--name repo_name

创建自定义存储库:

hammer repository create \
--product prod_name \
--content-type cont_type \
--publish-via-http true \
--url repo_url \
--name repo_name

将内容上传到自定义存储库:

hammer repository upload-content \
--product prod_name \
--id repo_id \
--path path_to_dir

第 4 章 内容生命周期

表 4.1. 内容生命周期

子命令描述和任务

Lifecycle-environment
org

创建生命周期环境:

hammer lifecycle-environment create \
--name env_name
--description env_desc
--prior prior_env_name

列出生命周期环境:

hammer lifecycle-environment list

content-view
org

创建内容视图:

hammer content-view create \
--name cv_n \
--repository-ids repo_ID1,... \
--description cv_description

在内容视图中添加存储库:

hammer content-view add-repository \
--name cv_n \
--repository-id repo_ID

在内容视图中添加 Puppet 模块:

hammer content-view puppet-module add \
--content-view cv_n \
--name module_name

发布内容视图:

hammer content-view publish \
--id cv_ID

提升内容视图:

hammer content-view version promote \
--content-view cv_n \
--to-lifecycle-environment env_name

内容视图的增量更新:

hammer content-view version incremental-update \
--content-view-version-id cv_ID \
--packages pkg_n1,... \
--lifecycle-environment-ids env_ID1,...

第 5 章 置备环境

表 5.1. 置备环境

子命令描述和任务

创建域:

hammer domain create \
--name domain_name

subnet
org
loc

添加子网:

hammer subnet create \
--name subnet_name \
--organization-ids org_ID1,... \
--location-ids loc_ID1,... \
--domain-ids dom_ID1,... \
--boot-mode boot_mode \
--network network_address \
--mask netmask --ipam ipam

compute-resource
org
loc

创建计算资源:

hammer compute-resource create \
--name cr_name \
--organization-ids org_ID1,... \
--location-ids loc_ID1,... \
--provider provider_name

添加安装介质:

hammer medium create \
--name med_name \
--path path_to_medium

partition-table

添加分区表:

hammer partition-table create \
--name tab_name \
--path path_to_file \
--os-family os_family

模板

添加置备模板:

hammer template create \
--name tmp_name \
--file path_to_template

OS

添加操作系统:

hammer os create \
--name os_name \
--version version_num

第 6 章 激活码

表 6.1. 激活码

子命令描述和任务

activation-key
org

创建激活码:

hammer activation-key create \
--name ak_name \
--content-view cv_n \
--lifecycle-environment lc_name

在激活码中添加订阅:

hammer activation-key add-subscription \
--id ak_ID \
--subscription-id sub_ID

第 7 章 用户和权限

表 7.1. 用户和权限

子命令描述和任务

user
org

创建用户:

hammer user create \
--login user_name \
--mail user_mail \
--auth-source-id 1 \
--organization-ids org_ID1,org_ID2,...

为用户添加角色:

hammer user add-role \
--id user_id \
--role role_name

user-group

创建用户组:

hammer user-group create \
--name ug_name

为用户组添加角色:

hammer user-group add-role \
--id ug_id \
--role role_name

role

创建角色:

hammer role create \
--name role_name

filter

创建过滤器并将其添加到角色中:

hammer filter create \
--role role_name \
--permission-ids perm_ID1,perm_ID2,...

第 8 章 勘误

表 8.1. 勘误

子命令描述和任务

勘误

列出勘误:

hammer erratum list

通过 CVE 查找勘误:

hammer erratum list --cve CVE

检查勘误:

hammer erratum info --id err_ID

主机

列出适用于主机的勘误表:

hammer host errata list \
--host host_name

将勘误表应用到主机:

hammer host errata apply \
--host host_name \
--errata-ids err_ID1,err_ID2,...

第 9 章 主机

表 9.1. 主机

子命令描述和任务

hostgroup
org
loc

创建主机组:

hammer hostgroup create \
--name hg_name \
--puppet-environment env_name \
--architecture arch_name \
--domain domain_name \
--subnet subnet_name \
--puppet-proxy proxy_name \
--puppet-ca-proxy ca-proxy_name \
--operatingsystem os_name \
--partition-table table_name \
--medium medium_name \
--organization-ids org_ID1,... \
--location-ids loc_ID1,...

在主机组中添加激活码:

hammer hostgroup set-parameter \
--hostgroup "hg_name" \
--name "kt_activation_keys" \
--value key_name

host
org
loc

创建主机(继承主机组的参数):

hammer host create \
--name host_name \
--hostgroup hg_name \
--interface="primary=true, \
mac=mac_addr, ip=ip_addr, \
provision=true" \
--organization-id org_ID \
--location-id loc_ID \
--ask-root-password yes

job-template

为远程执行添加作业模板:

hammer job-template create \
--file path \
--name template_name \
--provider-type SSH \
--job-category category_name

job-invocation

调用远程作业:

hammer job-invocation create \
--job-template template_name \
--inputs key1=value,... \
--search-query query

监控远程作业:

hammer job-invocation output \
--id job_id --host host_name

第 10 章 任务

表 10.1. 任务

子命令描述和任务

任务

列出所有任务:

hammer task list
Monitor progress of a running task:
hammer task progress \
--id task_ID

法律通告

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.