Merge "Add inventory interface and cmd line integration"

This commit is contained in:
Zuul 2021-01-28 02:34:30 +00:00 committed by Gerrit Code Review
commit a2fd0b7b76
30 changed files with 221 additions and 193 deletions

View File

@ -15,14 +15,12 @@
package baremetal package baremetal
import ( import (
"context" "time"
"fmt"
"io"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/remote" "opendev.org/airship/airshipctl/pkg/inventory"
) )
// Action type is used to perform specific baremetal action // Action type is used to perform specific baremetal action
@ -34,30 +32,19 @@ const (
flagLabelDescription = "Label(s) to filter desired baremetal host documents" flagLabelDescription = "Label(s) to filter desired baremetal host documents"
flagName = "name" flagName = "name"
flagNameShort = "n"
flagNameDescription = "Name to filter desired baremetal host document" flagNameDescription = "Name to filter desired baremetal host document"
flagPhase = "phase" flagNamespace = "namespace"
flagPhaseDescription = "airshipctl phase that contains the desired baremetal host document(s)" flagNamespaceSort = "n"
flagNamespaceDescription = "airshipctl phase that contains the desired baremetal host document(s)"
ejectAction Action = iota flagTimeout = "timeout"
powerOffAction flagTimeoutDescription = "timeout on baremetal action"
powerOnAction
powerStatusAction
rebootAction
remoteDirectAction
) )
// CommonOptions is used to store common variables from cmd flags for baremetal command group
type CommonOptions struct {
labels string
name string
phase string
}
// NewBaremetalCommand creates a new command for interacting with baremetal using airshipctl. // NewBaremetalCommand creates a new command for interacting with baremetal using airshipctl.
func NewBaremetalCommand(cfgFactory config.Factory) *cobra.Command { func NewBaremetalCommand(cfgFactory config.Factory) *cobra.Command {
options := &CommonOptions{} options := inventory.NewOptions(inventory.NewInventory(cfgFactory))
baremetalRootCmd := &cobra.Command{ baremetalRootCmd := &cobra.Command{
Use: "baremetal", Use: "baremetal",
Short: "Perform actions on baremetal hosts", Short: "Perform actions on baremetal hosts",
@ -73,93 +60,10 @@ func NewBaremetalCommand(cfgFactory config.Factory) *cobra.Command {
return baremetalRootCmd return baremetalRootCmd
} }
func initFlags(options *CommonOptions, cmd *cobra.Command) { func initFlags(options *inventory.CommandOptions, cmd *cobra.Command) {
flags := cmd.Flags() flags := cmd.Flags()
flags.StringVarP(&options.labels, flagLabel, flagLabelShort, "", flagLabelDescription) flags.StringVarP(&options.Labels, flagLabel, flagLabelShort, "", flagLabelDescription)
flags.StringVarP(&options.name, flagName, flagNameShort, "", flagNameDescription) flags.StringVar(&options.Name, flagName, "", flagNameDescription)
flags.StringVar(&options.phase, flagPhase, config.BootstrapPhase, flagPhaseDescription) flags.StringVarP(&options.Namespace, flagNamespace, flagNamespaceSort, "", flagNamespaceDescription)
} flags.DurationVar(&options.Timeout, flagTimeout, 10*time.Minute, flagTimeoutDescription)
func performAction(cfgFactory config.Factory, options *CommonOptions, action Action, writer io.Writer) error {
cfg, err := cfgFactory()
if err != nil {
return err
}
selectors := GetHostSelections(options.name, options.labels)
m, err := remote.NewManager(cfg, options.phase, selectors...)
if err != nil {
return err
}
return selectAction(m, cfg, action, writer)
}
func selectAction(m *remote.Manager, cfg *config.Config, action Action, writer io.Writer) error {
if action == remoteDirectAction {
if len(m.Hosts) != 1 {
return remote.NewRemoteDirectErrorf("more than one node defined as the ephemeral node")
}
ephemeralHost := m.Hosts[0]
return ephemeralHost.DoRemoteDirect(cfg)
}
ctx := context.Background()
for _, host := range m.Hosts {
switch action {
case ejectAction:
if err := host.EjectVirtualMedia(ctx); err != nil {
return err
}
fmt.Fprintf(writer, "All media ejected from host '%s'.\n", host.HostName)
case powerOffAction:
if err := host.SystemPowerOff(ctx); err != nil {
return err
}
fmt.Fprintf(writer, "Powered off host '%s'.\n", host.HostName)
case powerOnAction:
if err := host.SystemPowerOn(ctx); err != nil {
return err
}
fmt.Fprintf(writer, "Powered on host '%s'.\n", host.HostName)
case powerStatusAction:
powerStatus, err := host.SystemPowerStatus(ctx)
if err != nil {
return err
}
fmt.Fprintf(writer, "Host '%s' has power status: '%s'\n",
host.HostName, powerStatus)
case rebootAction:
if err := host.RebootSystem(ctx); err != nil {
return err
}
fmt.Fprintf(writer, "Rebooted host '%s'.\n", host.HostName)
}
}
return nil
}
// GetHostSelections builds a list of selectors that can be passed to a manager
// using the name and label flags passed to airshipctl.
func GetHostSelections(name string, labels string) []remote.HostSelector {
var selectors []remote.HostSelector
if name != "" {
selectors = append(selectors, remote.ByName(name))
}
if labels != "" {
selectors = append(selectors, remote.ByLabel(labels))
}
if len(selectors) == 0 {
selectors = append(selectors, remote.All())
}
return selectors
} }

View File

@ -17,9 +17,8 @@ package baremetal_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"opendev.org/airship/airshipctl/cmd/baremetal" "opendev.org/airship/airshipctl/cmd/baremetal"
"opendev.org/airship/airshipctl/pkg/inventory"
"opendev.org/airship/airshipctl/testutil" "opendev.org/airship/airshipctl/testutil"
) )
@ -33,32 +32,32 @@ func TestBaremetal(t *testing.T) {
{ {
Name: "baremetal-ejectmedia-with-help", Name: "baremetal-ejectmedia-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewEjectMediaCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewEjectMediaCommand(nil, &inventory.CommandOptions{}),
}, },
{ {
Name: "baremetal-poweroff-with-help", Name: "baremetal-poweroff-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewPowerOffCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewPowerOffCommand(nil, &inventory.CommandOptions{}),
}, },
{ {
Name: "baremetal-poweron-with-help", Name: "baremetal-poweron-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewPowerOnCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewPowerOnCommand(nil, &inventory.CommandOptions{}),
}, },
{ {
Name: "baremetal-powerstatus-with-help", Name: "baremetal-powerstatus-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewPowerStatusCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewPowerStatusCommand(nil, &inventory.CommandOptions{}),
}, },
{ {
Name: "baremetal-reboot-with-help", Name: "baremetal-reboot-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewRebootCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewRebootCommand(nil, &inventory.CommandOptions{}),
}, },
{ {
Name: "baremetal-remotedirect-with-help", Name: "baremetal-remotedirect-with-help",
CmdLine: "-h", CmdLine: "-h",
Cmd: baremetal.NewRemoteDirectCommand(nil, &baremetal.CommonOptions{}), Cmd: baremetal.NewRemoteDirectCommand(nil, &inventory.CommandOptions{}),
}, },
} }
@ -66,18 +65,3 @@ func TestBaremetal(t *testing.T) {
testutil.RunTest(t, tt) testutil.RunTest(t, tt)
} }
} }
func TestGetHostSelectionsOneSelector(t *testing.T) {
selectors := baremetal.GetHostSelections("node0", "")
assert.Len(t, selectors, 1)
}
func TestGetHostSelectionsBothSelectors(t *testing.T) {
selectors := baremetal.GetHostSelections("node0", "airshipit.org/ephemeral-node=true")
assert.Len(t, selectors, 2)
}
func TestGetHostSelectionsNone(t *testing.T) {
selectors := baremetal.GetHostSelections("", "")
assert.Len(t, selectors, 1)
}

