Bug #13507
closedCreating VMs with hammer requires too many parameters
Description
Hi
while hammer is awesome for command line usage one has to be a bit verbose to get a VM going even if one is using host groups and compute profiles:
Let's say I have a hostgroup with a compute profile selected. That
compute profile has two compute resources:
If have a host group (deriving from another host group that has the compute profile association). This has a single compute profile and two compute resources so all should be set (except for maybe which of the two compute resources to use but that's not what happens):
hammer host create --name=test.example.com --hostgroup-id=1 --location-id 1
Could not create the host:
Error: At least one interface must be set as primary
Both compute profiles in the hostgroup only have a single interface but lets help a little:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1
Could not create the host:
Mac can't be blank
Partition Table can't be blank unless a custom partition has been defined
Medium can't be blank
Both compute profiles in the host group have an image specified in the default vm attributes but let's be explicit: and add a compute resource:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1 --compute-resource-id=1
Could not create the host:
Partition Table can't be blank unless a custom partition has been defined
Medium can't be blank
O.k. then add the compute-profile as well:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1 --compute-resource-id=1 --compute-profile-id=1
Could not create the host:
Partition Table can't be blank unless a custom partition has been defined
Medium can't be blank
still not derived from there so let's be explicit:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1 --compute-resource-id=1 --compute-profile-id=1 --provision-method=image
Could not create the host:
Ip can't be blank
So we're at the network step now (no idea it would pick the right image though), let's help again:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1 --compute-resource-id=1 --compute-profile-id=1 --provision-method=image --subnet-id=1
could not create the host:
Failed to create a compute MyComRes (VMware) instance test.example.com: cluster is required for this operation
The cluster is stored in the compute profile but again:
hammer host create --name=test.example.com --interface=primary=true,provision=true --hostgroup-id=1 --location-id 1 --compute-resource-id=1 --compute-profile-id=1 --provision-method=image --subnet-id=1 --compute-attributes="cluster=foo"
Could not create the host:
Failed to create a compute MyComRes (VMware) instance test.example.com: failed to create vm: InvalidDatastorePath: Ungültiger Datenspeicherpfad '[datastore1]'.
There is no datastore1, I could give this as well but I give up here since maintaining this list of details twice (in the hammer script and in the database) is too error prone (and giving the datastore gives more errors due to the disk not being fully specified).
Interestingly, the GUI gets it mostly right (new host->select location, select host group, select deploy on (which is always bare metal by default): it then gets the right compute profile and assigns the correct interface as primary/provision by itself; Head to "Operating System" Tab, Select provision method (defaults to network), select image (not taken from compute profile). So in hammer cli terms this would be:
hammer host create --name=test.example.com --location-id=1 --hostgroup-id=1 --compute-resource-id=1 --provision-method=image --image=myimage
and that would be o.k. to put into a script.
and if it would also pick the right image from the defined compute profile:
hammer host create --name=test.example.com --location-id=1 --hostgroup-id=1 --compute-resource-id=1
which would be totally awesome. Tested with hammer-cli-foreman 0.4 and 0.5. I'm happy
to help fix this if somebody points me into the right direction.