Problem with compute-profile/compute-attributes

Hi,

how to add “list” or nested parameters in compute-resource?
With hammer this seems not to working:

hammer compute-profile values update --compute-profile-id $WINDOWSSERVERPROFILEID --compute-resource-id $MYVCENTERID --compute-attributes=“cluster=XXXX.,corespersocket=1,cpus=1,memory_mb=2048,path=/root/ha-datacenter/vm,resource_pool=Resources,firmware=bios,guest_id=windows9Server64Guest,hardware_version=Default,memoryHotAddEnabled=0,cpuHotAddEnabled=0,add_cdrom=0,scsi_controllers=[{“type”=“ParaVirtualSCSIController”,“key”=1000}]”

Could not update the compute profile attributes:
Error: Option ‘–compute-profile-id’: Numeric value is required…

See: ‘hammer compute-profile values update --help’.

problem is last parameter:
scsi_controllers=[{“type”=“ParaVirtualSCSIController”,“key”=1000}]"

This parameter is a list/nested parameter.

How would you apply compute-attributes data to foreman?

Is there maybe a better way then foreman(i checked API DOC but in this particule case (compute-profile/compute-attributes )it was not really usefull for me)

Thanks for help
Thomas

Hi Thomas,
it seems like you sent the parameters correctly. can you share the hammer logs?
you can simply run the command -d (debug option)

Hi,
just to make shure it is possible to provide nested parameters with csv?
so this looks like a mix of csv and json format…
If so i will keep trying…and check/send debug

BR
Thomas

yes, it’s possible,
you can check this example (it’s an example of an host creation but it should be the same for compute profile):
check the second comment in : https://github.com/theforeman/hammer-cli-foreman/pull/424#issuecomment-505502119

please let me know if you were able to run the command.

Hi,

still not get it working :frowning:
Does someone maybe have a working hammer example to create/update a compute-profile for vsphere including all the relevant parameters?

Thanks
Thomas

Hi,

after some hard time of trail and error i was now able to create the compute-profile with all wanted parameters…maybe it will save some time for others here the result:

#################Start Compute-Profile CentOS Part############


CENTOSCOMPUTEPROFILENAME="CentOS_x64"
echo CENTOSCOMPUTEPROFILENAME=$CENTOSCOMPUTEPROFILENAME >>/root/$sitename/parameter.cfg
hammer compute-profile create --name $CENTOSCOMPUTEPROFILENAME
CENTOSSERVERPROFILEID=`hammer --csv --no-use-defaults compute-profile list |awk -v var=$CENTOSCOMPUTEPROFILENAME   -F, '($2==var){print $1}'`
echo "CentOS Server ProfileID: $CENTOSSERVERPROFILEID"
echo CENTOSSERVERPROFILEID=$CENTOSSERVERPROFILEID >>/root/$sitename/hammerids.cfg


MYVMWARECLIENTSNETWORKNAME=$MYVMNETWORK
MYVMWARECLIENTSNETWORKID=`hammer --csv compute-resource networks --id 1|awk -v var="$MYVMWARECLIENTSNETWORKNAME" -F, '($2==var){print $1}'`

hammer compute-profile values create --compute-profile-id $CENTOSSERVERPROFILEID --compute-resource-id $MYVCENTERID \
--compute-attributes="{\"cpus\":1,\"corespersocket\":1,\"memory_mb\":2048,\"firmware\":\"automatic\",\
\"resource_pool\":\"Resources\",\"cluster\":\"$ESXIIP\",\"guest_id\":\"centos7_64Guest\",\
\"path\":\"/Datacenters/$MYVCENTERDATACENTER/vm\",\"hardware_version\":\"Default\",\"memoryHotAddEnabled\":\"0\",\
\"cpuHotAddEnabled\":\"0\",\"add_cdrom\":\"0\",\"scsi_controllers\":[{\"type\":\"ParaVirtualSCSIController\",\"key\":1000}]}"


hammer compute-profile values add-volume --compute-profile-id $CENTOSSERVERPROFILEID --compute-resource-id $MYVCENTERID \
--volume="name"="Hard\ disk","mode"="persistent","controller_key"=1000,"size_gb"="10","datastore"="$ESXDATASTORE"

hammer compute-profile values update-interface --compute-profile-id $CENTOSSERVERPROFILEID --compute-resource-id $MYVCENTERID --interface-id 0 \
--interface="compute_type"="VirtualVmxnet3","compute_network"="$MYVMWARECLIENTSNETWORKID"

#################End Compute-Profile CentOS Part############