View File

@ -18,16 +18,18 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/inventory"
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
) )
// NewEjectMediaCommand provides a command to eject media attached to a baremetal host. // NewEjectMediaCommand provides a command to eject media attached to a baremetal host.
func NewEjectMediaCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewEjectMediaCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "ejectmedia", Use: "ejectmedia",
Short: "Eject media attached to a baremetal host", Short: "Eject media attached to a baremetal host",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return performAction(cfgFactory, options, ejectAction, cmd.OutOrStdout()) return options.BMHAction(ifc.BaremetalOperationEjectVirtualMedia)
}, },
} }

View File

@ -18,16 +18,18 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/inventory"
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
) )
// NewPowerOffCommand provides a command to shutdown a remote host. // NewPowerOffCommand provides a command to shutdown a remote host.
func NewPowerOffCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewPowerOffCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "poweroff", Use: "poweroff",
Short: "Shutdown a baremetal host", Short: "Shutdown a baremetal host",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return performAction(cfgFactory, options, powerOffAction, cmd.OutOrStdout()) return options.BMHAction(ifc.BaremetalOperationPowerOff)
}, },
} }

View File

@ -18,16 +18,18 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/inventory"
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
) )
// NewPowerOnCommand provides a command with the capability to power on baremetal hosts. // NewPowerOnCommand provides a command with the capability to power on baremetal hosts.
func NewPowerOnCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewPowerOnCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "poweron", Use: "poweron",
Short: "Power on a host", Short: "Power on a host",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return performAction(cfgFactory, options, powerOnAction, cmd.OutOrStdout()) return options.BMHAction(ifc.BaremetalOperationPowerOn)
}, },
} }

