secureagent

package
v0.0.0-...-4eedd94 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

nolint Package secureagent implements the secure agent

Package secureagent implements the secure agent

Package secureagent implements the secure agent

Package secureagent implements the secure agent

nolint Package secureagent implements the secure agent

Package secureagent implements the secure agent

SPDX-License-Identifier: Apache-2.0 Copyright (C) 2022-2023 Intel Corporation Copyright (c) 2022 Dell Inc, or its subsidiaries. Copyright (C) 2022 Red Hat.

nolint Package secureagent implements the secure agent

Package secureagent implements the secure agent

Package secureagent implements the secure agent

Index

Constants

View Source
const (
	CONTENT_TYPE_YANG = "application/yang-data+json"
	OS_RELEASE_FILE   = "/etc/os-release"
	SZTP_REDIRECT_URL = "sztp-redirect-urls"
	ARTIFACTS_PATH    = "/tmp/"
)
View Source
const (
	// PRE nolint:var-naming
	PRE = "pre"
	// POST nolint:var-naming
	POST = "post"
)

Variables

This section is empty.

Functions

func GetSerialNumber

func GetSerialNumber(givenSerialNumber string) string

GetSerialNumber returns the serial number of the device

func NewHTTPClient

func NewHTTPClient(bootstrapTrustAnchorCert string, deviceEndEntityCert string, devicePrivateKey string) http.Client

NewHTTPClient instantiate a new HTTP Client

Types

type Agent

type Agent struct {
	InputBootstrapURL             string                        // Bootstrap complete URL given by USER
	BootstrapURL                  string                        // Bootstrap complete URL
	SerialNumber                  string                        // Device's Serial Number
	DevicePassword                string                        // Device's Password
	DevicePrivateKey              string                        // Device's private key
	DeviceEndEntityCert           string                        // Device's end-entity cert
	BootstrapTrustAnchorCert      string                        // the trusted bootstrap server's trust-anchor certificate (PEM)
	ContentTypeReq                string                        // The content type for the request to the Server
	InputJSONContent              string                        // The input.json file serialized
	DhcpLeaseFile                 string                        // The dhcpfile
	ProgressJSON                  ProgressJSON                  // ProgressJson structure
	BootstrapServerOnboardingInfo BootstrapServerOnboardingInfo // BootstrapServerOnboardingInfo structure
	BootstrapServerRedirectInfo   BootstrapServerRedirectInfo   // BootstrapServerRedirectInfo structure
	HttpClient                    HttpClient
	StatusFilePath                string // Path to the status file
	ResultFilePath                string // Path to the result file
	SymLinkDir                    string // Path to the symlink directory for the status file
}

Agent is the basic structure to define an agent instance

func NewAgent

func NewAgent(bootstrapURL, serialNumber, dhcpLeaseFile, devicePassword, devicePrivateKey, deviceEndEntityCert, bootstrapTrustAnchorCert, statusFilePath, resultFilePath, symLinkDir string, httpClient HttpClient) *Agent

func (*Agent) GetBootstrapTrustAnchorCert

func (a *Agent) GetBootstrapTrustAnchorCert() string

func (*Agent) GetBootstrapURL

func (a *Agent) GetBootstrapURL() string

func (*Agent) GetContentTypeReq

func (a *Agent) GetContentTypeReq() string

func (*Agent) GetDeviceEndEntityCert

func (a *Agent) GetDeviceEndEntityCert() string

func (*Agent) GetDevicePassword

func (a *Agent) GetDevicePassword() string

func (*Agent) GetDevicePrivateKey

func (a *Agent) GetDevicePrivateKey() string

func (*Agent) GetInputJSONContent

func (a *Agent) GetInputJSONContent() string

func (*Agent) GetProgressJSON

func (a *Agent) GetProgressJSON() ProgressJSON

func (*Agent) GetResultFilePath

func (a *Agent) GetResultFilePath() string

func (*Agent) GetSerialNumber

