cloudinfo

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package cloudinfo contains functions and methods for searching and detailing various resources located in the IBM Cloud

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudInfoService

type CloudInfoService struct {
	// contains filtered or unexported fields
}

CloudInfoService is a structure that is used as the receiver to many methods in this package. It contains references to other important services and data structures needed to perform these methods.

func NewCloudInfoServiceFromEnv

func NewCloudInfoServiceFromEnv(apiKeyEnv string, options CloudInfoServiceOptions) (*CloudInfoService, error)

NewCloudInfoServiceFromEnv is a factory function used for creating a new initialized service structure. This function can be called if the IBM Cloud API Key should be extracted from an existing OS level environment variable. Returns a pointer to an initialized CloudInfoService and error.

func NewCloudInfoServiceWithKey

func NewCloudInfoServiceWithKey(options CloudInfoServiceOptions) (*CloudInfoService, error)

NewCloudInfoServiceWithKey is a factory function used for creating a new initialized service structure. This function can be called if an IBM Cloud API Key is known and passed in directly. Returns a pointer to an initialized CloudInfoService and error.

func (*CloudInfoService) CreatePowerSession added in v1.1.0

func (infoSvc *CloudInfoService) CreatePowerSession(instanceRegion string) (*ibmpisession.IBMPISession, error)

CreatePowercloudSession will return a PowerPI session object that is tailored to a specific cloud account and region/zone

func (*CloudInfoService) CreatePowercloudConnectionClient added in v1.1.0

func (infoSvc *CloudInfoService) CreatePowercloudConnectionClient(instanceId string, powerSession *ibmpisession.IBMPISession) *ibmpiinstance.IBMPICloudConnectionClient

CreatePowercloudConnectionClient will return a Power PI Connection Client based on an existing session object and a Powercloud instance Id

func (*CloudInfoService) GetAvailableVpcRegions

func (infoSvc *CloudInfoService) GetAvailableVpcRegions() ([]vpcv1.Region, error)

GetAvailableVpcRegions is a method for receiver CloudInfoService that will query the caller account for all regions that support the VPC resource type and are available in the account. Returns an array of vpcv1.Region and error.

func (*CloudInfoService) GetCBRRuleByID added in v1.6.0

func (infoSvc *CloudInfoService) GetCBRRuleByID(ruleID string) (*contextbasedrestrictionsv1.Rule, error)

GetCBRRuleByID gets a rule by its ID using the Context-based Restrictions service

func (*CloudInfoService) GetCBRZoneByID added in v1.6.0

func (infoSvc *CloudInfoService) GetCBRZoneByID(zoneID string) (*contextbasedrestrictionsv1.Zone, error)

GetCBRZoneByID gets a zone by its ID using the Context-based Restrictions service

func (*CloudInfoService) GetLeastPowerConnectionZone added in v1.1.0

func (infoSvc *CloudInfoService) GetLeastPowerConnectionZone() (string, error)

GetLeastPowerConnectionZone is a method for receiver CloudInfoService that will determine a zone (data center) available to the caller account that currently contains the least amount of deployed PowerCloud connections. This determination requires specifying CloudInfoService.regionsData with valid data centers (regions) that are supported by the PowerCloud service. Returns a string representing an IBM Cloud region name, and error.

func (*CloudInfoService) GetLeastVpcTestRegion

func (infoSvc *CloudInfoService) GetLeastVpcTestRegion() (string, error)

GetLeastVpcTestRegion is a method for receiver CloudInfoService that will determine a region available to the caller account that currently contains the least amount of deployed VPCs, using default options. Returns a string representing an IBM Cloud region name, and error.

func (*CloudInfoService) GetLeastVpcTestRegionO added in v1.2.0

func (infoSvc *CloudInfoService) GetLeastVpcTestRegionO(options GetTestRegionOptions) (string, error)

GetLeastVpcTestRegionO is a method for receiver CloudInfoService that will determine a region available to the caller account that currently contains the least amount of deployed VPCs. The determination can be influenced by specifying CloudInfoService.regionsData and supplying appropriate options. If no CloudInfoService.regionsData exists, it will simply loop through all available regions for the caller account and choose a region with lowest VPC count. Returns a string representing an IBM Cloud region name, and error.

func (*CloudInfoService) GetLeastVpcTestRegionWithoutActivityTracker added in v1.2.0

func (infoSvc *CloudInfoService) GetLeastVpcTestRegionWithoutActivityTracker() (string, error)

GetLeastVpcTestRegionWithoutActivityTracker is a method for receiver CloudInfoService that will determine a region available to the caller account that currently contains the least amount of deployed VPCs and does not currently contain an active Activity Tracker instance (can only have one per region). Returns a string representing an IBM Cloud region name, and error.

func (*CloudInfoService) GetTestRegionsByPriority

func (infoSvc *CloudInfoService) GetTestRegionsByPriority() ([]RegionData, error)

GetTestRegionsByPriority is a method for receiver CloudInfoService that will use the service regionsData to determine a priorty order and region eligibility for test resources to be deployed. The returned array will then be used by various methods to determine best region to use for different test scenarios. Returns an array of RegionData struct, and error.

func (*CloudInfoService) GetThreadLock added in v1.2.0

func (infoSvc *CloudInfoService) GetThreadLock() *sync.Mutex

func (*CloudInfoService) HasRegionData added in v1.2.0

func (infoSvc *CloudInfoService) HasRegionData() bool