View File

@ -18,16 +18,17 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/inventory"
) )
// NewPowerStatusCommand provides a command to retrieve the power status of a baremetal host. // NewPowerStatusCommand provides a command to retrieve the power status of a baremetal host.
func NewPowerStatusCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewPowerStatusCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "powerstatus", Use: "powerstatus",
Short: "Retrieve the power status of a baremetal host", Short: "Retrieve the power status of a baremetal host",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return performAction(cfgFactory, options, powerStatusAction, cmd.OutOrStdout()) return options.PowerStatus(cmd.OutOrStdout())
}, },
} }

View File

@ -18,16 +18,18 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/inventory"
"opendev.org/airship/airshipctl/pkg/inventory/ifc"
) )
// NewRebootCommand provides a command with the capability to reboot baremetal hosts. // NewRebootCommand provides a command with the capability to reboot baremetal hosts.
func NewRebootCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewRebootCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "reboot", Use: "reboot",
Short: "Reboot a host", Short: "Reboot a host",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return performAction(cfgFactory, options, rebootAction, cmd.OutOrStdout()) return options.BMHAction(ifc.BaremetalOperationReboot)
}, },
} }

View File

@ -18,20 +18,21 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/document" "opendev.org/airship/airshipctl/pkg/inventory"
) )
// NewRemoteDirectCommand provides a command with the capability to perform remote direct operations. // NewRemoteDirectCommand provides a command with the capability to perform remote direct operations.
func NewRemoteDirectCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command { func NewRemoteDirectCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "remotedirect", Use: "remotedirect",
Short: "Bootstrap the ephemeral host", Short: "Bootstrap the ephemeral host",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
options.phase = config.BootstrapPhase return options.RemoteDirect()
options.labels = document.EphemeralHostSelector
return performAction(cfgFactory, options, remoteDirectAction, cmd.OutOrStdout())
}, },
} }
initFlags(options, cmd)
cmd.Flags().StringVar(&options.IsoURL, "iso-url", "", "specify iso url for host to boot from")
return cmd return cmd
} }

View File

@ -4,7 +4,8 @@ Usage:
ejectmedia [flags] ejectmedia [flags]
Flags: Flags:
-h, --help help for ejectmedia -h, --help help for ejectmedia
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -4,7 +4,8 @@ Usage:
poweroff [flags] poweroff [flags]
Flags: Flags:
-h, --help help for poweroff -h, --help help for poweroff
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -4,7 +4,8 @@ Usage:
poweron [flags] poweron [flags]
Flags: Flags:
-h, --help help for poweron -h, --help help for poweron
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -4,7 +4,8 @@ Usage:
powerstatus [flags] powerstatus [flags]
Flags: Flags:
-h, --help help for powerstatus -h, --help help for powerstatus
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -4,7 +4,8 @@ Usage:
reboot [flags] reboot [flags]
Flags: Flags:
-h, --help help for reboot -h, --help help for reboot
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -4,4 +4,9 @@ Usage:
remotedirect [flags] remotedirect [flags]
Flags: Flags:
-h, --help help for remotedirect -h, --help help for remotedirect
--iso-url string specify iso url for host to boot from
-l, --labels string Label(s) to filter desired baremetal host documents
--name string Name to filter desired baremetal host document
-n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)

View File

@ -13,10 +13,11 @@ airshipctl baremetal ejectmedia [flags]
### Options ### Options
``` ```
-h, --help help for ejectmedia -h, --help help for ejectmedia
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,10 +13,11 @@ airshipctl baremetal poweroff [flags]
### Options ### Options
``` ```
-h, --help help for poweroff -h, --help help for poweroff
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,10 +13,11 @@ airshipctl baremetal poweron [flags]
### Options ### Options
``` ```
-h, --help help for poweron -h, --help help for poweron
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,10 +13,11 @@ airshipctl baremetal powerstatus [flags]
### Options ### Options
``` ```
-h, --help help for powerstatus -h, --help help for powerstatus
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,10 +13,11 @@ airshipctl baremetal reboot [flags]
### Options ### Options
``` ```
-h, --help help for reboot -h, --help help for reboot
-l, --labels string Label(s) to filter desired baremetal host documents -l, --labels string Label(s) to filter desired baremetal host documents
-n, --name string Name to filter desired baremetal host document --name string Name to filter desired baremetal host document
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso") -n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,7 +13,12 @@ airshipctl baremetal remotedirect [flags]
### Options ### Options
``` ```
-h, --help help for remotedirect -h, --help help for remotedirect
--iso-url string specify iso url for host to boot from
-l, --labels string Label(s) to filter desired baremetal host documents
--name string Name to filter desired baremetal host document
-n, --namespace string airshipctl phase that contains the desired baremetal host document(s)
--timeout duration timeout on baremetal action (default 10m0s)
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -13,7 +13,7 @@ airshipctl image build [flags]
### Options ### Options
``` ```
-h, --help help for build -h, --help help for build
``` ```
### Options inherited from parent commands ### Options inherited from parent commands

