cobblerclient

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

README

cobblerclient

Cobbler Client written in Go.

Authors:

Cobbler 3.3.x support

v0.5.0 of this client introduced support for Cobbler v3.3.0, which was a refactor from runtime-created Python attributes to Python Properties. For further details see release notes. Breaking changes:

  • This client's support for earlier Cobbler versions was dropped.
  • next_server attribute is now either next_server_v4 or next_server_v6
  • boot_loader string attribute is now boot_loaders list
  • The following string attributes are now lists: FetchableFiles, KernelOptions, KernelOptionsPost, TemplateFiles, AutoinstallMeta, Repos
To-do

Reinstate system interface testing when Cobbler issue #2846 is fixed.

Cobbler <=3.2.x support

Retaining the below notes for the time-being, which only apply to v0.4.2 and earlier clients:

Cobbler (up to version 2.8.x) was written in Python2. However, Python2 is EOL since January 2020.
Cobbler 3 has been adapted to use Python3 and so lots of code changed. Sadly this also broke backward compatability with the original cobblerclient.

XMLRPC API changes

Function read_or_write_kickstart_template was replaced with:

  • read_autoinstall_template
  • write_autoinstall_template
  • remove_autoinstall_template

Function read_or_write_snippet was replaced with:

  • read_autoinstall_snippet
  • write_autoinstall_snippet
  • remove_autoinstall_snippet
Other changes

Template names used are now short names without a path.
So foo.ks instead of /var/lib/cobbler/kickstarts/foo.ks.

Renamed

These attributes are renamed in Cobbler 3:

  • kickstart to autoinstall
  • ks_meta to autoinstall_meta, but it is still used as a "legacy field"

These directories have been renamed:

  • /var/www/cobbler/ks_mirror to /var/www/cobbler/distro_mirror
  • /var/lib/cobbler/kickstarts to /var/lib/cobbler/templates

The storage locations for the json files changed from /var/lib/cobbler/config/{distros,profiles,systems,etc...}.d to /var/lib/cobbler/collections/{distros,profiles,systems,etc...}.

There is being worked on a script to migrate these: scripts/migrate-data-v2-to-v3.py.

Added

These fields have been added:

  • boot_loader - must be either grub, pxe, or ipxe
Removed

Support for these attributes was dropped in Cobbler 3:

  • ldap_enabled
  • ldap_type
  • monit_enabled
  • redhat_management_server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Token string
	// contains filtered or unexported fields
}

Client is ...

func NewClient

func NewClient(httpClient HTTPClient, c ClientConfig) Client

NewClient is ...

func (*Client) Call added in v0.4.1

func (c *Client) Call(method string, args ...interface{}) (interface{}, error)

Call is ...

func (*Client) CreateDistro added in v0.4.1

func (c *Client) CreateDistro(distro Distro) (*Distro, error)

CreateDistro creates a distro.

func (*Client) CreateProfile added in v0.4.1

func (c *Client) CreateProfile(profile Profile) (*Profile, error)

CreateProfile creates a profile. It ensures that a Distro is set and then sets other default values.

func (*Client) CreateRepo added in v0.4.1

func (c *Client) CreateRepo(repo Repo) (*Repo, error)

CreateRepo creates a repo.

func (*Client) CreateSnippet

func (c *Client) CreateSnippet(s Snippet) error

CreateSnippet creates a snippet in Cobbler. Takes a Snippet struct as input Returns true/false and error if creation failed.

func (*Client) CreateSystem

func (c *Client) CreateSystem(system System) (*System, error)

CreateSystem creates a system. It ensures that either a Profile or Image are set and then sets other default values.

func (*Client) CreateTemplateFile added in v0.4.1

func (c *Client) CreateTemplateFile(f TemplateFile) error

CreateTemplateFile to create a template file in Cobbler. Takes a TemplateFile struct as input. Requires 3 arguments: file, data and token Returns true/false and error if creation failed.

func (*Client) DeleteDistro added in v0.4.1

func (c *Client) DeleteDistro(name string) error

DeleteDistro deletes a single distro by its name.

func (*Client) DeleteProfile added in v0.4.1

