Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Sat 6.1 Hammer Host Creation

Host creation is one of the most complex commands in the hammer's foreman plugin. The majority of its parameters is obvious but there are some that need further explanation as their values differ with the type of a compute resource.

$ hammer host create -h
Usage:
    hammer host create [OPTIONS]

Options:
 --architecture ARCHITECTURE_NAME                       Architecture name
 --architecture-id ARCHITECTURE_ID
 --ask-root-password ASK_ROOT_PW                        One of true/false, yes/no, 1/0.
 --build BUILD                                          One of true/false, yes/no, 1/0.
                                                        Default: "true"
 --comment COMMENT                                      Additional information about this host
 --compute-attributes COMPUTE_ATTRS                     Compute resource attributes.
                                                        Comma-separated list of key=value.
 --compute-profile COMPUTE_PROFILE_NAME                 Name to search by
 --compute-profile-id COMPUTE_PROFILE_ID
 --compute-resource COMPUTE_RESOURCE_NAME               Compute resource name
 --compute-resource-id COMPUTE_RESOURCE_ID
 --domain DOMAIN_NAME                                   Domain name
 --domain-id DOMAIN_ID                                  Numerical ID or domain name
 --enabled ENABLED                                      One of true/false, yes/no, 1/0.
                                                        Default: "true"
 --environment ENVIRONMENT_NAME                         Environment name
 --environment-id ENVIRONMENT_ID
 --hostgroup HOSTGROUP_NAME                             Hostgroup name
 --hostgroup-id HOSTGROUP_ID
 --image IMAGE_NAME                                     Name to search by
 --image-id IMAGE_ID
 --interface INTERFACE                                  Interface parameters.
                                                        Comma-separated list of key=value.
                                                        Can be specified multiple times.
 --ip IP                                                not required if using a subnet with DHCP proxy
 --location LOCATION_NAME                               Location name
 --location-id LOCATION_ID
 --mac MAC                                              required for managed host that is bare metal, not required if it's a
                                                        virtual machine
 --managed MANAGED                                      One of true/false, yes/no, 1/0.
                                                        Default: "true"
 --medium MEDIUM_NAME                                   Medium name
 --medium-id MEDIUM_ID
 --model MODEL_NAME                                     Model name
 --model-id MODEL_ID
 --name NAME
 --operatingsystem OPERATINGSYSTEM_TITLE                Operating system title
 --operatingsystem-id OPERATINGSYSTEM_ID
 --organization ORGANIZATION_NAME                       Organization name
 --organization-id ORGANIZATION_ID                      organization ID
 --owner OWNER_LOGIN                                    Login of the owner
 --owner-id OWNER_ID                                    ID of the owner
 --owner-type OWNER_TYPE                                Host's owner type
 --parameters PARAMS                                    Host parameters.
                                                        Comma-separated list of key=value.
 --partition-table, --ptable PARTITION_TABLE_NAME       Partition table name
 --partition-table-id, --ptable-id PARTITION_TABLE_ID
 --progress-report-id PROGRESS_REPORT_ID                UUID to track orchestration tasks status, GET
                                                        /api/orchestration/:UUID/tasks
 --provision-method METHOD                              One of 'build', 'image'
 --puppet-ca-proxy PUPPET_CA_PROXY_NAME
 --puppet-ca-proxy-id PUPPET_CA_PROXY_ID
 --puppet-class-ids, --puppetclass-ids PUPPET_CLASS_IDS Comma separated list of values.
 --puppet-classes PUPPET_CLASS_NAMES                    Comma separated list of values.
 --puppet-proxy PUPPET_PROXY_NAME
 --puppet-proxy-id PUPPET_PROXY_ID
 --realm REALM_NAME                                     Name to search by
 --realm-id REALM_ID                                    Numerical ID or realm name
 --root-pass ROOT_PASS                                  required if host is managed and value is not inherited from host group or
                                                        default password in settings
 --root-password ROOT_PW
 --subnet SUBNET_NAME                                   Subnet name
 --subnet-id SUBNET_ID
 --volume VOLUME                                        Volume parameters
                                                        Comma-separated list of key=value.
                                                        Can be specified multiple times.
 -h, --help                                             print help

Example

An example command for creating a host with 2 volumes (5GB raw + 10 GB qcow2) using a default network interface on a libvirt provider can look like this:

hammer host create
  --hostgroup-id=4                           # most of the settings is done in the hostgroup
  --compute-resource-id=1                    # set the libvirt provider
  --compute-attributes="cpus=2"              # specify the provider specific options, see the list below
  --interface="type=network,network=default" # add a network interface, can be passed multiple times
  --volume="capacity=5G"                     # add a volume, can be passed multiple times
  --volume="capacity=10G,format_type=qcow2"  # add another volume with different size and type
  --name="test-host"
  --ip="1.2.3.4"

See the list of all possible option keys below.

Networking

The host's primary interface properties are set directly on the host with parameters:

--ip
--mac
--subnet (or --subnet-id)
--domain (or --domain-id)

Additional interfaces can be added via parameter --interface, which takes key=values separated by commas. Keys differ accross providers (compute resources). Available options are described below.

Provider specific options

Bare Metal

Available keys for --interface:

type       # one of Nic::Managed, Nic::BMC, Nic::Bond
           # Warning: Type value is case sensitive. Different value may lead to internal server errors.
mac
ip
name       # DNS name
identifier
domain_id
subnet_id

# for virtual interfaces:
tag         # VLAN tag, this attribute has precedence over the subnet VLAN ID. Only for virtual interfaces.
attached_to # Identifier of the interface to which this interface belongs, e.g. eth1.

# for bonds:
mode             # One of balance-rr, active-backup, balance-xor, broadcast, 802.3ad, balance-tlb, balance-alb
attached_devices # Identifiers of slave interfaces, e.g. [eth1,eth2].
bond_options

# for BMCs:
provider   # always IPMI
username
password

EC2

Available keys for --compute-attributes:

flavor_id          # select one of available flavours
image_id           # select one of available images
availability_zone
security_group_ids
managed_ip

GCE

Available keys for --compute-attributes:

machine_type # one of available flavors
image_id
network
external_ip

Libvirt

Available keys for --compute-attributes:

cpus          # number of CPUs
memory        # string, amount of memory, value in bytes
start         # boolean, whether to start the machine or not

Available keys for --interface:

type              # one of [:bridge, :network]
network / bridge  # name of interface according to type
model             # one of [virtio, rtl8139, ne2k_pci, pcnet, e1000]

Available keys for --volume:

pool_name   # list of available storage pools
capacity    # string value, eg. 10G
format_type # one of [raw, qcow2]

OpenStack

Available keys for --compute-attributes:

flavor_ref
image_ref
tenant_id
security_groups
network

oVirt

Available keys for --compute-attributes:

cluster
template   # hardware profile to use
cores      # int value, number of cores
memory     # amount of memory, int value in bytes
start      # boolean, whether to start the machine or not

Available keys for --interface:

name         # eg. eth0
network      # select one of available networks for a cluster, use UUID from oVirt

Available keys for --volume:

size_gb          # volume size in GB, integer value
storage_domain   # select one of available storage domains, use UUID from oVirt
bootable         # boolean, only one volume can be bootable

Rackspace

Available keys for --compute-attributes:

flavor_id
image_id

VMware

Available keys for --compute-attributes:

cpus       # cpu count
memory_mb  # integer number
cluster
path

Available keys for --interface:

network    # use UUID from VMware

Available keys for --volume:

datastore  # use UUID from VMware
name
size_gb    # integer number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.