services

package
v0.0.0-...-cc49d4d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubernetesService

type KubernetesService interface {
	// Lifecycle management
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	HealthCheck(ctx context.Context) error

	// Namespace management for VDCs
	CreateNamespaceForVDC(ctx context.Context, vdc *models.VDC, org *models.Organization) error
	UpdateNamespaceForVDC(ctx context.Context, vdc *models.VDC, org *models.Organization) error
	DeleteNamespaceForVDC(ctx context.Context, vdc *models.VDC) error
	EnsureNamespaceForVDC(ctx context.Context, vdc *models.VDC, org *models.Organization) error

	// Template instantiation support
	GetTemplate(ctx context.Context, name string) (*TemplateInfo, error)

	// Template instantiation
	CreateTemplateInstance(ctx context.Context, req *TemplateInstanceRequest) (*TemplateInstanceResult, error)
	GetTemplateInstance(ctx context.Context, namespace, name string) (*TemplateInstanceStatus, error)
	DeleteTemplateInstance(ctx context.Context, namespace, name string) error

	// Resource management
	EnsureNamespaceResources(ctx context.Context, namespace string, vdc *models.VDC) error

	// Client access for power management operations
	GetClient() client.Client
}

KubernetesService provides Kubernetes operations for SSVirt

func NewKubernetesService

func NewKubernetesService(templateNamespace string, logger Logger) (KubernetesService, error)

NewKubernetesService creates a new Kubernetes service

type KubernetesServiceInterface

type KubernetesServiceInterface interface {
	KubernetesService
}

KubernetesServiceInterface defines the interface for Kubernetes operations

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Logger interface for structured logging

type TemplateInfo

type TemplateInfo struct {
	Name        string            `json:"name"`
	DisplayName string            `json:"displayName"`
	Description string            `json:"description"`
	IconClass   string            `json:"iconClass,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Parameters  []TemplateParam   `json:"parameters"`
	Objects     []TemplateObject  `json:"objects"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

TemplateInfo represents an OpenShift template available for instantiation

type TemplateInstanceCond

type TemplateInstanceCond struct {
	Type    string `json:"type"`
	Status  string `json:"status"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

TemplateInstanceCond represents a condition of template instantiation

type TemplateInstanceObj

type TemplateInstanceObj struct {
	Ref corev1.ObjectReference `json:"ref"`
}

TemplateInstanceObj represents an object created by template instantiation

type TemplateInstanceParam

type TemplateInstanceParam struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

TemplateInstanceParam represents a parameter for template instantiation

type TemplateInstanceRequest

type TemplateInstanceRequest struct {
	TemplateName string                  `json:"templateName"`
	Namespace    string                  `json:"namespace"`
	Name         string                  `json:"name"`
	Parameters   []TemplateInstanceParam `json:"parameters,omitempty"`
	Labels       map[string]string       `json:"labels,omitempty"`
}

TemplateInstanceRequest represents a request to instantiate a template

type TemplateInstanceResult

type TemplateInstanceResult struct {
	Name      string                 `json:"name"`
	Namespace string                 `json:"namespace"`
	Status    TemplateInstanceStatus `json:"status"`
}

TemplateInstanceResult represents the result of template instantiation

type TemplateInstanceStatus

type TemplateInstanceStatus struct {
	Phase      string                 `json:"phase"`
	Message    string                 `json:"message,omitempty"`
	Objects    []TemplateInstanceObj  `json:"objects,omitempty"`
	Conditions []TemplateInstanceCond `json:"conditions,omitempty"`
}

TemplateInstanceStatus represents the status of a template instance

type TemplateMapper

type TemplateMapper struct{}

TemplateMapper handles conversion between OpenShift Templates and CatalogItems

func (*TemplateMapper) ExtractResourceRequirements

func (m *TemplateMapper) ExtractResourceRequirements(template *templatev1.Template) (cpus int, memory int64, storage int64)

ExtractResourceRequirements extracts CPU, memory, and storage requirements from template parameters

func (*TemplateMapper) ExtractVMCount

func (m *TemplateMapper) ExtractVMCount(template *templatev1.Template) int

ExtractVMCount counts the number of VM objects in the template

func (*TemplateMapper) TemplateToCatalogItem

func (m *TemplateMapper) TemplateToCatalogItem(template *templatev1.Template, catalogID string) *models.CatalogItem

TemplateToCatalogItem converts an OpenShift Template to a CatalogItem

type TemplateObject

type TemplateObject struct {
	Kind       string            `json:"kind"`
	APIVersion string            `json:"apiVersion"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

TemplateObject represents an object in a template

type TemplateParam

type TemplateParam struct {
	Name        string `json:"name"`
	DisplayName string `json:"displayName,omitempty"`
	Description string `json:"description,omitempty"`
	Value       string `json:"value,omitempty"`
	Generate    string `json:"generate,omitempty"`
	From        string `json:"from,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

TemplateParam represents a template parameter

type TemplateService

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

TemplateService provides access to OpenShift Templates via Kubernetes client

func NewTemplateService

func NewTemplateService() (*TemplateService, error)

NewTemplateService creates a new TemplateService with caching client

func (*TemplateService) CountCatalogItems

func (s *TemplateService) CountCatalogItems(ctx context.Context, catalogID string) (int64, error)

CountCatalogItems returns the total count of catalog items for the specified catalog

func (*TemplateService) GetCatalogItem

func (s *TemplateService) GetCatalogItem(ctx context.Context, catalogID, itemID string) (*models.CatalogItem, error)

GetCatalogItem returns a specific catalog item by ID

func (*TemplateService) ListCatalogItems

func (s *TemplateService) ListCatalogItems(ctx context.Context, catalogID string, limit, offset int) ([]models.CatalogItem, error)

ListCatalogItems returns catalog items for the specified catalog with pagination

func (*TemplateService) Start

func (s *TemplateService) Start(ctx context.Context) error

Start starts the cache

type TemplateServiceInterface

type TemplateServiceInterface interface {
	ListCatalogItems(ctx context.Context, catalogID string, limit, offset int) ([]models.CatalogItem, error)
	CountCatalogItems(ctx context.Context, catalogID string) (int64, error)
	GetCatalogItem(ctx context.Context, catalogID, itemID string) (*models.CatalogItem, error)
	Start(ctx context.Context) error
}

TemplateServiceInterface defines the interface for template service operations

Jump to

Keyboard shortcuts

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