operation

package
v0.0.0-...-b908e55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package operation contains all vCenter objects related operation. Author : Smruti P Mohanty

Copyright (c) 2017 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClusterData

func GetClusterData(ctx context.Context, pc *property.Collector, clst mo.ClusterComputeResource, clus chan ClusterStruct, getvm bool)

GetClusterData is used by getvcinventory in example. It Returns Clusters and its child object. Do not change this sample.

func GetVMData

func GetVMData(ctx context.Context, pc *property.Collector, hst mo.HostSystem, vmchan chan []VMStruct)

GetVMData is used by getvcinventory in example. It Returns VM Objects and its power state.

func WalkFolder

WalkFolder is used to Walk the Folder of a Inventory Object

func WalkManagedEntity

func WalkManagedEntity(childEntity types.ManagedObjectReference) (bool, bool)

WalkManagedEntity is used to Walk through the child entity of a Managed ENtity

Types

type ClusterOperation

type ClusterOperation struct {
	Context context.Context
	Vcenter *VCenter
}

ClusterOperation is the Reciever Object For all Cluster Operation

func (*ClusterOperation) GetAllClusterHosts

func (cops *ClusterOperation) GetAllClusterHosts(clst mo.ClusterComputeResource, powerstate string) ([]mo.HostSystem, error)

GetAllClusterHosts Returns all the Hosts in a given Cluster Object.

type ClusterStruct

type ClusterStruct struct {
	Cluster string
	Hosts   []HostStruct
}

ClusterStruct is used for storing Cluster Name and the Arrays of Host Name within the cluster.

type DatacenterOperation

type DatacenterOperation struct {
	Context context.Context
	Vcenter *VCenter
}

DatacenterOperation is the Reciever Object For all Datacenter Operation

func (*DatacenterOperation) CreateCluster

func (dcops *DatacenterOperation) CreateCluster(datacenter *object.Datacenter, clustername string) (*object.ClusterComputeResource, error)

CreateCluster creates a Cluster under a specified datacenter object.

func (*DatacenterOperation) GetAllCluster

func (dcops *DatacenterOperation) GetAllCluster(datacenter *object.Datacenter) ([]mo.ClusterComputeResource, error)

GetAllCluster Returns all the cluster object under a data center

func (*DatacenterOperation) GetCluster

func (dcops *DatacenterOperation) GetCluster(clustername string) (mo.ClusterComputeResource, error)

GetCluster Returns cluster object under a data center when a cluster name is passed to it.

func (*DatacenterOperation) GetHostFolder

func (dcops *DatacenterOperation) GetHostFolder(datacenter *object.Datacenter) *object.Folder

GetHostFolder Returns the HostFolder of a Datacenter. Used for Creation of Cluster and Addition of standalone Hosts.

func (*DatacenterOperation) GetStandAloneHosts

func (dcops *DatacenterOperation) GetStandAloneHosts(datacenter *object.Datacenter) []mo.HostSystem

GetStandAloneHosts Returns all the Standalone Hosts Objects in a Cluster

type HostOperation

type HostOperation struct {
	Context context.Context
	Vcenter *VCenter
}

HostOperation is the Reciever Object For all Host Operation

func (*HostOperation) GetAllVMs

func (hostops *HostOperation) GetAllVMs(hst mo.HostSystem) ([]mo.VirtualMachine, error)

GetAllVMs Returns All VMs Objects in a Host Object

type HostStruct

type HostStruct struct {
	Hostname   string
	Connection string
	Vms        []VMStruct
}

HostStruct is used to store Hostname, its powerstate and the VMs that it contains.

type VCenter

type VCenter struct {
	Hostname string
	Username string
	Password string
	Client   *govmomi.Client
}

VCenter represents a vCenter server

func NewVCenter

func NewVCenter(hostname string, username string, password string) *VCenter

NewVCenter returns a new VCenter instance

func (*VCenter) Connect

func (vcenter *VCenter) Connect(ctx context.Context) error

Connect object is used to connect vCenter

func (*VCenter) CreateDataCenter

func (vcenter *VCenter) CreateDataCenter(ctx context.Context, dcname string) (*object.Datacenter, error)

CreateDataCenter creates a datacenter and returns a datacenter object

func (*VCenter) GetAllDatacenter

func (vcenter *VCenter) GetAllDatacenter(ctx context.Context) ([]*object.Datacenter, error)

GetAllDatacenter Returns all the datacenter in a Given vCenter. The vCenter reciever must be connected using vcenter.Connect(ctx) where ctx is the context of type context.Context

func (*VCenter) GetDatacenter

func (vcenter *VCenter) GetDatacenter(ctx context.Context, dcname string) (*object.Datacenter, error)

GetDatacenter Returns datacenter object when a datacenter name in a Given vCenter is passed to it. The vCenter reciever must be connected using vcenter.Connect(ctx) where ctx is the context of type context.Context

type VMOperation

type VMOperation struct {
	Context context.Context
	Vcenter *VCenter
}

VMOperation is the Reciever Object For all VM Operation

func (*VMOperation) CloneVM

func (vmops *VMOperation) CloneVM(newVMName string, poweron bool, host *mo.HostSystem, template *object.VirtualMachine, cluster *mo.ClusterComputeResource, datacenter *object.Datacenter, datastore *mo.Datastore) (*object.VirtualMachine, types.TaskInfoState)

CloneVM Clones a VM

type VMStruct

type VMStruct struct {
	VMName     string
	PowerState string
}

VMStruct contains the VM name and Its power State.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL