server

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: Apache-2.0 Imports: 10 Imported by: 16

Documentation

Index

Constants

View Source
const (
	LoopFileDir   = "/tmp/"
	LoopDevPrefix = "/dev/loop"
)
View Source
const (
	VolumeStateCreating  = "creating"
	VolumeStateAvailable = "available"
	VolumeStateInUse     = "in-use"
	VolumeStateDetaching = "detaching"
	VolumeStateAttaching = "attaching"
	VolumeStateDeleting  = "deleting"
	VolumeStateDeleted   = "deleted"
	VolumeStateError     = "error"
)

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.

Variables

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

Functions

This section is empty.

Types

type CreateVolumeOptions added in v0.9.1

type CreateVolumeOptions struct {
	AvailabilityZone string
	VolumeType       string
	Iops             int64
	VolumeSizeGB     int64
	Encrypted        bool
	TagSpecs         []common.KeyValuePair
}

CreateVolumeOptions includes the creation parameters for the volume.

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) AddNetworkInterface added in v0.8.1

func (s *LoopServer) AddNetworkInterface()

func (*LoopServer) AssignStaticIP added in v0.8.1

func (s *LoopServer) AssignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) error

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, opts *CreateVolumeOptions) (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) GetCidrBlock added in v0.8.1

func (s *LoopServer) GetCidrBlock() (cidrPrefix string, cidrIP string, cidrBlock string, cidrIPNet string)

func (*LoopServer) GetControlDBDeviceName

func (s *LoopServer) GetControlDBDeviceName() string

func (*LoopServer) GetFirstDeviceName

func (s *LoopServer) GetFirstDeviceName() string

func (*LoopServer) GetInstanceNetworkInterface added in v0.8.1

func (s *LoopServer) GetInstanceNetworkInterface(ctx context.Context, instanceID string) (netInterface *NetworkInterface, err error)

func (*LoopServer) GetNetworkInterfaces added in v0.8.1

func (s *LoopServer) GetNetworkInterfaces(ctx context.Context, cluster string,
	vpcID string, zone string) (netInterfaces []*NetworkInterface, cidrBlock string, err error)

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) UnassignStaticIP added in v0.8.1

func (s *LoopServer) UnassignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) 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) AssignStaticIP added in v0.8.1

func (s *MemServer) AssignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) error

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, opts *CreateVolumeOptions) (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) GetInstanceNetworkInterface added in v0.8.1

func (s *MemServer) GetInstanceNetworkInterface(ctx context.Context, instanceID string) (netInterface *NetworkInterface, err error)

func (*MemServer) GetNetworkInterfaces added in v0.8.1

func (s *MemServer) GetNetworkInterfaces(ctx context.Context, cluster string,
	vpcID string, zone string) (netInterfaces []*NetworkInterface, cidrBlock string, err error)

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) UnassignStaticIP added in v0.8.1

func (s *MemServer) UnassignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) 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 NetworkInterface added in v0.8.1

type NetworkInterface struct {
	InterfaceID      string
	ServerInstanceID string
	PrimaryPrivateIP string
	PrivateIPs       []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, opts *CreateVolumeOptions) (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)

	// GetNetworkInterfaces returns the network interfaces in the firecamp cluster, vpc and zone,
	// and the secondary IPs of the network interfaces.
	// Every instance in the firecamp cluster will have the specific cluster tag, as we don't want
	// to get the application servers run on the same vpc and zone.
	GetNetworkInterfaces(ctx context.Context, cluster string, vpcID string, zone string) (netInterfaces []*NetworkInterface, cidrBlock string, err error)
	// The firecamp cluster instance has only one network interface.
	GetInstanceNetworkInterface(ctx context.Context, instanceID string) (netInterface *NetworkInterface, err error)
	AssignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) error
	// UnassignStaticIP unassigns the staticIP from the networkInterface. If the networkInterface does not
	// own the ip, should return success.
	UnassignStaticIP(ctx context.Context, networkInterfaceID string, staticIP string) 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