func (a *Agent) GetSerialNumber() string

func (*Agent) GetStatusFilePath

func (a *Agent) GetStatusFilePath() string

func (*Agent) GetSymLinkDir

func (a *Agent) GetSymLinkDir() string

func (*Agent) RunCommand

func (a *Agent) RunCommand() error

RunCommand runs the command in the background

func (*Agent) RunCommandDaemon

func (a *Agent) RunCommandDaemon() error

RunCommandDaemon runs the command in the background

func (*Agent) RunCommandDisable

func (a *Agent) RunCommandDisable() error

RunCommandDisable runs the command in the background

func (*Agent) RunCommandEnable

func (a *Agent) RunCommandEnable() error

RunCommandEnable runs the command in the background

func (*Agent) RunCommandStatus

func (a *Agent) RunCommandStatus() error

RunCommandStatus runs the command in the background

func (*Agent) SetBootstrapTrustAnchorCert

func (a *Agent) SetBootstrapTrustAnchorCert(cacert string)

func (*Agent) SetBootstrapURL

func (a *Agent) SetBootstrapURL(url string)

func (*Agent) SetContentTypeReq

func (a *Agent) SetContentTypeReq(ct string)

func (*Agent) SetDeviceEndEntityCert

func (a *Agent) SetDeviceEndEntityCert(cert string)

func (*Agent) SetDevicePassword

func (a *Agent) SetDevicePassword(pass string)

func (*Agent) SetDevicePrivateKey

func (a *Agent) SetDevicePrivateKey(key string)

func (*Agent) SetProgressJSON

func (a *Agent) SetProgressJSON(p ProgressJSON)

func (*Agent) SetResultFilePath

func (a *Agent) SetResultFilePath(path string)

func (*Agent) SetSerialNumber

func (a *Agent) SetSerialNumber(serialNumber string)

func (*Agent) SetStatusFilePath

func (a *Agent) SetStatusFilePath(path string)

func (*Agent) SetSymLinkDir

func (a *Agent) SetSymLinkDir(path string)

type BootstrapServerErrorOutput

type BootstrapServerErrorOutput struct {
	IetfRestconfErrors struct {
		Error []struct {
			ErrorType    string `json:"error-type"`
			ErrorTag     string `json:"error-tag"`
			ErrorMessage string `json:"error-message"`
		} `json:"error"`
	} `json:"ietf-restconf:errors"`
}

type BootstrapServerOnboardingInfo

type BootstrapServerOnboardingInfo struct {
	IetfSztpConveyedInfoOnboardingInformation struct {
		InfoTimestampReference string // [not received in json] This is the reference to know exactly the time file downloaded and reference to the artifacts of a specific request
		BootImage              struct {
			DownloadURI       []string `json:"download-uri"`
			ImageVerification []struct {
				HashAlgorithm string `json:"hash-algorithm"`
				HashValue     string `json:"hash-value"`
			} `json:"image-verification"`
		} `json:"boot-image"`
		PreConfigurationScript  string `json:"pre-configuration-script"`
		ConfigurationHandling   string `json:"configuration-handling"`
		Configuration           string `json:"configuration"`
		PostConfigurationScript string `json:"post-configuration-script"`
	} `json:"ietf-sztp-conveyed-info:onboarding-information"`
}

type BootstrapServerPostOutput

type BootstrapServerPostOutput struct {
	IetfSztpBootstrapServerOutput struct {
		ConveyedInformation string `json:"conveyed-information"`
	} `json:"ietf-sztp-bootstrap-server:output"`
}

type BootstrapServerRedirectInfo

type BootstrapServerRedirectInfo struct {
	IetfSztpConveyedInfoRedirectInformation struct {
		BootstrapServer []struct {
			Address     string `json:"address"`
			Port        int    `json:"port"`
			TrustAnchor string `json:"trust-anchor"`
		} `json:"bootstrap-server"`
	} `json:"ietf-sztp-conveyed-info:redirect-information"`
}

