本文整理匯總了Golang中github.com/vmware/govmomi/object.HostSystem.Client方法的典型用法代碼示例。如果您正苦於以下問題:Golang HostSystem.Client方法的具體用法?Golang HostSystem.Client怎麽用?Golang HostSystem.Client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/vmware/govmomi/object.HostSystem
的用法示例。
在下文中一共展示了HostSystem.Client方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Remove
func (cmd *remove) Remove(ctx context.Context, host *object.HostSystem) error {
var h mo.HostSystem
err := host.Properties(ctx, host.Reference(), []string{"parent"}, &h)
if err != nil {
return err
}
remove := host.Destroy
if h.Parent.Type == "ComputeResource" {
// Standalone host. From the docs:
// "Invoking remove on a HostSystem of standalone type throws a NotSupported fault.
// A standalone HostSystem can be removeed only by invoking remove on its parent ComputeResource."
remove = object.NewComputeResource(host.Client(), *h.Parent).Destroy
}
task, err := remove(ctx)
if err != nil {
return err
}
logger := cmd.ProgressLogger(fmt.Sprintf("%s removing... ", host.InventoryPath))
defer logger.Wait()
_, err = task.WaitForResult(ctx, logger)
return err
}
示例2: GetFirewallInfo
// GetFirewallInfo via 'esxcli network firewall get'
// The HostFirewallSystem type does not expose this data.
// This helper can be useful in particular to determine if the firewall is enabled or disabled.
func GetFirewallInfo(s *object.HostSystem) (*FirewallInfo, error) {
x, err := NewExecutor(s.Client(), s)
res, err := x.Run([]string{"network", "firewall", "get"})
if err != nil {
return nil, err
}
info := &FirewallInfo{
Loaded: res.Values[0]["Loaded"][0] == "true",
Enabled: res.Values[0]["Enabled"][0] == "true",
DefaultAction: res.Values[0]["DefaultAction"][0],
}
return info, nil
}