func (c *Client) DeleteProfile(name string) error

DeleteProfile deletes a single profile by its name.

func (*Client) DeleteRepo added in v0.4.1

func (c *Client) DeleteRepo(name string) error

DeleteRepo deletes a single repo by its name.

func (*Client) DeleteSnippet added in v0.4.1

func (c *Client) DeleteSnippet(name string) error

DeleteSnippet deletes a snippet file in Cobbler. Takes a snippet file name as input. Returns error if delete failed.

func (*Client) DeleteSystem

func (c *Client) DeleteSystem(name string) error

DeleteSystem deletes a single system by its name.

func (*Client) DeleteTemplateFile added in v0.4.1

func (c *Client) DeleteTemplateFile(name string) error

DeleteTemplateFile to delete a template file in Cobbler. Takes a template file name as input. Requires 2 arguments: short filename and token Returns error if delete failed.

func (*Client) GetDistro added in v0.4.1

func (c *Client) GetDistro(name string) (*Distro, error)

GetDistro returns a single distro obtained by its name.

func (*Client) GetDistros added in v0.4.1

func (c *Client) GetDistros() ([]*Distro, error)

GetDistros returns all systems in Cobbler.

func (*Client) GetItemHandle added in v0.4.1

func (c *Client) GetItemHandle(what, name string) (string, error)

GetItemHandle gets the internal ID of a Cobbler item.

func (*Client) GetProfile added in v0.4.1

func (c *Client) GetProfile(name string) (*Profile, error)

GetProfile returns a single profile obtained by its name.

func (*Client) GetProfiles added in v0.4.1

func (c *Client) GetProfiles() ([]*Profile, error)

GetProfiles returns all systems in Cobbler.

func (*Client) GetRepo added in v0.4.1

func (c *Client) GetRepo(name string) (*Repo, error)

GetRepo returns a single repo obtained by its name.

func (*Client) GetRepos added in v0.4.1

func (c *Client) GetRepos() ([]*Repo, error)

GetRepos returns all repos in Cobbler.

func (*Client) GetSnippet added in v0.4.1

func (c *Client) GetSnippet(name string) (*Snippet, error)

GetSnippet gets a snippet file in Cobbler. Takes a snippet file name as input. Returns *Snippet and error if read failed.

func (*Client) GetSystem added in v0.4.1

func (c *Client) GetSystem(name string) (*System, error)

GetSystem returns a single system obtained by its name.

func (*Client) GetSystems added in v0.4.1

func (c *Client) GetSystems() ([]*System, error)

GetSystems returns all systems in Cobbler.

func (*Client) GetTemplateFile added in v0.4.1

func (c *Client) GetTemplateFile(ksName string) (*TemplateFile, error)

GetTemplateFile to get a template file in Cobbler. Takes a template file name as input. Requires 2 arguments: short filename and token Returns *TemplateFile and error if read failed.

func (*Client) Login

func (c *Client) Login() (bool, error)

Login will perform a login request to Cobbler using the credentials provided in the configuration in the initializer.

func (*Client) Sync

func (c *Client) Sync() error

Sync the system. Returns an error if anything went wrong

func (*Client) UpdateDistro added in v0.4.1

func (c *Client) UpdateDistro(distro *Distro) error

UpdateDistro updates a single distro.

func (*Client) UpdateProfile added in v0.4.1

func (c *Client) UpdateProfile(profile *Profile) error

UpdateProfile updates a single profile.

func (*Client) UpdateRepo added in v0.4.1

func (c *Client) UpdateRepo(repo *Repo) error

UpdateRepo updates a single repo.

func (*Client) UpdateSystem added in v0.4.1

func (c *Client) UpdateSystem(system *System) error

UpdateSystem updates a single system.

type ClientConfig

type ClientConfig struct {
	URL      string
	Username string
	Password string
}

ClientConfig is the URL of Cobbler plus login credentials.

type Distro added in v0.4.1

