server

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2017 License: Apache-2.0 Imports: 9 Imported by: 16

Documentation

Index

Constants

View Source
const (
	VolumeStateCreating  = "creating"
	VolumeStateAvailable = "available"
	VolumeStateInUse     = "in-use"
	VolumeStateDetaching = "detaching"
	VolumeStateAttaching = "attaching"
	VolumeStateDeleting  = "deleting"
	VolumeStateDeleted   = "deleted"
	VolumeStateError     = "error"

	VolumeTypeHDD     = "standard"
	VolumeTypeGPSSD   = "gp2"
	VolumeTypeIOPSSSD = "io1"
)

http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-volumes.html EBS volume has 2 states, The status of the volume (creating | available | in-use | deleting | deleted | error). The attachment state (attaching | attached | detaching | detached). The attachment state would be returned when volume status is in-use. Q: when will the attachment state be detached? After detached, volume status should be available.

View Source
const LoopDevPrefix = "/dev/loop"
View Source
const LoopFileDir = "/tmp/"

Variables

View Source
var (
	ErrVolumeIncorrectState = errors.New("IncorrectState")
	ErrVolumeInUse          = errors.New("VolumeInUse")
)

Functions

This section is empty.

Types

type Info

type Info interface {
	GetPrivateIP() string
	GetLocalAvailabilityZone() string
	GetLocalRegion() string
	GetLocalInstanceID() string
	GetLocalVpcID() string
	GetLocalRegionAZs() []string
}

Info defines the operations for the local server related info

type LoopServer

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

func NewLoopServer

func NewLoopServer() *LoopServer

func (*LoopServer) AttachVolume

func (s *LoopServer) AttachVolume(ctx context.Context, volID string, instanceID string, devName string) error

func (*LoopServer) CreateVolume

func (s *LoopServer) CreateVolume(ctx context.Context, az string, volSizeGB int64) (volID string, err error)

func (*LoopServer) DeleteVolume

func (s *LoopServer) DeleteVolume(ctx context.Context, volID string) error

func (*LoopServer) DetachVolume

func (s *LoopServer) DetachVolume(ctx context.Context, volID string, instanceID string, devName string) error

func (*LoopServer) GetControlDBDeviceName

func (s *LoopServer) GetControlDBDeviceName() string

func (*LoopServer) GetFirstDeviceName

func (s *LoopServer) GetFirstDeviceName() string

func (*LoopServer) GetNextDeviceName

func (s *LoopServer) GetNextDeviceName(lastDev string) (devName string, err error)

func (*LoopServer) GetVolumeInfo

func (s *LoopServer) GetVolumeInfo(ctx context.Context, volID string) (info VolumeInfo, err error)

func (*LoopServer) GetVolumeState

func (s *LoopServer) GetVolumeState(ctx context.Context, volID string) (state string, err error)

func (*LoopServer) WaitVolumeAttached

func (s *LoopServer) WaitVolumeAttached(ctx context.Context, volID string) error

func (*LoopServer) WaitVolumeCreated

func (s *LoopServer) WaitVolumeCreated(ctx context.Context, volID string) error

func (*LoopServer) WaitVolumeDetached

func (s *LoopServer) WaitVolumeDetached(ctx context.Context, volID string) error

type MemServer

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

func NewMemServer

func NewMemServer() *MemServer

func (*MemServer) AttachVolume

func (s *MemServer) AttachVolume(ctx context.Context, volID string, instanceID string, devName string) error

func (*MemServer) CreateVolume

func (s *MemServer) CreateVolume(ctx context.Context, az string, volSizeGB int64) (volID string, err error)

func (*MemServer) DeleteVolume

func (s *MemServer) DeleteVolume(ctx context.Context, volID string) error

func (*MemServer) DetachVolume

func (s *MemServer) DetachVolume(ctx context.Context, volID string, instanceID string, devName string) error

func (*MemServer) GetControlDBDeviceName

func (s *MemServer) GetControlDBDeviceName() string

func (*MemServer) GetFirstDeviceName

func (s *MemServer) GetFirstDeviceName() string

func (*MemServer) GetNextDeviceName

func (s *MemServer) GetNextDeviceName(lastDev string) (devName string, err error)

func (*MemServer) GetVolumeInfo

func (s *MemServer) GetVolumeInfo(ctx context.Context, volID string) (info VolumeInfo, err error)

func (*MemServer) GetVolumeState

func (s *MemServer) GetVolumeState(ctx context.Context, volID string) (state string, err error)

func (*MemServer) WaitVolumeAttached

func (s *MemServer) WaitVolumeAttached(ctx context.Context, volID string) error

func (*MemServer) WaitVolumeCreated

func (s *MemServer) WaitVolumeCreated(ctx context.Context, volID string) error

func (*MemServer) WaitVolumeDetached

func (s *MemServer) WaitVolumeDetached(ctx context.Context, volID string) error

type MockServerInfo

type MockServerInfo struct {
}

func NewMockServerInfo

func NewMockServerInfo() *MockServerInfo

func (*MockServerInfo) GetLocalAvailabilityZone

func (m *MockServerInfo) GetLocalAvailabilityZone() string

func (*MockServerInfo) GetLocalInstanceID

func (m *MockServerInfo) GetLocalInstanceID() string

func (*MockServerInfo) GetLocalRegion

func (m *MockServerInfo) GetLocalRegion() string

func (*MockServerInfo) GetLocalRegionAZs

func (m *MockServerInfo) GetLocalRegionAZs() []string

func (*MockServerInfo) GetLocalVpcID

func (m *MockServerInfo) GetLocalVpcID() string

func (*MockServerInfo) GetPrivateIP

func (m *MockServerInfo) GetPrivateIP() string

type Server

type Server interface {
	AttachVolume(ctx context.Context, volID string, instanceID string, devName string) error
	WaitVolumeAttached(ctx context.Context, volID string) error
	GetVolumeState(ctx context.Context, volID string) (state string, err error)
	GetVolumeInfo(ctx context.Context, volID string) (info VolumeInfo, err error)
	DetachVolume(ctx context.Context, volID string, instanceID string, devName string) error
	WaitVolumeDetached(ctx context.Context, volID string) error
	CreateVolume(ctx context.Context, az string, volSizeGB int64) (volID string, err error)
	WaitVolumeCreated(ctx context.Context, volID string) error
	DeleteVolume(ctx context.Context, volID string) error

	GetControlDBDeviceName() string
	GetFirstDeviceName() string
	GetNextDeviceName(lastDev string) (devName string, err error)
}

Server defines the volume and device related operations for one host such as EC2

type VolumeInfo

type VolumeInfo struct {
	VolID string
	State string
	// the instance that the volume is attached to.
	AttachInstanceID string
	// the device that the volume is attached to.
	Device string
	Size   int64
}

VolumeInfo records the volume's information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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