HasRegionData is a method for receiver CloudInfoService that will respond with a boolean to verify that the service instance has region data loaded. You can use this method to determine if you need to load preference data.

func (*CloudInfoService) ListPowerConnectionsForAccount added in v1.1.0

func (infoSvc *CloudInfoService) ListPowerConnectionsForAccount() ([]*PowerCloudConnectionDetail, error)

ListPowercloudConnectionsForAccount will return an array of CloudConnection that contains all unique connections in the current account (current account determined by API Key used)

func (*CloudInfoService) ListPowerWorkspaceConnections added in v1.1.0

func (infoSvc *CloudInfoService) ListPowerWorkspaceConnections(client ibmPICloudConnectionClient) ([]*ibmpimodels.CloudConnection, error)

ListPowerWorkspaceConnections will return an array of CloudConnection for a given existing connection client NOTE: the client passed into this method is derived from a specific PowerCloud Instance ID and Region/Zone. NOTE 2: the client object parameter is a reference to an interface to allow for unit test mocking

func (*CloudInfoService) ListPowerWorkspaces added in v1.1.0

func (infoSvc *CloudInfoService) ListPowerWorkspaces() ([]resourcecontrollerv2.ResourceInstance, error)

ListPowerWorkspaces will retrieve all PowerCloud parent instances for an account. There is no API to retrieve all Powercloud instances for an account. This function will loop through ALL resources of type "service_instance" in the account and then filter by looking for "power-iaas" in the CRN.

func (*CloudInfoService) ListResourcesByCrnServiceName added in v1.2.0

func (infoSvc *CloudInfoService) ListResourcesByCrnServiceName(crnServiceName string) ([]resourcecontrollerv2.ResourceInstance, error)

ListResourcesByCrnServiceName will retrieve all service instances of a provided type, for an account. This function will loop through ALL resources of type "service_instance" in the account and then filter by looking for the provided service type in the CRN.

func (*CloudInfoService) LoadRegionPrefsFromFile

func (infoSvc *CloudInfoService) LoadRegionPrefsFromFile(filePath string) error

LoadRegionPrefsFromFile is a method for receiver CloudInfoService that will populate the CloudInfoService.regionsData by reading a file in the YAML format. Returns error.

func (*CloudInfoService) LoadRegionsFromVpcAccount

func (infoSvc *CloudInfoService) LoadRegionsFromVpcAccount() error

LoadRegionsFromVpcAccount is a method for receiver CloudInfoService that will populate the CloudInfoService.regionsData by using an API call to retrieve all available regions for the caller account, and assuming all are for test use and same priority. Returns error.

func (*CloudInfoService) RemoveRegionForTest added in v1.2.0

func (infoSvc *CloudInfoService) RemoveRegionForTest(regionID string)

RemoveRegionForTest is a method for receiver CloudInfoService that will remove a given region for use in test considerations by setting the UseForTest property for the region to false

type CloudInfoServiceI added in v1.4.0

type CloudInfoServiceI interface {
	GetLeastVpcTestRegion() (string, error)
	GetLeastVpcTestRegionWithoutActivityTracker() (string, error)
	GetLeastPowerConnectionZone() (string, error)
	LoadRegionPrefsFromFile(string) error
	HasRegionData() bool
	RemoveRegionForTest(string)
	GetThreadLock() *sync.Mutex
}

interface for the cloudinfo service (can be mocked in tests)

type CloudInfoServiceOptions

type CloudInfoServiceOptions struct {
	ApiKey                    string
	Authenticator             *core.IamAuthenticator
	VpcService                vpcService
	ResourceControllerService resourceControllerService
	IamIdentityService        iamIdentityService
	CbrService                cbrService
	RegionPrefs               []RegionData
}

CloudInfoServiceOptions structure used as input params for service constructor.

type GetTestRegionOptions added in v1.2.0

type GetTestRegionOptions struct {
	// exclude a region if it contains an Activity Tracker
	ExcludeActivityTrackerRegions bool
}

func NewGetTestRegionOptions added in v1.2.0

func NewGetTestRegionOptions() *GetTestRegionOptions

NewGetTestRegionOptions will return the option struct with defaults

type PowerCloudConnectionDetail added in v1.1.0

type PowerCloudConnectionDetail struct {
	*ibmpimodels.CloudConnection
	Zone *string
}

extend the CloudConnection struct to add zone (region or datacenter)

type RegionData

type RegionData struct {
	Name          string
	UseForTest    bool `yaml:"useForTest"`
	TestPriority  int  `yaml:"testPriority"`
	Endpoint      string
	Status        string
	ResourceCount int
}

RegionData is a data structure used for holding configurable information about a region. Most of this data is configured by the caller in order to affect certain processing routines.

type SortedRegionsDataByPriority

type SortedRegionsDataByPriority []RegionData

SortedRegionsDataByPriority is an array of RegionData struct that is used as a receiver to implement the sort interface (Len/Less/Swap) with supplied methods to sort the array on the field RegionData.TestPriority.

func (SortedRegionsDataByPriority) Len

func (regions SortedRegionsDataByPriority) Len() int

func (SortedRegionsDataByPriority) Less

func (regions SortedRegionsDataByPriority) Less(i, j int) bool

func (SortedRegionsDataByPriority) Swap

func (regions SortedRegionsDataByPriority) Swap(i, j int)

Jump to

Keyboard shortcuts

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