type HttpClient

type HttpClient interface {
	Get(uri string) (*http.Response, error)
	Do(req *http.Request) (*http.Response, error)
}

type InputJSON

type InputJSON struct {
	IetfSztpBootstrapServerInput struct {
		HwModel   string `json:"hw-model"`
		OsName    string `json:"os-name"`
		OsVersion string `json:"os-version"`
		Nonce     string `json:"nonce"`
	} `json:"ietf-sztp-bootstrap-server:input"`
}

type ProgressJSON

type ProgressJSON struct {
	IetfSztpBootstrapServerInput struct {
		ProgressType string `json:"progress-type"`
		Message      string `json:"message"`
		SSHHostKeys  struct {
			SSHHostKey []struct {
				Algorithm string `json:"algorithm"`
				KeyData   string `json:"key-data"`
			} `json:"ssh-host-key,omitempty"`
		} `json:"ssh-host-keys,omitempty"`
		TrustAnchorCerts struct {
			TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
		} `json:"trust-anchor-certs,omitempty"`
	} `json:"ietf-sztp-bootstrap-server:input"`
}

type ProgressType

type ProgressType int64
const (
	ProgressTypeBootstrapInitiated ProgressType = iota
	ProgressTypeParsingInitiated
	ProgressTypeParsingWarning
	ProgressTypeParsingError
	ProgressTypeParsingComplete
	ProgressTypeBootImageInitiated
	ProgressTypeBootImageWarning
	ProgressTypeBootImageError
	ProgressTypeBootImageMismatch
	ProgressTypeBootImageInstalledRebooting
	ProgressTypeBootImageComplete
	ProgressTypePreScriptInitiated
	ProgressTypePreScriptWarning
	ProgressTypePreScriptError
	ProgressTypePreScriptComplete
	ProgressTypeConfigInitiated
	ProgressTypeConfigWarning
	ProgressTypeConfigError
	ProgressTypeConfigComplete
	ProgressTypePostScriptInitiated
	ProgressTypePostScriptWarning
	ProgressTypePostScriptError
	ProgressTypePostScriptComplete
	ProgressTypeBootstrapWarning
	ProgressTypeBootstrapError
	ProgressTypeBootstrapComplete
	ProgressTypeInformational
)

func (ProgressType) String

func (s ProgressType) String() string

type Result

type Result struct {
	Errors []string `json:"errors"`
}

Result represents the result of the provisioning process.

type StageStatus

type StageStatus struct {
	Errors []string `json:"errors"`
	Start  float64  `json:"start"`
	End    float64  `json:"end"`
}

StageStatus represents the status of a specific stage.

type StageType

type StageType int64
const (
	StageTypeInit StageType = iota
	StageTypeDownloadingFile
	StageTypePendingReboot
	StageTypeParsing
	StageTypeOnboarding
	StageTypeRedirect
	StageTypeBootImage
	StageTypePreScript
	StageTypeConfig
	StageTypePostScript
	StageTypeBootstrap
	StageTypeIsCompleted
)

func (StageType) String

func (s StageType) String() string

type Status

type Status struct {
	Init            StageStatus `json:"init"`
	DownloadingFile StageStatus `json:"downloading-file"`
	PendingReboot   StageStatus `json:"pending-reboot"`
	Parsing         StageStatus `json:"parsing"`
	Onboarding      StageStatus `json:"onboarding"`
	Redirect        StageStatus `json:"redirect"`
	BootImage       StageStatus `json:"boot-image"`
	PreScript       StageStatus `json:"pre-script"`
	Config          StageStatus `json:"config"`
	PostScript      StageStatus `json:"post-script"`
	Bootstrap       StageStatus `json:"bootstrap"`
	IsCompleted     StageStatus `json:"is-completed"`
	Informational   string      `json:"informational"`
	Stage           string      `json:"stage"`
}

Status represents the status of the provisioning process.

Jump to

Keyboard shortcuts

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