scm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

(C) Copyright 2019-2020 Intel Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.

(C) Copyright 2019 Intel Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.

(C) Copyright 2019-2020 Intel Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.

(C) Copyright 2019-2020 Intel Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE The Government's rights to use, modify, reproduce, release, perform, display, or disclose this software are subject to the terms of the Apache License as provided in Contract No. 8F-30005. Any reproduction of computer software, computer software documentation, or portions thereof marked with this legend must also reproduce the markings.

Index

Constants

View Source
const (
	MsgScmRebootRequired    = "A reboot is required to process new memory allocation goals."
	MsgScmNoModules         = "no scm modules to prepare"
	MsgScmNotInited         = "scm storage could not be accessed"
	MsgScmClassNotSupported = "operation unsupported on scm class"
	MsgIpmctlDiscoverFail   = "ipmctl module discovery"
)

Variables

View Source
var (
	FaultUnknown = scmFault(
		code.ScmUnknown, "unknown scm error", "",
	)
	FaultDiscoveryFailed = scmFault(
		code.ScmDiscoveryFailed, "module discovery failed", "",
	)
	FaultFormatInvalidSize = scmFault(
		code.ScmFormatInvalidSize, "format request must specify a size greater than 0", "",
	)
	FaultFormatInvalidDeviceCount = scmFault(
		code.ScmFormatInvalidDeviceCount, "format request must have exactly 1 dcpm device", "",
	)
	FaultFormatMissingMountpoint = scmFault(
		code.ScmFormatMissingMountpoint, "format request must specify mountpoint", "",
	)
	FaultFormatMissingParam = scmFault(
		code.ScmFormatMissingParam, "format request must have ramdisk or dcpm parameter", "",
	)
	FaultFormatConflictingParam = scmFault(
		code.ScmFormatConflictingParam,
		"format request must not have both ramdisk and dcpm parameters", "",
	)
	FaultFormatNoReformat = scmFault(
		code.StorageAlreadyFormatted,
		"format request for already-formatted storage and reformat not specified",
		"retry the operation with reformat option to overwrite existing format",
	)
	FaultDeviceAlreadyMounted = scmFault(
		code.StorageDeviceAlreadyMounted,
		"request included already-mounted device",
		"unmount the device and retry the operation",
	)
	FaultTargetAlreadyMounted = scmFault(
		code.StorageTargetAlreadyMounted,
		"request included already-mounted mount target (cannot double-mount)",
		"unmount the target and retry the operation",
	)
	FaultMissingNdctl = scmFault(
		code.MissingSoftwareDependency,
		"ndctl utility not found", "install the ndctl software for your OS",
	)
)

Functions

func FaultFormatMissingDevice

func FaultFormatMissingDevice(device string) *fault.Fault

Types

type Backend

type Backend interface {
	Discover() (storage.ScmModules, error)
	Prep(storage.ScmState) (bool, storage.ScmNamespaces, error)
	PrepReset(storage.ScmState) (bool, error)
	GetState() (storage.ScmState, error)
	GetNamespaces() (storage.ScmNamespaces, error)
}

Backend defines a set of methods to be implemented by a SCM backend.

type DcpmParams

type DcpmParams struct {
	Device string
}

DcpmParams defines the sub-parameters of a Format operation that will use DCPM storage.

type FormatRequest

type FormatRequest struct {
	pbin.ForwardableRequest
	Reformat   bool
	Mountpoint string
	OwnerUID   int
	OwnerGID   int
	Ramdisk    *RamdiskParams
	Dcpm       *DcpmParams
}

FormatRequest defines the parameters for a Format operation or query.

func CreateFormatRequest

func CreateFormatRequest(scmCfg storage.ScmConfig, reformat bool) (*FormatRequest, error)

func (FormatRequest) Validate

func (r FormatRequest) Validate() error

Validate checks the request for validity.

type FormatResponse

type FormatResponse struct {
	Mountpoint string
	Formatted  bool
	Mounted    bool
	Mountable  bool
}

FormatResponse contains the results of a successful Format operation or query.

type Forwarder

type Forwarder struct {
	pbin.Forwarder
}

func NewForwarder added in v0.9.0

func NewForwarder(log logging.Logger) *Forwarder

func (*Forwarder) CheckFormat

func (f *Forwarder) CheckFormat(req FormatRequest) (*FormatResponse, error)

func (*Forwarder) Format

func (f *Forwarder) Format(req FormatRequest) (*FormatResponse, error)

func (*Forwarder) Mount

func (f *Forwarder) Mount(req MountRequest) (*MountResponse, error)

func (*Forwarder) Prepare

func (f *Forwarder) Prepare(req PrepareRequest) (*PrepareResponse, error)

func (*Forwarder) Scan

func (f *Forwarder) Scan(req ScanRequest) (*ScanResponse, error)

func (*Forwarder) Unmount

func (f *Forwarder) Unmount(req MountRequest) (*MountResponse, error)

type MockBackend

type MockBackend struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func DefaultMockBackend

func DefaultMockBackend() *MockBackend

func NewMockBackend

func NewMockBackend(cfg *MockBackendConfig) *MockBackend

func (*MockBackend) Discover

func (mb *MockBackend) Discover() (storage.ScmModules, error)

func (*MockBackend) GetNamespaces

func (mb *MockBackend) GetNamespaces() (storage.ScmNamespaces, error)

func (*MockBackend) GetState

func (mb *MockBackend) GetState() (storage.ScmState, error)

func (*MockBackend) Prep

func (*MockBackend) PrepReset

func (mb *MockBackend) PrepReset(_ storage.ScmState) (bool, error)

type MockBackendConfig

