Add BMH manager executor api object
Also this commit extends helper interface with inventory Change-Id: I8df785f1c095a2e9502f23e1c83c5fcfe6f811fd
This commit is contained in:
parent
9bd01de3da
commit
3f9e56ecef
76
pkg/api/v1alpha1/baremetal_manager.go
Normal file
76
pkg/api/v1alpha1/baremetal_manager.go
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +kubebuilder:object:root=true
|
||||||
|
|
||||||
|
// BaremetalManager allows execution of control operations against baremetal hosts
|
||||||
|
type BaremetalManager struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
Spec BaremetalManagerSpec `json:"spec"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaremetalManagerSpec holds configuration for baremetal manager
|
||||||
|
type BaremetalManagerSpec struct {
|
||||||
|
Operation BaremetalOperation `json:"operation"`
|
||||||
|
HostSelector BaremetalHostSelector `json:"hostSelector"`
|
||||||
|
OperationOptions BaremetalOperationOptions `json:"operationOptions"`
|
||||||
|
// Timeout in seconds
|
||||||
|
Timeout int `json:"timeout"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaremetalOperationOptions hold operation options
|
||||||
|
type BaremetalOperationOptions struct {
|
||||||
|
RemoteDirect RemoteDirectOptions `json:"remoteDirect"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoteDirectOptions holds configuration for remote direct operation
|
||||||
|
type RemoteDirectOptions struct {
|
||||||
|
ISOURL string `json:"isoURL"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaremetalHostSelector allows to select a host by label selector, by name and namespace
|
||||||
|
type BaremetalHostSelector struct {
|
||||||
|
LabelSelector string `json:"labelSelector"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaremetalOperation defines an operation to be performed against baremetal host
|
||||||
|
type BaremetalOperation string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BaremetalOperationReboot reboot
|
||||||
|
BaremetalOperationReboot BaremetalOperation = "reboot"
|
||||||
|
// BaremetalOperationPowerOff power off
|
||||||
|
BaremetalOperationPowerOff BaremetalOperation = "power-off"
|
||||||
|
// BaremetalOperationPowerOn power on
|
||||||
|
BaremetalOperationPowerOn BaremetalOperation = "power-on"
|
||||||
|
// BaremetalOperationRemoteDirect boot iso with given url
|
||||||
|
BaremetalOperationRemoteDirect BaremetalOperation = "remote-direct"
|
||||||
|
// BaremetalOperationEjectVirtualMedia eject virtual media
|
||||||
|
BaremetalOperationEjectVirtualMedia BaremetalOperation = "eject-virtual-media"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DefaultBaremetalManager returns BaremetalManager executor document with default values
|
||||||
|
func DefaultBaremetalManager() *BaremetalManager {
|
||||||
|
return &BaremetalManager{Spec: BaremetalManagerSpec{Timeout: 300}}
|
||||||
|
}
|
@ -47,12 +47,12 @@ func init() {
|
|||||||
&KubeConfig{},
|
&KubeConfig{},
|
||||||
&KubernetesApply{},
|
&KubernetesApply{},
|
||||||
&IsoConfiguration{},
|
&IsoConfiguration{},
|
||||||
&RemoteDirectConfiguration{},
|
|
||||||
&ClusterMap{},
|
&ClusterMap{},
|
||||||
&ReplacementTransformer{},
|
&ReplacementTransformer{},
|
||||||
&Templater{},
|
&Templater{},
|
||||||
&BootConfiguration{},
|
&BootConfiguration{},
|
||||||
&GenericContainer{},
|
&GenericContainer{},
|
||||||
|
&BaremetalManager{},
|
||||||
)
|
)
|
||||||
_ = AddToScheme(Scheme) //nolint:errcheck
|
_ = AddToScheme(Scheme) //nolint:errcheck
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// +kubebuilder:object:root=true
|
|
||||||
|
|
||||||
// RemoteDirectConfiguration structure is inherited from apimachinery TypeMeta and ObjectMeta structures
|
|
||||||
// and defines parameters used to bootstrap the ephemeral node during the remote direct
|
|
||||||
type RemoteDirectConfiguration struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
|
||||||
|
|
||||||
// IsoURL specifies url to download ISO image for ephemeral node
|
|
||||||
IsoURL string `json:"isoUrl,omitempty"`
|
|
||||||
}
|
|
@ -70,6 +70,80 @@ func (in *ApplyWaitOptions) DeepCopy() *ApplyWaitOptions {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *BaremetalHostSelector) DeepCopyInto(out *BaremetalHostSelector) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BaremetalHostSelector.
|
||||||
|
func (in *BaremetalHostSelector) DeepCopy() *BaremetalHostSelector {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(BaremetalHostSelector)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *BaremetalManager) DeepCopyInto(out *BaremetalManager) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
out.Spec = in.Spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BaremetalManager.
|
||||||
|
func (in *BaremetalManager) DeepCopy() *BaremetalManager {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(BaremetalManager)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *BaremetalManager) DeepCopyObject() runtime.Object {
|
||||||
|
if c := in.DeepCopy(); c != nil {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *BaremetalManagerSpec) DeepCopyInto(out *BaremetalManagerSpec) {
|
||||||
|
*out = *in
|
||||||
|
out.HostSelector = in.HostSelector
|
||||||
|
out.OperationOptions = in.OperationOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BaremetalManagerSpec.
|
||||||
|
func (in *BaremetalManagerSpec) DeepCopy() *BaremetalManagerSpec {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(BaremetalManagerSpec)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *BaremetalOperationOptions) DeepCopyInto(out *BaremetalOperationOptions) {
|
||||||
|
*out = *in
|
||||||
|
out.RemoteDirect = in.RemoteDirect
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BaremetalOperationOptions.
|
||||||
|
func (in *BaremetalOperationOptions) DeepCopy() *BaremetalOperationOptions {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(BaremetalOperationOptions)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *BootConfiguration) DeepCopyInto(out *BootConfiguration) {
|
func (in *BootConfiguration) DeepCopyInto(out *BootConfiguration) {
|
||||||
*out = *in
|
*out = *in
|
||||||
@ -574,30 +648,20 @@ func (in *Provider) DeepCopy() *Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RemoteDirectConfiguration) DeepCopyInto(out *RemoteDirectConfiguration) {
|
func (in *RemoteDirectOptions) DeepCopyInto(out *RemoteDirectOptions) {
|
||||||
*out = *in
|
*out = *in
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteDirectConfiguration.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteDirectOptions.
|
||||||
func (in *RemoteDirectConfiguration) DeepCopy() *RemoteDirectConfiguration {
|
func (in *RemoteDirectOptions) DeepCopy() *RemoteDirectOptions {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := new(RemoteDirectConfiguration)
|
out := new(RemoteDirectOptions)
|
||||||
in.DeepCopyInto(out)
|
in.DeepCopyInto(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *RemoteDirectConfiguration) DeepCopyObject() runtime.Object {
|
|
||||||
if c := in.DeepCopy(); c != nil {
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplacementTransformer.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplacementTransformer.
|
||||||
func (in *ReplacementTransformer) DeepCopy() *ReplacementTransformer {
|
func (in *ReplacementTransformer) DeepCopy() *ReplacementTransformer {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
|
@ -23,6 +23,8 @@ import (
|
|||||||
"opendev.org/airship/airshipctl/pkg/cluster/clustermap"
|
"opendev.org/airship/airshipctl/pkg/cluster/clustermap"
|
||||||
"opendev.org/airship/airshipctl/pkg/config"
|
"opendev.org/airship/airshipctl/pkg/config"
|
||||||
"opendev.org/airship/airshipctl/pkg/document"
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/inventory"
|
||||||
|
inventoryifc "opendev.org/airship/airshipctl/pkg/inventory/ifc"
|
||||||
"opendev.org/airship/airshipctl/pkg/phase/ifc"
|
"opendev.org/airship/airshipctl/pkg/phase/ifc"
|
||||||
"opendev.org/airship/airshipctl/pkg/util"
|
"opendev.org/airship/airshipctl/pkg/util"
|
||||||
)
|
)
|
||||||
@ -34,7 +36,9 @@ type Helper struct {
|
|||||||
targetPath string
|
targetPath string
|
||||||
phaseRepoDir string
|
phaseRepoDir string
|
||||||
phaseEntryPointBasePath string
|
phaseEntryPointBasePath string
|
||||||
metadata *config.Metadata
|
|
||||||
|
inventory inventoryifc.Inventory
|
||||||
|
metadata *config.Metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHelper constructs metadata interface based on config
|
// NewHelper constructs metadata interface based on config
|
||||||
@ -58,6 +62,7 @@ func NewHelper(cfg *config.Config) (ifc.Helper, error) {
|
|||||||
helper.inventoryRoot = filepath.Join(helper.targetPath, helper.phaseRepoDir, helper.metadata.Inventory.Path)
|
helper.inventoryRoot = filepath.Join(helper.targetPath, helper.phaseRepoDir, helper.metadata.Inventory.Path)
|
||||||
helper.phaseEntryPointBasePath = filepath.Join(helper.targetPath, helper.phaseRepoDir,
|
helper.phaseEntryPointBasePath = filepath.Join(helper.targetPath, helper.phaseRepoDir,
|
||||||
helper.metadata.PhaseMeta.DocEntryPointPrefix)
|
helper.metadata.PhaseMeta.DocEntryPointPrefix)
|
||||||
|
helper.inventory = inventory.NewInventory(func() (*config.Config, error) { return cfg, nil })
|
||||||
return helper, nil
|
return helper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,3 +273,8 @@ func (helper *Helper) PhaseEntryPointBasePath() string {
|
|||||||
func (helper *Helper) WorkDir() (string, error) {
|
func (helper *Helper) WorkDir() (string, error) {
|
||||||
return filepath.Join(util.UserHomeDir(), config.AirshipConfigDir), nil
|
return filepath.Join(util.UserHomeDir(), config.AirshipConfigDir), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inventory return inventory interface
|
||||||
|
func (helper *Helper) Inventory() (inventoryifc.Inventory, error) {
|
||||||
|
return helper.inventory, nil
|
||||||
|
}
|
||||||
|
@ -510,6 +510,15 @@ func TestHelperWorkdir(t *testing.T) {
|
|||||||
assert.Greater(t, len(workDir), 0)
|
assert.Greater(t, len(workDir), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHelperInventory(t *testing.T) {
|
||||||
|
helper, err := phase.NewHelper(testConfig(t))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, helper)
|
||||||
|
inv, err := helper.Inventory()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NotNil(t, inv)
|
||||||
|
}
|
||||||
|
|
||||||
func testConfig(t *testing.T) *config.Config {
|
func testConfig(t *testing.T) *config.Config {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
confString := `apiVersion: airshipit.org/v1alpha1
|
confString := `apiVersion: airshipit.org/v1alpha1
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"opendev.org/airship/airshipctl/pkg/api/v1alpha1"
|
"opendev.org/airship/airshipctl/pkg/api/v1alpha1"
|
||||||
"opendev.org/airship/airshipctl/pkg/cluster/clustermap"
|
"opendev.org/airship/airshipctl/pkg/cluster/clustermap"
|
||||||
"opendev.org/airship/airshipctl/pkg/document"
|
"opendev.org/airship/airshipctl/pkg/document"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helper is a phase helper that provides phases with additional config related information
|
// Helper is a phase helper that provides phases with additional config related information
|
||||||
@ -34,5 +35,6 @@ type Helper interface {
|
|||||||
ClusterMap() (clustermap.ClusterMap, error)
|
ClusterMap() (clustermap.ClusterMap, error)
|
||||||
ExecutorDoc(phaseID ID) (document.Document, error)
|
ExecutorDoc(phaseID ID) (document.Document, error)
|
||||||
PhaseBundleRoot() string
|
PhaseBundleRoot() string
|
||||||
|
Inventory() (ifc.Inventory, error)
|
||||||
PhaseEntryPointBasePath() string
|
PhaseEntryPointBasePath() string
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user