platform

package
v2.272.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArpIterations          = 20
	ArpIterationDelay      = 5 * time.Second
	ArpInterfaceCheckDelay = 100 * time.Millisecond
)
View Source
const (
	OsErrorFileInUse     = syscall.Errno(0x20)
	OsErrorFileNotFound2 = syscall.Errno(0x2)
	OsErrorFileNotFound3 = syscall.Errno(0x3)
)
View Source
const CredentialFileName = "password"
View Source
const EtcHostsFileName = "etc_hosts"
View Source
const EtcHostsTemplate = `` /* 247-byte string literal not displayed */
View Source
const (
	SigarStatsCollectionInterval = 10 * time.Second
)

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

func DummyWrapFs

func DummyWrapFs(fs boshsys.FileSystem) boshsys.FileSystem

func NewMonitRetryable

func NewMonitRetryable(cmdRunner boshsys.CmdRunner) boshretry.Retryable

Types

type AuditLogger

type AuditLogger interface {
	Debug(string)
	Err(string)
	StartLogging()
}

type AuditLoggerProvider

type AuditLoggerProvider interface {
	ProvideDebugLogger() (*log.Logger, error)
	ProvideErrorLogger() (*log.Logger, error)
}

func NewAuditLoggerProvider

func NewAuditLoggerProvider() AuditLoggerProvider

type BootstrapState

type BootstrapState struct {
	Linux LinuxState
	// contains filtered or unexported fields
}

func NewBootstrapState

func NewBootstrapState(fs boshsys.FileSystem, path string) (*BootstrapState, error)

func (*BootstrapState) SaveState

func (s *BootstrapState) SaveState() (err error)

type DelayedAuditLogger

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

func NewDelayedAuditLogger

func NewDelayedAuditLogger(auditLoggerProvider AuditLoggerProvider, logger boshlog.Logger) *DelayedAuditLogger

func (*DelayedAuditLogger) Debug

func (l *DelayedAuditLogger) Debug(msg string)

func (*DelayedAuditLogger) Err

func (l *DelayedAuditLogger) Err(msg string)

func (*DelayedAuditLogger) StartLogging

func (l *DelayedAuditLogger) StartLogging()

type DummyFs

type DummyFs struct {
	boshsys.FileSystem
}

func (*DummyFs) Chown

func (d *DummyFs) Chown(path string, username string) error

type LinuxOptions

type LinuxOptions struct {
	// When set to true loop back device
	// is not going to be overlayed over /tmp to limit /tmp dir size
	UseDefaultTmpDir bool

	// When set to true persistent disk will be assumed to be pre-formatted;
	// otherwise agent will partition and format it right before mounting
	UsePreformattedPersistentDisk bool

	// When set to true persistent disk will be mounted as a bind-mount
	BindMountPersistentDisk bool

	// When set to true and no ephemeral disk is mounted, the agent will create
	// a partition on the same device as the root partition to use as the
	// ephemeral disk
	CreatePartitionIfNoEphemeralDisk bool

	// When set to true the agent will skip both root and ephemeral disk partitioning
	SkipDiskSetup bool

	// Strategy for resolving device paths;
	// possible values: virtio, scsi, iscsi, ""
	DevicePathResolutionType string

	// Strategy for resolving ephemeral & persistent disk partitioners;
	// possible values: parted, "" (default is sfdisk if disk < 2TB, parted otherwise)
	PartitionerType string
}

type LinuxState

type LinuxState struct {
	HostsConfigured bool `json:"hosts_configured"`
}

type Options

type Options struct {
	Linux   LinuxOptions
	Windows WindowsOptions
}

type Platform

