Documentation
¶
Overview ¶
Package azure provides direct Azure API call utilities for cases where CB-Spider is too slow or does not provide adequate functionality.
Index ¶
- Constants
- func BatchDescribeInstanceStatuses(ctx context.Context, region string, instanceIds []string) (map[string]string, error)
- func BatchUpsertTags(ctx context.Context, region, zone, cspResourceId, resourceType string, ...) error
- func FetchNodePricesByRegion(region string) (model.SpiderCloudPrice, error)
- func GetImage(ctx context.Context, region, urn string) (model.SpiderImageInfo, error)
- func ListImages(ctx context.Context, region string) ([]model.SpiderImageInfo, error)
- func ResolveLatestUrn(ctx context.Context, region, publisher, offer, sku string) (string, string, error)
- type PublisherFilterConfig
- type SpecCheckResult
Constants ¶
const (
DEBUG_AZURE_IMAGE = false // Set to true for detailed timing and progress debugging
)
Variables ¶
This section is empty.
Functions ¶
func BatchDescribeInstanceStatuses ¶ added in v0.12.9
func BatchDescribeInstanceStatuses(ctx context.Context, region string, instanceIds []string) (map[string]string, error)
BatchDescribeInstanceStatuses queries Azure Compute for the given VM ARM resource IDs and returns a map of armResourceID → TB status string.
VMs are fetched in parallel (up to azureStatusConcurrency concurrent calls) using individual Get calls with InstanceView expansion (which returns the power state). Azure has no batch-status API in the standard SDK.
func BatchUpsertTags ¶
func BatchUpsertTags(ctx context.Context, region, zone, cspResourceId, resourceType string, tags map[string]string) error
BatchUpsertTags merges multiple tags onto an Azure ARM resource in a single PATCH call. The region parameter is unused for Azure (ARM Tags API uses the full resource ID scope). The cspResourceId must be the full ARM resource ID (e.g., "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachines/{name}").
func FetchNodePricesByRegion ¶
func FetchNodePricesByRegion(region string) (model.SpiderCloudPrice, error)
FetchNodePricesByRegion fetches Azure VM prices directly from Azure Retail Prices API. It returns only fields required by cb-tumblebug's current spec price update flow.
func GetImage ¶
GetImage fetches a specific Azure VM image by URN format (publisher:offer:sku:version). Used for lookups of pre-identified images without full enumeration.
func ListImages ¶
ListImages fetches Azure VM images directly from Azure ARM API. It returns one latest version per (publisher, offer, sku), following Spider's behavior.
func ResolveLatestUrn ¶ added in v0.12.7
func ResolveLatestUrn(ctx context.Context, region, publisher, offer, sku string) (string, string, error)
ResolveLatestUrn returns the URN of the latest available image version for the given Azure (publisher, offer, sku) tuple in the specified region. Returns the full URN "publisher:offer:sku:<latestVersion>" and the version string. The input version (if any) is irrelevant; this lookup always picks the highest-sorted version (Azure VirtualMachineImagesClient.List with "name desc", top=1).
Returns an error if the SDK call fails or no version is available.
Types ¶
type PublisherFilterConfig ¶
type PublisherFilterConfig struct {
PublisherFiltering struct {
Enabled bool `yaml:"enabled"`
Strategy string `yaml:"strategy"` // "whitelist" or "blacklist"
} `yaml:"publisherFiltering"`
WhitelistedPublishers []string `yaml:"whitelistedPublishers"`
BlacklistedPatterns []string `yaml:"blacklistedPatterns"`
Debug struct {
LogFilteredPublishers bool `yaml:"logFilteredPublishers"`
LogIncludedPublishers bool `yaml:"logIncludedPublishers"`
} `yaml:"debug"`
}
PublisherFilterConfig represents the publisher filtering configuration from YAML
type SpecCheckResult ¶
type SpecCheckResult struct {
Available bool // true if the spec can be provisioned
Reason string // human-readable reason when not available
VCPUs int32 // vCPU count required by this spec
QuotaFamily string // vCPU family name (e.g., "standardDSv3Family")
QuotaCurrent int64 // current vCPU usage in this family
QuotaLimit int64 // vCPU limit for this family
}
SpecCheckResult holds the detailed result of an Azure spec availability check.
func CheckSpecAvailability ¶
func CheckSpecAvailability(ctx context.Context, region, nodeSize string) (*SpecCheckResult, error)
CheckSpecAvailability checks whether a given Azure VM spec is available in the specified region by checking both SKU restrictions (including opt-in / subscription-level) and vCPU quota.