mtx

package module
v0.0.0-...-edcebcf Latest Latest
Warning

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

Go to latest
Published: May 18, 2016 License: ISC Imports: 6 Imported by: 2

README

mtx

Package mtx provides functions for working with an automated library changer.

YMMV.

Example usage

This shows how to use the mock changer.

package main

import (
	"fmt"
	"log"

	"github.com/kbj/mtx"
	"github.com/kbj/mtx/mock"
)

func main() {
	mtx := mtx.NewChanger(mock.New(8, 32, 4, 16))

	status, err := mtx.Do("status")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%s", status)

	if err := mtx.Load(1, 0); err != nil {
		log.Fatal(err)
	}
}

Documentation

Overview

Package mtx provides functions for working with an automated library changer.

It includes two subpackages, scsi and mock. scsi calls the 'mtx' program and mock simulates the use of 'mtx' if no library changer is available doing testing/development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Changer

type Changer struct {
	Interface
}

Changer represents a library changer.

func NewChanger

func NewChanger(impl Interface) *Changer

NewChanger returns a new library changer using the given implementation.

func (*Changer) Drives

func (chgr *Changer) Drives() ([]*Slot, error)

Drives returns a slice of data transfer elements. Note that data transfer slots typically start with slot id 0.

func (*Changer) Load

func (chgr *Changer) Load(slotnum, drivenum int) error

Load drive with the volume from slot.

func (*Changer) MailSlots

func (chgr *Changer) MailSlots() ([]*Slot, error)

MailSlots returns a slice of storage elements. Note that mail slots typically start with slot ids counting from the id of the last storage slot.

func (*Changer) MaxDrives

func (chgr *Changer) MaxDrives() (int, error)

MaxDrives returns the number of data transfer elements. Note that this does not necessary correspond to the number of actual drives present in the system.

func (*Changer) NumMailSlots

func (chgr *Changer) NumMailSlots() (int, error)

NumMailSlots returns the number of mail slots.

func (*Changer) NumSlots

func (chgr *Changer) NumSlots() (int, error)

NumSlots returns the number of storage and mail slots.

func (*Changer) NumStorageSlots

func (chgr *Changer) NumStorageSlots() (int, error)

NumStorageSlots returns the number of storage slots.

func (*Changer) Slots

func (chgr *Changer) Slots() ([]*Slot, error)

Slots returns a slice of storage and mail elements. Note that storage slots typically start with slot id 1 and not 0.

func (*Changer) Status

func (chgr *Changer) Status() (*Status, error)

Status returns a Status structure with combined information about the status of the library.

func (*Changer) StorageSlots

func (chgr *Changer) StorageSlots() ([]*Slot, error)

StorageSlots returns a slice of storage elements. Note that storage slots typically start with slot id 1 and not 0.

func (*Changer) Transfer

func (chgr *Changer) Transfer(slotnum, drivenum int) error

Transfer moves a volume from one slot to another.

func (*Changer) Unload

func (chgr *Changer) Unload(slotnum, drivenum int) error

Unload a volume from a drive and return it to a slot.

type Interface

type Interface interface {
	// Do performs the raw operation identified by cmd.
	Do(args ...string) ([]byte, error)
}

The Interface interface describes operations supported by a library auto changer.

type Slot

type Slot struct {
	// The Slot number inside the library.
	Num int

	// Type is the slot type.
	Type SlotType

	// If a volume is in the slot, Vol will be non-nil.
	Vol *Volume
}

Slot represents a slot in the library.

func (*Slot) String

func (slot *Slot) String() string

String returns a textual representation of the slot.

type SlotType

type SlotType int

SlotType defines the type of slot.

const (
	DataTransferSlot SlotType = iota
	StorageSlot
	MailSlot
)

func (SlotType) String

func (i SlotType) String() string

type Status

type Status struct {
	MaxDrives       int
	NumSlots        int
	NumStorageSlots int
	NumMailSlots    int

	Drives []*Slot
	Slots  []*Slot
}

type Volume

type Volume struct {
	// The VOLSER of the tape.
	Serial string

	// The home slot of this volume.
	Home int
}

Volume represents a tape.

func (*Volume) String

func (vol *Volume) String() string

String returns a textual representation of the volume.

Directories

Path Synopsis
Package mock implements a mocked library auto changer that simulates 'mtx'.
Package mock implements a mocked library auto changer that simulates 'mtx'.
Package scsi implements the mtx.Interface for a scsi library auto changer by using the 'mtx' program.
Package scsi implements the mtx.Interface for a scsi library auto changer by using the 'mtx' program.

Jump to

Keyboard shortcuts

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