isclib

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultImportQualifiers = "/compile/keepsource/expand/multicompile"
)

Variables

View Source
var (
	TooManyRecursiveDirsErr   = errors.New("The glob must contain at most one **")
	MissingPathSeparatorErr   = errors.New("There must be a path separator between ** and file pattern")
	PathAfterRecursiveDirsErr = errors.New("A ** must only be used as the last portion of the path before the file pattern")
	WildcardInDirectoryErr    = errors.New("The directory portion of the glob must not contain *")
)
View Source
var (
	LoadFailedError = errors.New("Load did not appear to finish successfully.")
)

Functions

func CControlPath

func CControlPath() string

CControlPath returns the current path to the ccontrol executable

func CSessionPath

func CSessionPath() string

CSessionPath returns the current path to the csession executable

func ExecuteTemporaryDirectory

func ExecuteTemporaryDirectory() string

ExecuteTemporaryDirectory returns the directory where temporary files for ObjectScript execution will be placed. "" means the system default temp directory.

func ISCExists

func ISCExists() bool

ISCExists returns a boolean which is true when an ISC product or Caché instance exists on this system.

func SetCControlPath

func SetCControlPath(path string)

SetCControlPath sets the current path to the ccontrol executable

func SetCSessionPath

func SetCSessionPath(path string)

SetCSessionPath sets the current path to the csession executable

func SetExecuteTemporaryDirectory

func SetExecuteTemporaryDirectory(path string)

SetExecuteTemporaryDirectory sets the directory where temporary files for ObjectScript execution will be placed. Passing "" will result in using the system default temp directory.

func ToggleZSTU added in v1.2.0

func ToggleZSTU(cpfFilePath string, onOrOff bool) (originalValue bool, err error)

Types

type CacheDat

type CacheDat struct {
	Path       string
	Permission string
	Owner      string
	Group      string
	Exists     bool
}

type ISCProduct added in v1.2.0

type ISCProduct uint
const (
	Cache ISCProduct = iota
	Ensemble
	Iris
)

func ParseISCProduct added in v1.2.0

func ParseISCProduct(product string) ISCProduct

type ImportDescription

type ImportDescription struct {
	Dir         string
	FilePattern string
	Recursive   bool
	Qualifiers  string
}

func NewImportDescription

func NewImportDescription(pathGlob string, qualifiers string) (*ImportDescription, error)

func (*ImportDescription) String

func (i *ImportDescription) String() string

type Instance

type Instance struct {
	// Required to be able to run the executor
	CSessionPath string `json:"-"` // The path to the csession executable
	CControlPath string `json:"-"` // The path to the ccontrol executable

	// These values come directly from ccontrol qlist
	Name             string         `json:"name"`             // The name of the instance
	Directory        string         `json:"directory"`        // The directory in which the instance is installed
	Version          string         `json:"version"`          // The version of Caché/Ensemble
	Status           InstanceStatus `json:"status"`           // The status of the instance (down, running, etc.)
	Activity         string         `json:"activity"`         // The last activity date and time (as a string)
	CPFFileName      string         `json:"cpfFileName"`      // The name of the CPF file used by this instance at startup
	SuperServerPort  int            `json:"superServerPort"`  // The SuperServer port
	WebServerPort    int            `json:"webServerPort"`    // The internal WebServer port
	JDBCPort         int            `json:"jdbcPort"`         // The JDBC port
	State            string         `json:"state"`            // The State of the instance (warn, etc.)
	Product          ISCProduct     `json:"product"`          // The product name of the instance
	MirrorMemberType string         `json:"mirrorMemberType"` // The mirror member type (Failover, Disaster Recovery, etc)
	MirrorStatus     string         `json:"mirrorStatus"`     // The mirror Status (Primary, Backup, Connected, etc.)
	DataDirectory    string         `json:"dataDirectory"`    //  The instance data directory.  This might be the same as Directory if durable %SYS isn't in use
	// contains filtered or unexported fields
}

An Instance represents an instance of Caché/Ensemble on the current system.

func InstanceFromQList

func InstanceFromQList(qlist string) (*Instance, error)

InstanceFromQList will parse the output of a ccontrol qlist into an Instance struct. It expects the results of a ccontrol qlist for a single instance as a string. It returns the parsed instance and any error encountered.

func LoadInstance

func LoadInstance(name string) (*Instance, error)

