Skip to content

Instantly share code, notes, and snippets.

@phoracek
Created August 9, 2017 11:03
Show Gist options
  • Save phoracek/0022434b1f105fa0466ed04576b6d7f4 to your computer and use it in GitHub Desktop.
Save phoracek/0022434b1f105fa0466ed04576b6d7f4 to your computer and use it in GitHub Desktop.
setup ovirtmgmt network with static ip via vdsm-client
echo '{"bondings": {}, "networks": {"ovirtmgmt": {"nic": "eth0", "netmask": "255.255.255.0", "ipaddr": "1.1.1.2", "gateway": "1.1.1.1", "defaultRoute": true}}, "options": {"connectivityCheck": false}}' | vdsm-client -f - Host setupNetworks
vdsm-client Host setSafeNetworkConfig
@DeivAstra
Copy link

DeivAstra commented Nov 28, 2019

Tons of thanks! Was very helpful for me today in datacenter!
I don't know what I will do without this script.

Also, today I created repo with my ovirtctl script.
https://github.com/danykey/ovirtctl
Hope that it save time for somebody in the future.

Thanks!

@phoracek
Copy link
Author

Thanks for reminding me this exists, glad to help :)

Copy link

ghost commented Jul 2, 2020

Hi Petr,

Can you please advice me on the following, Thank you in advance.

I am trying to use this utility to set up the ovirtmgmt over a VLAN interface (eno1.2).

echo '{"networks": {"ovirtmgmt": {"nic": "eno1", "bridged": true, "vlan": 2, "ipaddr": "192.168.81.241", "netmask": "255.255.255.240", "defaultRoute": false}}, "bondings": {}, "options": {"connectivityCheck": false}}' | vdsm-client -f - Host setupNetworks

ISSUE: The vdsm-client set the ifcfg-eno1.2 and ifcfg-ovirtmgmt configuration as desired. But it also overwrites my configuration in ifcfg-eno1 which is not desired. Is there a way I can block vdsm form doing this?

[root@atghost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1.2

Generated by VDSM version 4.30.46.1

DEVICE=eno1.2
VLAN=yes
BRIDGE=ovirtmgmt
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no

[root@atghost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ovirtmgmt

Generated by VDSM version 4.30.46.1

DEVICE=ovirtmgmt
TYPE=Bridge
DELAY=0
STP=off
ONBOOT=yes
IPADDR=192.168.81.241
NETMASK=255.255.255.240
BOOTPROTO=none
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no
MTU=1500

[root@atghost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1

Generated by VDSM version 4.30.46.1

DEVICE=eno1
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no

@phoracek
Copy link
Author

Hello @raoravin. IIRIC, VDSM owns the networking on its hosts, If you configure a network on top of eno1, it will become owned by it. I would advice you not to fight it and to use VDSM setupNetworks to configure your interface into your desired state explicitly. If it does not solve your issue, I'd recommend you to send your question to users@ovirt.org. Maybe there is another way.

@thissuper
Copy link

@phoracek Hi, Why did I specify mode=1 and actually mode=0?

echo '{
  "bondings": {
    "bond1": {
      "nics": ["ens34", "ens38"],
      "mode": 1
    }
  },
  "networks": {
    "mgmtnet": {
      "bonding": "bond1",
      "bootproto": "static",
      "ipaddr": "10.17.38.33",
      "netmask": "255.255.255.0",
      "gateway": "10.17.38.1", 
      "defaultRoute": true
    }
  },
  "options": {
    "connectivityCheck": false
  }
}' | vdsm-client -f - Host setupNetworks

vdsm-client Host setSafeNetworkConfig

@phoracek
Copy link
Author

phoracek commented Jan 1, 2024

@thissuper hey. I don't know why you used mode 1. AFAIK you can select any of the supported modes.

@thissuper
Copy link

@phoracek I read redhat documentation, ovirt should support mode 1. Did I make a mistake in my json?
Very confused, I think you may know, so consult you.
image

@phoracek
Copy link
Author

phoracek commented Jan 2, 2024

Sorry, I don't understand what you are asking. When you apply the JSON you shared above, does it fail?

@thissuper
Copy link

Sorry, I don't understand what you are asking. When you apply the JSON you shared above, does it fail?

Sorry, I was busy with other things these days, so I couldn't reply to you in time.

I am binding the network configuration of the ovirt host to make the ens192 interface and ens224 interface bonding1, but it is actually bonding0. Did I make a mistake in my json?

English is not my native language, so it may not be accurate enough. Please see shell below

[root@node-1 ~]# echo '{
  "bondings": {
    "bond1": {
      "nics": ["ens192", "ens224"],
      "mode": 1
    }
  },
  "networks": {
    "mgmtnet": {
      "bonding": "bond1",
      "bootproto": "static",
      "ipaddr": "10.17.35.52",
      "netmask": "255.255.255.0",
      "gateway": "10.17.35.1", 
      "defaultRoute": true
    }
  },
  "options": {
    "connectivityCheck": false
  }
}' | vdsm-client -f - Host setupNetworks

[root@node-1 ~]# vdsm-client Host setSafeNetworkConfig

[root@node-1 ~]# 
[root@node-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond1
# Generated by VDSM version 4.20.32-1.el7
DEVICE=bond1
BONDING_OPTS=mode=0
BRIDGE=mgmtnet
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no
[root@node-1 ~]#
[root@node-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192
# Generated by VDSM version 4.20.32-1.el7
DEVICE=ens192
MASTER=bond1
SLAVE=yes
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no
[root@node-1 ~]#
[root@node-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens224
# Generated by VDSM version 4.20.32-1.el7
DEVICE=ens224
MASTER=bond1
SLAVE=yes
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no
[root@node-1 ~]#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment