appliance

package
v0.0.0-...-f23cdb6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//lint:file-ignore U1000 All available upgrade statuses
	UpgradeStatusIdle        = "idle"
	UpgradeStatusStarted     = "started"
	UpgradeStatusDownloading = "downloading"
	UpgradeStatusVerifying   = "verifying"
	UpgradeStatusReady       = "ready"
	UpgradeStatusInstalling  = "installing"
	UpgradeStatusSuccess     = "success"
	UpgradeStatusFailed      = "failed"

	FileReady  = "Ready"
	FileFailed = "Failed"
)
View Source
const (
	SkipReasonNotPrepared            = "appliance is not prepared for upgrade"
	SkipReasonOffline                = "appliance is offline"
	SkipReasonFiltered               = "filtered using the '--include' and/or '--exclude' flag"
	SkipReasonAlreadyPrepared        = "appliance is already prepared for upgrade with a higher or equal version"
	SkipReasonUnsupportedUpgradePath = "Upgrading from version 6.0.0 to version 6.2.x is unsupported. Version 6.0.1 or later is required."
)
View Source
const (
	IsLower   = -1
	IsEqual   = 0
	IsGreater = 1
)
View Source
const (
	MajorVersion = uint8(4)
	MinorVersion = uint8(2)
	PatchVersion = uint8(1)
)
View Source
const (
	FunctionController   = "Controller"
	FunctionGateway      = "Gateway"
	FunctionPortal       = "Portal"
	FunctionConnector    = "Connector"
	FunctionLogServer    = "LogServer"
	FunctionLogForwarder = "LogForwarder"
	FilterDelimiter      = "&"
)
View Source
const (
	PrimaryUpgrade IsPrimaryUpgrade = "IsPrimaryUpgrade"
	Caller         CalledAs         = "calledAs"
)

Variables

View Source
var (
	DefaultBackupDestination = filesystem.BackupDir()
)
View Source
var DefaultCommandFilter = map[string]map[string]string{
	"include": {},
	"exclude": {},
}
View Source
var StatReady = []string{
	statControllerReady,
	statSingleControllerReady,
	statMultiControllerReady,
	statApplianceReady,
}
View Source
var StatusNotBusy = []string{
	statusHealthy,
	statusWarning,
	statusError,
	statusNotAvailable,
	statusOffline,
}

Functions

func ActiveFunctions

func ActiveFunctions(appliances []openapi.Appliance) map[string]bool

ActiveFunctions returns a map of all active functions in the appliances.

func AppendUniqueAppliance

func AppendUniqueAppliance(appliances []openapi.Appliance, appliance openapi.Appliance) []openapi.Appliance

func AutoscalingGateways

func AutoscalingGateways(appliances []openapi.Appliance) (*openapi.Appliance, []openapi.Appliance)

AutoscalingGateways return the template appliance and all gateways

func BackupPrompt

func BackupPrompt(appliances []openapi.Appliance, preSelected []openapi.Appliance) ([]openapi.Appliance, error)

func ChunkApplianceGroup

func ChunkApplianceGroup(chunkSize int, applianceGroups map[int][]openapi.Appliance) [][]openapi.Appliance

ChunkApplianceGroup separates the result from SplitAppliancesByGroup into different slices based on the appliance functions and site configuration

func CleanupBackup

func CleanupBackup(opts *BackupOpts, IDs map[string]string) error

func CompareVersionsAndBuildNumber

func CompareVersionsAndBuildNumber(x, y *version.Version) (int, error)

CompareVersionsAndBuildNumber compares two versions and returns the result with an integer representation -1 if y is lower than x 0 if versions match 1 if y is greater than x

func DownloadDockerBundles

func DownloadDockerBundles(ctx context.Context, p *tui.Progress, client *http.Client, path string, registry *url.URL, images map[string]string, ciMode bool) (*os.File, error)

func FilterAppliances

func FilterAppliances(appliances []openapi.Appliance, filter map[string]map[string]string, orderBy []string, descending bool) ([]openapi.Appliance, []openapi.Appliance, error)

func FilterAvailable

func FilterAvailable(appliances []openapi.Appliance, stats []openapi.StatsAppliancesListAllOfData) ([]openapi.Appliance, []openapi.Appliance, error)

FilterAvailable return lists of online, offline, errors that will be used during upgrade

func FindCurrentController

func FindCurrentController(appliances []openapi.Appliance, hostname string) (*openapi.Appliance, error)

func FindPrimaryController

func FindPrimaryController(appliances []openapi.Appliance, hostname string, validate bool) (*openapi.Appliance, error)

FindPrimaryController The given hostname should match one of the Controller's actual admin hostname. Hostnames should be compared in a case insensitive way.

func GetActiveFunctions

func GetActiveFunctions(appliance openapi.Appliance) []string

func GetApplianceVersion

func GetApplianceVersion(appliance openapi.Appliance, stats openapi.StatsAppliancesList) (*version.Version, error)

func GroupByFunctions

func GroupByFunctions(appliances []openapi.Appliance) map[string][]openapi.Appliance

GroupByFunctions group appliances by function

func HasDiffVersions

