In Part 5, we are now going to have a look at networking section of the VAMI UI.
VAMI UI Area of Focus
In the Networking tab, under the "Manage" sub-tab, you can find details about the system Hostname (PNID), DNS servers as well as the configurations for each network interface (in the case of a VCHA deployment, you would have more than one network interface configured).
VAMI APIs Used
- GET /appliance/networking/dns/hostname
- GET /appliance/networking/dns/servers
- GET /appliance/networking/interfaces
- GET /appliance/techpreview/networking/ipv4
PowerCLI Function
Sample Output
This sample script only retrieves IPv4 networking information, but you can easily retrieve IPv6 information by calling into the IPv6 VAMI API endpoints which you can refer to the documentation or the API Explorer for more details.
- Exploring new VCSA VAMI API w/PowerCLI: Part 1
- Exploring new VCSA VAMI API w/PowerCLI: Part 2
- Exploring new VCSA VAMI API w/PowerCLI: Part 3
- Exploring new VCSA VAMI API w/PowerCLI: Part 4
- Exploring new VCSA VAMI API w/PowerCLI: Part 5
- Exploring new VCSA VAMI API w/PowerCLI: Part 6
- Exploring new VCSA VAMI API w/PowerCLI: Part 7
- Exploring new VCSA VAMI API w/PowerCLI: Part 8
- Exploring new VCSA VAMI API w/PowerCLI: Part 9
- Exploring new VCSA VAMI API w/PowerCLI: Part 10
vlx says
Link is wrong, it should be: https://github.com/lamw/PowerCLI-Example-Scripts/blob/master/Modules/VAMI/VAMI.psm1
Antoine says
Hi William.
Is there way to change IP Address and default gateway for VAMI using powercli ? Thx
William Lam says
Yes. All VAMI/Appliance Management functionality is exposed via VAMI API https://developer.vmware.com/apis/vsphere-automation/latest/appliance/ which can be consumed via PowerCLI
Antoine says
Hi William. Thx for your reply. Is it possible to giveme an exemple ? my powershell knowledge isn't as goog as yours. Thx
William Lam says
Did you click through the different operations ... the page provides PowerCLI examples using some of the auto-generated cmdlets. I recommend you write down the things you'd like to automate then spend some time going through the documentation
Antoine says
Hi. Yes i did click but i didnt understand anything. i'll try to learn more about this. Thx for the link btw 🙂
Antoine says
Hi WIllian. I'm sorry to come back to you again, i Tried this :
Connect-CisServer -server "xxx.xxx.xx" -user "*protected email*" -password "xxxxxxx" | Out-Null
$interfaces = (Get-VAMIServiceAPI -NameFilter "interfaces").list()
$NetworkingService = Get-CisService -Name "com.vmware.appliance.networking.interfaces.ipv4"
$Networkingconfig = $NetworkingService.Help.set.config.Create()
#$Networkingconfig.mode = 'static'
$Networkingconfig.mode = 'is_static'
$Networkingconfig.address = "192.168.8.2"
$Networkingconfig.prefix = "24"
$Networkingconfig.default_gateway = "192.168.8.254"
$NetworkingService.set($interfaces.name,$Networkingconfig)
but i have this error :
A server error occurred: 'com.vmware.vapi.std.errors.invalid_argument': Structure com.vmware.appliance.networking.interfaces.ipv4.config has a union with a field not required for this case = prefix (Server error id: 'vapi.data.structure.union.extra'). Check $Error[0].Exception.ServerError for more details.
Au caractère Ligne:19 : 1
+ $NetworkingService.set($interfaces.name,$Networkingconfig)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
i cannot find how to set the configuration into vCenter appliance.
William Lam says
Just looking at your code, I can see several issues including what looks to be confusion between the DNS and Interface configurations ...
Hint: Remember, the API documentation is what tells you HOW and WHAT values to use. I'm not sure why you're using "is_static" as thats only applicable for DNS https://developer.vmware.com/apis/vsphere-automation/latest/appliance/data-structures/Networking/Dns/Servers/DNSServerConfig/ and for interface "static" is NOT a valid value for mode https://developer.vmware.com/apis/vsphere-automation/latest/appliance/data-structures/Networking/Interfaces/Ipv4/Config/
Here is a working example and again, this is all laid out in the documentation 🙂
$NetworkingService = Get-CisService -Name "com.vmware.appliance.networking.interfaces.ipv4"
$Networkingconfig = $NetworkingService.Help.set.config.Create()
$Networkingconfig.mode = "STATIC"
$Networkingconfig.address = "192.168.30.244"
$Networkingconfig.default_gateway = "192.168.30.1"
$Networkingconfig.prefix = "24"
$NetworkingService.set("nic0",$Networkingconfig)
Antoine says
Hi William
Thx for your reply and for your help. i'm sorry i didnt understand the documentation and i lack of knowladge but i'm leaning every day. i succeded to change the address Ip.
Thx again 🙂