Documentation ¶
Index ¶
- Constants
- func SupportedPlatforms() []string
- func WithCandidateName(s string) util.Option
- func WithCandidateTimestamp() util.Option
- func WithDedicated() util.Option
- func WithDefaultLogger() util.Option
- func WithDiffColorize() util.Option
- func WithDiffSideBySideW(i int) util.Option
- func WithFilesystem(s string) util.Option
- func WithFilesystemSpaceAvailBuffPerc(f float32) util.Option
- func WithLogger(l *logging.Instance) util.Option
- func WithOnPrepare(f func(*network.Driver) error) util.Option
- type Cfg
- func (c *Cfg) AbortConfig() (*response.Response, error)
- func (c *Cfg) Cleanup() error
- func (c *Cfg) CommitConfig() (*response.Response, error)
- func (c *Cfg) DiffConfig(source string, opts ...util.Option) (*response.DiffResponse, error)
- func (c *Cfg) GetConfig(source string) (*response.Response, error)
- func (c *Cfg) GetVersion() (*response.Response, error)
- func (c *Cfg) LoadConfig(config string, replace bool, opts ...util.Option) (*response.Response, error)
- func (c *Cfg) LoadConfigFromFile(f string, replace bool, opts ...util.Option) (*response.Response, error)
- func (c *Cfg) Prepare() error
- type Platform
- type WriteToFSPlatform
Constants ¶
const ( // CiscoIOSXE is the Cisco IOS-XE scrapligocfg platform type. CiscoIOSXE = "cisco_iosxe" // CiscoNXOS is the Cisco NX-OS scrapligocfg platform type. CiscoNXOS = "cisco_nxos" // CiscoIOSXR is the Cisco IOS-XR scrapligocfg platform type. CiscoIOSXR = "cisco_iosxr" // AristaEOS is the Arista EOS scrapligocfg platform type. AristaEOS = "arista_eos" // JuniperJUNOS is the Juniper JunOS scrapligocfg platform type. JuniperJUNOS = "juniper_junos" )
const ( // GetVersion is the name of the get version operation. GetVersion = "GetVersion" // GetConfig is the name of the get config operation. GetConfig = "GetConfig" // LoadConfig is the name of the load config operation. LoadConfig = "LoadConfig" // CommitConfig is the name of the commit config operation. CommitConfig = "CommitConfig" // AbortConfig is the name of the abort config operation. AbortConfig = "AbortConfig" )
Variables ¶
This section is empty.
Functions ¶
func SupportedPlatforms ¶
func SupportedPlatforms() []string
SupportedPlatforms returns a slice of all available supported "cfg" platforms.
func WithCandidateName ¶
WithCandidateName sets a preferred candidate configuration name.
func WithCandidateTimestamp ¶
WithCandidateTimestamp enables appending a unix timestamp to the candidate configuration name.
func WithDedicated ¶
WithDedicated sets the Dedicated option -- this options means that scrapligocfg can safely assume that the scrapligo connection is "dedicated" to the scrapligocfg object, and it can be opened and closed (rather than left open for subsequent use).
func WithDefaultLogger ¶
WithDefaultLogger applies the default logging setup to a driver object. This means log.Print for the logger function, and "info" for the log level.
func WithDiffColorize ¶
WithDiffColorize sets the diff colorization to true.
func WithDiffSideBySideW ¶
WithDiffSideBySideW sets the character width for each column in side-by-side diffs.
func WithFilesystem ¶
WithFilesystem sets the filesystem to write candidate configurations to for those platforms that implement WriteToFSPlatform.
func WithFilesystemSpaceAvailBuffPerc ¶
WithFilesystemSpaceAvailBuffPerc sets the filesystem space buffer percent -- or the amount of "wiggle room" to leave in a filesystem when determining available space. This is only applicable for platforms that satisfy WriteToFSPlatform.
func WithLogger ¶
WithLogger accepts a logging.Instance and applies it to the driver object.
Types ¶
type Cfg ¶
type Cfg struct { Logger *logging.Instance Impl Platform Conn *network.Driver OnPrepare func(*network.Driver) error Dedicated bool Candidate string CandidateName string CandidateTimestamp bool // contains filtered or unexported fields }
Cfg is the primary point of interaction for scrapligocfg users -- this struct wraps the target Platform implementation and provides a consistent look and feel for users regardless of the underlying device type.
func (*Cfg) AbortConfig ¶
AbortConfig aborts a loaded candidate configuration.
func (*Cfg) Cleanup ¶
Cleanup executes the Platform implementations Cleanup method and closes the scrapligo Conn.
func (*Cfg) CommitConfig ¶
CommitConfig commits a loaded candidate configuration.
func (*Cfg) DiffConfig ¶
DiffConfig diffs the requested `source` config with the candidate config. Supports `WithDiff` options to modify the DiffResponse behavior.
func (*Cfg) GetConfig ¶
GetConfig fetches the source configuration from the target device -- the source is usually one of 'running', 'startup', or 'candidate', but valid options may vary from platform to platform.
func (*Cfg) GetVersion ¶
GetVersion captures target device version information and stores it in the response.Response.
func (*Cfg) LoadConfig ¶
func (c *Cfg) LoadConfig( config string, replace bool, opts ...util.Option, ) (*response.Response, error)
LoadConfig loads a candidate configuration 'config' onto the target device. The replace argument is required -- when set to 'true' this means that scrapligocfg will load the provided candidate config in "replace" mode, which, when "committed" will fully replace the devices target config. If replace is false, the configuration will be loaded as a "merge" mode.
type Platform ¶
type Platform interface { GetVersion() (*response.PlatformResponse, error) GetConfig(source string) (*response.PlatformResponse, error) LoadConfig( f, config string, replace bool, options *util.OperationOptions, ) (*response.PlatformResponse, error) AbortConfig() (*response.PlatformResponse, error) CommitConfig() (*response.PlatformResponse, error) GetDeviceDiff(source string) (*response.PlatformResponse, error) NormalizeConfig(config string) string Cleanup() error }
Platform defines the required methods that a scrapligocfg "platform" needs to implement.
type WriteToFSPlatform ¶
type WriteToFSPlatform interface { Platform SetFilesystem(s string) SetSpaceAvailBuffPerc(f float32) }
WriteToFSPlatform defines additional Platform methods for those platforms that have candidate configurations written to the filesystem.