type Distro struct {
	// These are internal fields and cannot be modified.
	Ctime             float64  `mapstructure:"ctime"           cobbler:"noupdate"` // TODO: convert to time
	Depth             int      `mapstructure:"depth"          cobbler:"noupdate"`
	Mtime             float64  `mapstructure:"mtime"           cobbler:"noupdate"` // TODO: convert to time
	SourceRepos       []string `mapstructure:"source_repos"   cobbler:"noupdate"`
	TreeBuildTime     string   `mapstructure:tree_build_time" cobbler:"noupdate"`
	UID               string   `mapstructure:"uid"            cobbler:"noupdate"`
	Arch              string   `mapstructure:"arch"`
	BootFiles         []string `mapstructure:"boot_files"`
	BootLoaders       []string `mapstructure:"boot_loaders"`
	Breed             string   `mapstructure:"breed"`
	Comment           string   `mapstructure:"comment"`
	FetchableFiles    []string `mapstructure:"fetchable_files"`
	Initrd            string   `mapstructure:"initrd"`
	Kernel            string   `mapstructure:"kernel"`
	KernelOptions     []string `mapstructure:"kernel_options"`
	KernelOptionsPost []string `mapstructure:"kernel_options_post"`
	MGMTClasses       []string `mapstructure:"mgmt_classes"`
	Name              string   `mapstructure:"name"`
	OSVersion         string   `mapstructure:"os_version"`
	Owners            []string `mapstructure:"owners"`
	TemplateFiles     []string `mapstructure:"template_files"`
}

Distro is a created distro. Get the fields from cobbler/items/distro.py

type HTTPClient

type HTTPClient interface {
	Post(string, string, io.Reader) (*http.Response, error)
}

HTTPClient is ...

type Interface added in v0.4.1

type Interface struct {
	CNAMEs             []string `mapstructure:"cnames" structs:"cnames"`
	DHCPTag            string   `mapstructure:"dhcp_tag" structs:"dhcp_tag"`
	DNSName            string   `mapstructure:"dns_name" structs:"dns_name"`
	BondingOpts        string   `mapstructure:"bonding_opts" structs:"bonding_opts"`
	BridgeOpts         string   `mapstructure:"bridge_opts" structs:"bridge_opts"`
	Gateway            string   `mapstructure:"if_gateway" structs:"if_gateway"`
	InterfaceType      string   `mapstructure:"interface_type" structs:"interface_type"`
	InterfaceMaster    string   `mapstructure:"interface_master" structs:"interface_master"`
	IPAddress          string   `mapstructure:"ip_address" structs:"ip_address"`
	IPv6Address        string   `mapstructure:"ipv6_address" structs:"ipv6_address"`
	IPv6Secondaries    []string `mapstructure:"ipv6_secondaries" structs:"ipv6_secondaries"`
	IPv6MTU            string   `mapstructure:"ipv6_mtu" structs:"ipv6_mtu"`
	IPv6StaticRoutes   []string `mapstructure:"ipv6_static_routes" structs:"ipv6_static_routes"`
	IPv6DefaultGateway string   `mapstructure:"ipv6_default_gateway" structs:"ipv6_default_gateway"`
	MACAddress         string   `mapstructure:"mac_address" structs:"mac_address"`
	Management         bool     `mapstructure:"management" structs:"management"`
	Netmask            string   `mapstructure:"netmask" structs:"netmask"`
	Static             bool     `mapstructure:"static" structs:"static"`
	StaticRoutes       []string `mapstructure:"static_routes" structs:"static_routes"`
	VirtBridge         string   `mapstructure:"virt_bridge" structs:"virt_bridge"`
}

Interface is an interface in a system.

type Interfaces added in v0.4.1

type Interfaces map[string]Interface

Interfaces is a collection of interfaces in a system.

type Profile added in v0.4.1

