Merge "Add inventory interface and cmd line integration"
This commit is contained in:
commit
a2fd0b7b76
@ -15,14 +15,12 @@
|
||||
package baremetal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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
|
||||
@ -34,30 +32,19 @@ const (
|
||||
flagLabelDescription = "Label(s) to filter desired baremetal host documents"
|
||||
|
||||
flagName = "name"
|
||||
flagNameShort = "n"
|
||||
flagNameDescription = "Name to filter desired baremetal host document"
|
||||
|
||||
flagPhase = "phase"
|
||||
flagPhaseDescription = "airshipctl phase that contains the desired baremetal host document(s)"
|
||||
flagNamespace = "namespace"
|
||||
flagNamespaceSort = "n"
|
||||
flagNamespaceDescription = "airshipctl phase that contains the desired baremetal host document(s)"
|
||||
|
||||
ejectAction Action = iota
|
||||
powerOffAction
|
||||
powerOnAction
|
||||
powerStatusAction
|
||||
rebootAction
|
||||
remoteDirectAction
|
||||
flagTimeout = "timeout"
|
||||
flagTimeoutDescription = "timeout on baremetal action"
|
||||
)
|
||||
|
||||
// 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.
|
||||
func NewBaremetalCommand(cfgFactory config.Factory) *cobra.Command {
|
||||
options := &CommonOptions{}
|
||||
options := inventory.NewOptions(inventory.NewInventory(cfgFactory))
|
||||
baremetalRootCmd := &cobra.Command{
|
||||
Use: "baremetal",
|
||||
Short: "Perform actions on baremetal hosts",
|
||||
@ -73,93 +60,10 @@ func NewBaremetalCommand(cfgFactory config.Factory) *cobra.Command {
|
||||
return baremetalRootCmd
|
||||
}
|
||||
|
||||
func initFlags(options *CommonOptions, cmd *cobra.Command) {
|
||||
func initFlags(options *inventory.CommandOptions, cmd *cobra.Command) {
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&options.labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVarP(&options.name, flagName, flagNameShort, "", flagNameDescription)
|
||||
flags.StringVar(&options.phase, flagPhase, config.BootstrapPhase, flagPhaseDescription)
|
||||
}
|
||||
|
||||
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
|
||||
flags.StringVarP(&options.Labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVar(&options.Name, flagName, "", flagNameDescription)
|
||||
flags.StringVarP(&options.Namespace, flagNamespace, flagNamespaceSort, "", flagNamespaceDescription)
|
||||
flags.DurationVar(&options.Timeout, flagTimeout, 10*time.Minute, flagTimeoutDescription)
|
||||
}
|
||||
|
@ -17,9 +17,8 @@ package baremetal_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"opendev.org/airship/airshipctl/cmd/baremetal"
|
||||
"opendev.org/airship/airshipctl/pkg/inventory"
|
||||
"opendev.org/airship/airshipctl/testutil"
|
||||
)
|
||||
|
||||
@ -33,32 +32,32 @@ func TestBaremetal(t *testing.T) {
|
||||
{
|
||||
Name: "baremetal-ejectmedia-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewEjectMediaCommand(nil, &baremetal.CommonOptions{}),
|
||||
Cmd: baremetal.NewEjectMediaCommand(nil, &inventory.CommandOptions{}),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-poweroff-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewPowerOffCommand(nil, &baremetal.CommonOptions{}),
|
||||
Cmd: baremetal.NewPowerOffCommand(nil, &inventory.CommandOptions{}),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-poweron-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewPowerOnCommand(nil, &baremetal.CommonOptions{}),
|
||||
Cmd: baremetal.NewPowerOnCommand(nil, &inventory.CommandOptions{}),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-powerstatus-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewPowerStatusCommand(nil, &baremetal.CommonOptions{}),
|
||||
Cmd: baremetal.NewPowerStatusCommand(nil, &inventory.CommandOptions{}),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-reboot-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewRebootCommand(nil, &baremetal.CommonOptions{}),
|
||||
Cmd: baremetal.NewRebootCommand(nil, &inventory.CommandOptions{}),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-remotedirect-with-help",
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -18,16 +18,18 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewEjectMediaCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewEjectMediaCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "ejectmedia",
|
||||
Short: "Eject media attached to a baremetal host",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return performAction(cfgFactory, options, ejectAction, cmd.OutOrStdout())
|
||||
return options.BMHAction(ifc.BaremetalOperationEjectVirtualMedia)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,18 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewPowerOffCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewPowerOffCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "poweroff",
|
||||
Short: "Shutdown a baremetal host",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return performAction(cfgFactory, options, powerOffAction, cmd.OutOrStdout())
|
||||
return options.BMHAction(ifc.BaremetalOperationPowerOff)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,18 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewPowerOnCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewPowerOnCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "poweron",
|
||||
Short: "Power on a host",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return performAction(cfgFactory, options, powerOnAction, cmd.OutOrStdout())
|
||||
return options.BMHAction(ifc.BaremetalOperationPowerOn)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,17 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewPowerStatusCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewPowerStatusCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "powerstatus",
|
||||
Short: "Retrieve the power status of a baremetal host",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return performAction(cfgFactory, options, powerStatusAction, cmd.OutOrStdout())
|
||||
return options.PowerStatus(cmd.OutOrStdout())
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,18 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewRebootCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewRebootCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "reboot",
|
||||
Short: "Reboot a host",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return performAction(cfgFactory, options, rebootAction, cmd.OutOrStdout())
|
||||
return options.BMHAction(ifc.BaremetalOperationReboot)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,20 +18,21 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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.
|
||||
func NewRemoteDirectCommand(cfgFactory config.Factory, options *CommonOptions) *cobra.Command {
|
||||
func NewRemoteDirectCommand(cfgFactory config.Factory, options *inventory.CommandOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "remotedirect",
|
||||
Short: "Bootstrap the ephemeral host",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
options.phase = config.BootstrapPhase
|
||||
options.labels = document.EphemeralHostSelector
|
||||
return performAction(cfgFactory, options, remoteDirectAction, cmd.OutOrStdout())
|
||||
return options.RemoteDirect()
|
||||
},
|
||||
}
|
||||
initFlags(options, cmd)
|
||||
|
||||
cmd.Flags().StringVar(&options.IsoURL, "iso-url", "", "specify iso url for host to boot from")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ Usage:
|
||||
ejectmedia [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for ejectmedia
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for ejectmedia
|
||||
-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)
|
||||
|
@ -4,7 +4,8 @@ Usage:
|
||||
poweroff [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for poweroff
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for poweroff
|
||||
-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)
|
||||
|
@ -4,7 +4,8 @@ Usage:
|
||||
poweron [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for poweron
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for poweron
|
||||
-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)
|
||||
|
@ -4,7 +4,8 @@ Usage:
|
||||
powerstatus [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for powerstatus
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for powerstatus
|
||||
-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)
|
||||
|
@ -4,7 +4,8 @@ Usage:
|
||||
reboot [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for reboot
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for reboot
|
||||
-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)
|
||||
|
@ -4,4 +4,9 @@ Usage:
|
||||
remotedirect [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)
|
||||
|
@ -13,10 +13,11 @@ airshipctl baremetal ejectmedia [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for ejectmedia
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for ejectmedia
|
||||
-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
|
||||
|
@ -13,10 +13,11 @@ airshipctl baremetal poweroff [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for poweroff
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for poweroff
|
||||
-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
|
||||
|
@ -13,10 +13,11 @@ airshipctl baremetal poweron [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for poweron
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for poweron
|
||||
-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
|
||||
|
@ -13,10 +13,11 @@ airshipctl baremetal powerstatus [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for powerstatus
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for powerstatus
|
||||
-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
|
||||
|
@ -13,10 +13,11 @@ airshipctl baremetal reboot [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for reboot
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap-iso")
|
||||
-h, --help help for reboot
|
||||
-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
|
||||
|
@ -13,7 +13,12 @@ airshipctl baremetal remotedirect [flags]
|
||||
### 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
|
||||
|
@ -13,7 +13,7 @@ airshipctl image build [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for build
|
||||
-h, --help help for build
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
20
manifests/site/test-site/host-inventory/ephemeral-patch.yaml
Normal file
20
manifests/site/test-site/host-inventory/ephemeral-patch.yaml
Normal 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
|
@ -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
|
@ -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
|
@ -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
|
@ -0,0 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
generators:
|
||||
- hostgenerator
|
||||
|
||||
patchesStrategicMerge:
|
||||
- ephemeral-patch.yaml
|
@ -1,3 +1,5 @@
|
||||
phase:
|
||||
path: manifests/site/test-site/phases
|
||||
docEntryPointPrefix: manifests/site/test-site
|
||||
inventory:
|
||||
path: manifests/site/test-site/host-inventory
|
@ -26,7 +26,7 @@ hosts:
|
||||
node02:
|
||||
bootMode: UEFI
|
||||
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
|
||||
bmcPassword: password
|
||||
disableCertificateVerification: false
|
||||
@ -51,3 +51,16 @@ hosts:
|
||||
oam: 52:54:00:9b:27:07
|
||||
pxe: 52:54:00:b6:ed:23
|
||||
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
|
||||
|
@ -20,7 +20,10 @@ export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
|
||||
export KUBECONFIG_EPHEMERAL_CONTEXT=${KUBECONFIG_EPHEMERAL_CONTEXT:-"ephemeral-cluster"}
|
||||
|
||||
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"
|
||||
N=0
|
||||
|
@ -15,7 +15,6 @@
|
||||
set -xe
|
||||
|
||||
export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
|
||||
NODENAME="node01"
|
||||
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
|
||||
|
||||
echo "Deploy calico using tigera operator"
|
||||
|
Loading…
Reference in New Issue
Block a user