vsphere

package
v0.0.0-...-c48caec Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDatastores

func GetDatastores(sess *session.Session, datacenter *object.Datacenter) ([]*object.Datastore, error)

Types

type ClusterContext

type ClusterContext struct {
	NumCpuCores int16
	TotalMemory int64
}

type DatacenterContext

type DatacenterContext struct {
	ClusterContexts   map[string]ClusterContext
	PortGroupContexts map[string]PortGroupContext
}

type Metadata

type Metadata struct {
	VCenterContexts map[string]VCenterContext

	VCenterCredentials map[string]VCenterCredential
	// contains filtered or unexported fields
}

Metadata holds vcenter stuff.

func NewMetadata

func NewMetadata() *Metadata

NewMetadata initializes a new Metadata object.

func (*Metadata) AddCredentials

func (m *Metadata) AddCredentials(server, username, password string) (*session.Params, error)

AddCredentials creates a session param from the vCenter server, username and password to the Credentials Map.

func (*Metadata) FindVCenterVirtualMachine

func (m *Metadata) FindVCenterVirtualMachine(server string) (*mo.VirtualMachine, error)

func (*Metadata) GetClusterByPath

func (m *Metadata) GetClusterByPath(server, path string) (*object.ClusterComputeResource, error)

func (*Metadata) GetClusterCapacity

func (m *Metadata) GetClusterCapacity(server string, cluster *object.ClusterComputeResource) (int16, int64, error)

func (*Metadata) GetClusters

func (m *Metadata) GetClusters(sess *session.Session, datacenter *object.Datacenter) ([]*object.ClusterComputeResource, error)

func (*Metadata) GetDatacenterByPath

func (m *Metadata) GetDatacenterByPath(server, path string) (*object.Datacenter, error)

func (*Metadata) GetDatacenters

func (m *Metadata) GetDatacenters(server string) ([]*object.Datacenter, error)

func (*Metadata) GetDistributedPortGroups

func (m *Metadata) GetDistributedPortGroups(server, portGroupSubString string) ([]mo.DistributedVirtualPortgroup, error)

func (*Metadata) GetFailureDomainsViaTag

func (m *Metadata) GetFailureDomainsViaTag(server string) (*[]v1.VSpherePlatformFailureDomainSpec, error)

func (*Metadata) GetHostnameUrlVpxd

func (m *Metadata) GetHostnameUrlVpxd(server string) (*string, error)
func (m *Metadata) GetTopologyByTags(server string, objectID []mo.Reference) error {
	var openshiftZoneTagCatId string
	var openshiftRegionTagCatId string

	ctx, cancel := context.WithTimeout(context.TODO(), timeout)
	defer cancel()

	sess, err := m.Session(ctx, server)
	if err != nil {
		return err
	}

	err = m.GetTagCategories(server)
	if err != nil {
		return err
	}

	attachedTags, err := sess.TagManager.GetAttachedTagsOnObjects(ctx, objectID)
	if err != nil {
		return err
	}

	for _, tc := range m.VCenterContexts[server].TagCategories {
		if tc.Name == openshiftZoneTagCatName {
			openshiftZoneTagCatId = tc.ID
		}
		if tc.Name == openshiftRegionTagCatName {
			openshiftRegionTagCatId = tc.ID
		}
	}

	for _, atag := range attachedTags {
		for _, tag := range atag.Tags {
			if tag.CategoryID == openshiftZoneTagCatId {

				log.Print(tag.Name)
				log.Print(atag.ObjectID)

			}
			if tag.CategoryID == openshiftRegionTagCatId {

			}
		}
	}

	return nil
}

func (*Metadata) GetPortGroupVlanFromMoRef

func (m *Metadata) GetPortGroupVlanFromMoRef(networks []types.ManagedObjectReference, server string) ([]int32, error)

func (*Metadata) GetPortGroups

func (m *Metadata) GetPortGroups(server string, datacenter *object.Datacenter) ([]*mo.DistributedVirtualPortgroup, error)

func (*Metadata) GetTagCategories

func (m *Metadata) GetTagCategories(server string) error

func (*Metadata) Session

func (m *Metadata) Session(ctx context.Context, server string) (*session.Session, error)

Session returns a session from unlockedSession based on the server (vCenter URL).

type PortGroupContext

type PortGroupContext struct {
	VlanId int16
}

type VCenterContext

type VCenterContext struct {
	VCenter            string
	DatacenterContexts map[string]DatacenterContext
	IPAddresses        []net.IP
	TagCategories      []tags.Category
}

VCenterContext maintains context of known vCenters to be used in CAPI manifest reconciliation.

type VCenterCredential

type VCenterCredential struct {
	Username string
	Password string
}

VCenterCredential contains the vCenter username and password.

Jump to

Keyboard shortcuts

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