type Profile struct {
	// These are internal fields and cannot be modified.
	Ctime        float64 `mapstructure:"ctime"                  cobbler:"noupdate"` // TODO: convert to time
	Depth        int     `mapstructure:"depth"                  cobbler:"noupdate"`
	ID           string  `mapstructure:"uid"                    cobbler:"noupdate"`
	Mtime        float64 `mapstructure:"mtime"                  cobbler:"noupdate"` // TODO: convert to time
	ReposEnabled bool    `mapstructure:"repos_enabled"          cobbler:"noupdate"`

	Autoinstall       string   `mapstructure:"autoinstall"`
	AutoinstallMeta   []string `mapstructure:"autoinstall_meta"`
	BootFiles         []string `mapstructure:"boot_files"`
	Comment           string   `mapstructure:"comment"`
	DHCPTag           string   `mapstructure:"dhcp_tag"`
	Distro            string   `mapstructure:"distro"`
	EnableGPXE        bool     `mapstructure:"enable_gpxe"`
	EnableMenu        bool     `mapstructure:"enable_menu"`
	FetchableFiles    []string `mapstructure:"fetchable_files"`
	KernelOptions     []string `mapstructure:"kernel_options"`
	KernelOptionsPost []string `mapstructure:"kernel_options_post"`
	MGMTClasses       []string `mapstructure:"mgmt_classes"`
	MGMTParameters    string   `mapstructure:"mgmt_parameters"`
	Name              string   `mapstructure:"name"`
	NameServers       []string `mapstructure:"name_servers"`
	NameServersSearch []string `mapstructure:"name_servers_search"`
	NextServerv4      string   `mapstructure:"next_server_v4"`
	NextServerv6      string   `mapstructure:"next_server_v6"`
	Owners            []string `mapstructure:"owners"`
	Parent            string   `mapstructure:"parent"`
	Proxy             string   `mapstructure:"proxy"`
	Repos             []string `mapstructure:"repos"`
	Server            string   `mapstructure:"server"`
	TemplateFiles     []string `mapstructure:"template_files"`
	VirtAutoBoot      string   `mapstructure:"virt_auto_boot"`
	VirtBridge        string   `mapstructure:"virt_bridge"`
	VirtCPUs          string   `mapstructure:"virt_cpus"`
	VirtDiskDriver    string   `mapstructure:"virt_disk_driver"`
	VirtFileSize      string   `mapstructure:"virt_file_size"`
	VirtPath          string   `mapstructure:"virt_path"`
	VirtRAM           string   `mapstructure:"virt_ram"`
	VirtType          string   `mapstructure:"virt_type"`

	Client
}

Profile is a created profile.

type Repo added in v0.4.1

type Repo struct {
	// These are internal fields and cannot be modified.
	Ctime         float64 `mapstructure:"ctime"          cobbler:"noupdate"` // TODO: convert to time
	Depth         int     `mapstructure:"depth"          cobbler:"noupdate"`
	Mtime         float64 `mapstructure:"mtime"          cobbler:"noupdate"` // TODO: convert to time
	TreeBuildTime string  `mapstructure:tree_build_time" cobbler:"noupdate"`
	Parent        string  `mapstructure:"parent"            cobbler:"noupdate"`
	UID           string  `mapstructure:"uid"            cobbler:"noupdate"`

	AptComponents   []string `mapstructure:"apt_components"`
	AptDists        []string `mapstructure:"apt_dists"`
	Arch            string   `mapstructure:"arch"`
	Breed           string   `mapstructure:"breed"`
	Comment         string   `mapstructure:"comment"`
	CreateRepoFlags string   `mapstructure:"createrepo_flags"`
	Environment     []string `mapstructure:"environment"`
	KeepUpdated     bool     `mapstructure:"keep_updated"`
	Mirror          string   `mapstructure:"mirror"`
	MirrorLocally   bool     `mapstructure:"mirror_locally"`
	Name            string   `mapstructure:"name"`
	Owners          []string `mapstructure:"owners"`
	Proxy           string   `mapstructure:"proxy" cobbler:"newfield"`
	RpmList         []string `mapstructure:"rpm_list"`
}

Repo is a created repo. Get the fileds from cobbler/items/repo.py

type Snippet

type Snippet struct {
	Name string // The name the snippet file will be saved in Cobbler
	Body string // The contents of the template file
}

Snippet is a snippet file

type System

