#!/bin/bash

#

# Setup environment variables for auto login to CloudClient Shell

. ./env.sh

# Run the script to generate sample json file that can be used to create a new reservation.

. ./GenerateVSphereReservationTemplate.sh

# Though the above command create a sample reservation template, if used as is to create a new reservation, the reservation cannot be used to provision machines as there are no resources allocated/reserved such as memory, disk size, etc.
# Modify the json file as needed to remove any values for multi valued fields, so that only those resources needed are selected to create reservation.
# Modify the json file, to enter the appropriate values for fields such as memoryReservedSizeMb, machineQuota, storageReservationPriority, storageReservedSizeGB, so that the reservation can be used to provision machines.

# Pause the script to allow the user to modify json as needed
read -p "Press [Enter] key to create the reservation once the json is modified as needed..."

# Create a new reservation
$cloudclient_home/bin/cloudclient.sh vra reservation add --type VSPHERE --inputfile /tmp/vsphere-request.json

# A sample json file can be used to create multiple reservations by providing the values for arguments to 'vra reservation add' command.
# If values are provided for 'vra reservation add' command arguments '--businessGroupId', '--enable', '--name', '--priority', '--reservationPolicyId', and '--tenantId', these values are used instead of the ones in the json file provided in the '--inputfile' argument.
# Using the following command, another reservation can be created with just the values defined in command arguments being different.

# $cloudclient_home/bin/cloudclient.sh vra reservation add --type VSPHERE --inputfile /tmp/vsphere-request.json --businessGroupId='valid-business-group-id-1' --enable false --name 'Reservation-1' --priority 1 --reservationPolicyId 'valid-reservation-policy-id-1' --tenant 'valid-tenant-id-1'