func HasDiffVersions(stats []openapi.StatsAppliancesListAllOfData) (bool, map[string]string)

func IsMajorUpgrade

func IsMajorUpgrade(current, next *version.Version) bool

func IsMinorUpgrade

func IsMinorUpgrade(current, next *version.Version) bool

func IsOnAppliance

func IsOnAppliance() bool

func IsPatchUpgrade

func IsPatchUpgrade(current, next *version.Version) bool

func NeedsMultiControllerUpgrade

func NeedsMultiControllerUpgrade(upgradeStatuses map[string]UpgradeStatusResult, initialStatData []openapi.StatsAppliancesListAllOfData, all, preparing []openapi.Appliance, majorOrMinor bool) (bool, error)

func ParseVersionFromZip

func ParseVersionFromZip(filename string) (*version.Version, error)

func ParseVersionString

func ParseVersionString(input string) (*version.Version, error)

ParseVersionString tries to determine appliance version based on the input filename, It assumes the file is has the standard naming convention of appgate-5.4.4-26245-release.img.zip where 5.4.4 is the semver of the appliance.

func PerformBackup

func PerformBackup(cmd *cobra.Command, args []string, opts *BackupOpts) (map[string]string, error)

func PrepareBackup

func PrepareBackup(opts *BackupOpts) error

func PrettyBytes

func PrettyBytes(v float64) string

func PrintDiskSpaceWarningMessage

func PrintDiskSpaceWarningMessage(out io.Writer, stats []openapi.StatsAppliancesListAllOfData, apiVersion int)

func PromptSelect

func PromptSelect(ctx context.Context, a *Appliance, filter map[string]map[string]string, orderBy []string, descending bool) (string, error)

PromptSelect from online appliances

func PromptSelectAll

func PromptSelectAll(ctx context.Context, a *Appliance, filter map[string]map[string]string, orderBy []string, descending bool) (string, error)

PromptSelectAll from all appliances, offline and online

func ShouldDisable

func ShouldDisable(from, to *version.Version) bool

func ShowAutoscalingWarningMessage

func ShowAutoscalingWarningMessage(templateAppliance *openapi.Appliance, gateways []openapi.Appliance) (string, error)

func SpecificVersionChecks

func SpecificVersionChecks(current, future *version.Version) error

func SplitAppliancesByGroup

func SplitAppliancesByGroup(appliances []openapi.Appliance) map[int][]openapi.Appliance

SplitAppliancesByGroup return a map of slices of appliances based on their active function and site. e.g All active gateways in the same site are grouped together.

func StatsIsOnline

func StatsIsOnline(s openapi.StatsAppliancesListAllOfData) bool

StatsIsOnline will return true if the Controller reports the appliance to be online in a valid status

func ValidateHostname

func ValidateHostname(controller openapi.Appliance, hostname string) error

Types

type Appliance

type Appliance struct {
	APIClient           *openapi.APIClient
	HTTPClient          *http.Client
	Token               string
	UpgradeStatusWorker WaitForUpgradeStatus
	ApplianceStats      WaitForApplianceStatus
}

Appliance is a wrapper around the APIClient for common functions around the appliance API that will be used within several commands.

func (*Appliance) ApplianceSwitchPartition

func (a *Appliance) ApplianceSwitchPartition(ctx context.Context, id string) error

func (*Appliance) DeleteFile

func (a *Appliance) DeleteFile(ctx context.Context, filename string) error

DeleteFile Delete a File from the current Controller.

func (*Appliance) DisableController

func (a *Appliance) DisableController(ctx context.Context, id string, appliance openapi.Appliance) error

func (*Appliance) DisableMaintenanceMode

func (a *Appliance) DisableMaintenanceMode(ctx context.Context, id string) (string, error)

func (*Appliance) EnableController

func (a *Appliance) EnableController(ctx context.Context, id string, appliance openapi.Appliance) error

func (*Appliance) EnableMaintenanceMode

func (a *Appliance) EnableMaintenanceMode(ctx context.Context, id string) (string, error)

func (*Appliance) FileStatus

func (a *Appliance) FileStatus(ctx context.Context, filename string) (*openapi.File, error)

FileStatus Get the status of a File uploaded to the current Controller.

func (*Appliance) Get

func (a *Appliance) Get(ctx context.Context, applianceID string) (*openapi.Appliance, error)

Get return a single appliance based on applianceID

func (*Appliance) List

func (a *Appliance) List(ctx context.Context, filter map[string]map[string]string, orderBy []string, descending bool) ([]openapi.Appliance, error)

List from the Collective Filter is applied in app after getting all the appliances because the auto generated API screws up the 'filterBy' command

func (*Appliance) ListFiles

func (a *Appliance) ListFiles(ctx context.Context, orderBy []string, descending bool) ([]openapi.File, error)

func (*Appliance) PrepareFileOn

func (a *Appliance) PrepareFileOn(ctx context.Context, filename, id string, devKeyring bool) (string, error)

func (*Appliance) RepartitionIPAllocations

func (a *Appliance) RepartitionIPAllocations(ctx context.Context) (string, error)

func (*Appliance) Stats