type Platform interface {
	GetFs() boshsys.FileSystem
	GetRunner() boshsys.CmdRunner
	GetCompressor() boshcmd.Compressor
	GetCopier() boshcmd.Copier
	GetDirProvider() boshdir.Provider
	GetVitalsService() boshvitals.Service
	GetAuditLogger() AuditLogger
	GetDevicePathResolver() (devicePathResolver boshdpresolv.DevicePathResolver)
	GetAgentSettingsPath(tmpfs bool) string
	GetPersistentDiskSettingsPath(tmpfs bool) string

	// User management
	CreateUser(username, basePath string) (err error)
	AddUserToGroups(username string, groups []string) (err error)
	DeleteEphemeralUsersMatching(regex string) (err error)

	// Bootstrap functionality
	SetupRootDisk(ephemeralDiskPath string) (err error)
	SetupSSH(publicKey []string, username string) (err error)
	SetUserPassword(user, encryptedPwd string) (err error)
	SetupBoshSettingsDisk() (err error)
	SetupIPv6(boshsettings.IPv6) error
	SetupHostname(hostname string) (err error)
	SetupNetworking(networks boshsettings.Networks) (err error)
	SetupLogrotate(groupName, basePath, size string) (err error)
	SetTimeWithNtpServers(servers []string) (err error)
	SetupEphemeralDiskWithPath(devicePath string, desiredSwapSizeInBytes *uint64, labelPrefix string) (err error)
	SetupRawEphemeralDisks(devices []boshsettings.DiskSettings) (err error)
	SetupDataDir(boshsettings.JobDir) (err error)
	SetupSharedMemory() (err error)
	SetupTmpDir() (err error)
	SetupCanRestartDir() (err error)
	SetupHomeDir() (err error)
	SetupBlobsDir() (err error)
	SetupMonitUser() (err error)
	StartMonit() (err error)
	SetupRuntimeConfiguration() (err error)
	SetupLogDir() (err error)
	SetupLoggingAndAuditing() (err error)
	SetupRecordsJSONPermission(path string) error

	// Disk management
	MountPersistentDisk(diskSettings boshsettings.DiskSettings, mountPoint string) error
	UnmountPersistentDisk(diskSettings boshsettings.DiskSettings) (didUnmount bool, err error)
	MigratePersistentDisk(fromMountPoint, toMountPoint string) (err error)
	GetEphemeralDiskPath(diskSettings boshsettings.DiskSettings) string
	IsMountPoint(path string) (partitionPath string, result bool, err error)
	IsPersistentDiskMounted(diskSettings boshsettings.DiskSettings) (result bool, err error)
	IsPersistentDiskMountable(diskSettings boshsettings.DiskSettings) (bool, error)
	AssociateDisk(name string, settings boshsettings.DiskSettings) error

	GetFileContentsFromCDROM(filePath string) (contents []byte, err error)
	GetFilesContentsFromDisk(diskPath string, fileNames []string) (contents [][]byte, err error)

	// Network misc
	GetDefaultNetwork() (boshsettings.Network, error)
	GetConfiguredNetworkInterfaces() ([]string, error)
	PrepareForNetworkingChange() error
	DeleteARPEntryWithIP(ip string) error
	SaveDNSRecords(dnsRecords boshsettings.DNSRecords, hostname string) error

	// Additional monit management
	GetMonitCredentials() (username, password string, err error)

	GetCertManager() cert.Manager

	GetHostPublicKey() (string, error)

	RemoveDevTools(packageFileListPath string) error
	RemoveStaticLibraries(packageFileListPath string) error

	Shutdown() error
}

func NewDummyPlatform

func NewDummyPlatform(
	collector boshstats.Collector,
	fs boshsys.FileSystem,
	cmdRunner boshsys.CmdRunner,
	dirProvider boshdirs.Provider,
	devicePathResolver boshdpresolv.DevicePathResolver,
	logger boshlog.Logger,
	auditLogger AuditLogger,
) Platform

func NewLinuxPlatform

func NewLinuxPlatform(
	fs boshsys.FileSystem,
	cmdRunner boshsys.CmdRunner,
	collector boshstats.Collector,
	compressor boshcmd.Compressor,
	copier boshcmd.Copier,
	dirProvider boshdirs.Provider,
	vitalsService boshvitals.Service,
	cdutil cdrom.CDUtil,
	diskManager boshdisk.Manager,
	netManager boshnet.Manager,
	certManager boshcert.Manager,
	monitRetryStrategy boshretry.RetryStrategy,
	devicePathResolver boshdpresolv.DevicePathResolver,
	state *BootstrapState,
	options LinuxOptions,
	logger boshlog.Logger,
	defaultNetworkResolver boshsettings.DefaultNetworkResolver,
	uuidGenerator boshuuid.Generator,
	auditLogger AuditLogger,
) Platform

func NewWindowsPlatform

func NewWindowsPlatform(
	collector boshstats.Collector,
	fs boshsys.FileSystem,
	cmdRunner boshsys.CmdRunner,
	dirProvider boshdirs.Provider,
	netManager boshnet.Manager,
	certManager boshcert.Manager,
	devicePathResolver boshdpresolv.DevicePathResolver,
	options Options,
	logger boshlog.Logger,
	defaultNetworkResolver boshsettings.DefaultNetworkResolver,
	auditLogger AuditLogger,
	uuidGenerator boshuuid.Generator,
	diskManager WindowsDiskManager,
) Platform

type Provider

type Provider interface {
	Get(name string) (Platform, error)
}

