I am working on a project where I need to apply live, permanent networking configuration changes to Linux VMs that may not even have a network configured in the first place.
To do so I am leveraging:
vSphere guest operations allowing to run commands in the guest OS even if it is not networked yet.
NetworkManager / nmcli which provides a command line way to get and set a broad set of network configurations that can be applied immediately and permanently . NetworkManager was first developed by Red Hat and is now available in several distributions.
The VM network cards appear as network manager devices.
The “Get all properties from a device” workflow will list all the devices and their properties in the workflow log and set a workflow output parameter of type array of properties
The inputs are the virtual Machine hosting the Linux guest OS, the credentials to access the guest OS.
Here is a sample output showing some properties with the most important being :
GENERAL.DEVICE later referred as “device name” and used in all workflows requiring a device name input.
GENERAL.CONNECTION later referred as “connection profile” or “connection id” and used in all workflows requiring a connection name input.
The list of properties is variable depending on the type of device and the connection profile it is bound to.
In case you need to get this set of properties for all connections I have created a “Get really all properties from all connections” workflow that work in 2 steps:
First it gets all the connection names
Then it run a command for each connection and outputting an aggregated array of properties.
The workflows “Get connection names for given property values” and “Get devices names for given property values” allow you to find out the name of a connection or a device that has a set of property values matching the one you request.
For example if I need to change the IP address of a connection without knowing its name I can for example get the connections that have and ipv4 gateway set to a given IP.
Another example would be to find out devices without a connection. This would be the case if a new NIC would be added via vSphere but no configuration would be done yet in the OS. For this the “Get device names for given property values” could be used with the device property “GENERAL.STATE” with a value of “30 (disconnected)” or with an empty connection : “GENERAL.CONNECTION” property with “–” value.
The “Run network manager command” workflow assist you to generate a network manager command and runs it.
The timeout is the time the workflow will wait for the command to complete before failing.
The second time is the period in seconds the result of the command is going to be checked.
The second screen allows to select the object you will be acting on, the command, the ID / name of the device or connection if these are required.
The last field is the command string being built. You may need to add additional parameters manually if you want to do more complex operations or if the workflow run tells you it is missing a parameter.
The “Commands samples” folder contains workflows that have hard coded network manager commands I used often and provide simple inputs to be used as part of your custom workflows.
You should find most of the workflows you need to operate and change settings on connections and devices. If not it is easy to duplicate one of these workflows and to modify the nmcli command to be run.
The sample flows category contains an example of a flow called “Change IP addresses and hostname on Oracle RAC node” with multiple get / set operations:
Basically the node we need to configure has 2 devices (one for public, one for private access) and the only information we have at run time is the network gateway used for each of these networks. By getting all the connection properties the workflow finds the unactive connections having the gateways we are looking for and assign new IPs for each. As a last step the hostname is changed.
Note that the IP addresses include the sub-netting in the form /xx and that to make an IP address change immediate the “Set a connection IP V4 addresses” workflow run an additional “nmcli connection up” command.
Here is a demo of this workflow:
You can download the networkManager package from flowgrab.
About Christophe Decanini:
Christophe has worked at VMware, Inc., where he started in 2007 after VMware acquired Dunes. Based in Gland, Switzerland, Christophe is a global resource supporting customers in their orchestration and automation needs. He has presented orchestration solutions at conferences such as VMworld and is the primary contributor to this site.