LoadInstance retrieves a single instance by name. The instance name is case insensitive. It returns the instance and any error encountered.

func (*Instance) DetermineCacheDatInfo

func (i *Instance) DetermineCacheDatInfo() (map[string]CacheDat, error)

DetermineCacheDatInfo will parse the ensemble instance's CPF file for its databases (CACHE.DAT). It will get the path of the CACHE.DAT file, the permissions on it, and its owning user / group. The function returns a map of cacheDat structs containing the above information using the name of the database as its key.

func (*Instance) DetermineManager

func (i *Instance) DetermineManager() (string, string, error)

DetermineManager will determine the manager of an instance by reading the parameters file associated with this instance. The manager is the primary user of the instance that will be able to perform start/stop operations etc. It returns the manager and manager group as strings and any error encountered.

func (*Instance) DetermineOwner

func (i *Instance) DetermineOwner() (string, string, error)

DetermineOwner will determine the owner of an instance by reader the parameters file associate with this instance. The owner is the user which owns the files from the installers and as who most Caché processes will be running. It returns the owner and owner group as strings and any error encountered.

func (*Instance) DeterminePrimaryJournalDirectory added in v1.3.0

func (i *Instance) DeterminePrimaryJournalDirectory() (string, error)

DeterminePrimaryJournalDirectory will parse the ISC instance's CPF file for its primary journal directory (CurrentDirectory).

func (*Instance) DetermineSecondaryJournalDirectory added in v1.3.0

func (i *Instance) DetermineSecondaryJournalDirectory() (string, error)

DetermineSecondaryJournalDirectory will parse the ISC instance's CPF file for its secondary journal directory (AlternateDirectory).

func (*Instance) Execute

func (i *Instance) Execute(namespace string, codeReader io.Reader) (string, error)

Execute will read code from the provided io.Reader ane execute it in the provided namespace. The code must be valid Caché ObjectScript INT code obeying all of the correct spacing with a MAIN label as the primary entry point. Valid INT code means (this list is not exhaustive)...

  • Labels start at the first character on the line
  • Non-labels start with a single space
  • You may not have blank lines internal to the code
  • You must have a single blank line at the end of the script

It returns any output of the execution and any error encountered.

func (*Instance) ExecuteAsCurrentUser

func (i *Instance) ExecuteAsCurrentUser() error

ExecuteAsCurrentUser will configure the instance to execute all future commands as the current user. It returns any error encountered.

func (*Instance) ExecuteAsManager

func (i *Instance) ExecuteAsManager() error

ExecuteAsManager will configure the instance to execute all future commands as the instance's owner. This command only functions if the calling program is running as root. It returns any error encountered.

func (*Instance) ExecuteAsUser

func (i *Instance) ExecuteAsUser(execUser string) error

ExecuteAsUser will configure the instance to execute all future commands as the provided user. This command only functions if the calling program is running as root. It returns any error encountered.

func (*Instance) ExecuteString

func (i *Instance) ExecuteString(namespace string, code string) (string, error)

ExecuteString will execute the provided code in the specified namespace. code must be properly formatted INT code. See the documentation for Execute for more information. It returns any output of the execution and any error encountered.

func (*Instance) ExecuteWithOutput

func (i *Instance) ExecuteWithOutput(namespace string, codeReader io.Reader, out io.Writer) error

func (*Instance) GetCSessionCommand added in v1.1.0

func (i *Instance) GetCSessionCommand(namespace, command string) *exec.Cmd

GetCSessionCommand will return a properly configured instance of exec.Cmd to run the provided command (properly formatted for csession) in the provided namespace.

func (*Instance) ImportSource

func (i *Instance) ImportSource(namespace, sourcePathGlob string, qualifiers ...string) (string, error)

ImportSource will import the source specified using a glob pattern into Caché with the provided qualifiers. sourcePathGlob only allows a subset of glob patterns. It must be in the format /p/a/t/h/**/*.xml

/p/a/t/h/ is the import directory
you have have at most one **
after the ** you must have only a file pattern
To import a single file it would be /a/b/c/file.xml

qualifiers are standard Caché import/compile qualifiers, if none are provided a default set will be used It returns any output of the import and any error encountered.

func (*Instance) ReadParametersISC

func (i *Instance) ReadParametersISC() (ParametersISC, error)

ReadParametersISC will read the current instances parameters ISC file into a simple data structure. It returns the ParametersISC data structure and any error encountered.

func (*Instance) Start