type MockBackendConfig struct {
	DiscoverRes      storage.ScmModules
	DiscoverErr      error
	GetNamespaceRes  storage.ScmNamespaces
	GetNamespaceErr  error
	GetStateErr      error
	StartingState    storage.ScmState
	NextState        storage.ScmState
	PrepNeedsReboot  bool
	PrepNamespaceRes storage.ScmNamespaces
	PrepErr          error
}

MockBackendConfig specifies behaviour for a mock SCM backend implementation providing capability to access and configure SCM modules and namespaces.

type MockSysConfig

type MockSysConfig struct {
	IsMountedBool bool
	IsMountedErr  error
	MountErr      error
	UnmountErr    error
	MkfsErr       error
	GetfsStr      string
	GetfsErr      error
}

type MockSysProvider

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

func DefaultMockSysProvider

func DefaultMockSysProvider() *MockSysProvider

func NewMockSysProvider

func NewMockSysProvider(cfg *MockSysConfig) *MockSysProvider

func (*MockSysProvider) Getfs

func (msp *MockSysProvider) Getfs(_ string) (string, error)

func (*MockSysProvider) IsMounted

func (msp *MockSysProvider) IsMounted(target string) (bool, error)

func (*MockSysProvider) Mkfs

func (msp *MockSysProvider) Mkfs(_, _ string, _ bool) error

func (*MockSysProvider) Mount

func (msp *MockSysProvider) Mount(_, _, _ string, _ uintptr, _ string) error

func (*MockSysProvider) Unmount

func (msp *MockSysProvider) Unmount(_ string, _ int) error

type MountRequest

type MountRequest struct {
	pbin.ForwardableRequest
	Source string
	Target string
	FsType string
	Flags  uintptr
	Data   string
}

MountRequest defines the parameters for a Mount operation.

type MountResponse

type MountResponse struct {
	Target  string
	Mounted bool
}

MountResponse contains the results of a successful Mount operation.

type PrepareRequest

type PrepareRequest struct {
	pbin.ForwardableRequest
	// Reset indicates that the operation should reset (clear) DCPM namespaces.
	Reset bool
}

PrepareRequest defines the parameters for a Prepare opration.

type PrepareResponse

type PrepareResponse struct {
	State          storage.ScmState
	RebootRequired bool
	Namespaces     storage.ScmNamespaces
}

PrepareResponse contains the results of a successful Prepare operation.

type Provider

type Provider struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Provider encapsulates configuration and logic for providing SCM management and interrogation.

func DefaultMockProvider

func DefaultMockProvider(log logging.Logger) *Provider

func DefaultProvider

func DefaultProvider(log logging.Logger) *Provider

DefaultProvider returns an initialized *Provider suitable for use with production code.

func NewMockProvider

func NewMockProvider(log logging.Logger, mbc *MockBackendConfig, msc *MockSysConfig) *Provider

func NewProvider

func NewProvider(log logging.Logger, backend Backend, sys SystemProvider) *Provider

NewProvider returns an initialized *Provider.

func (*Provider) CheckFormat

func (p *Provider) CheckFormat(req FormatRequest) (*FormatResponse, error)

CheckFormat attempts to determine whether or not the SCM specified in the request is already formatted. If it is mounted, it is assumed to be formatted. In the case of DCPM, the device is checked directly for the presence of a filesystem.

func (*Provider) Format

func (p *Provider) Format(req FormatRequest) (*FormatResponse, error)

Format attempts to fulfill the specified SCM format request.

func (*Provider) GetState

func (p *Provider) GetState() (storage.ScmState, error)

GetState returns the current state of DCPM namespaces, if available.

func (*Provider) IsMounted

func (p *Provider) IsMounted(target string) (bool, error)

IsMounted checks to see if the target device or directory is mounted.

func (*Provider) Mount

func (p *Provider) Mount(req MountRequest) (*MountResponse, error)

Mount attempts to mount the target specified in the supplied request.

func (*Provider) MountDcpm

func (p *Provider) MountDcpm(device, target string) (*MountResponse, error)

MountDcpm attempts to mount a DCPM device at the specified mountpoint.

func (*Provider) MountRamdisk

func (p *Provider) MountRamdisk(target string, size uint) (*MountResponse, error)

MountRamdisk attempts to mount a tmpfs-based ramdisk of the specified size at the specified mountpoint.

func (*Provider) Prepare

func (p *Provider) Prepare(req PrepareRequest) (res *PrepareResponse, err error)

Prepare attempts to fulfill a SCM Prepare request.

func (*Provider) Scan

func (p *Provider) Scan(req ScanRequest) (*ScanResponse, error)

Scan attempts to scan the system for SCM storage components.

func (*Provider) Unmount

func (p *Provider) Unmount(req MountRequest) (*MountResponse, error)

Unmount attempts to unmount the target specified in the supplied request.

func (*Provider) WithForwardingDisabled

func (p *Provider) WithForwardingDisabled() *Provider

type RamdiskParams

type RamdiskParams struct {
	Size uint
}

RamdiskParams defines the sub-parameters of a Format operation that will use tmpfs-based ramdisk storage.

type ScanRequest

type ScanRequest struct {
	pbin.ForwardableRequest
	Rescan bool
}

ScanRequest defines the parameters for a Scan operation.

type ScanResponse

type ScanResponse struct {
	State      storage.ScmState
	Modules    storage.ScmModules
	Namespaces storage.ScmNamespaces
}

ScanResponse contains information gleaned during a successful Scan operation.

type SystemProvider

type SystemProvider interface {
	system.IsMountedProvider
	system.MountProvider
	system.UnmountProvider
	Mkfs(fsType, device string, force bool) error
	Getfs(device string) (string, error)
}

SystemProvider defines a set of methods to be implemented by a provider of SCM-specific system capabilties.

Jump to

Keyboard shortcuts

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