func NewProvider

func NewProvider(logger boshlog.Logger, dirProvider boshdirs.Provider, statsCollector boshstats.Collector, fs boshsys.FileSystem, options Options, bootstrapState *BootstrapState, clock clock.Clock, auditLogger AuditLogger) Provider

type WindowsDiskManager

type WindowsDiskManager interface {
	GetFormatter() disk.WindowsDiskFormatter
	GetLinker() disk.WindowsDiskLinker
	GetPartitioner() disk.WindowsDiskPartitioner
	GetProtector() disk.WindowsDiskProtector
}

type WindowsOptions

type WindowsOptions struct {
	// Feature flag during ephemeral disk support rollout
	EnableEphemeralDiskMounting bool
}

type WindowsPlatform

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

func (WindowsPlatform) AddUserToGroups

func (p WindowsPlatform) AddUserToGroups(username string, groups []string) (err error)

func (WindowsPlatform) AssociateDisk

func (p WindowsPlatform) AssociateDisk(name string, settings boshsettings.DiskSettings) error

func (WindowsPlatform) CleanIPMacAddressCache

func (p WindowsPlatform) CleanIPMacAddressCache(ip string) error

func (WindowsPlatform) CreateUser

func (p WindowsPlatform) CreateUser(username, _ string) error

func (WindowsPlatform) DeleteARPEntryWithIP

func (p WindowsPlatform) DeleteARPEntryWithIP(ip string) error

func (WindowsPlatform) DeleteEphemeralUsersMatching

func (p WindowsPlatform) DeleteEphemeralUsersMatching(pattern string) error

func (WindowsPlatform) GetAgentSettingsPath

func (p WindowsPlatform) GetAgentSettingsPath(tmpfs bool) string

func (WindowsPlatform) GetAuditLogger

func (p WindowsPlatform) GetAuditLogger() AuditLogger

func (WindowsPlatform) GetCertManager

func (p WindowsPlatform) GetCertManager() (certManager boshcert.Manager)

func (WindowsPlatform) GetCompressor

func (p WindowsPlatform) GetCompressor() (compressor boshcmd.Compressor)

func (WindowsPlatform) GetConfiguredNetworkInterfaces

func (p WindowsPlatform) GetConfiguredNetworkInterfaces() (interfaces []string, err error)

func (WindowsPlatform) GetCopier

func (p WindowsPlatform) GetCopier() (copier boshcmd.Copier)

func (WindowsPlatform) GetDefaultNetwork

func (p WindowsPlatform) GetDefaultNetwork() (boshsettings.Network, error)

func (WindowsPlatform) GetDevicePathResolver

func (p WindowsPlatform) GetDevicePathResolver() (devicePathResolver boshdpresolv.DevicePathResolver)

func (WindowsPlatform) GetDirProvider

func (p WindowsPlatform) GetDirProvider() (dirProvider boshdir.Provider)

func (WindowsPlatform) GetEphemeralDiskPath

func (p WindowsPlatform) GetEphemeralDiskPath(diskSettings boshsettings.DiskSettings) (diskPath string)

func (WindowsPlatform) GetFileContentsFromCDROM

func (p WindowsPlatform) GetFileContentsFromCDROM(filePath string) (contents []byte, err error)

func (WindowsPlatform) GetFilesContentsFromDisk

func (p WindowsPlatform) GetFilesContentsFromDisk(diskPath string, fileNames []string) (contents [][]byte, err error)

func (WindowsPlatform) GetFs

func (p WindowsPlatform) GetFs() (fs boshsys.FileSystem)

func (WindowsPlatform) GetHostPublicKey

func (p WindowsPlatform) GetHostPublicKey() (string, error)

func (WindowsPlatform) GetMonitCredentials

func (p WindowsPlatform) GetMonitCredentials() (username, password string, err error)

func (WindowsPlatform) GetPersistentDiskSettingsPath

func (p WindowsPlatform) GetPersistentDiskSettingsPath(tmpfs bool) string

func (WindowsPlatform) GetRunner

func (p WindowsPlatform) GetRunner() (runner boshsys.CmdRunner)

func (WindowsPlatform) GetVitalsService

func (p WindowsPlatform) GetVitalsService() (service boshvitals.Service)

func (WindowsPlatform) IsMountPoint

func (p WindowsPlatform) IsMountPoint(path string) (string, bool, error)

func (WindowsPlatform) IsPersistentDiskMountable

func (p WindowsPlatform) IsPersistentDiskMountable(diskSettings boshsettings.DiskSettings) (bool, error)

func (WindowsPlatform) IsPersistentDiskMounted