func (i *Instance) Start() error

Start will ensure that an instance is started. It returns any error encountered when attempting to start the instance.

func (*Instance) Stop

func (i *Instance) Stop() error

Stop will ensure that an instance is started. It returns any error encountered when attempting to stop the instance.

func (*Instance) Update

func (i *Instance) Update() error

Update will query the the underlying instance and update the Instance fields with its current state. It returns any error encountered.

func (*Instance) UpdateFromQList

func (i *Instance) UpdateFromQList(qlist string) (err error)

UpdateFromQList will update the current Instance with the values from the qlist string. It returns any error encountered.

type InstanceStatus

type InstanceStatus string

An InstanceStatus represents one of the various status associated with Caché/Ensemble instances.

const (
	// InstanceStatusUnknown represents a blank/unknown instance status.
	InstanceStatusUnknown InstanceStatus = ""

	// InstanceStatusRunning represents a running instance.
	InstanceStatusRunning InstanceStatus = "running"

	// InstanceStatusInhibited represents an instance that is up but sign-ons have been inhibited due to an issue.
	InstanceStatusInhibited InstanceStatus = "sign-on inhibited"

	// InstanceStatusPrimaryTransition represents an instance that is up but the primary mirror memeber is being determined.
	InstanceStatusPrimaryTransition InstanceStatus = "sign-on inhibited:primary transition"

	// InstanceStatusDown represents an instance that is down.
	InstanceStatusDown InstanceStatus = "down"

	// InstanceStatusMissingIDS represents an instance that is up but missing a non-critical (but expected) information file.
	InstanceStatusMissingIDS InstanceStatus = "running on node ? (cache.ids missing)"
)

func (InstanceStatus) Down

func (iis InstanceStatus) Down() bool

Down will return true if the instance status represents a fully down instance.

func (InstanceStatus) Handled

func (iis InstanceStatus) Handled() bool

Handled will return true when this status is a known and handled status.

func (InstanceStatus) Ready

func (iis InstanceStatus) Ready() bool

Ready will return true if the status represents an acceptably running status.

func (InstanceStatus) RequiresBypass

func (iis InstanceStatus) RequiresBypass() bool

RequiresBypass returns true when a bypass is required to stop the instance

func (InstanceStatus) Up

func (iis InstanceStatus) Up() bool

Up will return true if status represents any up status (even unclean states like sign-on inhibited)

type Instances

type Instances []*Instance

Instances represents a collection of Caché/Ensemble instances

func LoadInstances

func LoadInstances() (Instances, error)

LoadInstances returns a listing of all Caché/Ensemble instances on this system. It returns the list of instances and any error encountered.

func (Instances) Update

func (instances Instances) Update() error

Update will query the underlying instances and update the Instance fields with their current values. It returns any error encountered.

type ParametersISC

type ParametersISC map[string]ParametersISCGroup

ParametersISC represents the contents of the parameters ISC file

func LoadParametersISC

func LoadParametersISC(r io.Reader) (ParametersISC, error)

LoadParametersISC will load the parameters contained in the provided reader It returns the ParametersISC data structure and any error encountered

func (ParametersISC) Value

func (pi ParametersISC) Value(identifiers ...string) string

Value will, given a set of identifiers making up a parameter key, return the single value at that key Identifiers can be...

the full key (group.name)
the group, name as two separate parameters
A single parameter representing the name of a parameter in the "" group

It returns the value if a single value exists for the key or "" if it does not

func (ParametersISC) Values

func (pi ParametersISC) Values(identifiers ...string) []string

Values will, given a set of identifiers making up a parameter key, return the values at that key Identifiers can be...

the full key (group.name)
the group, name as two separate parameters
A single parameter representing the name of a parameter in the "" group

It returns the values at that key or an empty slice if it does not exist

type ParametersISCEntry

type ParametersISCEntry struct {
	// The group for this entry (the portion of the key before the .)
	Group string

	// The name of this entry (the portion of the key after the .)
	Name string

	// The values for this entry
	Values []string
}

ParametersISCEntry represents a single entry from the parameters ISC file

func (ParametersISCEntry) Key

func (pie ParametersISCEntry) Key() string

Key returns the full group.name key for this element

type ParametersISCGroup

type ParametersISCGroup map[string]*ParametersISCEntry

ParametersISCGroup represents a group of related parameters from the ISC file

Jump to

Keyboard shortcuts

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