From f814a9cab3db93e92b264697d7b58dff91e551c5 Mon Sep 17 00:00:00 2001 From: akutz Date: Mon, 17 May 2021 09:37:31 -0500 Subject: [PATCH] ESX Agent Manager (EAM) Client and Simulator This patch introduces the bindings, client, and simulator for the ESX Agent Manager (EAM). EAM is a long-lived service on vCenter that acts as an intermediary for provisioning agent virtual machines and VIB modules on behalf of the user. The following packages include: * ./eam - the EAM client * ./eam/types - the EAM bindings - types * ./eam/methods - the EAM bindings - methods * ./eam/object - the EAM helper objects, ie. more than just MoRefs * ./eam/simulator - the EAM simulator For more information on how to use EAM, please see the public, EAM SDK at http://bit.ly/eam-sdk. This patch also updates the vC Simulator code so when containers are deployed as VMs, goroutines are created to monitor the containers and automatically update the runtime properties of the VM to match the underlying state of the container, such as power state, IP addr, etc. --- eam/README.md | 11 + eam/client.go | 42 + eam/eam.go | 27 + eam/internal/internal.go | 32 + eam/methods/methods.go | 444 ++++++++ eam/mo/agency.go | 33 + eam/mo/agent.go | 31 + eam/mo/eam_object.go | 36 + eam/mo/esx_agent_manager.go | 29 + eam/object/agency.go | 166 +++ eam/object/agency_test.go | 452 ++++++++ eam/object/agent.go | 70 ++ eam/object/eam_object.go | 98 ++ eam/object/esx_agent_manager.go | 84 ++ eam/object/object_test.go | 76 ++ eam/simulator/README.md | 23 + eam/simulator/agency.go | 245 +++++ eam/simulator/agent.go | 266 +++++ eam/simulator/eam_object.go | 145 +++ eam/simulator/esx_agent_manager.go | 81 ++ eam/simulator/issue.go | 70 ++ eam/simulator/simulator.go | 44 + eam/simulator/simulator_test.go | 342 ++++++ eam/simulator/utils.go | 209 ++++ eam/types/enum.go | 93 ++ eam/types/if.go | 287 +++++ eam/types/types.go | 1605 ++++++++++++++++++++++++++++ gen/.gitignore | 1 + gen/gen.sh | 11 + gen/vim_wsdl.rb | 2 +- simulator/container.go | 71 +- simulator/internal/object_lock.go | 2 +- simulator/registry.go | 16 + vcsim/main.go | 1 + 34 files changed, 5137 insertions(+), 8 deletions(-) create mode 100644 eam/README.md create mode 100644 eam/client.go create mode 100644 eam/eam.go create mode 100644 eam/internal/internal.go create mode 100644 eam/methods/methods.go create mode 100644 eam/mo/agency.go create mode 100644 eam/mo/agent.go create mode 100644 eam/mo/eam_object.go create mode 100644 eam/mo/esx_agent_manager.go create mode 100644 eam/object/agency.go create mode 100644 eam/object/agency_test.go create mode 100644 eam/object/agent.go create mode 100644 eam/object/eam_object.go create mode 100644 eam/object/esx_agent_manager.go create mode 100644 eam/object/object_test.go create mode 100644 eam/simulator/README.md create mode 100644 eam/simulator/agency.go create mode 100644 eam/simulator/agent.go create mode 100644 eam/simulator/eam_object.go create mode 100644 eam/simulator/esx_agent_manager.go create mode 100644 eam/simulator/issue.go create mode 100644 eam/simulator/simulator.go create mode 100644 eam/simulator/simulator_test.go create mode 100644 eam/simulator/utils.go create mode 100644 eam/types/enum.go create mode 100644 eam/types/if.go create mode 100644 eam/types/types.go create mode 100644 gen/.gitignore diff --git a/eam/README.md b/eam/README.md new file mode 100644 index 000000000..6d2a0eaac --- /dev/null +++ b/eam/README.md @@ -0,0 +1,11 @@ +# ESX Agent Manager (EAM) + +ESX Agent Manager ([EAM](https://vdc-download.vmware.com/vmwb-repository/dcr-public/3d076a12-29a2-4d17-9269-cb8150b5a37f/8b5969e2-1a66-4425-af17-feff6d6f705d/SDK/eam/doc/index.html)) is a long-lived service on vCenter that acts as an intermediary for provisioning agent virtual machines and VIB modules on behalf of the user. + +## HowTo + +Please refer to [`simulator/simulator_test.go`](./simulator/simulator_test.go) for an example on how to use this package. + +## Simulator + +The [`simulator`](./simulator/) package provides an EAM simulator that can even simulate the lifecycle of agent VMs using containers. diff --git a/eam/client.go b/eam/client.go new file mode 100644 index 000000000..9cb4c1cad --- /dev/null +++ b/eam/client.go @@ -0,0 +1,42 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package eam + +import ( + "github.com/vmware/govmomi/vim25" + "github.com/vmware/govmomi/vim25/soap" +) + +const ( + // Namespace is the namespace for EAM SOAP operations. + Namespace = "eam" + + // Path is the path to the EAM service. + Path = "/eam/sdk" +) + +// Client is a client for the ESX Agent Manager API. +type Client struct { + *soap.Client +} + +// NewClient returns a new EAM client. +func NewClient(c *vim25.Client) *Client { + return &Client{ + Client: c.Client.NewServiceClient(Path, Namespace), + } +} diff --git a/eam/eam.go b/eam/eam.go new file mode 100644 index 000000000..c832aaca8 --- /dev/null +++ b/eam/eam.go @@ -0,0 +1,27 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package eam + +import ( + "github.com/vmware/govmomi/eam/internal" + "github.com/vmware/govmomi/vim25/types" +) + +var EsxAgentManager = types.ManagedObjectReference{ + Type: internal.EsxAgentManager, + Value: internal.EsxAgentManager, +} diff --git a/eam/internal/internal.go b/eam/internal/internal.go new file mode 100644 index 000000000..d488a80ff --- /dev/null +++ b/eam/internal/internal.go @@ -0,0 +1,32 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package internal + +const ( + // EamObject is the managed object type for the EamObject base class. + EamObject = "EamObject" + + // EsxAgentManager is both the managed object type and ID for the + // EsxAgentManager class. + EsxAgentManager = "EsxAgentManager" + + // Agency is the managed object type for the Agency class. + Agency = "Agency" + + // Agent is the managed object type for the Agency class. + Agent = "Agent" +) diff --git a/eam/methods/methods.go b/eam/methods/methods.go new file mode 100644 index 000000000..a6a064bc7 --- /dev/null +++ b/eam/methods/methods.go @@ -0,0 +1,444 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package methods + +import ( + "context" + + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/vim25/soap" +) + +type AddIssueBody struct { + Req *types.AddIssue `xml:"urn:eam AddIssue,omitempty"` + Res *types.AddIssueResponse `xml:"urn:eam AddIssueResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *AddIssueBody) Fault() *soap.Fault { return b.Fault_ } + +func AddIssue(ctx context.Context, r soap.RoundTripper, req *types.AddIssue) (*types.AddIssueResponse, error) { + var reqBody, resBody AddIssueBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type AgencyQueryRuntimeBody struct { + Req *types.AgencyQueryRuntime `xml:"urn:eam AgencyQueryRuntime,omitempty"` + Res *types.AgencyQueryRuntimeResponse `xml:"urn:eam AgencyQueryRuntimeResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *AgencyQueryRuntimeBody) Fault() *soap.Fault { return b.Fault_ } + +func AgencyQueryRuntime(ctx context.Context, r soap.RoundTripper, req *types.AgencyQueryRuntime) (*types.AgencyQueryRuntimeResponse, error) { + var reqBody, resBody AgencyQueryRuntimeBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type AgentQueryConfigBody struct { + Req *types.AgentQueryConfig `xml:"urn:eam AgentQueryConfig,omitempty"` + Res *types.AgentQueryConfigResponse `xml:"urn:eam AgentQueryConfigResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *AgentQueryConfigBody) Fault() *soap.Fault { return b.Fault_ } + +func AgentQueryConfig(ctx context.Context, r soap.RoundTripper, req *types.AgentQueryConfig) (*types.AgentQueryConfigResponse, error) { + var reqBody, resBody AgentQueryConfigBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type AgentQueryRuntimeBody struct { + Req *types.AgentQueryRuntime `xml:"urn:eam AgentQueryRuntime,omitempty"` + Res *types.AgentQueryRuntimeResponse `xml:"urn:eam AgentQueryRuntimeResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *AgentQueryRuntimeBody) Fault() *soap.Fault { return b.Fault_ } + +func AgentQueryRuntime(ctx context.Context, r soap.RoundTripper, req *types.AgentQueryRuntime) (*types.AgentQueryRuntimeResponse, error) { + var reqBody, resBody AgentQueryRuntimeBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type CreateAgencyBody struct { + Req *types.CreateAgency `xml:"urn:eam CreateAgency,omitempty"` + Res *types.CreateAgencyResponse `xml:"urn:eam CreateAgencyResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *CreateAgencyBody) Fault() *soap.Fault { return b.Fault_ } + +func CreateAgency(ctx context.Context, r soap.RoundTripper, req *types.CreateAgency) (*types.CreateAgencyResponse, error) { + var reqBody, resBody CreateAgencyBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type DestroyAgencyBody struct { + Req *types.DestroyAgency `xml:"urn:eam DestroyAgency,omitempty"` + Res *types.DestroyAgencyResponse `xml:"urn:eam DestroyAgencyResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *DestroyAgencyBody) Fault() *soap.Fault { return b.Fault_ } + +func DestroyAgency(ctx context.Context, r soap.RoundTripper, req *types.DestroyAgency) (*types.DestroyAgencyResponse, error) { + var reqBody, resBody DestroyAgencyBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type DisableBody struct { + Req *types.Disable `xml:"urn:eam Disable,omitempty"` + Res *types.DisableResponse `xml:"urn:eam DisableResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *DisableBody) Fault() *soap.Fault { return b.Fault_ } + +func Disable(ctx context.Context, r soap.RoundTripper, req *types.Disable) (*types.DisableResponse, error) { + var reqBody, resBody DisableBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type EnableBody struct { + Req *types.Enable `xml:"urn:eam Enable,omitempty"` + Res *types.EnableResponse `xml:"urn:eam EnableResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *EnableBody) Fault() *soap.Fault { return b.Fault_ } + +func Enable(ctx context.Context, r soap.RoundTripper, req *types.Enable) (*types.EnableResponse, error) { + var reqBody, resBody EnableBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type MarkAsAvailableBody struct { + Req *types.MarkAsAvailable `xml:"urn:eam MarkAsAvailable,omitempty"` + Res *types.MarkAsAvailableResponse `xml:"urn:eam MarkAsAvailableResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *MarkAsAvailableBody) Fault() *soap.Fault { return b.Fault_ } + +func MarkAsAvailable(ctx context.Context, r soap.RoundTripper, req *types.MarkAsAvailable) (*types.MarkAsAvailableResponse, error) { + var reqBody, resBody MarkAsAvailableBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type QueryAgencyBody struct { + Req *types.QueryAgency `xml:"urn:eam QueryAgency,omitempty"` + Res *types.QueryAgencyResponse `xml:"urn:eam QueryAgencyResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *QueryAgencyBody) Fault() *soap.Fault { return b.Fault_ } + +func QueryAgency(ctx context.Context, r soap.RoundTripper, req *types.QueryAgency) (*types.QueryAgencyResponse, error) { + var reqBody, resBody QueryAgencyBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type QueryAgentBody struct { + Req *types.QueryAgent `xml:"urn:eam QueryAgent,omitempty"` + Res *types.QueryAgentResponse `xml:"urn:eam QueryAgentResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *QueryAgentBody) Fault() *soap.Fault { return b.Fault_ } + +func QueryAgent(ctx context.Context, r soap.RoundTripper, req *types.QueryAgent) (*types.QueryAgentResponse, error) { + var reqBody, resBody QueryAgentBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type QueryConfigBody struct { + Req *types.QueryConfig `xml:"urn:eam QueryConfig,omitempty"` + Res *types.QueryConfigResponse `xml:"urn:eam QueryConfigResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *QueryConfigBody) Fault() *soap.Fault { return b.Fault_ } + +func QueryConfig(ctx context.Context, r soap.RoundTripper, req *types.QueryConfig) (*types.QueryConfigResponse, error) { + var reqBody, resBody QueryConfigBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type QueryIssueBody struct { + Req *types.QueryIssue `xml:"urn:eam QueryIssue,omitempty"` + Res *types.QueryIssueResponse `xml:"urn:eam QueryIssueResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *QueryIssueBody) Fault() *soap.Fault { return b.Fault_ } + +func QueryIssue(ctx context.Context, r soap.RoundTripper, req *types.QueryIssue) (*types.QueryIssueResponse, error) { + var reqBody, resBody QueryIssueBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type QuerySolutionIdBody struct { + Req *types.QuerySolutionId `xml:"urn:eam QuerySolutionId,omitempty"` + Res *types.QuerySolutionIdResponse `xml:"urn:eam QuerySolutionIdResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *QuerySolutionIdBody) Fault() *soap.Fault { return b.Fault_ } + +func QuerySolutionId(ctx context.Context, r soap.RoundTripper, req *types.QuerySolutionId) (*types.QuerySolutionIdResponse, error) { + var reqBody, resBody QuerySolutionIdBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type RegisterAgentVmBody struct { + Req *types.RegisterAgentVm `xml:"urn:eam RegisterAgentVm,omitempty"` + Res *types.RegisterAgentVmResponse `xml:"urn:eam RegisterAgentVmResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *RegisterAgentVmBody) Fault() *soap.Fault { return b.Fault_ } + +func RegisterAgentVm(ctx context.Context, r soap.RoundTripper, req *types.RegisterAgentVm) (*types.RegisterAgentVmResponse, error) { + var reqBody, resBody RegisterAgentVmBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type ResolveBody struct { + Req *types.Resolve `xml:"urn:eam Resolve,omitempty"` + Res *types.ResolveResponse `xml:"urn:eam ResolveResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *ResolveBody) Fault() *soap.Fault { return b.Fault_ } + +func Resolve(ctx context.Context, r soap.RoundTripper, req *types.Resolve) (*types.ResolveResponse, error) { + var reqBody, resBody ResolveBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type ResolveAllBody struct { + Req *types.ResolveAll `xml:"urn:eam ResolveAll,omitempty"` + Res *types.ResolveAllResponse `xml:"urn:eam ResolveAllResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *ResolveAllBody) Fault() *soap.Fault { return b.Fault_ } + +func ResolveAll(ctx context.Context, r soap.RoundTripper, req *types.ResolveAll) (*types.ResolveAllResponse, error) { + var reqBody, resBody ResolveAllBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type ScanForUnknownAgentVmBody struct { + Req *types.ScanForUnknownAgentVm `xml:"urn:eam ScanForUnknownAgentVm,omitempty"` + Res *types.ScanForUnknownAgentVmResponse `xml:"urn:eam ScanForUnknownAgentVmResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *ScanForUnknownAgentVmBody) Fault() *soap.Fault { return b.Fault_ } + +func ScanForUnknownAgentVm(ctx context.Context, r soap.RoundTripper, req *types.ScanForUnknownAgentVm) (*types.ScanForUnknownAgentVmResponse, error) { + var reqBody, resBody ScanForUnknownAgentVmBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type UninstallBody struct { + Req *types.Uninstall `xml:"urn:eam Uninstall,omitempty"` + Res *types.UninstallResponse `xml:"urn:eam UninstallResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *UninstallBody) Fault() *soap.Fault { return b.Fault_ } + +func Uninstall(ctx context.Context, r soap.RoundTripper, req *types.Uninstall) (*types.UninstallResponse, error) { + var reqBody, resBody UninstallBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type UnregisterAgentVmBody struct { + Req *types.UnregisterAgentVm `xml:"urn:eam UnregisterAgentVm,omitempty"` + Res *types.UnregisterAgentVmResponse `xml:"urn:eam UnregisterAgentVmResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *UnregisterAgentVmBody) Fault() *soap.Fault { return b.Fault_ } + +func UnregisterAgentVm(ctx context.Context, r soap.RoundTripper, req *types.UnregisterAgentVm) (*types.UnregisterAgentVmResponse, error) { + var reqBody, resBody UnregisterAgentVmBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} + +type UpdateBody struct { + Req *types.Update `xml:"urn:eam Update,omitempty"` + Res *types.UpdateResponse `xml:"urn:eam UpdateResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *UpdateBody) Fault() *soap.Fault { return b.Fault_ } + +func Update(ctx context.Context, r soap.RoundTripper, req *types.Update) (*types.UpdateResponse, error) { + var reqBody, resBody UpdateBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} diff --git a/eam/mo/agency.go b/eam/mo/agency.go new file mode 100644 index 000000000..e00e939b0 --- /dev/null +++ b/eam/mo/agency.go @@ -0,0 +1,33 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mo + +import ( + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +// Agency handles the deployment of a single type of agent virtual +// machine and any associated VIB bundle, on a set of compute resources. +type Agency struct { + EamObject `yaml:",inline"` + + Agent []vim.ManagedObjectReference `json:"agent,omitempty"` + Config types.AgencyConfigInfo `json:"config"` + Runtime types.EamObjectRuntimeInfo `json:"runtime"` + SolutionId string `json:"solutionId,omitempty"` +} diff --git a/eam/mo/agent.go b/eam/mo/agent.go new file mode 100644 index 000000000..e20983cd6 --- /dev/null +++ b/eam/mo/agent.go @@ -0,0 +1,31 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mo + +import ( + "github.com/vmware/govmomi/eam/types" +) + +// Agenct is the vSphere ESX Agent Manager managed object responsible +// fordeploying an Agency on a single host. The Agent maintains the state +// of the current deployment in its runtime information +type Agent struct { + EamObject `yaml:",inline"` + + Config types.AgentConfigInfo `json:"config,omitempty"` + Runtime types.AgentRuntimeInfo `json:"runtime,omitempty"` +} diff --git a/eam/mo/eam_object.go b/eam/mo/eam_object.go new file mode 100644 index 000000000..fc3c70f26 --- /dev/null +++ b/eam/mo/eam_object.go @@ -0,0 +1,36 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mo + +import ( + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +// EamObject contains the fields common to all EAM objects. +type EamObject struct { + Self vim.ManagedObjectReference `json:"self"` + Issue []types.BaseIssue `json:"issue,omitempty"` +} + +func (m EamObject) String() string { + return m.Self.String() +} + +func (m EamObject) Reference() vim.ManagedObjectReference { + return m.Self +} diff --git a/eam/mo/esx_agent_manager.go b/eam/mo/esx_agent_manager.go new file mode 100644 index 000000000..148c88f4d --- /dev/null +++ b/eam/mo/esx_agent_manager.go @@ -0,0 +1,29 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mo + +import ( + vim "github.com/vmware/govmomi/vim25/types" +) + +// EsxAgentManager is the main entry point for a solution to create +// agencies in the vSphere ESX Agent Manager server. +type EsxAgentManager struct { + EamObject `yaml:",inline"` + + Agency []vim.ManagedObjectReference `json:"agency,omitempty"` +} diff --git a/eam/object/agency.go b/eam/object/agency.go new file mode 100644 index 000000000..64246974f --- /dev/null +++ b/eam/object/agency.go @@ -0,0 +1,166 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "context" + + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +type Agency struct { + EamObject +} + +// NewAgency returns a wrapper for an Agency managed object. +func NewAgency(c *eam.Client, ref vim.ManagedObjectReference) Agency { + return Agency{ + EamObject: EamObject{ + c: c, + r: ref, + }, + } +} + +func (m Agency) Agents(ctx context.Context) ([]Agent, error) { + resp, err := methods.QueryAgent(ctx, m.c, &types.QueryAgent{ + This: m.r, + }) + if err != nil { + return nil, err + } + objs := make([]Agent, len(resp.Returnval)) + for i := range resp.Returnval { + objs[i].c = m.c + objs[i].r = resp.Returnval[i] + } + return objs, nil +} + +func (m Agency) Config(ctx context.Context) (*types.AgencyConfigInfo, error) { + resp, err := methods.QueryConfig(ctx, m.c, &types.QueryConfig{ + This: m.r, + }) + if err != nil { + return nil, err + } + return &resp.Returnval, nil +} + +func (m Agency) Runtime(ctx context.Context) (*types.EamObjectRuntimeInfo, error) { + resp, err := methods.AgencyQueryRuntime(ctx, m.c, &types.AgencyQueryRuntime{ + This: m.r, + }) + if err != nil { + return nil, err + } + return resp.Returnval.GetEamObjectRuntimeInfo(), nil +} + +func (m Agency) SolutionId(ctx context.Context) (string, error) { + resp, err := methods.QuerySolutionId(ctx, m.c, &types.QuerySolutionId{ + This: m.r, + }) + if err != nil { + return "", err + } + return resp.Returnval, nil +} + +func (m Agency) Destroy(ctx context.Context) error { + _, err := methods.DestroyAgency(ctx, m.c, &types.DestroyAgency{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} + +func (m Agency) Disable(ctx context.Context) error { + _, err := methods.Disable(ctx, m.c, &types.Disable{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} + +func (m Agency) Enable(ctx context.Context) error { + _, err := methods.Enable(ctx, m.c, &types.Enable{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} + +func (m Agency) RegisterAgentVm( + ctx context.Context, + agentVmMoRef vim.ManagedObjectReference) (*Agent, error) { + + resp, err := methods.RegisterAgentVm(ctx, m.c, &types.RegisterAgentVm{ + This: m.r, + AgentVm: agentVmMoRef, + }) + if err != nil { + return nil, err + } + return NewAgent(m.c, resp.Returnval), nil +} + +func (m Agency) Uninstall(ctx context.Context) error { + _, err := methods.Uninstall(ctx, m.c, &types.Uninstall{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} + +func (m Agency) UnregisterAgentVm( + ctx context.Context, + agentVmMoRef vim.ManagedObjectReference) error { + + _, err := methods.UnregisterAgentVm(ctx, m.c, &types.UnregisterAgentVm{ + This: m.r, + AgentVm: agentVmMoRef, + }) + if err != nil { + return err + } + return nil +} + +func (m Agency) Update( + ctx context.Context, + config types.AgencyConfigInfo) error { + + _, err := methods.Update(ctx, m.c, &types.Update{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} diff --git a/eam/object/agency_test.go b/eam/object/agency_test.go new file mode 100644 index 000000000..0970b3cb6 --- /dev/null +++ b/eam/object/agency_test.go @@ -0,0 +1,452 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object_test + +import ( + "errors" + "fmt" + "testing" + "time" + + "github.com/vmware/govmomi/eam/object" + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/find" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" +) + +func TestAgency(t *testing.T) { + + // Create a finder that sets the default datacenter. + finder := find.NewFinder(client.vim, true) + + // Get the datacenter to use when creating the agency. + datacenter, err := finder.DefaultDatacenter(client.ctx) + if err != nil { + t.Fatal(err) + } + finder.SetDatacenter(datacenter) + + // Get the "vm" folder. + folder, err := finder.DefaultFolder(client.ctx) + if err != nil { + t.Fatal(err) + } + + // Get the cluster to use when creating the agency. + computeResource, err := finder.ClusterComputeResourceOrDefault(client.ctx, "") + if err != nil { + t.Fatal(err) + } + + // Get the resource pool to use when creating the agency. + pool, err := computeResource.ResourcePool(client.ctx) + if err != nil { + t.Fatal(err) + } + + // Get the datastore to use when creating the agency. + datastore, err := finder.DatastoreOrDefault(client.ctx, "") + if err != nil { + t.Fatal(err) + } + + // Get the network to use when creating the agency. + network, err := finder.NetworkOrDefault(client.ctx, "DVS0") + if err != nil { + t.Fatal(err) + } + + const ( + initialGoalState = string(types.EamObjectRuntimeInfoGoalStateEnabled) + ) + var ( + agency object.Agency + agencyConfig = types.AgencyConfigInfo{ + AgencyName: t.Name(), + AgentName: t.Name(), + AgentConfig: []types.AgentConfigInfo{ + { + HostVersion: "1", + }, + }, + AgentVmDatastore: []vim.ManagedObjectReference{ + datastore.Reference(), + }, + Folders: []types.AgencyVMFolder{ + { + FolderId: folder.Reference(), + DatacenterId: datacenter.Reference(), + }, + }, + ResourcePools: []types.AgencyVMResourcePool{ + { + ResourcePoolId: pool.Reference(), + ComputeResourceId: computeResource.Reference(), + }, + }, + AgentVmNetwork: []vim.ManagedObjectReference{ + network.Reference(), + }, + } + ) + + agencyExists := func(agency object.Agency) (bool, error) { + agencies, err := client.eam.Agencies(client.ctx) + if err != nil { + return false, err + } + for _, a := range agencies { + if a.Reference() == agency.Reference() { + return true, nil + } + } + return false, nil + } + + testCreate := func(t *testing.T) { + var err error + if agency, err = client.eam.CreateAgency( + client.ctx, agencyConfig, initialGoalState); err != nil { + t.Fatal(err) + } + if ok, err := agencyExists(agency); !ok { + if err != nil { + t.Fatal(err) + } + t.Fatal("agency not returned by Agencies") + } + } + + testConfig := func(t *testing.T) { + t.Parallel() + + config, err := agency.Config(client.ctx) + if err != nil { + t.Fatal(err) + } + if config.AgencyName != agencyConfig.AgencyName { + t.Fatalf( + "unexpected agency name: exp=%v, act=%v", + agencyConfig.AgencyName, + config.AgencyName) + } + if config.AgentName != agencyConfig.AgentName { + t.Fatalf( + "unexpected agency agent name: exp=%v, act=%v", + agencyConfig.AgentName, + config.AgentName) + } + } + + // This test waits up to 10 seconds for the agency.runtime.issue + // list to be non-empty. Because this test is run in parallel with + // the TestAgency.Created.Runtime.Issues.Add test, there should be an + // issue returned by the tested call before 10 seconds has elapsed. + testRuntimeIssues := func(t *testing.T) { + t.Parallel() + const ( + waitTotalSecs = 10 + waitIntervalSecs = time.Duration(1) * time.Second + ) + hasIssues := false + for i := 0; i < waitTotalSecs; i++ { + runtime, err := agency.Runtime(client.ctx) + if err != nil { + t.Fatal(err) + } + if len(runtime.Issue) > 0 { + hasIssues = true + break + } + time.Sleep(waitIntervalSecs) + } + if !hasIssues { + t.Fatalf( + "agency.runtime had no issues after %d seconds", + waitTotalSecs) + } + } + + testRuntimeGoalState := func(t *testing.T) { + validateExpectedGoalState := func(expGoalState interface{}) error { + runtime, err := agency.Runtime(client.ctx) + if err != nil { + return err + } + if runtime.GoalState != fmt.Sprintf("%s", expGoalState) { + return fmt.Errorf( + "unexpected agency goal state: exp=%v, act=%v", + expGoalState, + runtime.GoalState) + } + return nil + } + + t.Run("Initial", func(t *testing.T) { + if err := validateExpectedGoalState( + initialGoalState); err != nil { + t.Fatal(err) + } + }) + t.Run("Disabled", func(t *testing.T) { + if err := agency.Disable(client.ctx); err != nil { + t.Fatal(err) + } + if err := validateExpectedGoalState( + types.EamObjectRuntimeInfoGoalStateDisabled); err != nil { + t.Fatal(err) + } + }) + t.Run("Uninstalled", func(t *testing.T) { + if err := agency.Uninstall(client.ctx); err != nil { + t.Fatal(err) + } + if err := validateExpectedGoalState( + types.EamObjectRuntimeInfoGoalStateUninstalled); err != nil { + t.Fatal(err) + } + }) + t.Run("Enabled", func(t *testing.T) { + if err := agency.Enable(client.ctx); err != nil { + t.Fatal(err) + } + if err := validateExpectedGoalState( + types.EamObjectRuntimeInfoGoalStateEnabled); err != nil { + t.Fatal(err) + } + }) + } + + testRuntime := func(t *testing.T) { + t.Parallel() + + runtime, err := agency.Runtime(client.ctx) + if err != nil { + t.Fatal(err) + } + if runtime.GoalState != initialGoalState { + t.Fatalf( + "unexpected agency goal state: exp=%v, act=%v", + initialGoalState, + runtime.GoalState) + } + + t.Run("Issues", testRuntimeIssues) + t.Run("GoalState", testRuntimeGoalState) + } + + testIssues := func(t *testing.T) { + t.Parallel() + + var issueKey int32 + + t.Run("Add", func(t *testing.T) { + baseIssue, err := agency.AddIssue(client.ctx, &types.OrphanedAgency{ + AgencyIssue: types.AgencyIssue{ + Agency: agency.Reference(), + AgencyName: agencyConfig.AgencyName, + }, + }) + if err != nil { + t.Fatal(err) + } + baseAgencyIssue, ok := baseIssue.(types.BaseAgencyIssue) + if !ok { + t.Fatalf( + "unexpected issue type: exp=%v, act=%T", + "types.BaseAgencyIssue", + baseIssue) + } + issue := baseAgencyIssue.GetAgencyIssue() + if issue == nil { + t.Fatal("returned issue is nil") + } + if issue.Key == 0 { + t.Fatal("issue.Key == 0") + } + if issue.Time.IsZero() { + t.Fatal("issue.Time is not set") + } + if issue.Agency != agency.Reference() { + t.Fatalf( + "unexpected agency moRef: exp=%v, act=%v", + agency.Reference(), + issue.Agency) + } + if issue.AgencyName != agencyConfig.AgencyName { + t.Fatalf( + "unexpected agency name: exp=%v, act=%v", + agencyConfig.AgencyName, + issue.AgencyName) + } + issueKey = issue.Key + t.Logf("added new issue to agency: agency=%v, issueKey=%d", + agency.Reference(), issueKey) + }) + + t.Run("Query", func(t *testing.T) { + validateIssueIsInList := func( + issues []types.BaseIssue, + inErr error) error { + + if inErr != nil { + return inErr + } + if len(issues) == 0 { + return errors.New("no issues returned") + } + foundIssueKey := false + for _, baseIssue := range issues { + issue := baseIssue.GetIssue() + if issue == nil { + return errors.New("returned issue is nil") + } + if issue.Key == issueKey { + foundIssueKey = true + break + } + } + if !foundIssueKey { + return fmt.Errorf( + "did not find expected issue: key=%d", issueKey) + } + return nil + } + + t.Run("All", func(t *testing.T) { + t.Parallel() + if err := validateIssueIsInList( + agency.Issues(client.ctx)); err != nil { + t.Fatal(err) + } + }) + t.Run("ByKey", func(t *testing.T) { + t.Parallel() + if err := validateIssueIsInList( + agency.Issues(client.ctx, issueKey)); err != nil { + t.Fatal(err) + } + }) + }) + } + + testAgents := func(t *testing.T) { + t.Parallel() + + var agent *object.Agent + + t.Run("Query", func(t *testing.T) { + agents, err := agency.Agents(client.ctx) + if err != nil { + t.Fatal(err) + } + if len(agents) != 1 { + t.Fatal("expected one agent") + } + agent = &agents[0] + }) + + t.Run("Queried", func(t *testing.T) { + t.Run("Config", func(t *testing.T) { + t.Parallel() + config, err := agent.Config(client.ctx) + if err != nil { + t.Fatal(err) + } + if config.HostVersion != "1" { + t.Fatalf( + "unexpected agent config host version: exp=%v, act=%v", + "1", + config.HostVersion) + } + }) + t.Run("Runtime", func(t *testing.T) { + t.Parallel() + var runtime *types.AgentRuntimeInfo + + t.Run("Query", func(t *testing.T) { + var err error + if runtime, err = agent.Runtime(client.ctx); err != nil { + t.Fatal(err) + } else if runtime.Agency == nil { + t.Fatal("agent runtime.Agency is nil") + } + }) + t.Run("Properties", func(t *testing.T) { + t.Run("Agency", func(t *testing.T) { + t.Parallel() + if *runtime.Agency != agency.Reference() { + t.Fatalf( + "unexpected agent runtime.Agency: exp=%v, act=%v", + agency.Reference(), + *runtime.Agency) + } + }) + t.Run("VirtualMachine", func(t *testing.T) { + t.Parallel() + if runtime.Vm == nil { + t.Fatal("runtime.Vm is nil") + } + }) + }) + }) + }) + } + + testDestroy := func(t *testing.T) { + t.Run("HappyPath", func(t *testing.T) { + if err := agency.Destroy(client.ctx); err != nil { + t.Fatal(err) + } + }) + + // Attempt to destroy the agency a second time, asserting that a + // ManagedObjectNotFound error will occur. + t.Run("NotFound", func(t *testing.T) { + if err := agency.Destroy(client.ctx); err == nil { + t.Fatal("error did not occur") + } else if fault := soap.ToSoapFault(err); fault == nil { + t.Fatalf("soap fault did not occur: %+v", err) + } else if fault, ok := fault.VimFault().(vim.ManagedObjectNotFound); !ok { + t.Fatalf("expected soap fault did not occur: %+v", fault) + } else if fault.Obj != agency.Reference() { + t.Fatalf("unexpected error details: exp=%v, act=%v", + agency.Reference(), fault.Obj) + } + }) + + t.Run("Verify", func(t *testing.T) { + if ok, err := agencyExists(agency); err != nil { + t.Fatal(err) + } else if ok { + t.Fatal("agency still returned after being destroyed") + } + }) + } + + t.Run("Create", testCreate) + + t.Run("Created", func(t *testing.T) { + t.Run("Config", testConfig) + t.Run("Issues", testIssues) + t.Run("Runtime", testRuntime) + t.Run("Agents", testAgents) + }) + + t.Run("Destroy", testDestroy) +} diff --git a/eam/object/agent.go b/eam/object/agent.go new file mode 100644 index 000000000..72bef4d96 --- /dev/null +++ b/eam/object/agent.go @@ -0,0 +1,70 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "context" + + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +type Agent struct { + EamObject +} + +// NewAgent returns a wrapper for an Agent managed object. +func NewAgent(c *eam.Client, ref vim.ManagedObjectReference) *Agent { + return &Agent{ + EamObject: EamObject{ + c: c, + r: ref, + }, + } +} + +func (m Agent) Config(ctx context.Context) (*types.AgentConfigInfo, error) { + resp, err := methods.AgentQueryConfig(ctx, m.c, &types.AgentQueryConfig{ + This: m.r, + }) + if err != nil { + return nil, err + } + return &resp.Returnval, nil +} + +func (m Agent) Runtime(ctx context.Context) (*types.AgentRuntimeInfo, error) { + resp, err := methods.AgentQueryRuntime(ctx, m.c, &types.AgentQueryRuntime{ + This: m.r, + }) + if err != nil { + return nil, err + } + return &resp.Returnval, nil +} + +func (m Agent) MarkAsAvailable(ctx context.Context) error { + _, err := methods.MarkAsAvailable(ctx, m.c, &types.MarkAsAvailable{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} diff --git a/eam/object/eam_object.go b/eam/object/eam_object.go new file mode 100644 index 000000000..2c045f7ce --- /dev/null +++ b/eam/object/eam_object.go @@ -0,0 +1,98 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "context" + "fmt" + + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +// EamObject contains the fields and functions common to all objects. +type EamObject struct { + c *eam.Client + r vim.ManagedObjectReference +} + +func (m EamObject) String() string { + return fmt.Sprintf("%v", m.Reference()) +} + +func (m EamObject) Reference() vim.ManagedObjectReference { + return m.r +} + +func (m EamObject) Client() *eam.Client { + return m.c +} + +func (m EamObject) AddIssue( + ctx context.Context, + issue types.BaseIssue) (types.BaseIssue, error) { + + resp, err := methods.AddIssue(ctx, m.c, &types.AddIssue{ + This: m.r, + Issue: issue, + }) + if err != nil { + return nil, err + } + return resp.Returnval, nil +} + +func (m EamObject) Issues( + ctx context.Context, + issueKeys ...int32) ([]types.BaseIssue, error) { + + resp, err := methods.QueryIssue(ctx, m.c, &types.QueryIssue{ + This: m.r, + IssueKey: issueKeys, + }) + if err != nil { + return nil, err + } + return resp.Returnval, nil +} + +func (m EamObject) Resolve( + ctx context.Context, + issueKeys []int32) ([]int32, error) { + + resp, err := methods.Resolve(ctx, m.c, &types.Resolve{ + This: m.r, + IssueKey: issueKeys, + }) + if err != nil { + return nil, err + } + return resp.Returnval, nil +} + +func (m EamObject) ResolveAll(ctx context.Context) error { + + _, err := methods.ResolveAll(ctx, m.c, &types.ResolveAll{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} diff --git a/eam/object/esx_agent_manager.go b/eam/object/esx_agent_manager.go new file mode 100644 index 000000000..d400b1949 --- /dev/null +++ b/eam/object/esx_agent_manager.go @@ -0,0 +1,84 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object + +import ( + "context" + + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/types" + vim "github.com/vmware/govmomi/vim25/types" +) + +type EsxAgentManager struct { + EamObject +} + +// NewEsxAgentManager returns a wrapper for an EsxAgentManager managed object. +func NewEsxAgentManager(c *eam.Client, ref vim.ManagedObjectReference) EsxAgentManager { + return EsxAgentManager{ + EamObject: EamObject{ + c: c, + r: ref, + }, + } +} + +func (m EsxAgentManager) CreateAgency( + ctx context.Context, + config types.AgencyConfigInfo, + initialGoalState string) (Agency, error) { + + var agency Agency + resp, err := methods.CreateAgency(ctx, m.c, &types.CreateAgency{ + This: m.r, + AgencyConfigInfo: config, + InitialGoalState: initialGoalState, + }) + if err != nil { + return agency, err + } + agency.c = m.c + agency.r = resp.Returnval + return agency, nil +} + +func (m EsxAgentManager) Agencies(ctx context.Context) ([]Agency, error) { + resp, err := methods.QueryAgency(ctx, m.c, &types.QueryAgency{ + This: m.r, + }) + if err != nil { + return nil, err + } + objs := make([]Agency, len(resp.Returnval)) + for i := range resp.Returnval { + objs[i].c = m.c + objs[i].r = resp.Returnval[i] + } + return objs, nil +} + +func (m EsxAgentManager) ScanForUnknownAgentVm(ctx context.Context) error { + _, err := methods.ScanForUnknownAgentVm(ctx, m.c, &types.ScanForUnknownAgentVm{ + This: m.r, + }) + if err != nil { + return err + } + return nil +} diff --git a/eam/object/object_test.go b/eam/object/object_test.go new file mode 100644 index 000000000..0316883e5 --- /dev/null +++ b/eam/object/object_test.go @@ -0,0 +1,76 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package object_test + +import ( + "context" + "log" + "os" + "testing" + + "github.com/vmware/govmomi" + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/object" + "github.com/vmware/govmomi/eam/simulator" + vcsim "github.com/vmware/govmomi/simulator" + "github.com/vmware/govmomi/vim25" +) + +var ( + client struct { + *eam.Client + ctx context.Context + eam object.EsxAgentManager + vim *vim25.Client + } +) + +func TestMain(m *testing.M) { + client.ctx = context.Background() + + // Define a new model for vC Sim. + model := vcsim.VPX() + defer model.Remove() + + // Create the resources from the model. + if err := model.Create(); err != nil { + log.Fatal(err) + } + + // Register the EAM endpoint. + model.Service.RegisterSDK(simulator.New()) + + // Start the simulator. + server := model.Service.NewServer() + defer server.Close() + + // Get a vCenter client to the simulator. + govmomiClient, err := govmomi.NewClient(client.ctx, server.URL, true) + if err != nil { + log.Fatal(err) + } + client.vim = govmomiClient.Client + + // Get an EAM client. + client.Client = eam.NewClient(client.vim) + + // Get the EAM root object. + client.eam = object.NewEsxAgentManager(client.Client, eam.EsxAgentManager) + + // Run the tests. + os.Exit(m.Run()) +} diff --git a/eam/simulator/README.md b/eam/simulator/README.md new file mode 100644 index 000000000..d38059569 --- /dev/null +++ b/eam/simulator/README.md @@ -0,0 +1,23 @@ +# ESX Agent Manager (EAM) Simulator + +This simulator package works with the existing vC Sim. Please see [`simulator_test.go`](simulator_test.go) for an example of how to use the EAM simulator with vC Sim. + +## Use Docker to Simulate Agent VMs + +It is possible to run the simulator test whereby the creation of agent VMs results in the creation of containers in Docker to simulate the lifecycle of the VMs. Docker must be installed and running, but other than that, simply set the value of the `AgentConfigInfo.OvfPackageUrl` field to a: + +* non-empty string, +* that does not start with `./`, `/`, or `https?:`. + +If those conditions are met, then the EAM simulator treats this value as the name of a Docker image, and will create a simualted VM with `RUN.container` key set to the value, causing the core vC Simulator to simulate the VM with a container based on the specified image. + + +### Example of Simulated Agent VMs + +There is a test that provides an example of this simulated agent VM behavior. Again, Docker must be installed and running, but otherwise just execute the following: + +```shell +go test -v ./simulator/ -powerOnVMs +``` + +The flag `-powerOnVMs` causes the the simulator test code to create the agencies with agent configuration information that uses the `nginx` container to simulate two VMs. The presence of the flag then causes the VMs to be powered on, and the test waits for the agent runtime information to report the VMs' power state and IP addresses. diff --git a/eam/simulator/agency.go b/eam/simulator/agency.go new file mode 100644 index 000000000..01dc9d812 --- /dev/null +++ b/eam/simulator/agency.go @@ -0,0 +1,245 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "fmt" + "math/rand" + "time" + + "github.com/google/uuid" + + "github.com/vmware/govmomi/eam/internal" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/mo" + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/simulator" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" +) + +// Agency handles the deployment of a single type of agent virtual +// machine and any associated VIB bundle, on a set of compute resources. +type Agency struct { + EamObject + mo.Agency +} + +// NewAgency returns a new Agency as if CreateAgency were called on the +// EsxAgentManager object. +func NewAgency( + ctx *simulator.Context, + agencyConfig types.AgencyConfigInfo, + initialGoalState string) (*Agency, vim.BaseMethodFault) { + + if agencyConfig.AgentName == "" { + agencyConfig.AgentName = agencyConfig.AgencyName + } + + // Define a new Agency object. + agency := &Agency{ + EamObject: EamObject{ + Self: vim.ManagedObjectReference{ + Type: internal.Agency, + Value: uuid.New().String(), + }, + }, + Agency: mo.Agency{ + Config: agencyConfig, + Runtime: types.EamObjectRuntimeInfo{ + GoalState: initialGoalState, + }, + }, + } + + // Register the agency with the registry in order for the agency to + // start receiving API calls from clients. + ctx.Map.Put(agency) + + // Define a random numbrer generator to help select resources for the + // agent VMs. + rng := rand.New(rand.NewSource(time.Now().UnixNano())) + + // Alias the registry that contains the vim25 objects. + vimMap := simulator.Map + + // Create the agents. + for i, agentConfig := range agencyConfig.AgentConfig { + + // vmName follows the defined pattern for naming agent VMs + vmName := fmt.Sprintf("%s (%d)", agencyConfig.AgentName, i+1) + + // vmPlacement contains MoRefs to the resources required to create and + // place the VM inside of the inventory. + vmPlacement, err := getAgentVMPlacementOptions( + ctx, + vimMap, + rng, + i, + agencyConfig) + if err != nil { + return nil, &vim.MethodFault{ + FaultCause: &vim.LocalizedMethodFault{ + LocalizedMessage: err.Error(), + }, + } + } + + if _, fault := NewAgent( + ctx, + agency.Self, + agentConfig, + vmName, + vmPlacement); fault != nil { + + return nil, fault + } + } + + return agency, nil +} + +func (m *Agency) AgencyQueryRuntime( + ctx *simulator.Context, + req *types.AgencyQueryRuntime) soap.HasFault { + + // Copy the agency's issues into its runtime object upon return. + m.Runtime.Issue = make([]types.BaseIssue, len(m.Issue)) + i := 0 + for _, issue := range m.Issue { + m.Runtime.Issue[i] = issue + i++ + } + + return &methods.AgencyQueryRuntimeBody{ + Res: &types.AgencyQueryRuntimeResponse{ + Returnval: &m.Runtime, + }, + } +} + +func (m *Agency) DestroyAgency( + ctx *simulator.Context, + req *types.DestroyAgency) soap.HasFault { + + // Remove any agents associated with this agency. + agentObjs := ctx.Map.AllReference(internal.Agent) + for _, obj := range agentObjs { + agent := obj.(*Agent) + if *agent.Runtime.Agency == m.Self { + ctx.Map.Remove(ctx, agent.Self) + } + } + + ctx.Map.Remove(ctx, m.Self) + return &methods.DestroyAgencyBody{ + Res: &types.DestroyAgencyResponse{}, + } +} + +func (m *Agency) Disable( + ctx *simulator.Context, + req *types.Disable) soap.HasFault { + + m.Runtime.GoalState = string(types.EamObjectRuntimeInfoGoalStateDisabled) + + return &methods.DisableBody{ + Res: &types.DisableResponse{}, + } +} + +func (m *Agency) Enable( + ctx *simulator.Context, + req *types.Enable) soap.HasFault { + + m.Runtime.GoalState = string(types.EamObjectRuntimeInfoGoalStateEnabled) + + return &methods.EnableBody{ + Res: &types.EnableResponse{}, + } +} + +func (m *Agency) QueryAgent( + ctx *simulator.Context, + req *types.QueryAgent) soap.HasFault { + + objs := ctx.Map.AllReference(internal.Agent) + moRefs := make([]vim.ManagedObjectReference, len(objs)) + i := 0 + for _, ref := range objs { + moRefs[i] = ref.Reference() + i++ + } + return &methods.QueryAgentBody{ + Res: &types.QueryAgentResponse{ + Returnval: moRefs, + }, + } +} + +func (m *Agency) QueryConfig( + ctx *simulator.Context, + req *types.QueryConfig) soap.HasFault { + + return &methods.QueryConfigBody{ + Res: &types.QueryConfigResponse{ + Returnval: m.Config, + }, + } +} + +func (m *Agency) RegisterAgentVm( + ctx *simulator.Context, + req *types.RegisterAgentVm) soap.HasFault { + + return &methods.RegisterAgentVmBody{ + Res: &types.RegisterAgentVmResponse{ + Returnval: vim.ManagedObjectReference{}, + }, + } +} + +func (m *Agency) Uninstall( + ctx *simulator.Context, + req *types.Uninstall) soap.HasFault { + + m.Runtime.GoalState = string(types.EamObjectRuntimeInfoGoalStateUninstalled) + + return &methods.UninstallBody{ + Res: &types.UninstallResponse{}, + } +} + +func (m *Agency) UnregisterAgentVm( + ctx *simulator.Context, + req *types.UnregisterAgentVm) soap.HasFault { + + return &methods.UnregisterAgentVmBody{ + Res: &types.UnregisterAgentVmResponse{}, + } +} + +func (m *Agency) Update( + ctx *simulator.Context, + req *types.Update) soap.HasFault { + + m.Config = req.Config + + return &methods.UpdateBody{ + Res: &types.UpdateResponse{}, + } +} diff --git a/eam/simulator/agent.go b/eam/simulator/agent.go new file mode 100644 index 000000000..2ed8e886f --- /dev/null +++ b/eam/simulator/agent.go @@ -0,0 +1,266 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "fmt" + "log" + "time" + + "github.com/google/uuid" + + "github.com/vmware/govmomi/simulator" + vimmethods "github.com/vmware/govmomi/vim25/methods" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" + + "github.com/vmware/govmomi/eam/internal" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/mo" + "github.com/vmware/govmomi/eam/types" +) + +// Agenct is the vSphere ESX Agent Manager managed object responsible +// fordeploying an Agency on a single host. The Agent maintains the state +// of the current deployment in its runtime information +type Agent struct { + EamObject + mo.Agent +} + +type AgentVMPlacementOptions struct { + computeResource vim.ManagedObjectReference + datacenter vim.ManagedObjectReference + datastore vim.ManagedObjectReference + folder vim.ManagedObjectReference + host vim.ManagedObjectReference + network vim.ManagedObjectReference + pool vim.ManagedObjectReference +} + +// NewAgent returns a new Agent as if CreateAgency were called on the +// EsxAgentManager object. +func NewAgent( + ctx *simulator.Context, + agency vim.ManagedObjectReference, + config types.AgentConfigInfo, + vmName string, + vmPlacement AgentVMPlacementOptions) (*Agent, vim.BaseMethodFault) { + + vimMap := simulator.Map + + agent := &Agent{ + EamObject: EamObject{ + Self: vim.ManagedObjectReference{ + Type: internal.Agent, + Value: uuid.New().String(), + }, + }, + Agent: mo.Agent{ + Config: config, + Runtime: types.AgentRuntimeInfo{ + Agency: &agency, + VmName: vmName, + Host: &vmPlacement.host, + EsxAgentFolder: &vmPlacement.folder, + EsxAgentResourcePool: &vmPlacement.pool, + }, + }, + } + + // Register the agent with the registry in order for the agent to start + // receiving API calls from clients. + ctx.Map.Put(agent) + + createVm := func() (vim.ManagedObjectReference, *vim.LocalizedMethodFault) { + var vmRef vim.ManagedObjectReference + + // vmExtraConfig is used when creating the VM for this agent. + vmExtraConfig := []vim.BaseOptionValue{} + + // If config.OvfPackageUrl is non-empty and does not appear to point to + // a local file or an HTTP URI, then assume it is a container. + if url := config.OvfPackageUrl; url != "" && !fsOrHTTPRx.MatchString(url) { + vmExtraConfig = append( + vmExtraConfig, + &vim.OptionValue{ + Key: "RUN.container", + Value: url, + }) + } + + // Copy the OVF environment properties into the VM's ExtraConfig property. + if ovfEnv := config.OvfEnvironment; ovfEnv != nil { + for _, ovfProp := range ovfEnv.OvfProperty { + vmExtraConfig = append( + vmExtraConfig, + &vim.OptionValue{ + Key: ovfProp.Key, + Value: ovfProp.Value, + }) + } + } + + datastore := vimMap.Get(vmPlacement.datastore).(*simulator.Datastore) + vmPathName := fmt.Sprintf("[%[1]s] %[2]s/%[2]s.vmx", datastore.Name, vmName) + vmConfigSpec := vim.VirtualMachineConfigSpec{ + Name: vmName, + ExtraConfig: vmExtraConfig, + Files: &vim.VirtualMachineFileInfo{ + VmPathName: vmPathName, + }, + } + + // Create the VM for this agent. + vmFolder := vimMap.Get(vmPlacement.folder).(*simulator.Folder) + createVmTaskRef := vmFolder.CreateVMTask(ctx, &vim.CreateVM_Task{ + This: vmFolder.Self, + Config: vmConfigSpec, + Pool: vmPlacement.pool, + Host: &vmPlacement.host, + }).(*vimmethods.CreateVM_TaskBody).Res.Returnval + createVmTask := vimMap.Get(createVmTaskRef).(*simulator.Task) + + // Wait for the task to complete and see if there is an error. + createVmTask.Wait() + if createVmTask.Info.Error != nil { + return vmRef, createVmTask.Info.Error + } + + vmRef = createVmTask.Info.Result.(vim.ManagedObjectReference) + vm := vimMap.Get(vmRef).(*simulator.VirtualMachine) + log.Printf("created agent vm: MoRef=%v, Name=%s", vm.Self, vm.Name) + + // Link the agent to this VM. + agent.Runtime.Vm = &vm.Self + + return vm.Self, nil + } + + vmRef, err := createVm() + if err != nil { + return nil, &vim.RuntimeFault{ + MethodFault: vim.MethodFault{ + FaultCause: err, + }, + } + } + + // Start watching this VM and updating the agent's information about the VM. + go func(eamReg, vimReg *simulator.Registry) { + var ( + ctx = simulator.SpoofContext() + ticker = time.NewTicker(1 * time.Second) + vmName string + ) + for range ticker.C { + eamReg.WithLock(ctx, agent.Self, func() { + agentObj := eamReg.Get(agent.Self) + if agentObj == nil { + log.Printf("not found: %v", agent.Self) + // If the agent no longer exists then stop watching it. + ticker.Stop() + return + } + + updateAgent := func(vm *simulator.VirtualMachine) { + if vmName == "" { + vmName = vm.Config.Name + } + + // Update the agent's properties from the VM. + agent := agentObj.(*Agent) + agent.Runtime.VmPowerState = vm.Runtime.PowerState + if guest := vm.Summary.Guest; guest == nil { + agent.Runtime.VmIp = "" + } else { + agent.Runtime.VmIp = guest.IpAddress + } + } + + vimReg.WithLock(ctx, vmRef, func() { + if vmObj := vimReg.Get(vmRef); vmObj != nil { + updateAgent(vmObj.(*simulator.VirtualMachine)) + } else { + // If the VM no longer exists then create a new agent VM. + log.Printf( + "creating new agent vm: %v, %v, vmName=%s", + agent.Self, vmRef, vmName) + + newVmRef, err := createVm() + if err != nil { + log.Printf( + "failed to create new agent vm: %v, %v, vmName=%s, err=%v", + agent.Self, vmRef, vmName, *err) + ticker.Stop() + return + } + + // Make sure the vmRef variable is assigned to the new + // VM's reference for the next time through this loop. + vmRef = newVmRef + + // Get a lock for the *new* VM. + vimReg.WithLock(ctx, vmRef, func() { + vmObj = vimReg.Get(vmRef) + if vmObj == nil { + log.Printf("not found: %v", vmRef) + ticker.Stop() + return + } + updateAgent(vmObj.(*simulator.VirtualMachine)) + }) + } + + }) + }) + } + }(ctx.Map, vimMap) + + return agent, nil +} + +func (m *Agent) AgentQueryConfig( + ctx *simulator.Context, + req *types.AgentQueryConfig) soap.HasFault { + + return &methods.AgentQueryConfigBody{ + Res: &types.AgentQueryConfigResponse{ + Returnval: m.Config, + }, + } +} + +func (m *Agent) AgentQueryRuntime( + ctx *simulator.Context, + req *types.AgentQueryRuntime) soap.HasFault { + + return &methods.AgentQueryRuntimeBody{ + Res: &types.AgentQueryRuntimeResponse{ + Returnval: m.Runtime, + }, + } +} + +func (m *Agent) MarkAsAvailable( + ctx *simulator.Context, + req *types.MarkAsAvailable) soap.HasFault { + + return &methods.MarkAsAvailableBody{ + Res: &types.MarkAsAvailableResponse{}, + } +} diff --git a/eam/simulator/eam_object.go b/eam/simulator/eam_object.go new file mode 100644 index 000000000..ddb573293 --- /dev/null +++ b/eam/simulator/eam_object.go @@ -0,0 +1,145 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "time" + + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/mo" + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/simulator" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" +) + +// EamObject contains the fields and functions common to all objects. +type EamObject mo.EamObject + +func (m *EamObject) Reference() vim.ManagedObjectReference { + return m.Self +} + +func (m *EamObject) AddIssue( + ctx *simulator.Context, + req *types.AddIssue) soap.HasFault { + + // Get the typed issue to ensure the correct type of issue is stored and + // returned to the caller. + issue := issueType(req.Issue) + + // Get the base issue in order to assign an issue key and timestamp. + baseIssue := issue.GetIssue() + baseIssue.Key = nextAvailableIssueKey() + baseIssue.Time = time.Now().UTC() + + // Store and return the typed issue. + m.Issue = append(m.Issue, issue) + + return &methods.AddIssueBody{ + Res: &types.AddIssueResponse{ + Returnval: issue, + }, + } +} + +func (m *EamObject) QueryIssue( + ctx *simulator.Context, + req *types.QueryIssue) soap.HasFault { + + var issues []types.BaseIssue + + if len(req.IssueKey) == 0 { + // If no keys were specified then return all issues. + issues = m.Issue + } else { + // Get only the issues for the specified keys. + for _, issueKey := range req.IssueKey { + for _, issue := range m.Issue { + if issue.GetIssue().Key == issueKey { + issues = append(issues, issue) + } + } + } + } + + return &methods.QueryIssueBody{ + Res: &types.QueryIssueResponse{ + Returnval: issues, + }, + } +} + +func (m *EamObject) Resolve( + ctx *simulator.Context, + req *types.Resolve) soap.HasFault { + + // notFoundKeys is a list of issue keys that were sent but + // not found for the given object. + notFoundKeys := []int32{} + + // issueExists is a helper function that returns true + issueExists := func(issueKey int32) bool { + for _, k := range req.IssueKey { + if k == issueKey { + return true + } + } + return false + } + + // Iterate over the object's issues, and if a key matches, then remove + // the issue from the list of the object's issues. If a key does not match + // then record the key as notFound. + for i := 0; i < len(m.Issue); i++ { + issueKey := m.Issue[i].GetIssue().Key + + if ok := issueExists(issueKey); ok { + // Update the object's issue list so that it no longer includes + // the current issue. + m.Issue = append(m.Issue[:i], m.Issue[i+1:]...) + i-- + + // Ensure the key is removed from the global key space. + freeIssueKey(issueKey) + } else { + notFoundKeys = append(notFoundKeys, issueKey) + } + } + + return &methods.ResolveBody{ + Res: &types.ResolveResponse{ + Returnval: notFoundKeys, + }, + } +} + +func (m *EamObject) ResolveAll( + ctx *simulator.Context, + req *types.ResolveAll) soap.HasFault { + + // Iterate over the issues and ensure each one of their keys are removed + // from the global key space. + for _, issue := range m.Issue { + freeIssueKey(issue.GetIssue().Key) + } + + // Reset the object's issues. + m.Issue = m.Issue[:0] + + return &methods.ResolveAllBody{Res: &types.ResolveAllResponse{}} +} diff --git a/eam/simulator/esx_agent_manager.go b/eam/simulator/esx_agent_manager.go new file mode 100644 index 000000000..db240b90e --- /dev/null +++ b/eam/simulator/esx_agent_manager.go @@ -0,0 +1,81 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "github.com/vmware/govmomi/eam/internal" + "github.com/vmware/govmomi/eam/methods" + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/simulator" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" +) + +// EsxAgentManager is the main entry point for a solution to create +// agencies in the vSphere ESX Agent Manager server. +type EsxAgentManager struct { + EamObject +} + +func (m *EsxAgentManager) CreateAgency( + ctx *simulator.Context, + req *types.CreateAgency) soap.HasFault { + + var res methods.CreateAgencyBody + + if agency, err := NewAgency( + ctx, + req.AgencyConfigInfo, + req.InitialGoalState); err != nil { + + res.Fault_ = simulator.Fault("", err) + + } else { + res.Res = &types.CreateAgencyResponse{ + Returnval: agency.Self, + } + } + + return &res +} + +func (m *EsxAgentManager) QueryAgency( + ctx *simulator.Context, + req *types.QueryAgency) soap.HasFault { + + objs := ctx.Map.AllReference(internal.Agency) + moRefs := make([]vim.ManagedObjectReference, len(objs)) + i := 0 + for _, ref := range objs { + moRefs[i] = ref.Reference() + i++ + } + return &methods.QueryAgencyBody{ + Res: &types.QueryAgencyResponse{ + Returnval: moRefs, + }, + } +} + +func (m *EsxAgentManager) ScanForUnknownAgentVm( + ctx *simulator.Context, + req *types.ScanForUnknownAgentVm) soap.HasFault { + + return &methods.ScanForUnknownAgentVmBody{ + Res: &types.ScanForUnknownAgentVmResponse{}, + } +} diff --git a/eam/simulator/issue.go b/eam/simulator/issue.go new file mode 100644 index 000000000..bbe597ec2 --- /dev/null +++ b/eam/simulator/issue.go @@ -0,0 +1,70 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "sync" + + "github.com/vmware/govmomi/eam/types" +) + +var ( + activeIssueKeys = map[int32]struct{}{} + activeIssueKeysMu sync.RWMutex +) + +func nextAvailableIssueKey() int32 { + activeIssueKeysMu.Lock() + defer activeIssueKeysMu.Unlock() + for i := int32(1); ; i++ { + if _, isActiveKey := activeIssueKeys[i]; !isActiveKey { + activeIssueKeys[i] = struct{}{} + return i + } + } +} + +func freeIssueKey(i int32) { + activeIssueKeysMu.Lock() + defer activeIssueKeysMu.Unlock() + delete(activeIssueKeys, i) +} + +func issueType(issue types.BaseIssue) types.BaseIssue { + switch typedIssue := issue.(type) { + case types.BaseVmNotDeployed: + return typedIssue.GetVmNotDeployed() + case types.BaseVmDeployed: + return typedIssue.GetVmDeployed() + case types.BaseVmPoweredOff: + return typedIssue.GetVmPoweredOff() + case types.BaseVmIssue: + return typedIssue.GetVmIssue() + case types.BaseVibNotInstalled: + return typedIssue.GetVibNotInstalled() + case types.BaseVibIssue: + return typedIssue.GetVibIssue() + case types.BaseAgentIssue: + return typedIssue.GetAgentIssue() + case types.BaseAgencyIssue: + return typedIssue.GetAgencyIssue() + case types.BaseHostIssue: + return typedIssue.GetHostIssue() + default: + return issue + } +} diff --git a/eam/simulator/simulator.go b/eam/simulator/simulator.go new file mode 100644 index 000000000..19f01c7ab --- /dev/null +++ b/eam/simulator/simulator.go @@ -0,0 +1,44 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/simulator" +) + +func init() { + simulator.RegisterEndpoint(func(s *simulator.Service, r *simulator.Registry) { + if r.IsVPX() { + s.RegisterSDK(New()) + } + }) +} + +func New() *simulator.Registry { + r := simulator.NewRegistry() + r.Namespace = eam.Namespace + r.Path = eam.Path + + r.Put(&EsxAgentManager{ + EamObject: EamObject{ + Self: eam.EsxAgentManager, + }, + }) + + return r +} diff --git a/eam/simulator/simulator_test.go b/eam/simulator/simulator_test.go new file mode 100644 index 000000000..7232a117d --- /dev/null +++ b/eam/simulator/simulator_test.go @@ -0,0 +1,342 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator_test + +import ( + "context" + "flag" + "fmt" + "os" + "os/signal" + "sync" + "testing" + "time" + + "github.com/vmware/govmomi/eam" + "github.com/vmware/govmomi/eam/object" + "github.com/vmware/govmomi/eam/types" + "github.com/vmware/govmomi/find" + vimobject "github.com/vmware/govmomi/object" + vcsim "github.com/vmware/govmomi/simulator" + "github.com/vmware/govmomi/vim25" + "github.com/vmware/govmomi/vim25/soap" + vim "github.com/vmware/govmomi/vim25/types" +) + +var ( + flagPowerOnVMs = flag.Bool("powerOnVMs", false, "Powers on the VMs in the test with Docker") + flagWaitToExit = flag.Bool("waitToExit", false, "Waits for user input to exit the test") +) + +func TestSimulator(t *testing.T) { + vcsim.Test(func(ctx context.Context, vimClient *vim25.Client) { + // Create a finder that sets the default datacenter. + finder := find.NewFinder(vimClient, true) + + // Get the datacenter to use when creating the agency. + datacenter, err := finder.DefaultDatacenter(ctx) + if err != nil { + t.Fatal(err) + } + finder.SetDatacenter(datacenter) + + // Get the "vm" folder. + folder, err := finder.DefaultFolder(ctx) + if err != nil { + t.Fatal(err) + } + + // Get the cluster to use when creating the agency. + computeResource, err := finder.ClusterComputeResourceOrDefault(ctx, "") + if err != nil { + t.Fatal(err) + } + + // Get the resource pool to use when creating the agency. + pool, err := computeResource.ResourcePool(ctx) + if err != nil { + t.Fatal(err) + } + + // Get the datastore to use when creating the agency. + datastore, err := finder.DatastoreOrDefault(ctx, "") + if err != nil { + t.Fatal(err) + } + + // Get the network to use when creating the agency. + network, err := finder.NetworkOrDefault(ctx, "DVS0") + if err != nil { + t.Fatal(err) + } + + // Get an EAM client. + eamClient := eam.NewClient(vimClient) + + // Get the EAM root object. + mgr := object.NewEsxAgentManager(eamClient, eam.EsxAgentManager) + + // Define a function that will list and print the agency MoRefs. + listAgencies := func() int { + t.Log("listing agencies") + agencies, err := mgr.Agencies(ctx) + if err != nil { + t.Fatal(err) + } + if len(agencies) == 0 { + t.Log("no agencies") + return 0 + } + for _, obj := range agencies { + t.Logf("agency: %v", obj.Reference()) + config, err := obj.Config(ctx) + if err != nil { + t.Fatal(err) + } + t.Logf("agency config: %+v", config) + runtime, err := obj.Runtime(ctx) + if err != nil { + t.Fatal(err) + } + t.Logf("agency runtime: %+v", runtime) + + agents, err := obj.Agents(ctx) + if err != nil { + t.Fatal(err) + } + if len(agents) == 0 { + t.Log("no agents") + } else { + for _, a := range agents { + t.Logf("agent: %v", a.Reference()) + config, err := a.Config(ctx) + if err != nil { + t.Fatal(err) + } + t.Logf("agent config: %+v", config) + runtime, err := a.Runtime(ctx) + if err != nil { + t.Fatal(err) + } + t.Logf("agent runtime: %+v", runtime) + } + } + } + return len(agencies) + } + + // List and print the agency MoRefs. There are none. + if listAgencies() > 0 { + t.Fatal("no agencies expected") + } + + // Create a new agency. + t.Log("creating a new agency") + agency, err := mgr.CreateAgency( + ctx, + types.AgencyConfigInfo{ + AgencyName: "nginx", + AgentVmDatastore: []vim.ManagedObjectReference{ + datastore.Reference(), + }, + Folders: []types.AgencyVMFolder{ + { + FolderId: folder.Reference(), + DatacenterId: datacenter.Reference(), + }, + }, + ResourcePools: []types.AgencyVMResourcePool{ + { + ResourcePoolId: pool.Reference(), + ComputeResourceId: computeResource.Reference(), + }, + }, + AgentVmNetwork: []vim.ManagedObjectReference{ + network.Reference(), + }, + AgentConfig: []types.AgentConfigInfo{ + { + OvfPackageUrl: "nginx", + }, + { + OvfPackageUrl: "nginx", + }, + }, + }, + string(types.EamObjectRuntimeInfoGoalStateEnabled), + ) + if err != nil { + if soap.IsSoapFault(err) { + fault := soap.ToSoapFault(err).VimFault() + t.Fatalf("%[1]T %[1]v", fault) + } else { + t.Fatalf("%[1]T %[1]v", err) + } + } + t.Logf("created agency: %v", agency.Reference()) + + // List the agencies again, and this time the newly created agency will be + // printed to the console. + if listAgencies() != 1 { + t.Fatal("one agency expected") + } + + // Check whether or not we want to power on the VMs with Docker. + if *flagPowerOnVMs { + agencies, err := mgr.Agencies(ctx) + if err != nil { + t.Fatal(err) + } + if len(agencies) == 0 { + t.Fatal("no agencies") + } + agency := agencies[0] + + // Wait for the agent VMs to have IP addresses + { + agents, err := agency.Agents(ctx) + if err != nil { + t.Fatal(err) + } + if len(agents) == 0 { + t.Fatal("no agents") + } + + wait := make(chan struct{}) + done := make(chan struct{}) + errs := make(chan error) + msgs := make(chan string) + var wg sync.WaitGroup + wg.Add(len(agents)) + + for _, agent := range agents { + agent := agent + go func() { + var ( + vmPowerState string + vmIp string + once sync.Once + vmon = map[vim.ManagedObjectReference]struct{}{} + ) + for { + runtime, err := agent.Runtime(ctx) + if err != nil { + errs <- err + return + } + if runtime.Vm == nil { + errs <- fmt.Errorf("vm is nil for agent %s", agent.Reference()) + return + } + if _, ok := vmon[*runtime.Vm]; !ok { + vm := vimobject.NewVirtualMachine(vimClient, *runtime.Vm) + if _, err := vm.PowerOn(ctx); err != nil { + errs <- err + return + } + vmon[*runtime.Vm] = struct{}{} + } + + if vmIp != runtime.VmIp || vmPowerState != string(runtime.VmPowerState) { + vmIp = runtime.VmIp + vmPowerState = string(runtime.VmPowerState) + msgs <- fmt.Sprintf( + "%v: name=%s, powerState=%s, ipAddr=%s", + *runtime.Vm, + runtime.VmName, + vmPowerState, + vmIp) + } + if vmIp != "" { + once.Do(func() { + wg.Done() + }) + } + select { + case <-time.After(1 * time.Second): + case <-done: + return + } + } + }() + } + + go func() { + wg.Wait() + if *flagWaitToExit { + <-wait + } + close(done) + }() + + go func() { + defer close(wait) + if !*flagWaitToExit { + return + } + t.Log(waitLoopMessage) + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + for { + select { + case <-time.After(1 * time.Second): + case <-c: + return + } + } + }() + + t.Log("waiting for the agent VMs to power on and get IP addresses") + timeout := time.After(10 * time.Minute) + func() { + for { + select { + case msg := <-msgs: + t.Log(msg) + case err := <-errs: + t.Fatal(err) + case <-done: + return + case <-timeout: + t.Fatal("timed out waiting for agent VMs to power on and get IP addresses") + return + } + } + }() + } + } + + // Destroy the agency. + t.Log("destroying agency") + if err := agency.Destroy(ctx); err != nil { + t.Fatal(err) + } + + if listAgencies() != 0 { + t.Fatal("no agencies expected") + } + }) +} + +const waitLoopMessage = ` + +################################################################################ +# When executed with the flags -powerOnVMs and -waitForExit, this test will # +# pause here and update the screen with the status of the agent VMs until # +# SIGINT is sent to this process. # +################################################################################ +` diff --git a/eam/simulator/utils.go b/eam/simulator/utils.go new file mode 100644 index 000000000..2e2c6a7d6 --- /dev/null +++ b/eam/simulator/utils.go @@ -0,0 +1,209 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package simulator + +import ( + "errors" + "fmt" + "math/rand" + "regexp" + + "github.com/vmware/govmomi/eam/types" + vimobj "github.com/vmware/govmomi/object" + "github.com/vmware/govmomi/simulator" + vimmo "github.com/vmware/govmomi/vim25/mo" + vim "github.com/vmware/govmomi/vim25/types" +) + +var ( + // fsOrHTTPRx matches a URI that is either on the local file + // system or an HTTP endpoint. + fsOrHTTPRx = regexp.MustCompile(`^(?:\.?/)|(?:http[s]?:)`) +) + +var ( + agentVmDatastoreEmptyErr = errors.New("AgentVmDatastore is empty") + agentVmNetworkEmptyErr = errors.New("AgentVmNetwork is empty") + foldersEmptyErr = errors.New("Folders is empty") + scopeComputeResourceEmptyErr = errors.New("Scope.ComputeResource is empty") + poolRefNilErr = errors.New("Unable to determine ResourcePool from ComputeResource") +) + +func getAgentVMPlacementOptions( + ctx *simulator.Context, + reg *simulator.Registry, + r *rand.Rand, i int, + agencyConfig types.AgencyConfigInfo) (AgentVMPlacementOptions, error) { + + var opts AgentVMPlacementOptions + + if l := len(agencyConfig.AgentVmDatastore); l == 0 { + return opts, agentVmDatastoreEmptyErr + } else if l == len(agencyConfig.AgentConfig) { + opts.datastore = agencyConfig.AgentVmDatastore[i] + } else { + opts.datastore = agencyConfig.AgentVmDatastore[r.Intn(l)] + } + + if l := len(agencyConfig.AgentVmNetwork); l == 0 { + return opts, agentVmNetworkEmptyErr + } else if l == len(agencyConfig.AgentConfig) { + opts.network = agencyConfig.AgentVmNetwork[i] + } else { + opts.network = agencyConfig.AgentVmNetwork[r.Intn(l)] + } + + if l := len(agencyConfig.Folders); l == 0 { + return opts, foldersEmptyErr + } else if l == len(agencyConfig.AgentConfig) { + opts.folder = agencyConfig.Folders[i].FolderId + opts.datacenter = agencyConfig.Folders[i].DatacenterId + } else { + j := r.Intn(l) + opts.folder = agencyConfig.Folders[j].FolderId + opts.datacenter = agencyConfig.Folders[j].DatacenterId + } + + if l := len(agencyConfig.ResourcePools); l == 0 { + switch tscope := agencyConfig.Scope.(type) { + case *types.AgencyComputeResourceScope: + crRefs := tscope.ComputeResource + if l := len(crRefs); l == 0 { + return opts, scopeComputeResourceEmptyErr + } else if l == len(agencyConfig.AgentConfig) { + opts.computeResource = crRefs[i] + } else { + opts.computeResource = crRefs[r.Intn(l)] + } + poolRef, err := getPoolFromComputeResource(ctx, reg, opts.computeResource) + if err != nil { + return opts, err + } + opts.pool = *poolRef + } + } else if l == len(agencyConfig.AgentConfig) { + opts.pool = agencyConfig.ResourcePools[i].ResourcePoolId + opts.computeResource = agencyConfig.ResourcePools[i].ComputeResourceId + } else { + j := r.Intn(l) + opts.pool = agencyConfig.ResourcePools[j].ResourcePoolId + opts.computeResource = agencyConfig.ResourcePools[j].ComputeResourceId + } + + hosts := getHostsFromPool(ctx, reg, opts.pool) + if l := len(hosts); l == 0 { + return opts, fmt.Errorf("HostSystems not found for %v", opts.pool) + } else if l == len(agencyConfig.AgentConfig) { + opts.host = hosts[i] + } else { + opts.host = hosts[r.Intn(l)] + } + + return opts, nil +} + +func getPoolFromComputeResource( + ctx *simulator.Context, + reg *simulator.Registry, + computeResource vim.ManagedObjectReference) (*vim.ManagedObjectReference, error) { + + var poolRef *vim.ManagedObjectReference + crObj := reg.Get(computeResource) + if crObj == nil { + return nil, fmt.Errorf("%v not in registry", computeResource) + } + ctx.WithLock(crObj, func() { + switch cr := crObj.(type) { + case *vimmo.ComputeResource: + poolRef = cr.ResourcePool + case *simulator.ClusterComputeResource: + poolRef = cr.ResourcePool + default: + panic(fmt.Errorf( + "%v is not a %s or %s", + crObj, + "*mo.ComputeResource", + "*simulator.ClusterComputeResource", + )) + } + }) + if poolRef == nil { + return nil, poolRefNilErr + } + return poolRef, nil +} + +// getHostsFromPool returns the host(s) for the provided compute resource. +func getHostsFromPool( + ctx *simulator.Context, + reg *simulator.Registry, + poolRef vim.ManagedObjectReference) []vim.ManagedObjectReference { + + pool := reg.Get(poolRef).(vimmo.Entity) + cr := getEntityComputeResource(reg, pool) + + var hosts []vim.ManagedObjectReference + + ctx.WithLock(cr, func() { + switch cr := cr.(type) { + case *vimmo.ComputeResource: + hosts = cr.Host + case *simulator.ClusterComputeResource: + hosts = cr.Host + } + }) + + return hosts +} + +// hostsWithDatastore returns hosts that have access to the given datastore path +func hostsWithDatastore( // nolint:unused nolint:deadcode + reg *simulator.Registry, + hosts []vim.ManagedObjectReference, path string) []vim.ManagedObjectReference { + + attached := hosts[:0] + var p vimobj.DatastorePath + p.FromString(path) + + for _, host := range hosts { + h := reg.Get(host).(*simulator.HostSystem) + if reg.FindByName(p.Datastore, h.Datastore) != nil { + attached = append(attached, host) + } + } + + return attached +} + +// getEntityComputeResource returns the ComputeResource parent for the given item. +// A ResourcePool for example may have N Parents of type ResourcePool, but the top +// most Parent pool is always a ComputeResource child. +func getEntityComputeResource( + reg *simulator.Registry, + item vimmo.Entity) vimmo.Entity { + + for { + parent := item.Entity().Parent + item = reg.Get(*parent).(vimmo.Entity) + switch item.Reference().Type { + case "ComputeResource": + return item + case "ClusterComputeResource": + return item + } + } +} diff --git a/eam/types/enum.go b/eam/types/enum.go new file mode 100644 index 000000000..41054be0d --- /dev/null +++ b/eam/types/enum.go @@ -0,0 +1,93 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +import ( + "reflect" + + "github.com/vmware/govmomi/vim25/types" +) + +type AgencyVMPlacementPolicyVMAntiAffinity string + +const ( + AgencyVMPlacementPolicyVMAntiAffinityNone = AgencyVMPlacementPolicyVMAntiAffinity("none") + AgencyVMPlacementPolicyVMAntiAffinitySoft = AgencyVMPlacementPolicyVMAntiAffinity("soft") +) + +func init() { + types.Add("eam:AgencyVMPlacementPolicyVMAntiAffinity", reflect.TypeOf((*AgencyVMPlacementPolicyVMAntiAffinity)(nil)).Elem()) +} + +type AgencyVMPlacementPolicyVMDataAffinity string + +const ( + AgencyVMPlacementPolicyVMDataAffinityNone = AgencyVMPlacementPolicyVMDataAffinity("none") + AgencyVMPlacementPolicyVMDataAffinitySoft = AgencyVMPlacementPolicyVMDataAffinity("soft") +) + +func init() { + types.Add("eam:AgencyVMPlacementPolicyVMDataAffinity", reflect.TypeOf((*AgencyVMPlacementPolicyVMDataAffinity)(nil)).Elem()) +} + +type AgentConfigInfoOvfDiskProvisioning string + +const ( + AgentConfigInfoOvfDiskProvisioningNone = AgentConfigInfoOvfDiskProvisioning("none") + AgentConfigInfoOvfDiskProvisioningThin = AgentConfigInfoOvfDiskProvisioning("thin") + AgentConfigInfoOvfDiskProvisioningThick = AgentConfigInfoOvfDiskProvisioning("thick") +) + +func init() { + types.Add("eam:AgentConfigInfoOvfDiskProvisioning", reflect.TypeOf((*AgentConfigInfoOvfDiskProvisioning)(nil)).Elem()) +} + +type AgentVmHookVmState string + +const ( + AgentVmHookVmStateProvisioned = AgentVmHookVmState("provisioned") + AgentVmHookVmStatePoweredOn = AgentVmHookVmState("poweredOn") + AgentVmHookVmStatePrePowerOn = AgentVmHookVmState("prePowerOn") +) + +func init() { + types.Add("eam:AgentVmHookVmState", reflect.TypeOf((*AgentVmHookVmState)(nil)).Elem()) +} + +type EamObjectRuntimeInfoGoalState string + +const ( + EamObjectRuntimeInfoGoalStateEnabled = EamObjectRuntimeInfoGoalState("enabled") + EamObjectRuntimeInfoGoalStateDisabled = EamObjectRuntimeInfoGoalState("disabled") + EamObjectRuntimeInfoGoalStateUninstalled = EamObjectRuntimeInfoGoalState("uninstalled") +) + +func init() { + types.Add("eam:EamObjectRuntimeInfoGoalState", reflect.TypeOf((*EamObjectRuntimeInfoGoalState)(nil)).Elem()) +} + +type EamObjectRuntimeInfoStatus string + +const ( + EamObjectRuntimeInfoStatusGreen = EamObjectRuntimeInfoStatus("green") + EamObjectRuntimeInfoStatusYellow = EamObjectRuntimeInfoStatus("yellow") + EamObjectRuntimeInfoStatusRed = EamObjectRuntimeInfoStatus("red") +) + +func init() { + types.Add("eam:EamObjectRuntimeInfoStatus", reflect.TypeOf((*EamObjectRuntimeInfoStatus)(nil)).Elem()) +} diff --git a/eam/types/if.go b/eam/types/if.go new file mode 100644 index 000000000..7d460d115 --- /dev/null +++ b/eam/types/if.go @@ -0,0 +1,287 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +import ( + "reflect" + + "github.com/vmware/govmomi/vim25/types" +) + +func (b *AgencyIssue) GetAgencyIssue() *AgencyIssue { return b } + +type BaseAgencyIssue interface { + GetAgencyIssue() *AgencyIssue +} + +func init() { + types.Add("BaseAgencyIssue", reflect.TypeOf((*AgencyIssue)(nil)).Elem()) +} + +func (b *AgencyScope) GetAgencyScope() *AgencyScope { return b } + +type BaseAgencyScope interface { + GetAgencyScope() *AgencyScope +} + +func init() { + types.Add("BaseAgencyScope", reflect.TypeOf((*AgencyScope)(nil)).Elem()) +} + +func (b *AgentIssue) GetAgentIssue() *AgentIssue { return b } + +type BaseAgentIssue interface { + GetAgentIssue() *AgentIssue +} + +func init() { + types.Add("BaseAgentIssue", reflect.TypeOf((*AgentIssue)(nil)).Elem()) +} + +func (b *AgentStoragePolicy) GetAgentStoragePolicy() *AgentStoragePolicy { return b } + +type BaseAgentStoragePolicy interface { + GetAgentStoragePolicy() *AgentStoragePolicy +} + +func init() { + types.Add("BaseAgentStoragePolicy", reflect.TypeOf((*AgentStoragePolicy)(nil)).Elem()) +} + +func (b *ClusterAgentAgentIssue) GetClusterAgentAgentIssue() *ClusterAgentAgentIssue { return b } + +type BaseClusterAgentAgentIssue interface { + GetClusterAgentAgentIssue() *ClusterAgentAgentIssue +} + +func init() { + types.Add("BaseClusterAgentAgentIssue", reflect.TypeOf((*ClusterAgentAgentIssue)(nil)).Elem()) +} + +func (b *ClusterAgentVmIssue) GetClusterAgentVmIssue() *ClusterAgentVmIssue { return b } + +type BaseClusterAgentVmIssue interface { + GetClusterAgentVmIssue() *ClusterAgentVmIssue +} + +func init() { + types.Add("BaseClusterAgentVmIssue", reflect.TypeOf((*ClusterAgentVmIssue)(nil)).Elem()) +} + +func (b *ClusterAgentVmNotDeployed) GetClusterAgentVmNotDeployed() *ClusterAgentVmNotDeployed { + return b +} + +type BaseClusterAgentVmNotDeployed interface { + GetClusterAgentVmNotDeployed() *ClusterAgentVmNotDeployed +} + +func init() { + types.Add("BaseClusterAgentVmNotDeployed", reflect.TypeOf((*ClusterAgentVmNotDeployed)(nil)).Elem()) +} + +func (b *ClusterAgentVmPoweredOff) GetClusterAgentVmPoweredOff() *ClusterAgentVmPoweredOff { return b } + +type BaseClusterAgentVmPoweredOff interface { + GetClusterAgentVmPoweredOff() *ClusterAgentVmPoweredOff +} + +func init() { + types.Add("BaseClusterAgentVmPoweredOff", reflect.TypeOf((*ClusterAgentVmPoweredOff)(nil)).Elem()) +} + +func (b *EamAppFault) GetEamAppFault() *EamAppFault { return b } + +type BaseEamAppFault interface { + GetEamAppFault() *EamAppFault +} + +func init() { + types.Add("BaseEamAppFault", reflect.TypeOf((*EamAppFault)(nil)).Elem()) +} + +func (b *EamFault) GetEamFault() *EamFault { return b } + +type BaseEamFault interface { + GetEamFault() *EamFault +} + +func init() { + types.Add("BaseEamFault", reflect.TypeOf((*EamFault)(nil)).Elem()) +} + +func (b *EamObjectRuntimeInfo) GetEamObjectRuntimeInfo() *EamObjectRuntimeInfo { return b } + +type BaseEamObjectRuntimeInfo interface { + GetEamObjectRuntimeInfo() *EamObjectRuntimeInfo +} + +func init() { + types.Add("BaseEamObjectRuntimeInfo", reflect.TypeOf((*EamObjectRuntimeInfo)(nil)).Elem()) +} + +func (b *EamRuntimeFault) GetEamRuntimeFault() *EamRuntimeFault { return b } + +type BaseEamRuntimeFault interface { + GetEamRuntimeFault() *EamRuntimeFault +} + +func init() { + types.Add("BaseEamRuntimeFault", reflect.TypeOf((*EamRuntimeFault)(nil)).Elem()) +} + +func (b *HostIssue) GetHostIssue() *HostIssue { return b } + +type BaseHostIssue interface { + GetHostIssue() *HostIssue +} + +func init() { + types.Add("BaseHostIssue", reflect.TypeOf((*HostIssue)(nil)).Elem()) +} + +func (b *IntegrityAgencyVUMIssue) GetIntegrityAgencyVUMIssue() *IntegrityAgencyVUMIssue { return b } + +type BaseIntegrityAgencyVUMIssue interface { + GetIntegrityAgencyVUMIssue() *IntegrityAgencyVUMIssue +} + +func init() { + types.Add("BaseIntegrityAgencyVUMIssue", reflect.TypeOf((*IntegrityAgencyVUMIssue)(nil)).Elem()) +} + +func (b *Issue) GetIssue() *Issue { return b } + +type BaseIssue interface { + GetIssue() *Issue +} + +func init() { + types.Add("BaseIssue", reflect.TypeOf((*Issue)(nil)).Elem()) +} + +func (b *NoAgentVmDatastore) GetNoAgentVmDatastore() *NoAgentVmDatastore { return b } + +type BaseNoAgentVmDatastore interface { + GetNoAgentVmDatastore() *NoAgentVmDatastore +} + +func init() { + types.Add("BaseNoAgentVmDatastore", reflect.TypeOf((*NoAgentVmDatastore)(nil)).Elem()) +} + +func (b *NoAgentVmNetwork) GetNoAgentVmNetwork() *NoAgentVmNetwork { return b } + +type BaseNoAgentVmNetwork interface { + GetNoAgentVmNetwork() *NoAgentVmNetwork +} + +func init() { + types.Add("BaseNoAgentVmNetwork", reflect.TypeOf((*NoAgentVmNetwork)(nil)).Elem()) +} + +func (b *PersonalityAgencyDepotIssue) GetPersonalityAgencyDepotIssue() *PersonalityAgencyDepotIssue { + return b +} + +type BasePersonalityAgencyDepotIssue interface { + GetPersonalityAgencyDepotIssue() *PersonalityAgencyDepotIssue +} + +func init() { + types.Add("BasePersonalityAgencyDepotIssue", reflect.TypeOf((*PersonalityAgencyDepotIssue)(nil)).Elem()) +} + +func (b *PersonalityAgencyPMIssue) GetPersonalityAgencyPMIssue() *PersonalityAgencyPMIssue { return b } + +type BasePersonalityAgencyPMIssue interface { + GetPersonalityAgencyPMIssue() *PersonalityAgencyPMIssue +} + +func init() { + types.Add("BasePersonalityAgencyPMIssue", reflect.TypeOf((*PersonalityAgencyPMIssue)(nil)).Elem()) +} + +func (b *PersonalityAgentPMIssue) GetPersonalityAgentPMIssue() *PersonalityAgentPMIssue { return b } + +type BasePersonalityAgentPMIssue interface { + GetPersonalityAgentPMIssue() *PersonalityAgentPMIssue +} + +func init() { + types.Add("BasePersonalityAgentPMIssue", reflect.TypeOf((*PersonalityAgentPMIssue)(nil)).Elem()) +} + +func (b *VibIssue) GetVibIssue() *VibIssue { return b } + +type BaseVibIssue interface { + GetVibIssue() *VibIssue +} + +func init() { + types.Add("BaseVibIssue", reflect.TypeOf((*VibIssue)(nil)).Elem()) +} + +func (b *VibNotInstalled) GetVibNotInstalled() *VibNotInstalled { return b } + +type BaseVibNotInstalled interface { + GetVibNotInstalled() *VibNotInstalled +} + +func init() { + types.Add("BaseVibNotInstalled", reflect.TypeOf((*VibNotInstalled)(nil)).Elem()) +} + +func (b *VmDeployed) GetVmDeployed() *VmDeployed { return b } + +type BaseVmDeployed interface { + GetVmDeployed() *VmDeployed +} + +func init() { + types.Add("BaseVmDeployed", reflect.TypeOf((*VmDeployed)(nil)).Elem()) +} + +func (b *VmIssue) GetVmIssue() *VmIssue { return b } + +type BaseVmIssue interface { + GetVmIssue() *VmIssue +} + +func init() { + types.Add("BaseVmIssue", reflect.TypeOf((*VmIssue)(nil)).Elem()) +} + +func (b *VmNotDeployed) GetVmNotDeployed() *VmNotDeployed { return b } + +type BaseVmNotDeployed interface { + GetVmNotDeployed() *VmNotDeployed +} + +func init() { + types.Add("BaseVmNotDeployed", reflect.TypeOf((*VmNotDeployed)(nil)).Elem()) +} + +func (b *VmPoweredOff) GetVmPoweredOff() *VmPoweredOff { return b } + +type BaseVmPoweredOff interface { + GetVmPoweredOff() *VmPoweredOff +} + +func init() { + types.Add("BaseVmPoweredOff", reflect.TypeOf((*VmPoweredOff)(nil)).Elem()) +} diff --git a/eam/types/types.go b/eam/types/types.go new file mode 100644 index 000000000..b77445a13 --- /dev/null +++ b/eam/types/types.go @@ -0,0 +1,1605 @@ +/* +Copyright (c) 2021 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +import ( + "reflect" + "time" + + "github.com/vmware/govmomi/vim25/types" +) + +type AddIssue AddIssueRequestType + +func init() { + types.Add("eam:AddIssue", reflect.TypeOf((*AddIssue)(nil)).Elem()) +} + +type AddIssueRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + Issue BaseIssue `xml:"issue,typeattr"` +} + +func init() { + types.Add("eam:AddIssueRequestType", reflect.TypeOf((*AddIssueRequestType)(nil)).Elem()) +} + +type AddIssueResponse struct { + Returnval BaseIssue `xml:"returnval,typeattr"` +} + +type AgencyComputeResourceScope struct { + AgencyScope + + ComputeResource []types.ManagedObjectReference `xml:"computeResource,omitempty"` +} + +func init() { + types.Add("eam:AgencyComputeResourceScope", reflect.TypeOf((*AgencyComputeResourceScope)(nil)).Elem()) +} + +type AgencyConfigInfo struct { + types.DynamicData + + AgentConfig []AgentConfigInfo `xml:"agentConfig,omitempty"` + Scope BaseAgencyScope `xml:"scope,omitempty,typeattr"` + ManuallyMarkAgentVmAvailableAfterProvisioning *bool `xml:"manuallyMarkAgentVmAvailableAfterProvisioning"` + ManuallyMarkAgentVmAvailableAfterPowerOn *bool `xml:"manuallyMarkAgentVmAvailableAfterPowerOn"` + OptimizedDeploymentEnabled *bool `xml:"optimizedDeploymentEnabled"` + AgentName string `xml:"agentName,omitempty"` + AgencyName string `xml:"agencyName,omitempty"` + ManuallyProvisioned *bool `xml:"manuallyProvisioned"` + ManuallyMonitored *bool `xml:"manuallyMonitored"` + BypassVumEnabled *bool `xml:"bypassVumEnabled"` + AgentVmNetwork []types.ManagedObjectReference `xml:"agentVmNetwork,omitempty"` + AgentVmDatastore []types.ManagedObjectReference `xml:"agentVmDatastore,omitempty"` + PreferHostConfiguration *bool `xml:"preferHostConfiguration"` + IpPool *types.IpPool `xml:"ipPool,omitempty"` + ResourcePools []AgencyVMResourcePool `xml:"resourcePools,omitempty"` + Folders []AgencyVMFolder `xml:"folders,omitempty"` +} + +func init() { + types.Add("eam:AgencyConfigInfo", reflect.TypeOf((*AgencyConfigInfo)(nil)).Elem()) +} + +type AgencyIssue struct { + Issue + + Agency types.ManagedObjectReference `xml:"agency"` + AgencyName string `xml:"agencyName"` + SolutionId string `xml:"solutionId"` + SolutionName string `xml:"solutionName"` +} + +func init() { + types.Add("eam:AgencyIssue", reflect.TypeOf((*AgencyIssue)(nil)).Elem()) +} + +type AgencyQueryRuntime AgencyQueryRuntimeRequestType + +func init() { + types.Add("eam:AgencyQueryRuntime", reflect.TypeOf((*AgencyQueryRuntime)(nil)).Elem()) +} + +type AgencyQueryRuntimeRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:AgencyQueryRuntimeRequestType", reflect.TypeOf((*AgencyQueryRuntimeRequestType)(nil)).Elem()) +} + +type AgencyQueryRuntimeResponse struct { + Returnval BaseEamObjectRuntimeInfo `xml:"returnval,typeattr"` +} + +type AgencyScope struct { + types.DynamicData +} + +func init() { + types.Add("eam:AgencyScope", reflect.TypeOf((*AgencyScope)(nil)).Elem()) +} + +type AgencyVMFolder struct { + types.DynamicData + + FolderId types.ManagedObjectReference `xml:"folderId"` + DatacenterId types.ManagedObjectReference `xml:"datacenterId"` +} + +func init() { + types.Add("eam:AgencyVMFolder", reflect.TypeOf((*AgencyVMFolder)(nil)).Elem()) +} + +type AgencyVMResourcePool struct { + types.DynamicData + + ResourcePoolId types.ManagedObjectReference `xml:"resourcePoolId"` + ComputeResourceId types.ManagedObjectReference `xml:"computeResourceId"` +} + +func init() { + types.Add("eam:AgencyVMResourcePool", reflect.TypeOf((*AgencyVMResourcePool)(nil)).Elem()) +} + +type AgentConfigInfo struct { + types.DynamicData + + ProductLineId string `xml:"productLineId,omitempty"` + HostVersion string `xml:"hostVersion,omitempty"` + OvfPackageUrl string `xml:"ovfPackageUrl,omitempty"` + OvfEnvironment *AgentOvfEnvironmentInfo `xml:"ovfEnvironment,omitempty"` + VibUrl string `xml:"vibUrl,omitempty"` + VibMatchingRules []AgentVibMatchingRule `xml:"vibMatchingRules,omitempty"` + VibName string `xml:"vibName,omitempty"` + DvFilterEnabled *bool `xml:"dvFilterEnabled"` + RebootHostAfterVibUninstall *bool `xml:"rebootHostAfterVibUninstall"` + VmciService []string `xml:"vmciService,omitempty"` + OvfDiskProvisioning string `xml:"ovfDiskProvisioning,omitempty"` + VmStoragePolicies []BaseAgentStoragePolicy `xml:"vmStoragePolicies,omitempty,typeattr"` +} + +func init() { + types.Add("eam:AgentConfigInfo", reflect.TypeOf((*AgentConfigInfo)(nil)).Elem()) +} + +type AgentIssue struct { + AgencyIssue + + Agent types.ManagedObjectReference `xml:"agent"` + AgentName string `xml:"agentName"` + Host types.ManagedObjectReference `xml:"host"` + HostName string `xml:"hostName"` +} + +func init() { + types.Add("eam:AgentIssue", reflect.TypeOf((*AgentIssue)(nil)).Elem()) +} + +type AgentOvfEnvironmentInfo struct { + types.DynamicData + + OvfProperty []AgentOvfEnvironmentInfoOvfProperty `xml:"ovfProperty,omitempty"` +} + +func init() { + types.Add("eam:AgentOvfEnvironmentInfo", reflect.TypeOf((*AgentOvfEnvironmentInfo)(nil)).Elem()) +} + +type AgentOvfEnvironmentInfoOvfProperty struct { + types.DynamicData + + Key string `xml:"key"` + Value string `xml:"value"` +} + +func init() { + types.Add("eam:AgentOvfEnvironmentInfoOvfProperty", reflect.TypeOf((*AgentOvfEnvironmentInfoOvfProperty)(nil)).Elem()) +} + +type AgentQueryConfig AgentQueryConfigRequestType + +func init() { + types.Add("eam:AgentQueryConfig", reflect.TypeOf((*AgentQueryConfig)(nil)).Elem()) +} + +type AgentQueryConfigRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:AgentQueryConfigRequestType", reflect.TypeOf((*AgentQueryConfigRequestType)(nil)).Elem()) +} + +type AgentQueryConfigResponse struct { + Returnval AgentConfigInfo `xml:"returnval"` +} + +type AgentQueryRuntime AgentQueryRuntimeRequestType + +func init() { + types.Add("eam:AgentQueryRuntime", reflect.TypeOf((*AgentQueryRuntime)(nil)).Elem()) +} + +type AgentQueryRuntimeRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:AgentQueryRuntimeRequestType", reflect.TypeOf((*AgentQueryRuntimeRequestType)(nil)).Elem()) +} + +type AgentQueryRuntimeResponse struct { + Returnval AgentRuntimeInfo `xml:"returnval"` +} + +type AgentRuntimeInfo struct { + EamObjectRuntimeInfo + + VmPowerState types.VirtualMachinePowerState `xml:"vmPowerState"` + ReceivingHeartBeat bool `xml:"receivingHeartBeat"` + Host *types.ManagedObjectReference `xml:"host,omitempty"` + Vm *types.ManagedObjectReference `xml:"vm,omitempty"` + VmIp string `xml:"vmIp,omitempty"` + VmName string `xml:"vmName"` + EsxAgentResourcePool *types.ManagedObjectReference `xml:"esxAgentResourcePool,omitempty"` + EsxAgentFolder *types.ManagedObjectReference `xml:"esxAgentFolder,omitempty"` + InstalledBulletin []string `xml:"installedBulletin,omitempty"` + InstalledVibs []VibVibInfo `xml:"installedVibs,omitempty"` + Agency *types.ManagedObjectReference `xml:"agency,omitempty"` + VmHook *AgentVmHook `xml:"vmHook,omitempty"` +} + +func init() { + types.Add("eam:AgentRuntimeInfo", reflect.TypeOf((*AgentRuntimeInfo)(nil)).Elem()) +} + +type AgentStoragePolicy struct { + types.DynamicData +} + +func init() { + types.Add("eam:AgentStoragePolicy", reflect.TypeOf((*AgentStoragePolicy)(nil)).Elem()) +} + +type AgentVibMatchingRule struct { + types.DynamicData + + VibNameRegex string `xml:"vibNameRegex"` + VibVersionRegex string `xml:"vibVersionRegex"` +} + +func init() { + types.Add("eam:AgentVibMatchingRule", reflect.TypeOf((*AgentVibMatchingRule)(nil)).Elem()) +} + +type AgentVmHook struct { + types.DynamicData + + Vm types.ManagedObjectReference `xml:"vm"` + VmState string `xml:"vmState"` +} + +func init() { + types.Add("eam:AgentVmHook", reflect.TypeOf((*AgentVmHook)(nil)).Elem()) +} + +type AgentVsanStoragePolicy struct { + AgentStoragePolicy + + ProfileId string `xml:"profileId"` +} + +func init() { + types.Add("eam:AgentVsanStoragePolicy", reflect.TypeOf((*AgentVsanStoragePolicy)(nil)).Elem()) +} + +type ArrayOfAgencyVMFolder struct { + AgencyVMFolder []AgencyVMFolder `xml:"AgencyVMFolder,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfAgencyVMFolder", reflect.TypeOf((*ArrayOfAgencyVMFolder)(nil)).Elem()) +} + +type ArrayOfAgencyVMResourcePool struct { + AgencyVMResourcePool []AgencyVMResourcePool `xml:"AgencyVMResourcePool,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfAgencyVMResourcePool", reflect.TypeOf((*ArrayOfAgencyVMResourcePool)(nil)).Elem()) +} + +type ArrayOfAgentConfigInfo struct { + AgentConfigInfo []AgentConfigInfo `xml:"AgentConfigInfo,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfAgentConfigInfo", reflect.TypeOf((*ArrayOfAgentConfigInfo)(nil)).Elem()) +} + +type ArrayOfAgentOvfEnvironmentInfoOvfProperty struct { + AgentOvfEnvironmentInfoOvfProperty []AgentOvfEnvironmentInfoOvfProperty `xml:"AgentOvfEnvironmentInfoOvfProperty,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfAgentOvfEnvironmentInfoOvfProperty", reflect.TypeOf((*ArrayOfAgentOvfEnvironmentInfoOvfProperty)(nil)).Elem()) +} + +type ArrayOfAgentStoragePolicy struct { + AgentStoragePolicy []BaseAgentStoragePolicy `xml:"AgentStoragePolicy,omitempty,typeattr"` +} + +func init() { + types.Add("eam:ArrayOfAgentStoragePolicy", reflect.TypeOf((*ArrayOfAgentStoragePolicy)(nil)).Elem()) +} + +type ArrayOfAgentVibMatchingRule struct { + AgentVibMatchingRule []AgentVibMatchingRule `xml:"AgentVibMatchingRule,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfAgentVibMatchingRule", reflect.TypeOf((*ArrayOfAgentVibMatchingRule)(nil)).Elem()) +} + +type ArrayOfIssue struct { + Issue []BaseIssue `xml:"Issue,omitempty,typeattr"` +} + +func init() { + types.Add("eam:ArrayOfIssue", reflect.TypeOf((*ArrayOfIssue)(nil)).Elem()) +} + +type ArrayOfVibVibInfo struct { + VibVibInfo []VibVibInfo `xml:"VibVibInfo,omitempty"` +} + +func init() { + types.Add("eam:ArrayOfVibVibInfo", reflect.TypeOf((*ArrayOfVibVibInfo)(nil)).Elem()) +} + +type CannotAccessAgentOVF struct { + VmNotDeployed + + DownloadUrl string `xml:"downloadUrl"` +} + +func init() { + types.Add("eam:CannotAccessAgentOVF", reflect.TypeOf((*CannotAccessAgentOVF)(nil)).Elem()) +} + +type CannotAccessAgentVib struct { + VibNotInstalled + + DownloadUrl string `xml:"downloadUrl"` +} + +func init() { + types.Add("eam:CannotAccessAgentVib", reflect.TypeOf((*CannotAccessAgentVib)(nil)).Elem()) +} + +type ClusterAgentAgentIssue struct { + AgencyIssue + + Agent types.ManagedObjectReference `xml:"agent"` + Cluster *types.ManagedObjectReference `xml:"cluster,omitempty"` +} + +func init() { + types.Add("eam:ClusterAgentAgentIssue", reflect.TypeOf((*ClusterAgentAgentIssue)(nil)).Elem()) +} + +type ClusterAgentInsufficientClusterResources struct { + ClusterAgentVmPoweredOff +} + +func init() { + types.Add("eam:ClusterAgentInsufficientClusterResources", reflect.TypeOf((*ClusterAgentInsufficientClusterResources)(nil)).Elem()) +} + +type ClusterAgentInsufficientClusterSpace struct { + ClusterAgentVmNotDeployed +} + +func init() { + types.Add("eam:ClusterAgentInsufficientClusterSpace", reflect.TypeOf((*ClusterAgentInsufficientClusterSpace)(nil)).Elem()) +} + +type ClusterAgentInvalidConfig struct { + ClusterAgentVmIssue + + Error types.AnyType `xml:"error,typeattr"` +} + +func init() { + types.Add("eam:ClusterAgentInvalidConfig", reflect.TypeOf((*ClusterAgentInvalidConfig)(nil)).Elem()) +} + +type ClusterAgentMissingClusterVmDatastore struct { + ClusterAgentVmNotDeployed + + MissingDatastores []types.ManagedObjectReference `xml:"missingDatastores,omitempty"` +} + +func init() { + types.Add("eam:ClusterAgentMissingClusterVmDatastore", reflect.TypeOf((*ClusterAgentMissingClusterVmDatastore)(nil)).Elem()) +} + +type ClusterAgentMissingClusterVmNetwork struct { + ClusterAgentVmNotDeployed + + MissingNetworks []types.ManagedObjectReference `xml:"missingNetworks,omitempty"` + NetworkNames []string `xml:"networkNames,omitempty"` +} + +func init() { + types.Add("eam:ClusterAgentMissingClusterVmNetwork", reflect.TypeOf((*ClusterAgentMissingClusterVmNetwork)(nil)).Elem()) +} + +type ClusterAgentOvfInvalidProperty struct { + ClusterAgentAgentIssue + + Error []types.LocalizedMethodFault `xml:"error,omitempty"` +} + +func init() { + types.Add("eam:ClusterAgentOvfInvalidProperty", reflect.TypeOf((*ClusterAgentOvfInvalidProperty)(nil)).Elem()) +} + +type ClusterAgentVmIssue struct { + ClusterAgentAgentIssue + + Vm types.ManagedObjectReference `xml:"vm"` +} + +func init() { + types.Add("eam:ClusterAgentVmIssue", reflect.TypeOf((*ClusterAgentVmIssue)(nil)).Elem()) +} + +type ClusterAgentVmNotDeployed struct { + ClusterAgentAgentIssue +} + +func init() { + types.Add("eam:ClusterAgentVmNotDeployed", reflect.TypeOf((*ClusterAgentVmNotDeployed)(nil)).Elem()) +} + +type ClusterAgentVmNotRemoved struct { + ClusterAgentVmIssue +} + +func init() { + types.Add("eam:ClusterAgentVmNotRemoved", reflect.TypeOf((*ClusterAgentVmNotRemoved)(nil)).Elem()) +} + +type ClusterAgentVmPoweredOff struct { + ClusterAgentVmIssue +} + +func init() { + types.Add("eam:ClusterAgentVmPoweredOff", reflect.TypeOf((*ClusterAgentVmPoweredOff)(nil)).Elem()) +} + +type ClusterAgentVmPoweredOn struct { + ClusterAgentVmIssue +} + +func init() { + types.Add("eam:ClusterAgentVmPoweredOn", reflect.TypeOf((*ClusterAgentVmPoweredOn)(nil)).Elem()) +} + +type ClusterAgentVmSuspended struct { + ClusterAgentVmIssue +} + +func init() { + types.Add("eam:ClusterAgentVmSuspended", reflect.TypeOf((*ClusterAgentVmSuspended)(nil)).Elem()) +} + +type CreateAgency CreateAgencyRequestType + +func init() { + types.Add("eam:CreateAgency", reflect.TypeOf((*CreateAgency)(nil)).Elem()) +} + +type CreateAgencyRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + AgencyConfigInfo AgencyConfigInfo `xml:"agencyConfigInfo"` + InitialGoalState string `xml:"initialGoalState"` +} + +func init() { + types.Add("eam:CreateAgencyRequestType", reflect.TypeOf((*CreateAgencyRequestType)(nil)).Elem()) +} + +type CreateAgencyResponse struct { + Returnval types.ManagedObjectReference `xml:"returnval"` +} + +type DestroyAgency DestroyAgencyRequestType + +func init() { + types.Add("eam:DestroyAgency", reflect.TypeOf((*DestroyAgency)(nil)).Elem()) +} + +type DestroyAgencyRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:DestroyAgencyRequestType", reflect.TypeOf((*DestroyAgencyRequestType)(nil)).Elem()) +} + +type DestroyAgencyResponse struct { +} + +type Disable DisableRequestType + +func init() { + types.Add("eam:Disable", reflect.TypeOf((*Disable)(nil)).Elem()) +} + +type DisableRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:DisableRequestType", reflect.TypeOf((*DisableRequestType)(nil)).Elem()) +} + +type DisableResponse struct { +} + +type EamAppFault struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamAppFault", reflect.TypeOf((*EamAppFault)(nil)).Elem()) +} + +type EamAppFaultFault BaseEamAppFault + +func init() { + types.Add("eam:EamAppFaultFault", reflect.TypeOf((*EamAppFaultFault)(nil)).Elem()) +} + +type EamFault struct { + types.MethodFault +} + +func init() { + types.Add("eam:EamFault", reflect.TypeOf((*EamFault)(nil)).Elem()) +} + +type EamFaultFault BaseEamFault + +func init() { + types.Add("eam:EamFaultFault", reflect.TypeOf((*EamFaultFault)(nil)).Elem()) +} + +type EamIOFault struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamIOFault", reflect.TypeOf((*EamIOFault)(nil)).Elem()) +} + +type EamIOFaultFault EamIOFault + +func init() { + types.Add("eam:EamIOFaultFault", reflect.TypeOf((*EamIOFaultFault)(nil)).Elem()) +} + +type EamInvalidLogin struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamInvalidLogin", reflect.TypeOf((*EamInvalidLogin)(nil)).Elem()) +} + +type EamInvalidLoginFault EamInvalidLogin + +func init() { + types.Add("eam:EamInvalidLoginFault", reflect.TypeOf((*EamInvalidLoginFault)(nil)).Elem()) +} + +type EamInvalidState struct { + EamAppFault +} + +func init() { + types.Add("eam:EamInvalidState", reflect.TypeOf((*EamInvalidState)(nil)).Elem()) +} + +type EamInvalidStateFault EamInvalidState + +func init() { + types.Add("eam:EamInvalidStateFault", reflect.TypeOf((*EamInvalidStateFault)(nil)).Elem()) +} + +type EamInvalidVibPackage struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamInvalidVibPackage", reflect.TypeOf((*EamInvalidVibPackage)(nil)).Elem()) +} + +type EamInvalidVibPackageFault EamInvalidVibPackage + +func init() { + types.Add("eam:EamInvalidVibPackageFault", reflect.TypeOf((*EamInvalidVibPackageFault)(nil)).Elem()) +} + +type EamObjectRuntimeInfo struct { + types.DynamicData + + Status string `xml:"status"` + Issue []BaseIssue `xml:"issue,omitempty,typeattr"` + GoalState string `xml:"goalState"` + Entity types.ManagedObjectReference `xml:"entity"` +} + +func init() { + types.Add("eam:EamObjectRuntimeInfo", reflect.TypeOf((*EamObjectRuntimeInfo)(nil)).Elem()) +} + +type EamRuntimeFault struct { + types.RuntimeFault +} + +func init() { + types.Add("eam:EamRuntimeFault", reflect.TypeOf((*EamRuntimeFault)(nil)).Elem()) +} + +type EamRuntimeFaultFault BaseEamRuntimeFault + +func init() { + types.Add("eam:EamRuntimeFaultFault", reflect.TypeOf((*EamRuntimeFaultFault)(nil)).Elem()) +} + +type EamServiceNotInitialized struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamServiceNotInitialized", reflect.TypeOf((*EamServiceNotInitialized)(nil)).Elem()) +} + +type EamServiceNotInitializedFault EamServiceNotInitialized + +func init() { + types.Add("eam:EamServiceNotInitializedFault", reflect.TypeOf((*EamServiceNotInitializedFault)(nil)).Elem()) +} + +type EamSystemFault struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:EamSystemFault", reflect.TypeOf((*EamSystemFault)(nil)).Elem()) +} + +type EamSystemFaultFault EamSystemFault + +func init() { + types.Add("eam:EamSystemFaultFault", reflect.TypeOf((*EamSystemFaultFault)(nil)).Elem()) +} + +type Enable EnableRequestType + +func init() { + types.Add("eam:Enable", reflect.TypeOf((*Enable)(nil)).Elem()) +} + +type EnableRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:EnableRequestType", reflect.TypeOf((*EnableRequestType)(nil)).Elem()) +} + +type EnableResponse struct { +} + +type ExtensibleIssue struct { + Issue + + TypeId string `xml:"typeId"` + Argument []types.KeyAnyValue `xml:"argument,omitempty"` + Target *types.ManagedObjectReference `xml:"target,omitempty"` + Agent *types.ManagedObjectReference `xml:"agent,omitempty"` + Agency *types.ManagedObjectReference `xml:"agency,omitempty"` +} + +func init() { + types.Add("eam:ExtensibleIssue", reflect.TypeOf((*ExtensibleIssue)(nil)).Elem()) +} + +type HostInMaintenanceMode struct { + VmDeployed +} + +func init() { + types.Add("eam:HostInMaintenanceMode", reflect.TypeOf((*HostInMaintenanceMode)(nil)).Elem()) +} + +type HostInStandbyMode struct { + VmDeployed +} + +func init() { + types.Add("eam:HostInStandbyMode", reflect.TypeOf((*HostInStandbyMode)(nil)).Elem()) +} + +type HostIssue struct { + Issue + + Host types.ManagedObjectReference `xml:"host"` +} + +func init() { + types.Add("eam:HostIssue", reflect.TypeOf((*HostIssue)(nil)).Elem()) +} + +type HostPoweredOff struct { + VmDeployed +} + +func init() { + types.Add("eam:HostPoweredOff", reflect.TypeOf((*HostPoweredOff)(nil)).Elem()) +} + +type ImmediateHostRebootRequired struct { + VibIssue +} + +func init() { + types.Add("eam:ImmediateHostRebootRequired", reflect.TypeOf((*ImmediateHostRebootRequired)(nil)).Elem()) +} + +type IncompatibleHostVersion struct { + VmNotDeployed +} + +func init() { + types.Add("eam:IncompatibleHostVersion", reflect.TypeOf((*IncompatibleHostVersion)(nil)).Elem()) +} + +type InsufficientIpAddresses struct { + VmPoweredOff + + Network types.ManagedObjectReference `xml:"network"` +} + +func init() { + types.Add("eam:InsufficientIpAddresses", reflect.TypeOf((*InsufficientIpAddresses)(nil)).Elem()) +} + +type InsufficientResources struct { + VmNotDeployed +} + +func init() { + types.Add("eam:InsufficientResources", reflect.TypeOf((*InsufficientResources)(nil)).Elem()) +} + +type InsufficientSpace struct { + VmNotDeployed +} + +func init() { + types.Add("eam:InsufficientSpace", reflect.TypeOf((*InsufficientSpace)(nil)).Elem()) +} + +type IntegrityAgencyCannotDeleteSoftware struct { + IntegrityAgencyVUMIssue +} + +func init() { + types.Add("eam:IntegrityAgencyCannotDeleteSoftware", reflect.TypeOf((*IntegrityAgencyCannotDeleteSoftware)(nil)).Elem()) +} + +type IntegrityAgencyCannotStageSoftware struct { + IntegrityAgencyVUMIssue +} + +func init() { + types.Add("eam:IntegrityAgencyCannotStageSoftware", reflect.TypeOf((*IntegrityAgencyCannotStageSoftware)(nil)).Elem()) +} + +type IntegrityAgencyVUMIssue struct { + AgencyIssue +} + +func init() { + types.Add("eam:IntegrityAgencyVUMIssue", reflect.TypeOf((*IntegrityAgencyVUMIssue)(nil)).Elem()) +} + +type IntegrityAgencyVUMUnavailable struct { + IntegrityAgencyVUMIssue +} + +func init() { + types.Add("eam:IntegrityAgencyVUMUnavailable", reflect.TypeOf((*IntegrityAgencyVUMUnavailable)(nil)).Elem()) +} + +type InvalidAgencyScope struct { + EamFault + + UnknownComputeResource []types.ManagedObjectReference `xml:"unknownComputeResource,omitempty"` +} + +func init() { + types.Add("eam:InvalidAgencyScope", reflect.TypeOf((*InvalidAgencyScope)(nil)).Elem()) +} + +type InvalidAgencyScopeFault InvalidAgencyScope + +func init() { + types.Add("eam:InvalidAgencyScopeFault", reflect.TypeOf((*InvalidAgencyScopeFault)(nil)).Elem()) +} + +type InvalidAgentConfiguration struct { + EamFault + + InvalidAgentConfiguration *AgentConfigInfo `xml:"invalidAgentConfiguration,omitempty"` + InvalidField string `xml:"invalidField,omitempty"` +} + +func init() { + types.Add("eam:InvalidAgentConfiguration", reflect.TypeOf((*InvalidAgentConfiguration)(nil)).Elem()) +} + +type InvalidAgentConfigurationFault InvalidAgentConfiguration + +func init() { + types.Add("eam:InvalidAgentConfigurationFault", reflect.TypeOf((*InvalidAgentConfigurationFault)(nil)).Elem()) +} + +type InvalidConfig struct { + VmIssue + + Error types.AnyType `xml:"error,typeattr"` +} + +func init() { + types.Add("eam:InvalidConfig", reflect.TypeOf((*InvalidConfig)(nil)).Elem()) +} + +type InvalidUrl struct { + EamFault + + Url string `xml:"url"` + MalformedUrl bool `xml:"malformedUrl"` + UnknownHost bool `xml:"unknownHost"` + ConnectionRefused bool `xml:"connectionRefused"` + ResponseCode int32 `xml:"responseCode,omitempty"` +} + +func init() { + types.Add("eam:InvalidUrl", reflect.TypeOf((*InvalidUrl)(nil)).Elem()) +} + +type InvalidUrlFault InvalidUrl + +func init() { + types.Add("eam:InvalidUrlFault", reflect.TypeOf((*InvalidUrlFault)(nil)).Elem()) +} + +type Issue struct { + types.DynamicData + + Key int32 `xml:"key"` + Description string `xml:"description"` + Time time.Time `xml:"time"` +} + +func init() { + types.Add("eam:Issue", reflect.TypeOf((*Issue)(nil)).Elem()) +} + +type ManagedHostNotReachable struct { + AgentIssue +} + +func init() { + types.Add("eam:ManagedHostNotReachable", reflect.TypeOf((*ManagedHostNotReachable)(nil)).Elem()) +} + +type MarkAsAvailable MarkAsAvailableRequestType + +func init() { + types.Add("eam:MarkAsAvailable", reflect.TypeOf((*MarkAsAvailable)(nil)).Elem()) +} + +type MarkAsAvailableRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:MarkAsAvailableRequestType", reflect.TypeOf((*MarkAsAvailableRequestType)(nil)).Elem()) +} + +type MarkAsAvailableResponse struct { +} + +type MissingAgentIpPool struct { + VmPoweredOff + + Network types.ManagedObjectReference `xml:"network"` +} + +func init() { + types.Add("eam:MissingAgentIpPool", reflect.TypeOf((*MissingAgentIpPool)(nil)).Elem()) +} + +type MissingDvFilterSwitch struct { + AgentIssue +} + +func init() { + types.Add("eam:MissingDvFilterSwitch", reflect.TypeOf((*MissingDvFilterSwitch)(nil)).Elem()) +} + +type NoAgentVmDatastore struct { + VmNotDeployed +} + +func init() { + types.Add("eam:NoAgentVmDatastore", reflect.TypeOf((*NoAgentVmDatastore)(nil)).Elem()) +} + +type NoAgentVmNetwork struct { + VmNotDeployed +} + +func init() { + types.Add("eam:NoAgentVmNetwork", reflect.TypeOf((*NoAgentVmNetwork)(nil)).Elem()) +} + +type NoConnectionToVCenter struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:NoConnectionToVCenter", reflect.TypeOf((*NoConnectionToVCenter)(nil)).Elem()) +} + +type NoConnectionToVCenterFault NoConnectionToVCenter + +func init() { + types.Add("eam:NoConnectionToVCenterFault", reflect.TypeOf((*NoConnectionToVCenterFault)(nil)).Elem()) +} + +type NoCustomAgentVmDatastore struct { + NoAgentVmDatastore + + CustomAgentVmDatastore []types.ManagedObjectReference `xml:"customAgentVmDatastore"` + CustomAgentVmDatastoreName []string `xml:"customAgentVmDatastoreName"` +} + +func init() { + types.Add("eam:NoCustomAgentVmDatastore", reflect.TypeOf((*NoCustomAgentVmDatastore)(nil)).Elem()) +} + +type NoCustomAgentVmNetwork struct { + NoAgentVmNetwork + + CustomAgentVmNetwork []types.ManagedObjectReference `xml:"customAgentVmNetwork"` + CustomAgentVmNetworkName []string `xml:"customAgentVmNetworkName"` +} + +func init() { + types.Add("eam:NoCustomAgentVmNetwork", reflect.TypeOf((*NoCustomAgentVmNetwork)(nil)).Elem()) +} + +type NoDiscoverableAgentVmDatastore struct { + VmNotDeployed +} + +func init() { + types.Add("eam:NoDiscoverableAgentVmDatastore", reflect.TypeOf((*NoDiscoverableAgentVmDatastore)(nil)).Elem()) +} + +type NoDiscoverableAgentVmNetwork struct { + VmNotDeployed +} + +func init() { + types.Add("eam:NoDiscoverableAgentVmNetwork", reflect.TypeOf((*NoDiscoverableAgentVmNetwork)(nil)).Elem()) +} + +type NotAuthorized struct { + EamRuntimeFault +} + +func init() { + types.Add("eam:NotAuthorized", reflect.TypeOf((*NotAuthorized)(nil)).Elem()) +} + +type NotAuthorizedFault NotAuthorized + +func init() { + types.Add("eam:NotAuthorizedFault", reflect.TypeOf((*NotAuthorizedFault)(nil)).Elem()) +} + +type OrphanedAgency struct { + AgencyIssue +} + +func init() { + types.Add("eam:OrphanedAgency", reflect.TypeOf((*OrphanedAgency)(nil)).Elem()) +} + +type OrphanedDvFilterSwitch struct { + HostIssue +} + +func init() { + types.Add("eam:OrphanedDvFilterSwitch", reflect.TypeOf((*OrphanedDvFilterSwitch)(nil)).Elem()) +} + +type OvfInvalidFormat struct { + VmNotDeployed + + Error []types.LocalizedMethodFault `xml:"error,omitempty"` +} + +func init() { + types.Add("eam:OvfInvalidFormat", reflect.TypeOf((*OvfInvalidFormat)(nil)).Elem()) +} + +type OvfInvalidProperty struct { + AgentIssue + + Error []types.LocalizedMethodFault `xml:"error,omitempty"` +} + +func init() { + types.Add("eam:OvfInvalidProperty", reflect.TypeOf((*OvfInvalidProperty)(nil)).Elem()) +} + +type PersonalityAgencyCannotConfigureSolutions struct { + PersonalityAgencyPMIssue + + Cr types.ManagedObjectReference `xml:"cr"` + SolutionsToModify []string `xml:"solutionsToModify,omitempty"` + SolutionsToRemove []string `xml:"solutionsToRemove,omitempty"` +} + +func init() { + types.Add("eam:PersonalityAgencyCannotConfigureSolutions", reflect.TypeOf((*PersonalityAgencyCannotConfigureSolutions)(nil)).Elem()) +} + +type PersonalityAgencyCannotUploadDepot struct { + PersonalityAgencyDepotIssue + + LocalDepotUrl string `xml:"localDepotUrl"` +} + +func init() { + types.Add("eam:PersonalityAgencyCannotUploadDepot", reflect.TypeOf((*PersonalityAgencyCannotUploadDepot)(nil)).Elem()) +} + +type PersonalityAgencyDepotIssue struct { + PersonalityAgencyPMIssue + + RemoteDepotUrl string `xml:"remoteDepotUrl"` +} + +func init() { + types.Add("eam:PersonalityAgencyDepotIssue", reflect.TypeOf((*PersonalityAgencyDepotIssue)(nil)).Elem()) +} + +type PersonalityAgencyInaccessibleDepot struct { + PersonalityAgencyDepotIssue +} + +func init() { + types.Add("eam:PersonalityAgencyInaccessibleDepot", reflect.TypeOf((*PersonalityAgencyInaccessibleDepot)(nil)).Elem()) +} + +type PersonalityAgencyInvalidDepot struct { + PersonalityAgencyDepotIssue +} + +func init() { + types.Add("eam:PersonalityAgencyInvalidDepot", reflect.TypeOf((*PersonalityAgencyInvalidDepot)(nil)).Elem()) +} + +type PersonalityAgencyPMIssue struct { + AgencyIssue +} + +func init() { + types.Add("eam:PersonalityAgencyPMIssue", reflect.TypeOf((*PersonalityAgencyPMIssue)(nil)).Elem()) +} + +type PersonalityAgencyPMUnavailable struct { + PersonalityAgencyPMIssue +} + +func init() { + types.Add("eam:PersonalityAgencyPMUnavailable", reflect.TypeOf((*PersonalityAgencyPMUnavailable)(nil)).Elem()) +} + +type PersonalityAgentAwaitingPMRemediation struct { + PersonalityAgentPMIssue +} + +func init() { + types.Add("eam:PersonalityAgentAwaitingPMRemediation", reflect.TypeOf((*PersonalityAgentAwaitingPMRemediation)(nil)).Elem()) +} + +type PersonalityAgentBlockedByAgencyOperation struct { + PersonalityAgentPMIssue +} + +func init() { + types.Add("eam:PersonalityAgentBlockedByAgencyOperation", reflect.TypeOf((*PersonalityAgentBlockedByAgencyOperation)(nil)).Elem()) +} + +type PersonalityAgentPMIssue struct { + AgentIssue +} + +func init() { + types.Add("eam:PersonalityAgentPMIssue", reflect.TypeOf((*PersonalityAgentPMIssue)(nil)).Elem()) +} + +type QueryAgency QueryAgencyRequestType + +func init() { + types.Add("eam:QueryAgency", reflect.TypeOf((*QueryAgency)(nil)).Elem()) +} + +type QueryAgencyRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:QueryAgencyRequestType", reflect.TypeOf((*QueryAgencyRequestType)(nil)).Elem()) +} + +type QueryAgencyResponse struct { + Returnval []types.ManagedObjectReference `xml:"returnval,omitempty"` +} + +type QueryAgent QueryAgentRequestType + +func init() { + types.Add("eam:QueryAgent", reflect.TypeOf((*QueryAgent)(nil)).Elem()) +} + +type QueryAgentRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:QueryAgentRequestType", reflect.TypeOf((*QueryAgentRequestType)(nil)).Elem()) +} + +type QueryAgentResponse struct { + Returnval []types.ManagedObjectReference `xml:"returnval,omitempty"` +} + +type QueryConfig QueryConfigRequestType + +func init() { + types.Add("eam:QueryConfig", reflect.TypeOf((*QueryConfig)(nil)).Elem()) +} + +type QueryConfigRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:QueryConfigRequestType", reflect.TypeOf((*QueryConfigRequestType)(nil)).Elem()) +} + +type QueryConfigResponse struct { + Returnval AgencyConfigInfo `xml:"returnval"` +} + +type QueryIssue QueryIssueRequestType + +func init() { + types.Add("eam:QueryIssue", reflect.TypeOf((*QueryIssue)(nil)).Elem()) +} + +type QueryIssueRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + IssueKey []int32 `xml:"issueKey,omitempty"` +} + +func init() { + types.Add("eam:QueryIssueRequestType", reflect.TypeOf((*QueryIssueRequestType)(nil)).Elem()) +} + +type QueryIssueResponse struct { + Returnval []BaseIssue `xml:"returnval,omitempty,typeattr"` +} + +type QuerySolutionId QuerySolutionIdRequestType + +func init() { + types.Add("eam:QuerySolutionId", reflect.TypeOf((*QuerySolutionId)(nil)).Elem()) +} + +type QuerySolutionIdRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:QuerySolutionIdRequestType", reflect.TypeOf((*QuerySolutionIdRequestType)(nil)).Elem()) +} + +type QuerySolutionIdResponse struct { + Returnval string `xml:"returnval"` +} + +type RegisterAgentVm RegisterAgentVmRequestType + +func init() { + types.Add("eam:RegisterAgentVm", reflect.TypeOf((*RegisterAgentVm)(nil)).Elem()) +} + +type RegisterAgentVmRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + AgentVm types.ManagedObjectReference `xml:"agentVm"` +} + +func init() { + types.Add("eam:RegisterAgentVmRequestType", reflect.TypeOf((*RegisterAgentVmRequestType)(nil)).Elem()) +} + +type RegisterAgentVmResponse struct { + Returnval types.ManagedObjectReference `xml:"returnval"` +} + +type Resolve ResolveRequestType + +func init() { + types.Add("eam:Resolve", reflect.TypeOf((*Resolve)(nil)).Elem()) +} + +type ResolveAll ResolveAllRequestType + +func init() { + types.Add("eam:ResolveAll", reflect.TypeOf((*ResolveAll)(nil)).Elem()) +} + +type ResolveAllRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:ResolveAllRequestType", reflect.TypeOf((*ResolveAllRequestType)(nil)).Elem()) +} + +type ResolveAllResponse struct { +} + +type ResolveRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + IssueKey []int32 `xml:"issueKey"` +} + +func init() { + types.Add("eam:ResolveRequestType", reflect.TypeOf((*ResolveRequestType)(nil)).Elem()) +} + +type ResolveResponse struct { + Returnval []int32 `xml:"returnval,omitempty"` +} + +type ScanForUnknownAgentVm ScanForUnknownAgentVmRequestType + +func init() { + types.Add("eam:ScanForUnknownAgentVm", reflect.TypeOf((*ScanForUnknownAgentVm)(nil)).Elem()) +} + +type ScanForUnknownAgentVmRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:ScanForUnknownAgentVmRequestType", reflect.TypeOf((*ScanForUnknownAgentVmRequestType)(nil)).Elem()) +} + +type ScanForUnknownAgentVmResponse struct { +} + +type Uninstall UninstallRequestType + +func init() { + types.Add("eam:Uninstall", reflect.TypeOf((*Uninstall)(nil)).Elem()) +} + +type UninstallRequestType struct { + This types.ManagedObjectReference `xml:"_this"` +} + +func init() { + types.Add("eam:UninstallRequestType", reflect.TypeOf((*UninstallRequestType)(nil)).Elem()) +} + +type UninstallResponse struct { +} + +type UnknownAgentVm struct { + HostIssue + + Vm types.ManagedObjectReference `xml:"vm"` +} + +func init() { + types.Add("eam:UnknownAgentVm", reflect.TypeOf((*UnknownAgentVm)(nil)).Elem()) +} + +type UnregisterAgentVm UnregisterAgentVmRequestType + +func init() { + types.Add("eam:UnregisterAgentVm", reflect.TypeOf((*UnregisterAgentVm)(nil)).Elem()) +} + +type UnregisterAgentVmRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + AgentVm types.ManagedObjectReference `xml:"agentVm"` +} + +func init() { + types.Add("eam:UnregisterAgentVmRequestType", reflect.TypeOf((*UnregisterAgentVmRequestType)(nil)).Elem()) +} + +type UnregisterAgentVmResponse struct { +} + +type Update UpdateRequestType + +func init() { + types.Add("eam:Update", reflect.TypeOf((*Update)(nil)).Elem()) +} + +type UpdateRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + Config AgencyConfigInfo `xml:"config"` +} + +func init() { + types.Add("eam:UpdateRequestType", reflect.TypeOf((*UpdateRequestType)(nil)).Elem()) +} + +type UpdateResponse struct { +} + +type VibCannotPutHostInMaintenanceMode struct { + VibIssue +} + +func init() { + types.Add("eam:VibCannotPutHostInMaintenanceMode", reflect.TypeOf((*VibCannotPutHostInMaintenanceMode)(nil)).Elem()) +} + +type VibCannotPutHostOutOfMaintenanceMode struct { + VibIssue +} + +func init() { + types.Add("eam:VibCannotPutHostOutOfMaintenanceMode", reflect.TypeOf((*VibCannotPutHostOutOfMaintenanceMode)(nil)).Elem()) +} + +type VibDependenciesNotMetByHost struct { + VibNotInstalled +} + +func init() { + types.Add("eam:VibDependenciesNotMetByHost", reflect.TypeOf((*VibDependenciesNotMetByHost)(nil)).Elem()) +} + +type VibInvalidFormat struct { + VibNotInstalled +} + +func init() { + types.Add("eam:VibInvalidFormat", reflect.TypeOf((*VibInvalidFormat)(nil)).Elem()) +} + +type VibIssue struct { + AgentIssue +} + +func init() { + types.Add("eam:VibIssue", reflect.TypeOf((*VibIssue)(nil)).Elem()) +} + +type VibNotInstalled struct { + VibIssue +} + +func init() { + types.Add("eam:VibNotInstalled", reflect.TypeOf((*VibNotInstalled)(nil)).Elem()) +} + +type VibRequirementsNotMetByHost struct { + VibNotInstalled +} + +func init() { + types.Add("eam:VibRequirementsNotMetByHost", reflect.TypeOf((*VibRequirementsNotMetByHost)(nil)).Elem()) +} + +type VibRequiresHostInMaintenanceMode struct { + VibIssue +} + +func init() { + types.Add("eam:VibRequiresHostInMaintenanceMode", reflect.TypeOf((*VibRequiresHostInMaintenanceMode)(nil)).Elem()) +} + +type VibRequiresHostReboot struct { + VibIssue +} + +func init() { + types.Add("eam:VibRequiresHostReboot", reflect.TypeOf((*VibRequiresHostReboot)(nil)).Elem()) +} + +type VibRequiresManualInstallation struct { + VibIssue + + Bulletin []string `xml:"bulletin"` +} + +func init() { + types.Add("eam:VibRequiresManualInstallation", reflect.TypeOf((*VibRequiresManualInstallation)(nil)).Elem()) +} + +type VibRequiresManualUninstallation struct { + VibIssue + + Bulletin []string `xml:"bulletin"` +} + +func init() { + types.Add("eam:VibRequiresManualUninstallation", reflect.TypeOf((*VibRequiresManualUninstallation)(nil)).Elem()) +} + +type VibVibInfo struct { + types.DynamicData + + Id string `xml:"id"` + Name string `xml:"name"` + Version string `xml:"version"` + Vendor string `xml:"vendor"` + Summary string `xml:"summary"` + SoftwareTags *VibVibInfoSoftwareTags `xml:"softwareTags,omitempty"` + ReleaseDate time.Time `xml:"releaseDate"` +} + +func init() { + types.Add("eam:VibVibInfo", reflect.TypeOf((*VibVibInfo)(nil)).Elem()) +} + +type VibVibInfoSoftwareTags struct { + types.DynamicData + + Tags []string `xml:"tags,omitempty"` +} + +func init() { + types.Add("eam:VibVibInfoSoftwareTags", reflect.TypeOf((*VibVibInfoSoftwareTags)(nil)).Elem()) +} + +type VmCorrupted struct { + VmIssue + + MissingFile string `xml:"missingFile,omitempty"` +} + +func init() { + types.Add("eam:VmCorrupted", reflect.TypeOf((*VmCorrupted)(nil)).Elem()) +} + +type VmDeployed struct { + VmIssue +} + +func init() { + types.Add("eam:VmDeployed", reflect.TypeOf((*VmDeployed)(nil)).Elem()) +} + +type VmIssue struct { + AgentIssue + + Vm types.ManagedObjectReference `xml:"vm"` +} + +func init() { + types.Add("eam:VmIssue", reflect.TypeOf((*VmIssue)(nil)).Elem()) +} + +type VmMarkedAsTemplate struct { + VmIssue +} + +func init() { + types.Add("eam:VmMarkedAsTemplate", reflect.TypeOf((*VmMarkedAsTemplate)(nil)).Elem()) +} + +type VmNotDeployed struct { + AgentIssue +} + +func init() { + types.Add("eam:VmNotDeployed", reflect.TypeOf((*VmNotDeployed)(nil)).Elem()) +} + +type VmOrphaned struct { + VmIssue +} + +func init() { + types.Add("eam:VmOrphaned", reflect.TypeOf((*VmOrphaned)(nil)).Elem()) +} + +type VmPoweredOff struct { + VmIssue +} + +func init() { + types.Add("eam:VmPoweredOff", reflect.TypeOf((*VmPoweredOff)(nil)).Elem()) +} + +type VmPoweredOn struct { + VmIssue +} + +func init() { + types.Add("eam:VmPoweredOn", reflect.TypeOf((*VmPoweredOn)(nil)).Elem()) +} + +type VmRequiresHostOutOfMaintenanceMode struct { + VmNotDeployed +} + +func init() { + types.Add("eam:VmRequiresHostOutOfMaintenanceMode", reflect.TypeOf((*VmRequiresHostOutOfMaintenanceMode)(nil)).Elem()) +} + +type VmSuspended struct { + VmIssue +} + +func init() { + types.Add("eam:VmSuspended", reflect.TypeOf((*VmSuspended)(nil)).Elem()) +} + +type VmWrongFolder struct { + VmIssue + + CurrentFolder types.ManagedObjectReference `xml:"currentFolder"` + RequiredFolder types.ManagedObjectReference `xml:"requiredFolder"` +} + +func init() { + types.Add("eam:VmWrongFolder", reflect.TypeOf((*VmWrongFolder)(nil)).Elem()) +} + +type VmWrongResourcePool struct { + VmIssue + + CurrentResourcePool types.ManagedObjectReference `xml:"currentResourcePool"` + RequiredResourcePool types.ManagedObjectReference `xml:"requiredResourcePool"` +} + +func init() { + types.Add("eam:VmWrongResourcePool", reflect.TypeOf((*VmWrongResourcePool)(nil)).Elem()) +} + +type VersionURI string + +func init() { + types.Add("eam:versionURI", reflect.TypeOf((*VersionURI)(nil)).Elem()) +} diff --git a/gen/.gitignore b/gen/.gitignore new file mode 100644 index 000000000..db872fac1 --- /dev/null +++ b/gen/.gitignore @@ -0,0 +1 @@ +sdk/ diff --git a/gen/gen.sh b/gen/gen.sh index 4386a9525..b19611582 100755 --- a/gen/gen.sh +++ b/gen/gen.sh @@ -53,6 +53,17 @@ generate "../vim25" "vim" "./rbvmomi/vmodl.db" # from github.com/vmware/rbvmomi@ generate "../pbm" "pbm" generate "../vslm" "vslm" generate "../sms" "sms" + +# ./sdk/ contains the files eam-messagetypes.xsd and eam-types.xsd from +# eam-wsdl.zip, from eam-vcenter build 17073099 (vSphere 7.0U1), a +# dependency component of the aforementioned vimbase build 17097359. +# +# Please note the EAM files are also available at the following, public URL -- +# http://bit.ly/eam-sdk, therefore the WSDL resource for EAM are in fact +# public. A specific build was obtained in order to match the same build as +# used for the file from above, wsdl.zip. +COPYRIGHT_DATE_RANGE=2021 generate "../eam" "eam" + # originally generated, then manually pruned as there are several vim25 types that are duplicated. # generate "../lookup" "lookup" # lookup.wsdl from build 4571810 # originally generated, then manually pruned. diff --git a/gen/vim_wsdl.rb b/gen/vim_wsdl.rb index ba404cdac..1ea3b440f 100644 --- a/gen/vim_wsdl.rb +++ b/gen/vim_wsdl.rb @@ -866,7 +866,7 @@ def peek def self.header(name) return <