github.com/vmware/govmomi@v0.43.0/govc/host/esxcli/firewall_info.go (about) 1 /* 2 Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package esxcli 18 19 import "github.com/vmware/govmomi/object" 20 21 type FirewallInfo struct { 22 Loaded bool `json:"loaded"` 23 Enabled bool `json:"enabled"` 24 DefaultAction string `json:"defaultAction"` 25 } 26 27 // GetFirewallInfo via 'esxcli network firewall get' 28 // The HostFirewallSystem type does not expose this data. 29 // This helper can be useful in particular to determine if the firewall is enabled or disabled. 30 func GetFirewallInfo(s *object.HostSystem) (*FirewallInfo, error) { 31 x, err := NewExecutor(s.Client(), s) 32 if err != nil { 33 return nil, err 34 } 35 36 res, err := x.Run([]string{"network", "firewall", "get"}) 37 if err != nil { 38 return nil, err 39 } 40 41 info := &FirewallInfo{ 42 Loaded: res.Values[0]["Loaded"][0] == "true", 43 Enabled: res.Values[0]["Enabled"][0] == "true", 44 DefaultAction: res.Values[0]["DefaultAction"][0], 45 } 46 47 return info, nil 48 }