Creating Additional VLANs With the HMC CLI

Edit: Some links no longer work. I still love the CLI.

Originally posted December 9, 2014 on AIXchange

When I create LPARs, I prefer the HMC command line interface (CLI) to the GUI. The CLI is especially advantageous when I’m using a VPN to a remote site that’s slower than I’d prefer. Pointing and clicking and going through wizards is inconvenient — and it becomes exponentially so when you’re talking about setting up hundreds of LPARs at a time in multiple data centers.

I’ve previously discussed the HMC CLI, and of course I’m not the only one to have written about the various options (herehere and here). Still, I couldn’t find any good examples of a scenario where you’re creating virtual Ethernet adapters with multiple additional VLANs.

The typical GUI interface looks like this: 

In this simple example I’m looking to have additional VLANs on this virtual interface. This information on chsyscfg was helpful:

                virtual_eth_adapters
                Comma separated list of virtual ethernet adapters,
                with each adapter having the following format:

                virtual-slot-number/is-IEEE/port-vlan-ID/
                [additional-vlan-IDs]/[trunk-priority]/
                is-required[/[virtual-switch][/[MAC-address]/
                [allowed-OS-MAC-addresses]/[QoS-priority]]]

In particular, this caught my eye:

                If values are specified for additional-vlan-IDs, they
                must be comma separated.

So here you have a command that is expecting a comma separated list of virtual Ethernet adapters, and inside of that you have a comma separated list of additional VLANs.

However, things didn’t go as I hoped. I tried many different combinations of “ and ‘ and \” but couldn’t get it to work. I finally opened a PMR, so I’ll skip to the conclusion you can hopefully avoid my pain. All I was doing was adding in an adapter to an existing profile, and that’s what ultimately worked. Obviously the serial number and the actual VLAN names are changed, but this command should correspond to the example from the GUI above.

chsyscfg -m SN12345 -r prof -i name=default,lpar_id=2,\”virtual_eth_adapters=\”\”4/1/1/1,2,3,4,5/2/1\”\”\” 

As you likely expect, doing more than one makes it even more convoluted:

chsyscfg -m SN12345 -r prof -i name=default,lpar_id=2,\”virtual_eth_adapters=\”\”2/1/1/1,2,3,4,5/2/1\”\”\,\”\”3/1/2/6,7,8,9,10/2/1\”\”,4/0/10//0/1\”

Just imagine if you had 15 or 20 VLANs per virtual adapter that you needed to deploy throughout your environment.

Maybe this syntax is obvious to you, but it wasn’t obvious to me, so I’m putting this information out there for the next person who needs to determine how to use a comma separated list inside of another comma separated list with the HMC CLI.