I really could use help with onetemplate instantiate if anyone has a moment

I’m working in the vOnecloud 3.2.1 environment and am having issues with instantiating from template.

I have declared 3 new ‘mandatory’ variables in the templates context:

[oneadmin@machine root]$ onetemplate show 4
TEMPLATE 4 INFORMATION
ID : 4
NAME : opennebula-rhel-7.6-1902.2
USER : oneadmin
GROUP : labadmin
LOCK : None
REGISTER TIME : 03/19 15:27:32

PERMISSIONS
OWNER : um-
GROUP : u–
OTHER : u–

TEMPLATE CONTENTS
CONTEXT=[
DATACENTER="$DATACENTER",
DOMAIN="$DOMAIN",
INSTALL_APP="$INSTALL_APP",
NETWORK=“YES”,
SET_HOSTNAME="$NAME",
SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]",
START_SCRIPT_BASE64=“IyEvYmluL2Jhc2gKZWNobyAkRE-truncated”
CPU=“1”
DESCRIPTION=“Image Template with bootstrap script”
DISK=[
IMAGE_ID=“7”,
OPENNEBULA_MANAGED=“NO” ]
GRAPHICS=[
LISTEN=“0.0.0.0”,
TYPE=“VNC” ]
HYPERVISOR=“vcenter”
INPUTS_ORDER=“DATACENTER,DOMAIN,INSTALL_APP”
MEMORY=“2048”
MEMORY_UNIT_COST=“MB”
NIC=[
NETWORK_ID=“0”,
OPENNEBULA_MANAGED=“NO” ]
OS=[
BOOT="" ]
USER_INPUTS=[
DATACENTER=“O|list|Please Enter Datacenter|VCENTER1,VCENTER2,VCENTER3,VCENTER4,VCENTER5,VCENTER6,VCENTER7,VCENTER8|VCENTER1”,
DOMAIN=“O|list|Please Select Domain for VM|domain1.net,domain2.com,domain3.net,domain4.com|domain1.net”,
INSTALL_APP=“O|list|Does APP need to be installed|NO,YES|NO” ]
VCENTER_CCR_REF=“domain-c137”
VCENTER_INSTANCE_ID=“7da4f44f-4092-4712-9496-beea7c4ba527”
VCENTER_TEMPLATE_REF=“vm-275”
VCENTER_VM_FOLDER=""
VCPU=“1”

onetemplate instantiate 4 --memory 1g --disk 7:size=50g --nic vDS_LabNetwork:IP=10.26.48.79 --name TESTHOST --cpu 1 --context ‘DATACENTER=DATACENTER1,DOMAIN=domain1.net,INSTALL_APP=NO’

No matter how I try to format the syntax around --context it doesn’t appear the variables are being inserted into the instantiation process: Continually receive the message ''There are some parameters that require user input. Use the string <> to launch an editor (e.g. for multi-line inputs)"

http://docs.opennebula.org/5.8/operation/vm_management/vm_instances.html

and have to select all my options and the instance instantiates fine. Is there a way around this?
I see references to having to do an additional append from a file to the template, but can’t this be done in one step?

Thank you,
Christina

If you want to use user input vars, you can pass them from stdin with command like:

printf “DATACENTER1\ndomain1.net\nNO” | onetemplate instantiate 4 --memory 1g --disk 7:size=50g --nic vDS_LabNetwork:IP=10.26.48.79 --name TESTHOST --cpu 1

But you can also drop the user input vars and only pass the values to the context as you did with the --context attr.

1 Like

Jimmy,

Thank you, this was exactly what I needed for now!
After I read this, it made perfect sense.

Christina