type System struct {
	// These are internal fields and cannot be modified.
	Ctime                 float64                `mapstructure:"ctime"                 cobbler:"noupdate"` // TODO: convert to time
	Depth                 int                    `mapstructure:"depth"                 cobbler:"noupdate"`
	ID                    string                 `mapstructure:"uid"                   cobbler:"noupdate"`
	IPv6Autoconfiguration bool                   `mapstructure:"ipv6_autoconfiguration" cobbler:"noupdate"`
	Mtime                 float64                `mapstructure:"mtime"                 cobbler:"noupdate"` // TODO: convert to time
	ReposEnabled          bool                   `mapstructure:"repos_enabled"          cobbler:"noupdate"`
	Autoinstall           string                 `mapstructure:"autoinstall"`
	AutoinstallMeta       []string               `mapstructure:"autoinstall_meta"`
	BootFiles             string                 `mapstructure:"boot_files"`
	BootLoaders           []string               `mapstructure:"boot_loaders"`
	Comment               string                 `mapstructure:"comment"`
	EnableGPXE            bool                   `mapstructure:"enable_gpxe"`
	FetchableFiles        []string               `mapstructure:"fetchable_files"`
	Gateway               string                 `mapstructure:"gateway"`
	Hostname              string                 `mapstructure:"hostname"`
	Image                 string                 `mapstructure:"image"`
	Interfaces            map[string]interface{} `mapstructure:"interfaces" cobbler:"noupdate"`
	IPv6DefaultDevice     string                 `mapstructure:"ipv6_default_device"`
	KernelOptions         []string               `mapstructure:"kernel_options"`
	KernelOptionsPost     []string               `mapstructure:"kernel_options_post"`
	MGMTClasses           []string               `mapstructure:"mgmt_classes"`
	MGMTParameters        string                 `mapstructure:"mgmt_parameters"`
	Name                  string                 `mapstructure:"name"`
	NameServers           []string               `mapstructure:"name_servers"`
	NameServersSearch     []string               `mapstructure:"name_servers_search"`
	NetbootEnabled        bool                   `mapstructure:"netboot_enabled"`
	NextServerv4          string                 `mapstructure:"next_server_v4"`
	NextServerv6          string                 `mapstructure:"next_server_v6"`
	Owners                []string               `mapstructure:"owners"`
	PowerAddress          string                 `mapstructure:"power_address"`
	PowerID               string                 `mapstructure:"power_id"`
	PowerPass             string                 `mapstructure:"power_pass"`
	PowerType             string                 `mapstructure:"power_type"`
	PowerUser             string                 `mapstructure:"power_user"`
	Profile               string                 `mapstructure:"profile"`
	Proxy                 string                 `mapstructure:"proxy"`
	Status                string                 `mapstructure:"status"`
	TemplateFiles         []string               `mapstructure:"template_files"`
	VirtAutoBoot          string                 `mapstructure:"virt_auto_boot"`
	VirtCPUs              string                 `mapstructure:"virt_cpus"`
	VirtDiskDriver        string                 `mapstructure:"virt_disk_driver"`
	VirtFileSize          string                 `mapstructure:"virt_file_size"`
	VirtPath              string                 `mapstructure:"virt_path"`
	VirtPXEBoot           int                    `mapstructure:"virt_pxe_boot"`
	VirtRAM               string                 `mapstructure:"virt_ram"`
	VirtType              string                 `mapstructure:"virt_type"`

	Client
}

System is a created system.

func (*System) CreateInterface added in v0.4.1

func (s *System) CreateInterface(name string, iface Interface) error

CreateInterface controls network interfaces in Cobbler

func (*System) DeleteInterface added in v0.4.1

func (s *System) DeleteInterface(name string) error

DeleteInterface deletes a single interface in a System.

func (*System) GetInterface added in v0.4.1

func (s *System) GetInterface(name string) (Interface, error)

GetInterface returns a single interface in a System.

func (*System) GetInterfaces added in v0.4.1

func (s *System) GetInterfaces() (Interfaces, error)

GetInterfaces returns all interfaces in a System.

type TemplateFile added in v0.4.1

type TemplateFile struct {
	Name string // The name the template file will be saved in Cobbler
	Body string // The contents of the template file
}

TemplateFile is the former TemplateFile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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