Impossible to set IP address when onetemplate instantiate

Hello!

I keep getting “Cannot get IP/MAC lease from virtual network” trying to run:

onetemplate instantiate 69 --hold
–name testvm --memory 2048
–cpu 4 --vcpu 4
–user-inputs “SET_HOSTNAME=test”,“CORES_PER_SOCKET=2”,“IPADDR”=“10.50.28.100”

but it gets ip address OK when I set the var directly like that:

NIC = [
IP = “10.50.28.100”,

]

I think the possible reason may be that no IP variable substitution happens when
IP = $IPADDR
(am I right here?)

Extracts from the template:

CONTEXT = [
CORES_PER_SOCKET = “$CORES_PER_SOCKET”,
IPADDR = “$IPADDR”,
SET_HOSTNAME = “$SET_HOSTNAME”,
NETWORK = “YES”,
]

NIC = [
IP = “$IPADDR”,
NETWORK = “WN_int_10-50-28-15”,
NETWORK_UNAME = “gridadmin”,
SECURITY_GROUPS = “0” ]

USER_INPUTS = [
CORES_PER_SOCKET = “M|number|cores per socket| |”,
IPADDR = “M|text|ipaddress| |”,
SET_HOSTNAME = “M|text|VM hostname| |” ]

Notes:

Other variables SET_HOSTNAME and CORES_PER_SOCKET that is used in section
TOPOLOGY = [CORES = “$CORES_PER_SOCKET”, … ]

are initiated OK.

I tried disable/enable network contextualization
CONTEXT = [

NETWORK = “YES”,
]

with no luck.

My OpenNebula version: 6.2.0.1

best regards,
Dzmitry

Instead of defining the IP parameter in the NIC, try and define ETH0_IP in the CONTEXT section.

For example

CONTEXT = [
CORES_PER_SOCKET = “$CORES_PER_SOCKET”,
ETH0_IP="$IPADDR",
SET_HOSTNAME = “$SET_HOSTNAME”,
NETWORK = “YES”,
]
…
NIC = [
NETWORK = “WN_int_10-50-28-15”,
NETWORK_UNAME = “gridadmin”,
SECURITY_GROUPS = “0” ]
…
USER_INPUTS = [
CORES_PER_SOCKET = “M|number|cores per socket| |”,
IPADDR = “M|text|ipaddress| |”,
SET_HOSTNAME = “M|text|VM hostname| |” ]

Daniel,

thank you very much for your reply.

Unfortunatly, it does not work. It looks like Opennebula ignores direct ETH0_IP setting.

As a result I can see that settings in the VM template:

User template

CORES_PER_SOCKET = “2”
IPADDR = “"10.50.28.100"”
USER_INPUTS = [
CORES_PER_SOCKET = “M|number|cores per socket| |”,
IPADDR = “M|text|ipaddress| |"10.50.28.100"”,
SET_HOSTNAME = “M|text|VM hostname| |” ]

Template

CONTEXT = [

CORES_PER_SOCKET = “2”,
ETH0_IP = “10.50.28.100”,
NETWORK = “YES”,
SET_HOSTNAME = “test”]

NIC = [
IP = “10.50.28.15”,
NAME = “NIC0”,
NETWORK = “WN_int_10-50-28-15” ]

TOPOLOGY = [

CORES = “$CORES_PER_SOCKET” ]

My 10.50.28.100 is ignored and 10.50.28.15 is autoselected from available Network address range.

p.s. and I found that “Add network contextualization” checkbock has no effect on the selection process.

Dzmitry

I think the problem could be that you have both NIC[IP] and CONTEXT[ETH0_IP]. Try removing NIC[IP] and just leave ETH0_IP in CONTEXT.

Daniel,
thank you!

The problem was that I set no NIC[IP] when instantiated that VM. That value 10.50.28.15 was autoselected and desirable IP was ignored.

I posted the template of active and running VM, I can see it in menu “Instances” → “VM”.

I tried different combinations of settings. In the end I just used web fontend to start all my VMs. There was no problem to set desirable IP addresses for VMs by GUI - unlike CLI.

Dzmitry