func (a *Appliance) Stats(ctx context.Context, filter map[string]map[string]string, orderBy []string, descending bool) (*openapi.StatsAppliancesList, *http.Response, error)

func (*Appliance) UpdateAppliance

func (a *Appliance) UpdateAppliance(ctx context.Context, id string, appliance openapi.Appliance) error

func (*Appliance) UpdateMaintenanceMode

func (a *Appliance) UpdateMaintenanceMode(ctx context.Context, id string, value bool) (string, error)

func (*Appliance) UpgradeCancel

func (a *Appliance) UpgradeCancel(ctx context.Context, applianceID string) error

func (*Appliance) UpgradeComplete

func (a *Appliance) UpgradeComplete(ctx context.Context, id string, SwitchPartition bool) error

func (*Appliance) UpgradeStatus

func (a *Appliance) UpgradeStatus(ctx context.Context, applianceID string) (*openapi.AppliancesIdUpgradeDelete200Response, error)

func (*Appliance) UpgradeStatusMap

func (a *Appliance) UpgradeStatusMap(ctx context.Context, appliances []openapi.Appliance) (map[string]UpgradeStatusResult, error)

UpgradeStatusMap return a map with appliance.id, UpgradeStatusResult

func (*Appliance) UpgradeStatusRetry

func (a *Appliance) UpgradeStatusRetry(ctx context.Context, applianceID string) (*openapi.AppliancesIdUpgradeDelete200Response, error)

func (*Appliance) UpgradeSwitchPartition

func (a *Appliance) UpgradeSwitchPartition(ctx context.Context, id string) error

func (*Appliance) UploadFile

func (a *Appliance) UploadFile(ctx context.Context, r io.Reader, headers map[string]string) error

UploadFile directly to the current Controller. Note that the File is stored only on the current Controller, not synced between Controllers.

func (*Appliance) UploadToController

func (a *Appliance) UploadToController(ctx context.Context, url, filename string) error

func (*Appliance) ZTPStatus

func (a *Appliance) ZTPStatus(ctx context.Context) (*openapi.ZtpStatus, error)

func (*Appliance) ZTPUpdateNotify

func (a *Appliance) ZTPUpdateNotify(ctx context.Context) (*openapi.ZtpVersionStatus, error)

type ApplianceStatus

type ApplianceStatus struct {
	Appliance *Appliance
}

func (*ApplianceStatus) WaitForApplianceState

func (u *ApplianceStatus) WaitForApplianceState(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error

func (*ApplianceStatus) WaitForApplianceStatus

func (u *ApplianceStatus) WaitForApplianceStatus(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error

type BackupOpts

type BackupOpts struct {
	Config        *configuration.Config
	Appliance     func(*configuration.Config) (*Appliance, error)
	Out           io.Writer
	SpinnerOut    func() io.Writer
	Destination   string
	With          []string
	AllFlag       bool
	PrimaryFlag   bool
	CurrentFlag   bool
	NoInteractive bool
	FilterFlag    map[string]map[string]string
	OrderBy       []string
	Descending    bool
	Quiet         bool
	CiMode        bool
}

type CalledAs

type CalledAs string

type DockerManifest

type DockerManifest struct {
	SchemaVersion int
	MediaType     string
	Config        ManifestConfig
	Layers        []ManifestConfig
}

type ImageJSON

type ImageJSON struct {
	Image string `json:"image"`
}

type IsPrimaryUpgrade

type IsPrimaryUpgrade string

type ManifestConfig

type ManifestConfig struct {
	MediaType string
	Size      int
	Digest    string
}

type SkipUpgrade

type SkipUpgrade struct {
	Reason    string
	Appliance openapi.Appliance
}

func CheckVersions

func CheckVersions(ctx context.Context, stats openapi.StatsAppliancesList, appliances []openapi.Appliance, v *version.Version) ([]openapi.Appliance, []SkipUpgrade)

CheckVersions will check if appliance versions are equal to the version being uploaded on all appliances Returns a slice of appliances that are not equal, a slice of appliances that have the same version and an error

func (SkipUpgrade) Error

func (su SkipUpgrade) Error() string

type UpgradeStatus

type UpgradeStatus struct {
	Appliance *Appliance
}

func (*UpgradeStatus) WaitForUpgradeStatus

func (u *UpgradeStatus) WaitForUpgradeStatus(ctx context.Context, appliance openapi.Appliance, desiredStatuses []string, undesiredStatuses []string, tracker *tui.Tracker) error

type UpgradeStatusResult

type UpgradeStatusResult struct {
	Status, Details, Name string
}

type WaitForApplianceStatus

type WaitForApplianceStatus interface {
	WaitForApplianceState(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error
	// WaitForStatus tries appliance stats until the appliance has want status or it reaches the timeout
	WaitForApplianceStatus(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error
}

type WaitForUpgradeStatus

type WaitForUpgradeStatus interface {
	// WaitForUpgradeStatus does exponential backoff retries on upgrade status until it reaches a desiredStatuses and reports it to current <- string
	WaitForUpgradeStatus(ctx context.Context, appliance openapi.Appliance, desiredStatuses []string, undesiredStatuses []string, tracker *tui.Tracker) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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