github.com/vmware/govmomi@v0.51.0/cli/esx/firewall_info.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package esx 6 7 import "context" 8 9 type FirewallInfo struct { 10 Loaded bool `json:"loaded"` 11 Enabled bool `json:"enabled"` 12 DefaultAction string `json:"defaultAction"` 13 } 14 15 // GetFirewallInfo via 'esxcli network firewall get' 16 // The HostFirewallSystem type does not expose this data. 17 // This helper can be useful in particular to determine if the firewall is enabled or disabled. 18 func (x *Executor) GetFirewallInfo(ctx context.Context) (*FirewallInfo, error) { 19 res, err := x.Run(ctx, []string{"network", "firewall", "get"}) 20 if err != nil { 21 return nil, err 22 } 23 24 info := &FirewallInfo{ 25 Loaded: res.Values[0]["Loaded"][0] == "true", 26 Enabled: res.Values[0]["Enabled"][0] == "true", 27 DefaultAction: res.Values[0]["DefaultAction"][0], 28 } 29 30 return info, nil 31 }