View File

@ -0,0 +1,20 @@
# This patches the node02 BMH to be suitable for ephemeral purposes
apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
labels:
airshipit.org/ephemeral-node: "true"
airshipit.org/deploy-k8s: "false"
name: node02
spec:
online: true
bmc:
address: redfish+https://localhost:8443/redfish/v1/Systems/air-ephemeral
status:
provisioning:
# we need this status to make sure, that the host is not going to be
# reprovisioned by the ephemeral baremetal operator.
# when we have more flexible labeling system in place, we will not
# deliver this document to ephemeral cluster
state: externally provisioned

View File

@ -0,0 +1,14 @@
# Site-level, phase-specific lists of hosts to generate
# This is used by the hostgenerator-m3 function to narrow down the site-level
# host-catalogue to just the hosts needed for a particular phase.
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: host-generation-catalogue
hosts:
m3:
# Note: this list should be kept up to date with
# the full list of hosts in the cluster
- node01
- node02
- node03

View File

@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../../function/hostgenerator-m3
- ../../target/catalogues
- host-generation.yaml
transformers:
- ../../../../function/hostgenerator-m3/replacements
- patchesstrategicmerge.yaml

View File

@ -0,0 +1,41 @@
apiVersion: builtin
kind: PatchStrategicMergeTransformer
metadata:
name: smp
patches: |-
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: host-catalogue
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: host-generation-catalogue
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: networking
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: env-vars-catalogue
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: versions-airshipctl
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: password-secret
$patch: delete

View File

@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
generators:
- hostgenerator
patchesStrategicMerge:
- ephemeral-patch.yaml

View File

@ -1,3 +1,5 @@
phase: phase:
path: manifests/site/test-site/phases path: manifests/site/test-site/phases
docEntryPointPrefix: manifests/site/test-site docEntryPointPrefix: manifests/site/test-site
inventory:
path: manifests/site/test-site/host-inventory

View File

@ -26,7 +26,7 @@ hosts:
node02: node02:
bootMode: UEFI bootMode: UEFI
macAddress: 52:54:00:b6:ed:02 macAddress: 52:54:00:b6:ed:02
bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2 bmcAddress: redfish+https://localhost:8443/redfish/v1/Systems/air-ephemeral
bmcUsername: username bmcUsername: username
bmcPassword: password bmcPassword: password
disableCertificateVerification: false disableCertificateVerification: false
@ -51,3 +51,16 @@ hosts:
oam: 52:54:00:9b:27:07 oam: 52:54:00:9b:27:07
pxe: 52:54:00:b6:ed:23 pxe: 52:54:00:b6:ed:23
hardwareProfile: default # defined in the hardwareprofile-example function hardwareProfile: default # defined in the hardwareprofile-example function
node04:
bootMode: UEFI
macAddress: 52:54:00:36:5e:e3
bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2
bmcUsername: username
bmcPassword: password
ipAddresses:
oam-ipv4: 10.23.25.104
pxe-ipv4: 10.23.24.104
macAddresses:
oam: 52:54:00:dc:ab:04
pxe: 52:54:00:51:0b:e4
hardwareProfile: default # defined in the hardwareprofile-example function

View File

@ -20,7 +20,10 @@ export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
export KUBECONFIG_EPHEMERAL_CONTEXT=${KUBECONFIG_EPHEMERAL_CONTEXT:-"ephemeral-cluster"} export KUBECONFIG_EPHEMERAL_CONTEXT=${KUBECONFIG_EPHEMERAL_CONTEXT:-"ephemeral-cluster"}
echo "Deploy ephemeral node using redfish with iso" echo "Deploy ephemeral node using redfish with iso"
airshipctl baremetal remotedirect --debug airshipctl baremetal remotedirect \
--iso-url http://localhost:8099/ephemeral.iso \
--name "node02" \
--debug
echo "Wait for apiserver to become available" echo "Wait for apiserver to become available"
N=0 N=0

View File

@ -15,7 +15,6 @@
set -xe set -xe
export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"} export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
NODENAME="node01"
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"} export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
echo "Deploy calico using tigera operator" echo "Deploy calico using tigera operator"