|
#!/bin/bash
|
|
# ex: set expandtab ts=4 sw=4:
|
|
|
|
{
|
|
|
|
FM_ADMIN_PASSWD='changeme'
|
|
VM_R8_APP_HGW_IP='172.17.31.10'
|
|
VM_R8_HOSTNAME='r80dm'
|
|
|
|
# create VM-R8
|
|
hammer -d --username admin --password $FM_ADMIN_PASSWD host create --environment-id 1 --architecture-id 1 --domain-id 1 --puppet-proxy-id 1 --operatingsystem-id 2 --hostgroup-id 3 --provision-method image --compute-resource-id 1 --interface "primary=true,provision=true,compute_type=bridge,compute_bridge=br0,compute_model=virtio,ip=$VM_R8_APP_HGW_IP" --name $VM_R8_HOSTNAME --subnet-id 1 --compute-attributes "cpus=4,memory=12884901888,start=1,image_id=/var/lib/libvirt/images/win7-appnode.qcow2" --volume "pool_name=virt-images,capacity=150G,format_type=qcow2,allocation=0G" --build 1 --enabled 1 --managed 1 --puppet-ca-proxy-id 1
|
|
|
|
VM_R8="
|
|
{
|
|
\"host\":{
|
|
\"name\":\"$VM_R8_HOSTNAME\",
|
|
\"hostgroup_id\":\"3\",
|
|
\"compute_resource_id\":\"1\",
|
|
\"managed\":\"true\",
|
|
\"interfaces_attributes\":
|
|
{\"0\":
|
|
{
|
|
\"_destroy\":\"0\",
|
|
\"name\":\"$VM_R8_HOSTNAME\",
|
|
\"domain_id\":\"1\",
|
|
\"subnet_id\":\"1\",
|
|
\"ip\":\"$VM_R8_APP_HGW_IP\",
|
|
\"managed\":\"1\",
|
|
\"primary\":\"1\",
|
|
\"provision\":\"1\",
|
|
\"virtual\":\"0\",
|
|
\"compute_attributes\":
|
|
{
|
|
\"type\":\"bridge\",
|
|
\"bridge\":\"br0\",
|
|
\"model\":\"virtio\"
|
|
}
|
|
}
|
|
},
|
|
\"compute_attributes\":
|
|
{
|
|
\"cpus\":\"4\",
|
|
\"memory\":\"12884901888\",
|
|
\"start\":\"1\",
|
|
\"volumes_attributes\":
|
|
{
|
|
\"0\":{
|
|
\"_delete\":\"\",
|
|
\"pool_name\":\"virt-images\",
|
|
\"capacity\":\"150G\",
|
|
\"allocation\":\"0G\",
|
|
\"format_type\":\"qcow2\"
|
|
}
|
|
},
|
|
\"image_id\":\"/var/lib/libvirt/images/win7-appnode.qcow2\"
|
|
},
|
|
\"architecture_id\":\"1\",
|
|
\"operatingsystem_id\":\"2\",
|
|
\"provision_method\":\"image\",
|
|
\"build\":\"1\",
|
|
\"puppet_proxy_id\":\"1\",
|
|
\"puppet_ca_proxy_id\":\"1\",
|
|
\"enabled\":\"1\"
|
|
}
|
|
}
|
|
"
|
|
HOST=$(echo $VM_R8 | tr -d \\n )
|
|
curl -k -u admin:$FM_ADMIN_PASSWD -H "Content-Type: application/json, version=2" -X POST -d "$HOST" https://localhost/api/hosts > create_$VM_R8_HOSTNAME.log
|
|
|
|
cat create_$VM_R8_HOSTNAME.log
|
|
|
|
|
|
} 2>&1 | tee guest.log
|
|
|