func (p WindowsPlatform) IsPersistentDiskMounted(diskSettings boshsettings.DiskSettings) (bool, error)

func (WindowsPlatform) MigratePersistentDisk

func (p WindowsPlatform) MigratePersistentDisk(fromMountPoint, toMountPoint string) (err error)

func (WindowsPlatform) MountPersistentDisk

func (p WindowsPlatform) MountPersistentDisk(diskSettings boshsettings.DiskSettings, mountPoint string) (err error)

func (WindowsPlatform) PrepareForNetworkingChange

func (p WindowsPlatform) PrepareForNetworkingChange() error

func (WindowsPlatform) RemoveDevTools

func (p WindowsPlatform) RemoveDevTools(packageFileListPath string) error

func (WindowsPlatform) RemoveStaticLibraries

func (p WindowsPlatform) RemoveStaticLibraries(packageFileListPath string) error

func (WindowsPlatform) SaveDNSRecords

func (p WindowsPlatform) SaveDNSRecords(dnsRecords boshsettings.DNSRecords, hostname string) (err error)

func (WindowsPlatform) SetTimeWithNtpServers

func (p WindowsPlatform) SetTimeWithNtpServers(servers []string) (err error)

func (WindowsPlatform) SetUserPassword

func (p WindowsPlatform) SetUserPassword(user, encryptedPwd string) (err error)

func (WindowsPlatform) SetupBlobsDir

func (p WindowsPlatform) SetupBlobsDir() error

func (WindowsPlatform) SetupBoshSettingsDisk

func (p WindowsPlatform) SetupBoshSettingsDisk() error

func (WindowsPlatform) SetupCanRestartDir

func (p WindowsPlatform) SetupCanRestartDir() error

func (WindowsPlatform) SetupDataDir

func (p WindowsPlatform) SetupDataDir(_ boshsettings.JobDir) error

func (WindowsPlatform) SetupEphemeralDiskWithPath

func (p WindowsPlatform) SetupEphemeralDiskWithPath(devicePath string, desiredSwapSizeInBytes *uint64, labelPrefix string) error

func (WindowsPlatform) SetupHomeDir

func (p WindowsPlatform) SetupHomeDir() error

func (WindowsPlatform) SetupHostname

func (p WindowsPlatform) SetupHostname(hostname string) (err error)

func (WindowsPlatform) SetupIPv6 added in v0.0.34

func (p WindowsPlatform) SetupIPv6(config boshsettings.IPv6) error

func (WindowsPlatform) SetupLogDir

func (p WindowsPlatform) SetupLogDir() error

func (WindowsPlatform) SetupLoggingAndAuditing

func (p WindowsPlatform) SetupLoggingAndAuditing() error

func (WindowsPlatform) SetupLogrotate

func (p WindowsPlatform) SetupLogrotate(groupName, basePath, size string) (err error)

func (WindowsPlatform) SetupMonitUser

func (p WindowsPlatform) SetupMonitUser() (err error)

func (WindowsPlatform) SetupNetworking

func (p WindowsPlatform) SetupNetworking(networks boshsettings.Networks) (err error)

func (WindowsPlatform) SetupRawEphemeralDisks

func (p WindowsPlatform) SetupRawEphemeralDisks(devices []boshsettings.DiskSettings) (err error)

func (WindowsPlatform) SetupRecordsJSONPermission

func (p WindowsPlatform) SetupRecordsJSONPermission(path string) error

func (WindowsPlatform) SetupRootDisk

func (p WindowsPlatform) SetupRootDisk(ephemeralDiskPath string) (err error)

func (WindowsPlatform) SetupRuntimeConfiguration

func (p WindowsPlatform) SetupRuntimeConfiguration() error

func (WindowsPlatform) SetupSSH

func (p WindowsPlatform) SetupSSH(publicKey []string, username string) error

func (WindowsPlatform) SetupSharedMemory

func (p WindowsPlatform) SetupSharedMemory() error

func (WindowsPlatform) SetupTmpDir

func (p WindowsPlatform) SetupTmpDir() error

func (WindowsPlatform) Shutdown

func (p WindowsPlatform) Shutdown() error

func (WindowsPlatform) StartMonit

func (p WindowsPlatform) StartMonit() (err error)

func (WindowsPlatform) UnmountPersistentDisk

func (p WindowsPlatform) UnmountPersistentDisk(diskSettings boshsettings.DiskSettings) (didUnmount bool, err error)

Directories

Path Synopsis
certfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
diskfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
net
arp
ip
netfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
vitalsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
windows
disk/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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